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 Jun 1, 2024
2 parents 868d340 + ffccdfc commit acfe50c
Show file tree
Hide file tree
Showing 25 changed files with 1,286 additions and 1,182 deletions.
144 changes: 77 additions & 67 deletions src/Language/ChineseTW.yml

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions src/com/bekvon/bukkit/residence/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.bekvon.bukkit.residence.protection.FlagPermissions;
import com.bekvon.bukkit.residence.protection.FlagPermissions.FlagState;

import net.Zrips.CMILib.CMILib;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.CMINumber;
import net.Zrips.CMILib.Effects.CMIEffectManager.CMIParticle;
Expand Down Expand Up @@ -222,9 +223,9 @@ public class ConfigManager {
protected boolean CreeperExplodeBelow;
protected int CreeperExplodeBelowLevel;

protected List<CMIMaterial> customContainers = new ArrayList<CMIMaterial>();
protected List<CMIMaterial> customBothClick = new ArrayList<CMIMaterial>();
protected List<CMIMaterial> customRightClick = new ArrayList<CMIMaterial>();
protected List<Material> customContainers = new ArrayList<Material>();
protected List<Material> customBothClick = new ArrayList<Material>();
protected List<Material> customRightClick = new ArrayList<Material>();
protected List<Material> CleanBlocks = new ArrayList<Material>();

protected List<String> NoFlowWorlds;
Expand Down Expand Up @@ -1288,23 +1289,23 @@ public void UpdateConfigFile() {

c.addComment("Global.CustomContainers", "Experimental - The following settings are lists of block IDs to be used as part of the checks for the 'container' and 'use' flags when using mods.");
List<String> pls = c.get("Global.CustomContainers", new ArrayList<String>());
for (Object one : pls) {
CMIMaterial mat = CMIMaterial.get(String.valueOf(one));
if (mat != CMIMaterial.NONE)
for (String one : pls) {
Material mat = CMILib.getInstance().getItemManager().getMaterial(one);
if (mat != null)
customContainers.add(mat);
}

pls = c.get("Global.CustomBothClick", new ArrayList<String>());
for (Object one : pls) {
CMIMaterial mat = CMIMaterial.get(String.valueOf(one));
if (mat != CMIMaterial.NONE)
for (String one : pls) {
Material mat = CMILib.getInstance().getItemManager().getMaterial(one);
if (mat != null)
customBothClick.add(mat);
}

pls = c.get("Global.CustomRightClick", new ArrayList<String>());
for (Object one : pls) {
CMIMaterial mat = CMIMaterial.get(String.valueOf(one));
if (mat != CMIMaterial.NONE)
for (String one : pls) {
Material mat = CMILib.getInstance().getItemManager().getMaterial(one);
if (mat != null)
customRightClick.add(mat);
}

Expand Down Expand Up @@ -2138,15 +2139,15 @@ public boolean isOfflineMode() {
return OfflineMode;
}

public List<CMIMaterial> getCustomContainers() {
public List<Material> getCustomContainers() {
return customContainers;
}

public List<CMIMaterial> getCustomBothClick() {
public List<Material> getCustomBothClick() {
return customBothClick;
}

public List<CMIMaterial> getCustomRightClick() {
public List<Material> getCustomRightClick() {
return customRightClick;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ public void sendUsage(CommandSender sender, String command) {

private boolean commandHelp(String[] args, boolean resadmin, CommandSender sender, Command command) {


if (plugin.getHelpPages() == null)
return false;

Expand All @@ -335,12 +334,10 @@ private boolean commandHelp(String[] args, boolean resadmin, CommandSender sende
if (command.getName().equalsIgnoreCase("res"))
resadmin = false;

CMIDebug.d("on commands ", 1, helppath);
if (plugin.getHelpPages().containesEntry(helppath)) {
CMIDebug.d("on commands ", 0);
plugin.getHelpPages().printHelp(sender, page, helppath, resadmin);
}
CMIDebug.d("on commands ", 2);

return true;
}

Expand Down
92 changes: 68 additions & 24 deletions src/com/bekvon/bukkit/residence/commands/bank.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,102 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import net.Zrips.CMILib.FileHandler.ConfigReader;
import com.bekvon.bukkit.residence.LocaleManager;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.containers.CommandAnnotation;
import com.bekvon.bukkit.residence.containers.cmd;
import com.bekvon.bukkit.residence.containers.lm;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;

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

public class bank implements cmd {

private enum Action {
deposit, withdraw, balance;

public static Action get(String name) {
for (Action one : Action.values()) {
if (one.name().equalsIgnoreCase(name))
return one;
}
return null;
}
}

@Override
@CommandAnnotation(simple = true, priority = 3400, regVar = { 2, 3 }, consoleVar = { 2, 3 })
@CommandAnnotation(simple = true, priority = 3400, regVar = { 1, 2, 3 }, consoleVar = { 2, 3 })
public Boolean perform(Residence plugin, CommandSender sender, String[] args, boolean resadmin) {

String resName = null;
ClaimedResidence res = null;
Action action = null;
double amount = 0D;

for (String one : args) {

if (action == null) {
action = Action.get(one);
continue;
}

if (resName == null) {
resName = one;
continue;
}

try {
if (amount <= 0)
amount = Double.parseDouble(one);
} catch (Exception ex) {
}
}

if (action == null)
action = Action.balance;

if (!action.equals(Action.balance) && amount == 0) {
try {
amount = Double.parseDouble(resName);
} catch (Exception ex) {
}
resName = null;
}

amount = CMINumber.clamp(amount, 0, Double.MAX_VALUE);

if (!action.equals(Action.balance) && amount == 0) {
plugin.msg(sender, lm.Invalid_Amount);
return null;
}
if (resName != null) {
res = plugin.getResidenceManager().getByName(resName);

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":
switch (action) {
case deposit:
res.getBank().deposit(sender, amount, resadmin);
return true;
case "withdraw":
case withdraw:
res.getBank().withdraw(sender, amount, resadmin);
return true;
case balance:
res.getBank().showBalance(sender, resadmin);
return true;
}

return false;
Expand All @@ -66,9 +110,9 @@ public Boolean perform(Residence plugin, CommandSender sender, String[] args, bo
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]",
c.get("Info", Arrays.asList("&eUsage: &6/res bank [deposit/withdraw/balance] <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]");
LocaleManager.addTabCompleteMain(this, "deposit%%withdraw%%balance", "[residence]");
}
}
Loading

0 comments on commit acfe50c

Please sign in to comment.