more specific placeholders

This commit is contained in:
RonanCraft
2022-10-14 11:48:55 -04:00
parent 69f38d524d
commit 64161b7b72
3 changed files with 75 additions and 15 deletions

View File

@@ -7,7 +7,7 @@
<groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTP</artifactId>
<packaging>jar</packaging>
<version>3.5.0-DEV3</version>
<version>3.5.0-DEV4</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>

View File

@@ -43,26 +43,41 @@ public class DepPlaceholderAPI extends PlaceholderExpansion {
if (request.equalsIgnoreCase("cooldown")) {
return cooldown(data, player.getWorld());
} else if (request.startsWith("cooldown_")) {
World world = getWorld(request.replace("cooldown_", ""));
return cooldown(data, world);
return cooldown(data, getWorld(request.replace("cooldown_", "")));
} else if (request.equalsIgnoreCase("cooldowntime")) {
return cooldownTime(data, player.getWorld());
} else if (request.startsWith("cooldowntime_")) {
World world = getWorld(request.replace("cooldowntime_", ""));
return cooldownTime(data, world);
return cooldownTime(data, getWorld(request.replace("cooldowntime_", "")));
}
} else if (request.startsWith("canrtp")) {
if (request.equalsIgnoreCase("canrtp")) {
return canRTPALL(player, player.getWorld());
} else if (request.startsWith("canrtp_")) {
return canRTPALL(player, getWorld(request.replace("canrtp_", "")));
} else if (request.startsWith("canrtpcooldown")) {
if (request.equalsIgnoreCase("canrtpcooldown")) {
return canRTP_cooldown(player, player.getWorld());
} else if (request.startsWith("canrtpcooldown_")) {
return canRTP_cooldown(player, getWorld(request.replace("canrtpcooldown_", "")));
}
} else if (request.startsWith("canrtpprice")) {
if (request.equalsIgnoreCase("canrtpprice")) {
return canRTP_price(player, player.getWorld());
} else if (request.startsWith("canrtpprice_")) {
return canRTP_price(player, getWorld(request.replace("canrtpprice_", "")));
}
} else if (request.startsWith("canrtphunger")) {
if (request.equalsIgnoreCase("canrtphunger")) {
return canRTP_hunger(player, player.getWorld());
} else if (request.startsWith("canrtphunger_")) {
return canRTP_hunger(player, getWorld(request.replace("canrtphunger_", "")));
}
}
} else if (request.startsWith("canrtp_")) {
World world = getWorld(request.replace("canrtp_", ""));
return canRTP(player, world);
} else if (request.equalsIgnoreCase("canrtp")) {
World world = player.getWorld();
return canRTP(player, world);
} else if (request.startsWith("price")) {
if (request.equalsIgnoreCase("price")) {
return price(player, player.getWorld());
} else if (request.startsWith("price_")) {
World world = getWorld(request.replace("price_", ""));
return price(player, world);
return price(player, getWorld(request.replace("price_", "")));
}
}
return null;
@@ -84,7 +99,7 @@ public class DepPlaceholderAPI extends PlaceholderExpansion {
return HelperDate.total(cooldownTime);
}
private String canRTP(Player player, World world) {
private String canRTPALL(Player player, World world) {
if (world == null) return "Invalid World";
world = HelperRTP.getActualWorld(player, world);
//Permission
@@ -105,6 +120,45 @@ public class DepPlaceholderAPI extends PlaceholderExpansion {
return BetterRTP.getInstance().getSettings().getPlaceholder_true();
}
private String canRTP_cooldown(Player player, World world) {
if (world == null) return "Invalid World";
world = HelperRTP.getActualWorld(player, world);
RTPSetupInformation setupInformation = new RTPSetupInformation(world, player, player, true);
WorldPlayer pWorld = HelperRTP.getPlayerWorld(setupInformation);
//Cooldown
if (HelperRTP_Check.isCoolingDown(player, player, pWorld))
return BetterRTP.getInstance().getSettings().getPlaceholder_cooldown();
//True
return BetterRTP.getInstance().getSettings().getPlaceholder_true();
}
private String canRTP_price(Player player, World world) {
if (world == null) return "Invalid World";
world = HelperRTP.getActualWorld(player, world);
RTPSetupInformation setupInformation = new RTPSetupInformation(world, player, player, true);
WorldPlayer pWorld = HelperRTP.getPlayerWorld(setupInformation);
//Price
if (!BetterRTP.getInstance().getEco().hasBalance(player, pWorld))
return BetterRTP.getInstance().getSettings().getPlaceholder_balance();
//True
return BetterRTP.getInstance().getSettings().getPlaceholder_true();
}
private String canRTP_hunger(Player player, World world) {
if (world == null) return "Invalid World";
world = HelperRTP.getActualWorld(player, world);
RTPSetupInformation setupInformation = new RTPSetupInformation(world, player, player, true);
WorldPlayer pWorld = HelperRTP.getPlayerWorld(setupInformation);
//Hunger
if (!BetterRTP.getInstance().getEco().hasHunger(player, pWorld))
return BetterRTP.getInstance().getSettings().getPlaceholder_hunger();
//True
return BetterRTP.getInstance().getSettings().getPlaceholder_true();
}
private String price(Player player, World world) {
if (world == null) return "Invalid World";
world = HelperRTP.getActualWorld(player, world);

View File

@@ -4,8 +4,14 @@ betterrtp_cooldown: 'Get cooldown in current world'
betterrtp_cooldown_<world_name>: 'Get cooldown of a specified world'
betterrtp_cooldowntime: 'Get cooldown time subject to in current world'
betterrtp_cooldowntime_<world_name>: 'Get cooldown time subject to in specified world'
betterrtp_canrtp_<world_name>: 'Get the reason or yes output if player can rtp in set world'
betterrtp_canrtp: 'Get the reason or yes output if player can rtp in current world'
betterrtp_canrtp_<world_name>: 'Get the reason or yes output if player can rtp in set world'
betterrtp_canrtpcooldown: 'Get if a player can rtp just based off their cooldown'
betterrtp_canrtpcooldown_<world_name>: 'Get if a player can rtp just based off their cooldown for this world'
betterrtp_canrtpprice: 'Get if a player can rtp just based off their bank account'
betterrtp_canrtpprice_<world_name>: 'Get if a player can rtp just based off their bank account for this world'
betterrtp_canrtphunger: 'Get if a player can rtp just based off their hunger'
betterrtp_canrtphunger_<world_name>: 'Get if a player can rtp just based off their hunger for this world'
betterrtp_price: 'Get the price of rtp''ing in current world'
betterrtp_price_<world_name>: 'Get the price of rtp''ing in specified world'