This commit is contained in:
Jules 2020-12-24 01:15:07 +01:00
commit 22be11bdb2
3 changed files with 65 additions and 66 deletions

View File

@ -26,8 +26,8 @@ public class BlockInfo {
private final BlockType block; private final BlockType block;
private final DropTable table; private final DropTable table;
private final boolean vanillaDrops; private final boolean vanillaDrops;
private final List<Trigger> triggers = new ArrayList<>();
private final RegenInfo regen; private final RegenInfo regen;
private final List<Trigger> triggers = new ArrayList<>();
private final List<BlockCondition> conditions = new ArrayList<>(); private final List<BlockCondition> conditions = new ArrayList<>();
/* /*

View File

@ -46,23 +46,21 @@ public class RPGPlaceholders extends PlaceholderExpansion {
@SuppressWarnings("DuplicateExpressions") @SuppressWarnings("DuplicateExpressions")
@Override @Override
public String onRequest(@Nullable OfflinePlayer player, @NotNull String identifier) { public String onRequest(@Nullable OfflinePlayer player, @NotNull String identifier) {
PlayerData playerData = PlayerData.get(player);
if (identifier.equals("mana_icon")) if (identifier.equals("mana_icon"))
return PlayerData.get(player).getProfess().getManaDisplay().getIcon(); return playerData.getProfess().getManaDisplay().getIcon();
if (identifier.equals("mana_name")) if (identifier.equals("mana_name"))
return PlayerData.get(player).getProfess().getManaDisplay().getName(); return playerData.getProfess().getManaDisplay().getName();
if (identifier.equals("level")) if (identifier.equals("level"))
return "" + PlayerData.get(player).getLevel(); return "" + playerData.getLevel();
else if (identifier.equals("level_percent")) { else if (identifier.equals("level_percent")) {
PlayerData playerData = PlayerData.get(player);
double current = playerData.getExperience(), next = playerData.getLevelUpExperience(); double current = playerData.getExperience(), next = playerData.getLevelUpExperience();
return MMOLib.plugin.getMMOConfig().decimal.format(current / next * 100); return MMOLib.plugin.getMMOConfig().decimal.format(current / next * 100);
} }
else if (identifier.equals("combat"))
return String.valueOf(PlayerData.get(player).isInCombat());
else if (identifier.equals("health") && player.isOnline()) { else if (identifier.equals("health") && player.isOnline()) {
return StatType.MAX_HEALTH.format(player.getPlayer().getHealth()); return StatType.MAX_HEALTH.format(player.getPlayer().getHealth());
} }
@ -73,71 +71,74 @@ public class RPGPlaceholders extends PlaceholderExpansion {
else if (identifier.equals("health_bar") && player.isOnline()) { else if (identifier.equals("health_bar") && player.isOnline()) {
StringBuilder format = new StringBuilder(); StringBuilder format = new StringBuilder();
double ratio = 20 * player.getPlayer().getHealth() double ratio = 20 * player.getPlayer().getHealth() / player.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
/ player.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
for (double j = 1; j < 20; j++) for (double j = 1; j < 20; j++)
format.append(ratio >= j ? ChatColor.RED : ratio >= j - .5 ? ChatColor.DARK_RED : ChatColor.DARK_GRAY).append(AltChar.listSquare); format.append(ratio >= j ? ChatColor.RED : ratio >= j - .5 ? ChatColor.DARK_RED : ChatColor.DARK_GRAY).append(AltChar.listSquare);
return format.toString(); return format.toString();
} }
else if (identifier.equals("class")) else if (identifier.equals("class"))
return PlayerData.get(player).getProfess().getName(); return playerData.getProfess().getName();
else if (identifier.startsWith("profession_percent_")) { else if (identifier.startsWith("profession_percent_")) {
PlayerProfessions professions = PlayerData.get(player).getCollectionSkills(); PlayerProfessions professions = playerData.getCollectionSkills();
String name = identifier.substring(19).replace(" ", "-").replace("_", "-").toLowerCase(); String name = identifier.substring(19).replace(" ", "-").replace("_", "-").toLowerCase();
Profession profession = MMOCore.plugin.professionManager.get(name); Profession profession = MMOCore.plugin.professionManager.get(name);
double current = professions.getExperience(profession), next = professions.getLevelUpExperience(profession); double current = professions.getExperience(profession), next = professions.getLevelUpExperience(profession);
return MMOLib.plugin.getMMOConfig().decimal.format(current / next * 100); return MMOLib.plugin.getMMOConfig().decimal.format(current / next * 100);
} }
else if (identifier.startsWith("is_casting")) {
return String.valueOf(playerData.isCasting());
} else if (identifier.startsWith("in_combat")) {
return String.valueOf(playerData.isInCombat());
}
else if (identifier.startsWith("bound_")) { else if (identifier.startsWith("bound_")) {
int slot = Math.max(0, Integer.parseInt(identifier.substring(6)) - 1); int slot = Math.max(0, Integer.parseInt(identifier.substring(6)) - 1);
PlayerData playerData = PlayerData.get(player);
return playerData.hasSkillBound(slot) ? playerData.getBoundSkill(slot).getSkill().getName() return playerData.hasSkillBound(slot) ? playerData.getBoundSkill(slot).getSkill().getName()
: MMOCore.plugin.configManager.noSkillBoundPlaceholder; : MMOCore.plugin.configManager.noSkillBoundPlaceholder;
} }
else if (identifier.startsWith("profession_experience_")) else if (identifier.startsWith("profession_experience_"))
return "" + PlayerData.get(player).getCollectionSkills() return String.valueOf(
.getExperience(identifier.substring(22).replace(" ", "-").replace("_", "-").toLowerCase()); playerData.getCollectionSkills().getExperience(identifier.substring(22).replace(" ", "-").replace("_", "-").toLowerCase()));
else if (identifier.startsWith("profession_next_level_")) else if (identifier.startsWith("profession_next_level_"))
return "" + PlayerData.get(player).getCollectionSkills() return "" + PlayerData.get(player).getCollectionSkills()
.getLevelUpExperience(identifier.substring(22).replace(" ", "-").replace("_", "-").toLowerCase()); .getLevelUpExperience(identifier.substring(22).replace(" ", "-").replace("_", "-").toLowerCase());
else if (identifier.startsWith("profession_")) else if (identifier.startsWith("profession_"))
return "" + PlayerData.get(player).getCollectionSkills() return String
.getLevel(identifier.substring(11).replace(" ", "-").replace("_", "-").toLowerCase()); .valueOf(playerData.getCollectionSkills().getLevel(identifier.substring(11).replace(" ", "-").replace("_", "-").toLowerCase()));
else if (identifier.equals("experience")) else if (identifier.equals("experience"))
return "" + PlayerData.get(player).getExperience(); return String.valueOf(playerData.getExperience());
else if (identifier.equals("next_level")) else if (identifier.equals("next_level"))
return "" + PlayerData.get(player).getLevelUpExperience(); return String.valueOf(playerData.getLevelUpExperience());
else if (identifier.equals("class_points")) else if (identifier.equals("class_points"))
return "" + PlayerData.get(player).getClassPoints(); return String.valueOf(playerData.getClassPoints());
else if (identifier.equals("skill_points")) else if (identifier.equals("skill_points"))
return "" + PlayerData.get(player).getSkillPoints(); return String.valueOf(playerData.getSkillPoints());
else if (identifier.equals("attribute_points")) else if (identifier.equals("attribute_points"))
return "" + PlayerData.get(player).getAttributePoints(); return String.valueOf(playerData.getAttributePoints());
else if (identifier.equals("attribute_reallocation_points")) else if (identifier.equals("attribute_reallocation_points"))
return "" + PlayerData.get(player).getAttributeReallocationPoints(); return String.valueOf(playerData.getAttributeReallocationPoints());
else if (identifier.startsWith("attribute_")) else if (identifier.startsWith("attribute_"))
return String.valueOf(PlayerData.get(player).getAttributes() return String.valueOf(playerData.getAttributes()
.getAttribute(MMOCore.plugin.attributeManager.get(identifier.substring(10).toLowerCase().replace("_", "-")))); .getAttribute(MMOCore.plugin.attributeManager.get(identifier.substring(10).toLowerCase().replace("_", "-"))));
else if (identifier.equals("mana")) else if (identifier.equals("mana"))
return MMOLib.plugin.getMMOConfig().decimal.format(PlayerData.get(player).getMana()); return MMOLib.plugin.getMMOConfig().decimal.format(playerData.getMana());
else if (identifier.equals("mana_bar")) { else if (identifier.equals("mana_bar")) {
PlayerData data = PlayerData.get(player); return playerData.getProfess().getManaDisplay().generateBar(playerData.getMana(), playerData.getStats().getStat(StatType.MAX_MANA));
return data.getProfess().getManaDisplay().generateBar(data.getMana(), data.getStats().getStat(StatType.MAX_MANA));
} }
else if (identifier.startsWith("exp_multiplier_")) { else if (identifier.startsWith("exp_multiplier_")) {
@ -153,68 +154,65 @@ public class RPGPlaceholders extends PlaceholderExpansion {
} }
else if (identifier.equals("stamina")) else if (identifier.equals("stamina"))
return MMOLib.plugin.getMMOConfig().decimal.format(PlayerData.get(player).getStamina()); return MMOLib.plugin.getMMOConfig().decimal.format(playerData.getStamina());
else if (identifier.equals("stamina_bar")) { else if (identifier.equals("stamina_bar")) {
StringBuilder format = new StringBuilder(); StringBuilder format = new StringBuilder();
PlayerData data = PlayerData.get(player); double ratio = 20 * playerData.getStamina() / playerData.getStats().getStat(StatType.MAX_STAMINA);
double ratio = 20 * data.getStamina() / data.getStats().getStat(StatType.MAX_STAMINA);
for (double j = 1; j < 20; j++) for (double j = 1; j < 20; j++)
format.append(ratio >= j ? MMOCore.plugin.configManager.staminaFull : ratio >= j - .5 ? MMOCore.plugin.configManager.staminaHalf : MMOCore.plugin.configManager.staminaEmpty).append(AltChar.listSquare); format.append(ratio >= j ? MMOCore.plugin.configManager.staminaFull
: ratio >= j - .5 ? MMOCore.plugin.configManager.staminaHalf : MMOCore.plugin.configManager.staminaEmpty)
.append(AltChar.listSquare);
return format.toString(); return format.toString();
} }
else if (identifier.startsWith("stat_")) { else if (identifier.startsWith("stat_")) {
StatType type = StatType.valueOf(identifier.substring(5).toUpperCase()); StatType type = StatType.valueOf(identifier.substring(5).toUpperCase());
return type == null ? "Invalid Stat" : type.format(PlayerData.get(player).getStats().getStat(type)); return type == null ? "Invalid Stat" : type.format(playerData.getStats().getStat(type));
} }
else if (identifier.equals("stellium")) else if (identifier.equals("stellium"))
return MMOLib.plugin.getMMOConfig().decimal.format(PlayerData.get(player).getStellium()); return MMOLib.plugin.getMMOConfig().decimal.format(playerData.getStellium());
else if (identifier.equals("stellium_bar")) { else if (identifier.equals("stellium_bar")) {
StringBuilder format = new StringBuilder(); StringBuilder format = new StringBuilder();
PlayerData data = PlayerData.get(player); double ratio = 20 * playerData.getStellium() / playerData.getStats().getStat(StatType.MAX_STELLIUM);
double ratio = 20 * data.getStellium() / data.getStats().getStat(StatType.MAX_STELLIUM);
for (double j = 1; j < 20; j++) for (double j = 1; j < 20; j++)
format.append(ratio >= j ? ChatColor.BLUE : ratio >= j - .5 ? ChatColor.AQUA : ChatColor.WHITE).append(AltChar.listSquare); format.append(ratio >= j ? ChatColor.BLUE : ratio >= j - .5 ? ChatColor.AQUA : ChatColor.WHITE).append(AltChar.listSquare);
return format.toString(); return format.toString();
} }
else if (identifier.equals("quest")) { else if (identifier.equals("quest")) {
PlayerQuests data = PlayerData.get(player).getQuestData(); PlayerQuests data = playerData.getQuestData();
return data.hasCurrent() ? data.getCurrent().getQuest().getName() : "None"; return data.hasCurrent() ? data.getCurrent().getQuest().getName() : "None";
} }
else if (identifier.equals("quest_progress")) { else if (identifier.equals("quest_progress")) {
PlayerQuests data = PlayerData.get(player).getQuestData(); PlayerQuests data = playerData.getQuestData();
return data.hasCurrent() return data.hasCurrent() ? MMOLib.plugin.getMMOConfig().decimal
? MMOLib.plugin.getMMOConfig().decimal .format((int) (double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100) : "0";
.format((int) (double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100)
: "0";
} }
else if (identifier.equals("quest_objective")) { else if (identifier.equals("quest_objective")) {
PlayerQuests data = PlayerData.get(player).getQuestData(); PlayerQuests data = playerData.getQuestData();
return data.hasCurrent() ? data.getCurrent().getFormattedLore() : "None"; return data.hasCurrent() ? data.getCurrent().getFormattedLore() : "None";
} }
else if (identifier.startsWith("guild_")) { else if (identifier.startsWith("guild_")) {
String placeholder = identifier.substring(6); String placeholder = identifier.substring(6);
PlayerData data = PlayerData.get(player); if (playerData.getGuild() == null)
if (data.getGuild() == null)
return ""; return "";
if (placeholder.equalsIgnoreCase("name")) if (placeholder.equalsIgnoreCase("name"))
return data.getGuild().getName(); return playerData.getGuild().getName();
else if (placeholder.equalsIgnoreCase("tag")) else if (placeholder.equalsIgnoreCase("tag"))
return data.getGuild().getTag(); return playerData.getGuild().getTag();
else if (placeholder.equalsIgnoreCase("leader")) else if (placeholder.equalsIgnoreCase("leader"))
return Bukkit.getOfflinePlayer(data.getGuild().getOwner()).getName(); return Bukkit.getOfflinePlayer(playerData.getGuild().getOwner()).getName();
else if (placeholder.equalsIgnoreCase("members")) else if (placeholder.equalsIgnoreCase("members"))
return "" + data.getGuild().getMembers().count(); return "" + playerData.getGuild().getMembers().count();
else if (placeholder.equalsIgnoreCase("online_members")) else if (placeholder.equalsIgnoreCase("online_members"))
return "" + data.getGuild().getMembers().countOnline(); return "" + playerData.getGuild().getMembers().countOnline();
} }
return null; return null;

View File

@ -49,11 +49,12 @@ public class BlockListener implements Listener {
/* /*
* If the block is a temporary block placed by block regen, immediately * If the block is a temporary block placed by block regen, immediately
* cancel the break event * cancel the break event; also check for extra config provided block
* conditions
*/ */
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block); BlockInfo info = MMOCore.plugin.mineManager.getInfo(block);
boolean temporaryBlock = MMOCore.plugin.mineManager.isTemporaryBlock(block); boolean temporaryBlock = MMOCore.plugin.mineManager.isTemporaryBlock(block);
if ((temporaryBlock && info == null) || !info.checkConditions(block)) { if ((temporaryBlock && info == null) || (info != null && !info.checkConditions(block))) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }