Skip to content

Commit

Permalink
Add "Enabled" option to triggers in config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Mar 10, 2013
1 parent a5b6ad9 commit c9410bb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
17 changes: 14 additions & 3 deletions src/main/java/net/aufdemrand/denizen/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static boolean HealthTraitRespawnEnabled() {

/*
# Whether NPCs with the Health trait should respawn after being killed
# How long it should take for NPCs with the Health trait to respawn
*/

Expand All @@ -78,6 +78,17 @@ public static String HealthTraitRespawnDelay() {

/*
# Whether a certain trigger is enabled by default or not
*/

public static boolean TriggerEnabled(String triggerName) {
return DenizenAPI.getCurrentInstance().getConfig()
.getBoolean("Triggers." + triggerName + ".Enabled", true);
}

/*
# Default duration of cooldown set to Denizens for when a trigger is
# triggered. Not all triggers may use this, it is optional!
Expand Down Expand Up @@ -166,7 +177,7 @@ public static double ChatToNpcOverhearingRange() {
# Prerequisites for triggering a Chat Trigger
*/
*/

public static boolean ChatMustSeeNPC() {
return DenizenAPI.getCurrentInstance().getConfig()
Expand All @@ -183,7 +194,7 @@ public static boolean ChatMustLookAtNPC() {
# Circumstances under which a player's Chat Trigger input should
# appear in the global chat
*/
*/

public static boolean ChatGloballyIfFailedChatTriggers() {
return DenizenAPI.getCurrentInstance().getConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ public boolean register(String triggerName, RegistrationableInstance instance) {

@Override
public void registerCoreMembers() {
new ClickTrigger().activate().as("Click").withOptions(true, Settings.TriggerDefaultCooldown("Click"), CooldownType.PLAYER);
new DamageTrigger().activate().as("Damage").withOptions(false, Settings.TriggerDefaultCooldown("Damage"), CooldownType.NPC);
new ChatTrigger().activate().as("Chat").withOptions(true, Settings.TriggerDefaultCooldown("Chat"), Settings.TriggerDefaultRange("Chat"), CooldownType.PLAYER);
new ProximityTrigger().activate ().as("Proximity").withOptions(false, Settings.TriggerDefaultCooldown("Proximity"), Settings.TriggerDefaultRange("Proximity"), CooldownType.PLAYER);
new ClickTrigger().activate().as("Click").withOptions(Settings.TriggerEnabled("Click"),
Settings.TriggerDefaultCooldown("Click"), CooldownType.PLAYER);
new ChatTrigger().activate().as("Chat").withOptions(Settings.TriggerEnabled("Chat"),
Settings.TriggerDefaultCooldown("Chat"), Settings.TriggerDefaultRange("Chat"), CooldownType.PLAYER);
new DamageTrigger().activate().as("Damage").withOptions(Settings.TriggerEnabled("Damage"),
Settings.TriggerDefaultCooldown("Damage"), CooldownType.NPC);
new ProximityTrigger().activate ().as("Proximity").withOptions(Settings.TriggerEnabled("Proximity"),
Settings.TriggerDefaultCooldown("Proximity"), Settings.TriggerDefaultRange("Proximity"), CooldownType.PLAYER);
dB.echoApproval("Loaded core triggers: " + instances.keySet().toString());
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Traits:

Triggers:
Chat:
Enabled: true
Cooldown: 2s
Range: 3
Overhearing Range: 4
Expand All @@ -33,14 +34,18 @@ Triggers:
If Triggers Failed: false
If NPC Uninteractable: true
Click:
Enabled: true
Cooldown: 2s
Allows Left Click: false
Damage:
Enabled: false
Cooldown: 0.5s
Location:
Enabled: false
Cooldown: 5s
Range: 2
Proximity:
Enabled: false
Cooldown: 1s
Range: 10

Expand Down

0 comments on commit c9410bb

Please sign in to comment.