mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-27 05:05:25 +01:00
Add config setting for click protection
This commit is contained in:
parent
04a2a63a37
commit
318f8e565b
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -66,12 +66,14 @@ public class BukkitItemListener implements Listener {
|
||||
}
|
||||
if (quester.getCurrentQuests().containsKey(quest)
|
||||
&& quester.getCurrentStage(quest).containsObjective(type)) {
|
||||
if (craftedItem.getMaxStackSize() == 0 || (BukkitInventoryUtil.getEmptySlots(player)
|
||||
< craftedItem.getAmount() / craftedItem.getMaxStackSize())) {
|
||||
BukkitActionBarProvider.sendActionBar(player, ChatColor.RED + BukkitLang.get(player,
|
||||
"inventoryFull"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
if (plugin.getConfigSettings().canPreventExploit()) {
|
||||
if (craftedItem.getMaxStackSize() == 0 || (BukkitInventoryUtil.getEmptySlots(player)
|
||||
< craftedItem.getAmount() / craftedItem.getMaxStackSize())) {
|
||||
BukkitActionBarProvider.sendActionBar(player, ChatColor.RED + BukkitLang.get(player,
|
||||
"inventoryFull"));
|
||||
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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user