Added infinite charging

This commit is contained in:
Niels Vergucht 2018-12-20 20:50:48 +01:00
parent 02b03f10ee
commit f8bf3cbc99
5 changed files with 29 additions and 1 deletions

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>EpicBuckets</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>1.2.5</version>
<version>1.3</version>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>

View File

@ -44,7 +44,11 @@ public class ConfigManager {
private int spongeRadius;
private int maxGenbucketsPerPlayer;
private boolean unlimitedGenbuckets;
private boolean infiniteUse;
private boolean chargeInfiniteUse;
private int infiniteUseCost;
private int maxVerticalHeight;
private int maxHorizontalLength;
private int delay;
@ -104,6 +108,8 @@ public class ConfigManager {
inventoryName = epicBuckets.getConfig().getString(menuItemsPath + ".inventory-name");
fillInventory = epicBuckets.getConfig().getBoolean(menuItemsPath + ".fill");
epicBuckets.getConfig().getConfigurationSection("CUSTOM-ACTIVE-GEN-PER-PLAY").getKeys(false).forEach(s -> genbucketGroups.put(epicBuckets.getConfig().getString("CUSTOM-ACTIVE-GEN-PER-PLAY." + s).split(":")[1], Integer.parseInt(epicBuckets.getConfig().getString("CUSTOM-ACTIVE-GEN-PER-PLAY." + s).split(":")[0])));
chargeInfiniteUse = epicBuckets.getConfig().getBoolean("CHARGE-FOR-INFINITE-USE");
infiniteUseCost = epicBuckets.getConfig().getInt("COST-FOR-INFINITE-USE");
}
private void loadValidFaces() {
@ -278,4 +284,12 @@ public class ConfigManager {
public boolean isInfiniteUse() {
return infiniteUse;
}
public boolean isChargeInfiniteUse() {
return chargeInfiniteUse;
}
public int getInfiniteUseCost() {
return infiniteUseCost;
}
}

View File

@ -10,6 +10,7 @@ import com.songoda.epicbuckets.genbucket.types.PsuedoVertical;
import com.songoda.epicbuckets.genbucket.types.Vertical;
import com.songoda.epicbuckets.util.XMaterial;
import de.tr7zw.itemnbtapi.NBTItem;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -89,6 +90,15 @@ public class GenbucketPlaceListener implements Listener {
}
}
if (EpicBuckets.getInstance().getConfigManager().isInfiniteUse() && EpicBuckets.getInstance().getConfigManager().isChargeInfiniteUse()) {
if (EpicBuckets.getInstance().getEcon().getBalance(Bukkit.getOfflinePlayer(e.getPlayer().getUniqueId())) < EpicBuckets.getInstance().getConfigManager().getInfiniteUseCost()) {
e.getPlayer().sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.genbucket.infiniteuse.notenough"));
return;
}
EpicBuckets.getInstance().getEcon().withdrawPlayer(Bukkit.getOfflinePlayer(e.getPlayer().getUniqueId()), EpicBuckets.getInstance().getConfigManager().getInfiniteUseCost());
e.getPlayer().sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.genbucket.infiniteuse.charge").replace("%charge%", EpicBuckets.getInstance().getConfigManager().getInfiniteUseCost() + ""));
}
EpicBuckets.getInstance().getGenbucketManager().registerGenbucketForPlayer(e.getPlayer(), genbucket);
EpicBuckets.getInstance().getGenbucketManager().notifyAdmins(e.getPlayer(), genbucket);
genbucket.generate();

View File

@ -21,6 +21,8 @@ ENCHANT: false # Enchant genbuckets in all guis
CLOSE-GUI-AFTER-PURCHASE: false # Close the inventory after purchase
INFINITE-USE: false # If enabled, you won't lose a genbucket when you place it down
CHARGE-FOR-INFINITE-USE: false # This requires infinite use to be enabled and will charge the player when placing a genbucket
COST-FOR-INFINITE-USE: 400 # Money charged for placing a genbucket when the above is enabled
USE-SPONGE-SUPPORT: false # If a sponge is found it will stop the genbucket
SPONGE-RADIUS: 3 # <- SPONGE-RADIUS 3 == 3x3. I do not recommending putting this higher than 3

View File

@ -31,3 +31,5 @@ event.genbucket.disabled = "&eGenbuckets &7are currently disabled!"
event.genbucket.placedwrong = "&e%genbucket% &7cant be placed on that side of the block!"
event.genbucket.wrongmaterialpsuedo = "&7You cannot use the psuedo bucket on this &eblock!"
event.genbucket.admin = "&e%player% &7has placed a &e%genbucket%&7!"
event.genbucket.infiniteuse.charge = "&7You were charged &a%charge% &7for placing a genbucket"
event.genbucket.infiniteuse.notenough = "&cYou do not have enough to place a genbucket!"