mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-05 18:37:40 +01:00
Added some new Permissions
This commit is contained in:
parent
31385edce5
commit
e1f10b6be1
99
plugin.yml
99
plugin.yml
@ -6,4 +6,101 @@ softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention]
|
||||
commands:
|
||||
brewery:
|
||||
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
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user