mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Added vault permission hook. Fixed tax exemption.
This commit is contained in:
1 parent
8f766d5081
commit
6c0c0e669a
4 files changed
+41
-2
No files matched your search
@@ -51,6 +51,7 @@ import org.maxgamer.quickshop.Shop.ShopManager;
|
||||
import org.maxgamer.quickshop.Shop.ShopType;
|
||||
import org.maxgamer.quickshop.Util.CustomItemName;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Permissions;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
import org.maxgamer.quickshop.Watcher.ItemWatcher;
|
||||
import org.maxgamer.quickshop.Watcher.LogWatcher;
|
||||
@@ -128,6 +129,12 @@ public class QuickShop extends JavaPlugin {
|
||||
if (loadEcon() == false)
|
||||
return;
|
||||
|
||||
if (Permissions.init()) {
|
||||
getLogger().info("Found permission provider.");
|
||||
} else {
|
||||
getLogger().info("Couldn't find a Vault permission provider. Some feature may be limited.");
|
||||
}
|
||||
|
||||
// Initialize Util
|
||||
Util.initialize();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.bukkit.material.Sign;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Database.Database;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Permissions;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
public class ShopManager {
|
||||
@@ -459,7 +460,7 @@ public class ShopManager {
|
||||
// themselves.
|
||||
// Do charge an amount of tax though.
|
||||
double tax = plugin.getConfig().getDouble("tax");
|
||||
if (shop.getOwner().equals(p.getUniqueId()) || p.hasPermission("quickshop.taxexemption")) {
|
||||
if (shop.getOwner().equals(p.getUniqueId()) || Permissions.hasPermission(Bukkit.getOfflinePlayer(shop.getOwner()), "quickshop.taxexemption")) {
|
||||
tax = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.maxgamer.quickshop.Util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
public class Permissions {
|
||||
private Permissions() {}
|
||||
private static Permission provider;
|
||||
|
||||
public static boolean init() {
|
||||
RegisteredServiceProvider<Permission> registeredService = Bukkit.getServicesManager().getRegistration(Permission.class);
|
||||
if (registeredService!=null) {
|
||||
provider = registeredService.getProvider();
|
||||
}
|
||||
return provider != null;
|
||||
}
|
||||
|
||||
public static boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
try {
|
||||
return provider.playerHas(null, player, permission);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user