Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lRENyaaa committed Feb 23, 2024
2 parents 2cd35eb + 87b2a93 commit 31fa49e
Show file tree
Hide file tree
Showing 21 changed files with 443 additions and 190 deletions.
244 changes: 206 additions & 38 deletions src/Language/Russian.yml

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions src/com/bekvon/bukkit/residence/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public class ConfigManager {
protected boolean useVisualizer;
protected boolean DisableListeners;
protected boolean DisableCommands;
private boolean DisableResidenceCreation;

//Town
// private boolean TownEnabled = false;
Expand Down Expand Up @@ -690,12 +691,14 @@ public void UpdateConfigFile() {
DefaultWorld = c.get("Global.Optimizations.DefaultWorld", defaultWorldName);

c.addComment("Global.Optimizations.DisabledWorlds.List", "List Of Worlds where this plugin is disabled", "Make sure that world names capitalization is correct");
DisabledWorldsList = c.get("Global.Optimizations.DisabledWorlds.List", new ArrayList<String>());
DisabledWorldsList = c.get("Global.Optimizations.DisabledWorlds.List", Arrays.asList("worldNamesHere"));

c.addComment("Global.Optimizations.DisabledWorlds.DisableListeners", "Disables all listeners in included worlds");
DisableListeners = c.get("Global.Optimizations.DisabledWorlds.DisableListeners", true);
c.addComment("Global.Optimizations.DisabledWorlds.DisableCommands", "Disabled any command usage in included worlds");
c.addComment("Global.Optimizations.DisabledWorlds.DisableCommands", "Disables any command usage in included worlds");
DisableCommands = c.get("Global.Optimizations.DisabledWorlds.DisableCommands", true);
c.addComment("Global.Optimizations.DisabledWorlds.DisableResidenceCreation", "Disables residence creation in included worlds");
DisableResidenceCreation = c.get("Global.Optimizations.DisabledWorlds.DisableResidenceCreation", true);

c.addComment("Global.Optimizations.ItemPickUpDelay", "Delay in seconds between item pickups after residence flag prevents it", "Keep it at arround 10 sec to lower unesecery checks");
ItemPickUpDelay = c.get("Global.Optimizations.ItemPickUpDelay", 10);
Expand Down Expand Up @@ -1503,8 +1506,6 @@ public void UpdateConfigFile() {
Pl3xMapFillRented = argb(CMINumber.clamp((int) (Pl3xMapFillOpacity * 255), 0, 255), processColor(c.get("Pl3xMap.Fill.Rented", "#99ff33")));
Pl3xMapFillForSale = argb(CMINumber.clamp((int) (Pl3xMapFillOpacity * 255), 0, 255), processColor(c.get("Pl3xMap.Fill.ForSale", "#0066ff")));

CMIDebug.d(Pl3xFillColor, Pl3xMapFillForRent, Pl3xMapFillRented, Pl3xMapFillForSale);

c.addComment("Pl3xMap.VisibleRegions", "Shows only regions on this list");
Pl3xMapVisibleRegions = c.get("Pl3xMap.VisibleRegions", new ArrayList<String>());
c.addComment("Pl3xMap.HiddenRegions", "Hides region on map even if its not hidden in game");
Expand Down Expand Up @@ -2369,6 +2370,10 @@ public String getAutoCleanUserName() {
return AutoCleanUserName;
}

public boolean isDisableResidenceCreation() {
return DisableResidenceCreation;
}

// public int getTownMinRange() {
// return TownMinRange;
// }
Expand Down
3 changes: 3 additions & 0 deletions src/com/bekvon/bukkit/residence/Residence.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import com.bekvon.bukkit.residence.listeners.ResidencePlayerListener1_15;
import com.bekvon.bukkit.residence.listeners.ResidencePlayerListener1_16;
import com.bekvon.bukkit.residence.listeners.ResidencePlayerListener1_17;
import com.bekvon.bukkit.residence.listeners.ResidencePlayerListener1_19;
import com.bekvon.bukkit.residence.listeners.ResidencePlayerListener1_20;
import com.bekvon.bukkit.residence.listeners.ResidencePlayerListener1_9;
import com.bekvon.bukkit.residence.listeners.SpigotListener;
Expand Down Expand Up @@ -724,6 +725,8 @@ public void onEnable() {
pm.registerEvents(new ResidencePlayerListener1_16(this), this);
if (Version.isCurrentEqualOrHigher(Version.v1_17_R1))
pm.registerEvents(new ResidencePlayerListener1_17(this), this);
if (Version.isCurrentEqualOrHigher(Version.v1_19_R1))
pm.registerEvents(new ResidencePlayerListener1_19(this), this);
if (Version.isCurrentEqualOrHigher(Version.v1_20_R1))
pm.registerEvents(new ResidencePlayerListener1_20(this), this);

Expand Down
87 changes: 46 additions & 41 deletions src/com/bekvon/bukkit/residence/commands/bank.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,51 +19,56 @@ public class bank implements cmd {
@CommandAnnotation(simple = true, priority = 3400, regVar = { 2, 3 }, consoleVar = { 2, 3 })
public Boolean perform(Residence plugin, CommandSender sender, String[] args, boolean resadmin) {

ClaimedResidence res = null;
ClaimedResidence res = null;

if (args.length == 3) {
res = plugin.getResidenceManager().getByName(args[1]);
if (res == null) {
plugin.msg(sender, lm.Invalid_Residence);
return null;
}
} else if (sender instanceof Player) {
res = plugin.getResidenceManager().getByLoc(((Player) sender).getLocation());
}
if (res == null) {
plugin.msg(sender, lm.Residence_NotIn);
return null;
}
double amount = 0D;
try {
if (args.length == 2)
amount = Double.parseDouble(args[1]);
else
amount = Double.parseDouble(args[2]);
} catch (Exception ex) {
plugin.msg(sender, lm.Invalid_Amount);
return null;
}

switch(args[0].toLowerCase()) {
case "deposit":
res.getBank().deposit(sender, amount, resadmin);
return true;
case "withdraw":
res.getBank().withdraw(sender, amount, resadmin);
return true;
}

return false;
if (args.length == 3) {
res = plugin.getResidenceManager().getByName(args[1]);
if (res == null) {
plugin.msg(sender, lm.Invalid_Residence);
return null;
}
} else if (sender instanceof Player) {
res = plugin.getResidenceManager().getByLoc(((Player) sender).getLocation());
}
if (res == null) {
plugin.msg(sender, lm.Residence_NotIn);
return null;
}
double amount = 0D;
try {
if (args.length == 2)
amount = Double.parseDouble(args[1]);
else
amount = Double.parseDouble(args[2]);
} catch (Exception ex) {
plugin.msg(sender, lm.Invalid_Amount);
return null;
}

if (amount <= 0) {
plugin.msg(sender, lm.Invalid_Amount);
return null;
}

switch (args[0].toLowerCase()) {
case "deposit":
res.getBank().deposit(sender, amount, resadmin);
return true;
case "withdraw":
res.getBank().withdraw(sender, amount, resadmin);
return true;
}

return false;
}

@Override
public void getLocale() {
ConfigReader c = Residence.getInstance().getLocaleManager().getLocaleConfig();
c.get("Description", "Manage money in a Residence");
c.get("Info", Arrays.asList("&eUsage: &6/res bank [deposit/withdraw] <residence> [amount]",
"You must be standing in a Residence or provide residence name",
"You must have the +bank flag."));
LocaleManager.addTabCompleteMain(this, "deposit%%withdraw", "[residence]");
ConfigReader c = Residence.getInstance().getLocaleManager().getLocaleConfig();
c.get("Description", "Manage money in a Residence");
c.get("Info", Arrays.asList("&eUsage: &6/res bank [deposit/withdraw] <residence> [amount]",
"You must be standing in a Residence or provide residence name",
"You must have the +bank flag."));
LocaleManager.addTabCompleteMain(this, "deposit%%withdraw", "[residence]");
}
}
1 change: 0 additions & 1 deletion src/com/bekvon/bukkit/residence/commands/expand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.bekvon.bukkit.residence.protection.CuboidArea;

import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Logs.CMIDebug;

public class expand implements cmd {

Expand Down
8 changes: 8 additions & 0 deletions src/com/bekvon/bukkit/residence/commands/market.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,20 @@ private boolean commandResMarketRentable(String[] args, boolean resadmin, Player
plugin.msg(player, lm.Invalid_Cost);
return true;
}
if (cost <= 0) {
plugin.msg(player, lm.Invalid_Cost);
return true;
}
try {
days = Integer.parseInt(args[3]);
} catch (Exception ex) {
plugin.msg(player, lm.Invalid_Days);
return true;
}
if (days <= 0) {
plugin.msg(player, lm.Invalid_Days);
return true;
}
boolean AllowRenewing = plugin.getConfigManager().isRentAllowRenewing();
if (args.length >= 5) {
String ag = args[4];
Expand Down
1 change: 1 addition & 0 deletions src/com/bekvon/bukkit/residence/containers/Flags.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public enum Flags {
flowerpot(CMIMaterial.FLOWER_POT, FlagMode.Both, "Allows or denys interaction with flower pot", true),
grow(CMIMaterial.WHEAT_SEEDS, FlagMode.Residence, "Allows or denys plant growing", true),
glow(CMIMaterial.SEA_LANTERN, FlagMode.Residence, "Players will start glowing when entering residence", true),
goathorn(CMIMaterial.GOAT_HORN, FlagMode.Both, "Allows or denys goat horn usage", true),
harvest(CMIMaterial.SWEET_BERRIES, FlagMode.Both, "Allows harvesting", true),
hotfloor(CMIMaterial.MAGMA_BLOCK, FlagMode.Residence, "Prevent damage from magma blocks", true),
hidden(CMIMaterial.GLASS_PANE, FlagMode.Residence, "Hides residence from list or listall commands", false),
Expand Down
1 change: 1 addition & 0 deletions src/com/bekvon/bukkit/residence/containers/lm.java
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ public enum lm {
Permissions_cmdPermissionColor("&2"),

General_DisabledWorld("&cResidence plugin is disabled in this world"),
General_CantCreate("&cCan't create residences in this world"),
General_UseNumbers("&cPlease use numbers..."),
General_CantPlaceLava("&cYou can't place lava outside residence and higher than &6%1 &cblock level", "Replace all text with '' to disable this message"),
General_CantPlaceWater("&cYou can't place Water outside residence and higher than &6%1 &cblock level", "Replace all text with '' to disable this message"),
Expand Down
5 changes: 5 additions & 0 deletions src/com/bekvon/bukkit/residence/economy/CMIEconomy.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public double getBalance(String playerName) {

@Override
public boolean canAfford(Player player, double amount) {
if (amount <= 0) return false;
CMIUser user = CMI.getInstance().getPlayerManager().getUser(player);
if (user != null && user.getBalance() >= amount) {
return true;
Expand All @@ -34,6 +35,7 @@ public boolean canAfford(Player player, double amount) {

@Override
public boolean canAfford(String playerName, double amount) {
if (amount <= 0) return false;
CMIUser user = CMI.getInstance().getPlayerManager().getUser(playerName);
if (user != null && user.getBalance() >= amount) {
return true;
Expand All @@ -43,6 +45,7 @@ public boolean canAfford(String playerName, double amount) {

@Override
public boolean add(String playerName, double amount) {
if (amount <= 0) return false;
CMIUser user = CMI.getInstance().getPlayerManager().getUser(playerName);
if (user != null)
user.deposit(amount);
Expand All @@ -51,6 +54,7 @@ public boolean add(String playerName, double amount) {

@Override
public boolean subtract(String playerName, double amount) {
if (amount <= 0) return false;
if (!canAfford(playerName, amount)) {
return false;
}
Expand All @@ -62,6 +66,7 @@ public boolean subtract(String playerName, double amount) {

@Override
public boolean transfer(String playerFrom, String playerTo, double amount) {
if (amount <= 0) return false;
if (!canAfford(playerFrom, amount)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public double getBalance(String playerName) {

@Override
public boolean canAfford(Player player, double amount) {
if (amount <= 0) return false;
try {
if (Economy.playerExists(player.getUniqueId())) {
return Economy.hasEnough(player.getUniqueId(), BigDecimal.valueOf(amount));
Expand All @@ -62,6 +63,7 @@ public boolean canAfford(Player player, double amount) {
@SuppressWarnings("deprecation")
@Override
public boolean canAfford(String playerName, double amount) {
if (amount <= 0) return false;
try {
if (Economy.playerExists(playerName)) {
return Economy.hasEnough(playerName, amount);
Expand All @@ -75,6 +77,7 @@ public boolean canAfford(String playerName, double amount) {
@SuppressWarnings("deprecation")
@Override
public boolean add(String playerName, double amount) {
if (amount <= 0) return false;
if (Economy.playerExists(playerName)) {
try {
Economy.add(playerName, amount);
Expand All @@ -91,6 +94,7 @@ public boolean add(String playerName, double amount) {
@SuppressWarnings("deprecation")
@Override
public boolean subtract(String playerName, double amount) {
if (amount <= 0) return false;
if (Economy.playerExists(playerName)) {
try {
Economy.subtract(playerName, amount);
Expand All @@ -107,6 +111,7 @@ public boolean subtract(String playerName, double amount) {
@SuppressWarnings("deprecation")
@Override
public boolean transfer(String playerFrom, String playerTo, double amount) {
if (amount <= 0) return false;
try {
if (Economy.playerExists(playerFrom) && Economy.playerExists(playerTo) && Economy.hasEnough(playerFrom, amount)) {
if (!subtract(playerFrom, amount))
Expand Down
4 changes: 4 additions & 0 deletions src/com/bekvon/bukkit/residence/economy/IConomy6Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public boolean canAfford(Player player, double amount) {

@Override
public boolean canAfford(String playerName, double amount) {
if (amount <= 0) return false;
checkExist(playerName);
double holdings = this.getBalance(playerName);
if (holdings >= amount) {
Expand All @@ -43,13 +44,15 @@ public boolean canAfford(String playerName, double amount) {

@Override
public boolean add(String playerName, double amount) {
if (amount <= 0) return false;
checkExist(playerName);
new Accounts().get(playerName).getHoldings().add(amount);
return true;
}

@Override
public boolean subtract(String playerName, double amount) {
if (amount <= 0) return false;
checkExist(playerName);
if (this.canAfford(playerName, amount)) {
new Accounts().get(playerName).getHoldings().subtract(amount);
Expand All @@ -60,6 +63,7 @@ public boolean subtract(String playerName, double amount) {

@Override
public boolean transfer(String playerFrom, String playerTo, double amount) {
if (amount <= 0) return false;
checkExist(playerTo);
checkExist(playerFrom);
if (this.canAfford(playerFrom, amount)) {
Expand Down
4 changes: 4 additions & 0 deletions src/com/bekvon/bukkit/residence/economy/RealShopEconomy.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public boolean canAfford(Player player, double amount) {

@Override
public boolean canAfford(String playerName, double amount) {
if (amount <= 0) return false;
if (plugin.getBalance(playerName) >= amount) {
return true;
}
Expand All @@ -37,12 +38,14 @@ public boolean canAfford(String playerName, double amount) {

@Override
public boolean add(String playerName, double amount) {
if (amount <= 0) return false;
plugin.setBalance(playerName, plugin.getBalance(playerName) + amount);
return true;
}

@Override
public boolean subtract(String playerName, double amount) {
if (amount <= 0) return false;
if (!canAfford(playerName, amount)) {
return false;
}
Expand All @@ -52,6 +55,7 @@ public boolean subtract(String playerName, double amount) {

@Override
public boolean transfer(String playerFrom, String playerTo, double amount) {
if (amount <= 0) return false;
if (!canAfford(playerFrom, amount)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public void setForRent(Player player, String landName, int amount, int days, boo

public void setForRent(Player player, ClaimedResidence res, int amount, int days, boolean AllowRenewing, boolean StayInMarket, boolean AllowAutoPay,
boolean resadmin) {
if (amount < 0) return;

if (res == null) {
plugin.msg(player, lm.Invalid_Residence);
Expand Down
2 changes: 0 additions & 2 deletions src/com/bekvon/bukkit/residence/gui/FlagUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import java.util.Set;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import com.Zrips.CMI.CMI;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.containers.lm;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,15 @@
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.projectiles.ProjectileSource;

import com.Zrips.CMI.CMI;
import com.bekvon.bukkit.residence.ConfigManager;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.containers.Flags;
Expand All @@ -75,7 +74,6 @@
import net.Zrips.CMILib.Entities.CMIEntityType;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Version.Version;

public class ResidenceEntityListener implements Listener {
Expand Down
Loading

0 comments on commit 31fa49e

Please sign in to comment.