mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-22 16:11:22 +01:00
[trunk] Unlimited: Breaking change!
In favor for a much easier system, the config.yml settings have been removed. New permissions: essentials.unlimited: activates the /unlimited command essentials.unlimited.others: allows to give unlimited stacks to others essentials.unlimited.item-all: Access to all items essentials.unlimited.item-bucket: Access to all buckets essentials.unlimited.item-[itemname]: Access to specific item item names are from https://github.com/Bukkit/Bukkit/blob/master/src/main/java/org/bukkit/Material.java lower case, with - instead of _ All other essentials.unlimited.* permissions have been removed. git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1118 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
cd64b68222
commit
2606e5d9ff
@ -166,59 +166,53 @@ public class EssentialsBlockListener extends BlockListener
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Essentials.getSettings().isUnlimitedPlacingEnabled()) {
|
||||
final User user = User.get(event.getPlayer());
|
||||
final ItemStack is = event.getItemInHand();
|
||||
if (is.getType() == Material.AIR) {
|
||||
is.setType(event.getBlockPlaced().getType());
|
||||
}
|
||||
switch(is.getType()) {
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
break;
|
||||
case IRON_DOOR_BLOCK:
|
||||
is.setType(Material.IRON_DOOR);
|
||||
break;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
is.setType(Material.SIGN);
|
||||
break;
|
||||
case CROPS:
|
||||
is.setType(Material.SEEDS);
|
||||
break;
|
||||
case CAKE_BLOCK:
|
||||
is.setType(Material.CAKE);
|
||||
break;
|
||||
case BED_BLOCK:
|
||||
is.setType(Material.BED);
|
||||
break;
|
||||
case REDSTONE_WIRE:
|
||||
is.setType(Material.REDSTONE);
|
||||
break;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
is.setType(Material.REDSTONE_TORCH_ON);
|
||||
break;
|
||||
case DIODE_BLOCK_OFF:
|
||||
case DIODE_BLOCK_ON:
|
||||
is.setType(Material.DIODE);
|
||||
break;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (user.isAuthorized("essentials.unlimited.placing") || unlimitedForUser) {
|
||||
List<Integer> whitelist = Essentials.getSettings().getUnlimitedWhitelist();
|
||||
if (whitelist.isEmpty() || whitelist.contains(is.getTypeId()) ||
|
||||
user.isAuthorized("essentials.unlimited.whitelist.override") || unlimitedForUser) {
|
||||
is.setAmount(1);
|
||||
Essentials.getStatic().getScheduler().scheduleSyncDelayedTask(Essentials.getStatic(),
|
||||
new Runnable() {
|
||||
final User user = User.get(event.getPlayer());
|
||||
final ItemStack is = event.getItemInHand();
|
||||
if (is.getType() == Material.AIR) {
|
||||
is.setType(event.getBlockPlaced().getType());
|
||||
}
|
||||
switch(is.getType()) {
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
break;
|
||||
case IRON_DOOR_BLOCK:
|
||||
is.setType(Material.IRON_DOOR);
|
||||
break;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
is.setType(Material.SIGN);
|
||||
break;
|
||||
case CROPS:
|
||||
is.setType(Material.SEEDS);
|
||||
break;
|
||||
case CAKE_BLOCK:
|
||||
is.setType(Material.CAKE);
|
||||
break;
|
||||
case BED_BLOCK:
|
||||
is.setType(Material.BED);
|
||||
break;
|
||||
case REDSTONE_WIRE:
|
||||
is.setType(Material.REDSTONE);
|
||||
break;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
is.setType(Material.REDSTONE_TORCH_ON);
|
||||
break;
|
||||
case DIODE_BLOCK_OFF:
|
||||
case DIODE_BLOCK_ON:
|
||||
is.setType(Material.DIODE);
|
||||
break;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser) {
|
||||
is.setAmount(1);
|
||||
Essentials.getStatic().getScheduler().scheduleSyncDelayedTask(Essentials.getStatic(),
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
public void run() {
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,36 +398,26 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
|
||||
@Override
|
||||
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
|
||||
if (Essentials.getSettings().isUnlimitedEggThrowEnabled()) {
|
||||
User user = User.get(event.getPlayer());
|
||||
ItemStack is = new ItemStack(Material.EGG, 1);
|
||||
if (user.isAuthorized("essentials.unlimited.eggthrow") || user.hasUnlimited(is)) {
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
User user = User.get(event.getPlayer());
|
||||
ItemStack is = new ItemStack(Material.EGG, 1);
|
||||
if (user.hasUnlimited(is)) {
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
if (Essentials.getSettings().isUnlimitedBucketsEnabled()) {
|
||||
final User user = User.get(event.getPlayer());
|
||||
boolean unlimitedForUser = user.hasUnlimited(new ItemStack(event.getBucket()));
|
||||
if (user.isAuthorized("essentials.unlimited.buckets") || unlimitedForUser) {
|
||||
List<Integer> whitelist = Essentials.getSettings().getUnlimitedWhitelist();
|
||||
if (whitelist.isEmpty() || whitelist.contains(event.getBucket().getId()) ||
|
||||
user.isAuthorized("essentials.unlimited.whitelist.override") ||
|
||||
unlimitedForUser) {
|
||||
event.getItemStack().setType(event.getBucket());
|
||||
Essentials.getStatic().getScheduler().scheduleSyncDelayedTask(Essentials.getStatic(),
|
||||
new Runnable() {
|
||||
final User user = User.get(event.getPlayer());
|
||||
if (user.hasUnlimited(new ItemStack(event.getBucket()))) {
|
||||
event.getItemStack().setType(event.getBucket());
|
||||
Essentials.getStatic().getScheduler().scheduleSyncDelayedTask(Essentials.getStatic(),
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
public void run() {
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,35 +433,4 @@ public class Settings implements IConf
|
||||
}
|
||||
return epBreakList;
|
||||
}
|
||||
|
||||
boolean isUnlimitedPlacingEnabled() {
|
||||
return config.getBoolean("unlimited.placing",false);
|
||||
}
|
||||
|
||||
boolean isUnlimitedEggThrowEnabled() {
|
||||
return config.getBoolean("unlimited.eggthrow",false);
|
||||
}
|
||||
|
||||
boolean isUnlimitedBucketsEnabled() {
|
||||
return config.getBoolean("unlimited.buckets",false);
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getUnlimitedWhitelist()
|
||||
{
|
||||
ArrayList<Integer> unlimitedWhitelist = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("unlimited.whitelist", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
unlimitedWhitelist.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Unknown item " + itemName + " in unlimited whitelist.");
|
||||
}
|
||||
}
|
||||
return unlimitedWhitelist;
|
||||
}
|
||||
}
|
||||
|
@ -27,35 +27,21 @@ public class Commandunlimited extends EssentialsCommand
|
||||
}
|
||||
ItemStack stack = ItemDb.get(args[0], 1);
|
||||
|
||||
if(!user.isAuthorized("essentials.infinite.whitelist.override") &&
|
||||
Essentials.getSettings().getUnlimitedWhitelist().contains(stack.getTypeId()))
|
||||
{
|
||||
user.sendMessage(ChatColor.RED + "You are not allowed to spawn that item");
|
||||
return;
|
||||
}
|
||||
User target = user;
|
||||
|
||||
if (args.length > 1 && user.isAuthorized("essentials.unlimited.others")) {
|
||||
target = getPlayer(server, args, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (target.isAuthorized("essentials.unlimited.eggthrow") && stack.getType() == Material.EGG) {
|
||||
user.sendMessage(ChatColor.RED + "Unlimited eggs already activated by permissions.");
|
||||
String itemname = stack.getType().toString().toLowerCase().replace("_", "-");
|
||||
if (!user.isAuthorized("essentials.unlimited.item-add") &&
|
||||
!user.isAuthorized("essentials.unlimited.item-"+itemname)
|
||||
&& !((stack.getType() == Material.WATER_BUCKET || stack.getType() == Material.LAVA_BUCKET)
|
||||
&& user.isAuthorized("essentials.unlimited.item-bucket"))) {
|
||||
user.sendMessage(ChatColor.RED + "No permission for unlimited item "+itemname+".");
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.isAuthorized("essentials.unlimited.buckets") &&
|
||||
(stack.getType() == Material.WATER_BUCKET || stack.getType() == Material.LAVA_BUCKET)) {
|
||||
user.sendMessage(ChatColor.RED + "Unlimited buckets already activated by permissions.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.isAuthorized("essentials.unlimited.placing") &&
|
||||
(stack.getType() != Material.WATER_BUCKET && stack.getType() != Material.LAVA_BUCKET &&
|
||||
stack.getType() != Material.EGG)) {
|
||||
user.sendMessage(ChatColor.RED + "Unlimited placing already activated by permissions.");
|
||||
return;
|
||||
}
|
||||
|
||||
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
|
||||
|
||||
|
@ -155,26 +155,6 @@ per-warp-permission: false
|
||||
# Sort output of /list command by groups
|
||||
sort-list-by-groups: false
|
||||
|
||||
# Unlimited placement of blocks, throwing of eggs, using of buckets
|
||||
# You have to enabled this here if you want to use the /unlimited command.
|
||||
# The following permissions will activate unlimited for all items:
|
||||
# - essentials.unlimited.placing
|
||||
# - essentials.unlimited.eggthrow
|
||||
# - essentials.unlimited.buckets
|
||||
# Since admins commonly have a '*' permission, they get everything unlimited.
|
||||
# If you want to avoid that, explicitly deactivate the above permissions.
|
||||
unlimited:
|
||||
placing: false
|
||||
eggthrow: false
|
||||
buckets: false
|
||||
# Use this whitelist to restrict the use of unlimited placing and buckets
|
||||
# Set permission
|
||||
# - essentials.unlimited.whitelist.override
|
||||
# for players, that are not bound to this list.
|
||||
# If empty, all items are allowed.
|
||||
whitelist:
|
||||
# Example: (You can use ids or names from items.csv)
|
||||
# whitelist: cobblestone, dirt, waterbucket
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
|
Loading…
Reference in New Issue
Block a user