Check permission for shop name again after querying it

This commit is contained in:
Phoenix616 2020-11-17 19:57:16 +01:00
parent 4263cd8d85
commit 2f8e7bae3f
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
1 changed files with 8 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import com.Acrobot.Breeze.Utils.MaterialUtil;
import com.Acrobot.Breeze.Utils.PriceUtil;
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.UUIDs.NameManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -12,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.NO_PERMISSION;
import static com.Acrobot.ChestShop.Permission.*;
import static com.Acrobot.ChestShop.Signs.ChestShopSign.ITEM_LINE;
import static com.Acrobot.ChestShop.Signs.ChestShopSign.NAME_LINE;
import static com.Acrobot.ChestShop.Signs.ChestShopSign.PRICE_LINE;
import static org.bukkit.event.EventPriority.HIGH;
@ -24,6 +26,12 @@ public class PermissionChecker implements Listener {
public static void onPreShopCreation(PreShopCreationEvent event) {
Player player = event.getPlayer();
if (!NameManager.canUseName(player, event.getSignLine(NAME_LINE))) {
event.setSignLine(NAME_LINE, "");
event.setOutcome(NO_PERMISSION);
return;
}
String priceLine = event.getSignLine(PRICE_LINE);
String itemLine = event.getSignLine(ITEM_LINE);