From 201d10ada563b4c0e2ee860e0a566543fff1094f Mon Sep 17 00:00:00 2001 From: drtshock Date: Tue, 11 Nov 2014 09:28:53 -0600 Subject: [PATCH] Add economy option for f warps from #126. --- pom.xml | 2 +- .../com/massivecraft/factions/cmd/CmdDelFWarp.java | 10 ++++++++++ .../java/com/massivecraft/factions/cmd/CmdFWarp.java | 10 ++++++++++ .../com/massivecraft/factions/cmd/CmdSetFWarp.java | 10 ++++++++++ src/main/resources/config.yml | 10 ++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aa163197..ac7a84bf 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.massivecraft Factions - 1.6.9.5-U0.1.11 + 1.6.9.5-U0.1.12-SNAPSHOT jar Factions diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java index 21f56ce6..a5dc7ef4 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java @@ -1,5 +1,8 @@ package com.massivecraft.factions.cmd; +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.P; +import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.struct.Permission; public class CmdDelFWarp extends FCommand { @@ -20,10 +23,17 @@ public class CmdDelFWarp extends FCommand { public void perform() { String warp = argAsString(0); if (myFaction.isWarp(warp)) { + if (!transact(fme)) { + return; + } myFaction.removeWarp(warp); fme.msg("Deleted warp %s", warp); } else { fme.msg("Couldn't find warp %s", warp); } } + + private boolean transact(FPlayer player) { + return P.p.getConfig().getBoolean("warp-cost.enabled", false) && !player.isAdminBypassing() && Econ.modifyMoney(player, P.p.getConfig().getDouble("warp-cost.delwarp", 5), "to delete warp", "for deleting warp"); + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java index c7177dba..42ea54b9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java @@ -1,5 +1,8 @@ package com.massivecraft.factions.cmd; +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.P; +import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.struct.Permission; public class CmdFWarp extends FCommand { @@ -29,6 +32,9 @@ public class CmdFWarp extends FCommand { } else { String warpName = argAsString(0); if (myFaction.isWarp(argAsString(0))) { + if (!transact(fme)) { + return; + } fme.getPlayer().teleport(myFaction.getWarp(warpName).getLocation()); fme.msg("Warped to %s", warpName); } else { @@ -36,4 +42,8 @@ public class CmdFWarp extends FCommand { } } } + + private boolean transact(FPlayer player) { + return P.p.getConfig().getBoolean("warp-cost.enabled", false) && !player.isAdminBypassing() && Econ.modifyMoney(player, P.p.getConfig().getDouble("warp-cost.warp", 5), "to warp", "for warping"); + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java index 5bec0ac8..13921eec 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java @@ -1,6 +1,8 @@ package com.massivecraft.factions.cmd; +import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.P; +import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.util.LazyLocation; @@ -31,9 +33,17 @@ public class CmdSetFWarp extends FCommand { return; } + if (!transact(fme)) { + return; + } + String warp = argAsString(0); LazyLocation loc = new LazyLocation(fme.getPlayer().getLocation()); myFaction.setWarp(warp, loc); fme.msg("Set warp %s to your location.", warp); } + + private boolean transact(FPlayer player) { + return P.p.getConfig().getBoolean("warp-cost.enabled", false) && !player.isAdminBypassing() && Econ.modifyMoney(player, P.p.getConfig().getDouble("warp-cost.setwarp", 5), "to set warp", "for setting warp"); + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 56800f49..e4bcf8f9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -23,6 +23,16 @@ findfactionsexploit: # What should be the max amount of warps that a Factoin can set? max-warps: 5 +# This is the cost section for warps. +# It will charge them each time the command would be successful. (won't charge on erroneous /f warp attempts). +# You can use decimal places here. +# If enabled is set to false, it will ignore the values. +warp-cost: + enabled: false + setwarp: 5 + delwarp: 5 + warp: 5 + # Pistons # Should we disable pistons in Faction territory? This will prevent people from doing something like: # http://i.gyazo.com/6a1a31222e58a5d60ff341c13f6a8404.gif