Added some new Permissions

This commit is contained in:
Sn0wStorm
2014-05-07 02:37:28 +02:00
parent 31385edce5
commit e1f10b6be1
7 changed files with 171 additions and 23 deletions
+97
View File
@@ -7,3 +7,100 @@ commands:
brewery: brewery:
description: Command for Administration description: Command for Administration
aliases: [brew,br] aliases: [brew,br]
permissions:
# -- Groups --
# User
brewery.user:
description: Access to everything needed for brewing
default: true
children:
brewery.cmd.unlabel: true
brewery.createbarrel: true
brewery.openbarrel: true
brewery.cauldron.time: true
brewery.cauldron.insert: true
brewery.cauldron.fill: true
# Mod
brewery.mod:
description: Allow to maintain Wakeup Points and to login even if overdrunken
children:
brewery.user: true
brewery.cmd.wakeup: true
brewery.bypass.logindeny: true
# Admin
brewery.admin:
description: Gives access to Every Command and most bypasses
default: op
children:
brewery.user: true
brewery.mod: true
brewery.cmd.info: true
brewery.cmd.infoOther: true
brewery.cmd.player: true
brewery.cmd.copy: true
brewery.cmd.delete: true
brewery.cmd.reload: true
# *
brewery.*:
description: Gives Access to every Permission, including bypasses and overrides
children:
brewery.user: true
brewery.mod: true
brewery.admin: true
brewery.bypass.overdrink: true
brewery.bypass.teleport: true
# -- Commands --
brewery.cmd.unlabel:
description: Remove Parts of the Potionlabel
brewery.cmd.info:
description: Information about your own drunkeness
brewery.cmd.infoOther:
description: Information about the drunkeness of another Player
brewery.cmd.player:
description: Set Player-values
brewery.cmd.wakeup:
description: Set, Check and Remove Wakeup Points
brewery.cmd.copy:
description: Copy Potions
brewery.cmd.delete:
description: Delete Potions
brewery.cmd.reload:
description: Reload config
# -- Barrel --
brewery.createbarrel:
description: Allow to create all types of Barrels
children:
brewery.createbarrel.small: true
brewery.createbarrel.big: true
brewery.createbarrel.small:
description: Allow to create small Barrels
brewery.createbarrel.big:
description: Allow to create big Barrels
brewery.openbarrel:
description: Allow to open all types of Barrels
children:
brewery.openbarrel.small: true
brewery.openbarrel.big: true
brewery.openbarrel.small:
description: Allow to open small Barrels
brewery.openbarrel.big:
description: Allow to open big Barrels
# -- Cauldron --
brewery.cauldron.time:
description: View the current Cooking time of a cauldron with a watch
brewery.cauldron.insert:
description: Add Ingredients to the Cauldron
brewery.cauldron.fill:
description: Fill a Bottle from a Cauldron with a brewery brew
# -- Bypasses --
brewery.bypass.logindeny:
description: Can always login, even with extreme drunkeness
brewery.bypass.overdrink:
description: Will despite config-setting not be kicked on overdrink
brewery.bypass.teleport:
description: Will despite config-setting not be teleported on login
+8
View File
@@ -89,6 +89,10 @@ public class BCauldron {
public static boolean fill(Player player, Block block) { public static boolean fill(Player player, Block block) {
BCauldron bcauldron = get(block); BCauldron bcauldron = get(block);
if (bcauldron != null) { if (bcauldron != null) {
if (!player.hasPermission("brewery.cauldron.fill")) {
P.p.msg(player, P.p.languageReader.get("Perms_NoCauldronFill"));
return true;
}
ItemStack potion = bcauldron.ingredients.cook(bcauldron.state); ItemStack potion = bcauldron.ingredients.cook(bcauldron.state);
if (potion != null) { if (potion != null) {
// Bukkit Bug, inventory not updating while in event so this // Bukkit Bug, inventory not updating while in event so this
@@ -115,6 +119,10 @@ public class BCauldron {
// prints the current cooking time to the player // prints the current cooking time to the player
public static void printTime(Player player, Block block) { public static void printTime(Player player, Block block) {
if (!player.hasPermission("brewery.cauldron.time")) {
P.p.msg(player, P.p.languageReader.get("Error_NoPermissions"));
return;
}
BCauldron bcauldron = get(block); BCauldron bcauldron = get(block);
if (bcauldron != null) { if (bcauldron != null) {
if (bcauldron.state > 1) { if (bcauldron.state > 1) {
+1
View File
@@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
+24 -1
View File
@@ -108,6 +108,18 @@ public class Barrel {
} }
public boolean hasPermsOpen(Player player, PlayerInteractEvent event) { public boolean hasPermsOpen(Player player, PlayerInteractEvent event) {
if (isLarge()) {
if (!player.hasPermission("brewery.openbarrel.big")) {
P.p.msg(player, P.p.languageReader.get("Error_NoBarrelAccess"));
return false;
}
} else {
if (!player.hasPermission("brewery.openbarrel.small")) {
P.p.msg(player, P.p.languageReader.get("Error_NoBarrelAccess"));
return false;
}
}
if (P.p.useWG) { if (P.p.useWG) {
Plugin plugin = P.p.getServer().getPluginManager().getPlugin("WorldGuard"); Plugin plugin = P.p.getServer().getPluginManager().getPlugin("WorldGuard");
if (plugin != null) { if (plugin != null) {
@@ -384,7 +396,7 @@ public class Barrel {
} }
// creates a new Barrel out of a sign // creates a new Barrel out of a sign
public static boolean create(Block sign) { public static boolean create(Block sign, Player player) {
Block spigot = getSpigotOfSign(sign); Block spigot = getSpigotOfSign(sign);
byte signoffset = 0; byte signoffset = 0;
@@ -396,6 +408,17 @@ public class Barrel {
if (barrel == null) { if (barrel == null) {
barrel = new Barrel(spigot, signoffset); barrel = new Barrel(spigot, signoffset);
if (barrel.getBrokenBlock(true) == null) { if (barrel.getBrokenBlock(true) == null) {
if (isSign(spigot)) {
if (!player.hasPermission("brewery.createbarrel.small")) {
P.p.msg(player, P.p.languageReader.get("Perms_NoSmallBarrelCreate"));
return false;
}
} else {
if (!player.hasPermission("brewery.createbarrel.big")) {
P.p.msg(player, P.p.languageReader.get("Perms_NoBigBarrelCreate"));
return false;
}
}
barrels.add(barrel); barrels.add(barrel);
return true; return true;
} }
+9 -2
View File
@@ -85,8 +85,6 @@ public class LanguageReader {
defaults.put("CMD_Copy_Error", "&6&v1 &cPotions did not fit into your inventory"); defaults.put("CMD_Copy_Error", "&6&v1 &cPotions did not fit into your inventory");
/* Error */ /* Error */
defaults.put("Error_NoPermissions", "&cYou don't have permissions to do this!");
defaults.put("Error_NoBarrelAccess", "&cYou don't have permissions to access this barrel!");
defaults.put("Error_UnknownCommand", "Unknown Command"); defaults.put("Error_UnknownCommand", "Unknown Command");
defaults.put("Error_ShowHelp", "Use &6/br help &fto display the help"); defaults.put("Error_ShowHelp", "Use &6/br help &fto display the help");
defaults.put("Error_PlayerCommand", "&cThis command can only be executed as a player!"); defaults.put("Error_PlayerCommand", "&cThis command can only be executed as a player!");
@@ -94,6 +92,15 @@ public class LanguageReader {
defaults.put("Error_Recipeload", "&cNot all recipes could be restored: More information in the server log!"); defaults.put("Error_Recipeload", "&cNot all recipes could be restored: More information in the server log!");
defaults.put("Error_ConfigUpdate", "Unknown Brewery config version: v&v1, config was not updated!"); defaults.put("Error_ConfigUpdate", "Unknown Brewery config version: v&v1, config was not updated!");
/* Permissions */
defaults.put("Error_NoPermissions", "&cYou don't have permissions to do this!");
defaults.put("Error_NoBarrelAccess", "&cYou don't have permissions to access this barrel!");
defaults.put("Perms_NoBarrelCreate", "&cYou don't have permissions to create barrels!");
defaults.put("Perms_NoSmallBarrelCreate", "&cYou don't have permissions to create small barrels!");
defaults.put("Perms_NoBigBarrelCreate", "&cYou don't have permissions to create big barrels!");
defaults.put("Perms_NoCauldronInsert", "&cYou don't have permissions to put ingredients into cauldrons!");
defaults.put("Perms_NoCauldronFill", "&cYou don't have permissions to fill bottles from this cauldron!");
/* Help */ /* Help */
defaults.put("Help_Help", "&6/br help <Page> &9Shows a specific help-page"); defaults.put("Help_Help", "&6/br help <Page> &9Shows a specific help-page");
defaults.put("Help_Player", "&6/br <Player> <%Drunkeness> <Quality>&9 Sets Drunkeness (and Quality) of a Player"); defaults.put("Help_Player", "&6/br <Player> <%Drunkeness> <Quality>&9 Sets Drunkeness (and Quality) of a Player");
@@ -1,6 +1,7 @@
package com.dre.brewery.listeners; package com.dre.brewery.listeners;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@@ -22,8 +23,13 @@ public class BlockListener implements Listener {
String[] lines = event.getLines(); String[] lines = event.getLines();
if (lines[0].equalsIgnoreCase(P.p.languageReader.get("Etc_Barrel"))) { if (lines[0].equalsIgnoreCase(P.p.languageReader.get("Etc_Barrel"))) {
if (Barrel.create(event.getBlock())) { Player player = event.getPlayer();
P.p.msg(event.getPlayer(), P.p.languageReader.get("Player_BarrelCreated")); if (!player.hasPermission("brewery.createbarrel.small") && !player.hasPermission("brewery.createbarrel.big")) {
P.p.msg(player, P.p.languageReader.get("Perms_NoBarrelCreate"));
return;
}
if (Barrel.create(event.getBlock(), player)) {
P.p.msg(player, P.p.languageReader.get("Player_BarrelCreated"));
} }
} }
} }
@@ -49,12 +49,14 @@ public class PlayerListener implements Listener {
if (player.getInventory().firstEmpty() != -1 || item.getAmount() == 1) { if (player.getInventory().firstEmpty() != -1 || item.getAmount() == 1) {
if (BCauldron.fill(player, clickedBlock)) { if (BCauldron.fill(player, clickedBlock)) {
event.setCancelled(true); event.setCancelled(true);
if (player.hasPermission("brewery.cauldron.fill")) {
if (item.getAmount() > 1) { if (item.getAmount() > 1) {
item.setAmount(item.getAmount() - 1); item.setAmount(item.getAmount() - 1);
} else { } else {
player.setItemInHand(new ItemStack(0)); player.setItemInHand(new ItemStack(0));
} }
} }
}
} else { } else {
event.setCancelled(true); event.setCancelled(true);
} }
@@ -72,6 +74,7 @@ public class PlayerListener implements Listener {
// add ingredient to cauldron that meet the previous // add ingredient to cauldron that meet the previous
// contitions // contitions
} else if (BIngredients.possibleIngredients.contains(materialInHand)) { } else if (BIngredients.possibleIngredients.contains(materialInHand)) {
if (player.hasPermission("brewery.cauldron.insert")) {
if (BCauldron.ingredientAdd(clickedBlock, materialInHand)) { if (BCauldron.ingredientAdd(clickedBlock, materialInHand)) {
boolean isBucket = item.getType().equals(Material.WATER_BUCKET) boolean isBucket = item.getType().equals(Material.WATER_BUCKET)
|| item.getType().equals(Material.LAVA_BUCKET) || item.getType().equals(Material.LAVA_BUCKET)
@@ -90,6 +93,9 @@ public class PlayerListener implements Listener {
} }
} }
} }
} else {
P.p.msg(player, P.p.languageReader.get("Perms_NoCauldronInsert"));
}
event.setCancelled(true); event.setCancelled(true);
} else { } else {
event.setCancelled(true); event.setCancelled(true);