Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the ability to have per item transaction permissions #5585

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ public void run(final Server server, final User user, final String commandLabel,
}
}
try {
if (!user.isAuthorized("essentials.item.sell."+stack.getType().toString())){
if (isBulk) {
notSold.add(stack);
continue;
}
user.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cError: &4You do not have sufficient permissions to sell " + stack.getType()));
return;
}

if (stack.getAmount() > 0) {
totalWorth = totalWorth.add(sellItem(user, stack, args, isBulk));
stack = stack.clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.earth2me.essentials.User;
import net.ess3.api.IEssentials;
import net.ess3.api.MaxMoneyException;
import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack;

import java.math.BigDecimal;
Expand All @@ -26,6 +27,10 @@ protected boolean onSignInteract(final ISign sign, final User player, final Stri
Trade items = getTrade(sign, 1, 2, player, ess);
Trade charge = getTrade(sign, 3, ess);

if (!player.isAuthorized("essentials.item.buy"+ items.getItemStack().getType())){
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cError: &4You do not have sufficient permissions to buy " + items.getItemStack().getType()));
return false;
}
// Check if the player is trying to buy in bulk.
if (ess.getSettings().isAllowBulkBuySell() && player.getBase().isSneaking()) {
final ItemStack heldItem = player.getItemInHand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import net.ess3.api.IEssentials;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -33,6 +34,10 @@ protected boolean onSignInteract(final ISign sign, final User player, final Stri
ItemStack itemStack = getItemStack(sign.getLine(1), 1, ess);
itemStack = getItemMeta(player.getSource(), itemStack, sign.getLine(2), ess);
final ItemStack item = getItemMeta(player.getSource(), itemStack, sign.getLine(3), ess);
if (!player.isAuthorized("essentials.item.free."+ item.getType())){
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cError: &4You do not have sufficient permissions to get " + item.getType()));
return false;
}

if (item.getType() == Material.AIR) {
throw new SignException(tl("cantSpawnItem", "Air"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.earth2me.essentials.User;
import net.ess3.api.IEssentials;
import net.ess3.api.MaxMoneyException;
import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack;

import java.math.BigDecimal;
Expand All @@ -26,6 +27,10 @@ protected boolean onSignCreate(final ISign sign, final User player, final String
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException, MaxMoneyException {
Trade charge = getTrade(sign, 1, 2, player, ess);
Trade money = getTrade(sign, 3, ess);
if (!player.isAuthorized("essentials.item.sell."+ charge.getItemStack().getType())){
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cError: &4You do not have sufficient permissions to sell " + charge.getItemStack().getType()));
return false;
}

// Check if the player is trying to sell in bulk.
if (ess.getSettings().isAllowBulkBuySell() && player.getBase().isSneaking()) {
Expand Down