Add config setting for click protection

This commit is contained in:
PikaMug 2024-10-15 03:55:44 -04:00
parent 04a2a63a37
commit 318f8e565b
4 changed files with 25 additions and 6 deletions

View File

@ -51,6 +51,8 @@ public interface ConfigSettings {
void setEffect(final String effect);
String getRedoEffect();
void setRedoEffect(final String redoEffect);
boolean canPreventExploit();
void setPreventExploit(final boolean preventExploit);
boolean canShowCompletedObjs();
void setShowCompletedObjs(final boolean showCompletedObjs);
boolean canShowQuestReqs();

View File

@ -40,6 +40,7 @@ public class BukkitConfigSettings implements ConfigSettings {
private boolean npcEffects = true;
private String effect = "note";
private String redoEffect = "angry_villager";
private boolean preventExploit;
private boolean showCompletedObjs = true;
private boolean showQuestReqs = true;
private boolean showQuestTitles = true;
@ -174,6 +175,12 @@ public class BukkitConfigSettings implements ConfigSettings {
public void setRedoEffect(final String redoEffect) {
this.redoEffect = redoEffect;
}
public boolean canPreventExploit() {
return preventExploit;
}
public void setPreventExploit(final boolean preventExploit) {
this.preventExploit = preventExploit;
}
public boolean canShowCompletedObjs() {
return showCompletedObjs;
}
@ -264,6 +271,7 @@ public class BukkitConfigSettings implements ConfigSettings {
npcEffects = config.getBoolean("npc-effects.enabled", true);
effect = config.getString("npc-effects.new-quest", "note");
redoEffect = config.getString("npc-effects.redo-quest", "angry_villager");
preventExploit = config.getBoolean("prevent-exploit", true);
showCompletedObjs = config.getBoolean("show-completed-objectives", true);
showQuestReqs = config.getBoolean("show-requirements", true);
showQuestTitles = config.getBoolean("show-titles", true);

View File

@ -66,6 +66,7 @@ public class BukkitItemListener implements Listener {
}
if (quester.getCurrentQuests().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective(type)) {
if (plugin.getConfigSettings().canPreventExploit()) {
if (craftedItem.getMaxStackSize() == 0 || (BukkitInventoryUtil.getEmptySlots(player)
< craftedItem.getAmount() / craftedItem.getMaxStackSize())) {
BukkitActionBarProvider.sendActionBar(player, ChatColor.RED + BukkitLang.get(player,
@ -73,6 +74,7 @@ public class BukkitItemListener implements Listener {
event.setCancelled(true);
return;
}
}
quester.craftItem(quest, craftedItem);
}
@ -178,6 +180,9 @@ public class BukkitItemListener implements Listener {
if (event.isCancelled()) {
return;
}
if (!plugin.getConfigSettings().canPreventExploit()) {
return;
}
if (event.getWhoClicked() instanceof Player) {
if (event.getInventory().getType() == InventoryType.BREWING) {
final Quester quester = plugin.getQuester(event.getWhoClicked().getUniqueId());
@ -193,6 +198,9 @@ public class BukkitItemListener implements Listener {
}
public boolean isAllowedBrewingAction(final InventoryClickEvent event) {
if (!plugin.getConfigSettings().canPreventExploit()) {
return true;
}
final int slot = event.getRawSlot();
final InventoryAction action = event.getAction();
// Prevent shift-click into Brewing Stand

View File

@ -19,6 +19,7 @@ npc-effects:
enabled: true
new-quest: note
redo-quest: heart
prevent-exploit: true
show-completed-objectives: true
show-requirements: true
show-titles: true