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
+8
View File
@@ -89,6 +89,10 @@ public class BCauldron {
public static boolean fill(Player player, Block block) {
BCauldron bcauldron = get(block);
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);
if (potion != null) {
// 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
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);
if (bcauldron != null) {
if (bcauldron.state > 1) {
+1
View File
@@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Material;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.util.Vector;
import org.bukkit.Location;
import org.bukkit.potion.PotionEffectType;
+24 -1
View File
@@ -108,6 +108,18 @@ public class Barrel {
}
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) {
Plugin plugin = P.p.getServer().getPluginManager().getPlugin("WorldGuard");
if (plugin != null) {
@@ -384,7 +396,7 @@ public class Barrel {
}
// 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);
byte signoffset = 0;
@@ -396,6 +408,17 @@ public class Barrel {
if (barrel == null) {
barrel = new Barrel(spigot, signoffset);
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);
return true;
}
+9 -2
View File
@@ -85,14 +85,21 @@ public class LanguageReader {
defaults.put("CMD_Copy_Error", "&6&v1 &cPotions did not fit into your inventory");
/* 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_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_ItemNotPotion", "&cThe item in your hand could not be identified as a potion!");
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!");
/* 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 */
defaults.put("Help_Help", "&6/br help <Page> &9Shows a specific help-page");
@@ -1,6 +1,7 @@
package com.dre.brewery.listeners;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -22,8 +23,13 @@ public class BlockListener implements Listener {
String[] lines = event.getLines();
if (lines[0].equalsIgnoreCase(P.p.languageReader.get("Etc_Barrel"))) {
if (Barrel.create(event.getBlock())) {
P.p.msg(event.getPlayer(), P.p.languageReader.get("Player_BarrelCreated"));
Player player = event.getPlayer();
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,10 +49,12 @@ public class PlayerListener implements Listener {
if (player.getInventory().firstEmpty() != -1 || item.getAmount() == 1) {
if (BCauldron.fill(player, clickedBlock)) {
event.setCancelled(true);
if (item.getAmount() > 1) {
item.setAmount(item.getAmount() - 1);
} else {
player.setItemInHand(new ItemStack(0));
if (player.hasPermission("brewery.cauldron.fill")) {
if (item.getAmount() > 1) {
item.setAmount(item.getAmount() - 1);
} else {
player.setItemInHand(new ItemStack(0));
}
}
}
} else {
@@ -72,23 +74,27 @@ public class PlayerListener implements Listener {
// add ingredient to cauldron that meet the previous
// contitions
} else if (BIngredients.possibleIngredients.contains(materialInHand)) {
if (BCauldron.ingredientAdd(clickedBlock, materialInHand)) {
boolean isBucket = item.getType().equals(Material.WATER_BUCKET)
|| item.getType().equals(Material.LAVA_BUCKET)
|| item.getType().equals(Material.MILK_BUCKET);
if (item.getAmount() > 1) {
item.setAmount(item.getAmount() - 1);
if (player.hasPermission("brewery.cauldron.insert")) {
if (BCauldron.ingredientAdd(clickedBlock, materialInHand)) {
boolean isBucket = item.getType().equals(Material.WATER_BUCKET)
|| item.getType().equals(Material.LAVA_BUCKET)
|| item.getType().equals(Material.MILK_BUCKET);
if (item.getAmount() > 1) {
item.setAmount(item.getAmount() - 1);
if (isBucket) {
BCauldron.giveItem(player, new ItemStack(Material.BUCKET));
}
} else {
if (isBucket) {
player.setItemInHand(new ItemStack(Material.BUCKET));
if (isBucket) {
BCauldron.giveItem(player, new ItemStack(Material.BUCKET));
}
} else {
player.setItemInHand(new ItemStack(0));
if (isBucket) {
player.setItemInHand(new ItemStack(Material.BUCKET));
} else {
player.setItemInHand(new ItemStack(0));
}
}
}
} else {
P.p.msg(player, P.p.languageReader.get("Perms_NoCauldronInsert"));
}
event.setCancelled(true);
} else {