forked from Upstream/mmocore
!Everything needed for Custom Blocks
This commit is contained in:
parent
5a16632610
commit
4f228fd40a
@ -2,6 +2,7 @@ package net.Indyuce.mmocore;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -246,6 +247,30 @@ public class MMOCore extends JavaPlugin {
|
||||
saveDefaultConfig();
|
||||
reloadPlugin();
|
||||
|
||||
/*
|
||||
* default action bar.
|
||||
* only ran if the action bar is enabled
|
||||
*/
|
||||
if(getConfig().getBoolean("action-bar.enabled")) {
|
||||
DecimalFormat format = new DecimalFormat(getConfig().getString("action-bar.decimal"), configManager.formatSymbols);
|
||||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
for (PlayerData data : PlayerData.getAll()) {
|
||||
if(!data.isCasting()) {
|
||||
data.displayActionBar(placeholderParser.parse(data.getPlayer(), ChatColor.translateAlternateColorCodes('&', getConfig().getString("action-bar.format")
|
||||
.replace("{health}", format.format(data.getPlayer().getHealth())).replace("{max_health}", "" + StatType.MAX_HEALTH.format(data.getStats().getStat(StatType.MAX_HEALTH)))
|
||||
.replace("{mana}", format.format(data.getMana())).replace("{max_mana}", "" + StatType.MAX_MANA.format(data.getStats().getStat(StatType.MAX_MANA)))
|
||||
.replace("{stamina}", format.format(data.getStamina())).replace("{max_stamina}", "" + StatType.MAX_STAMINA.format(data.getStats().getStat(StatType.MAX_STAMINA)))
|
||||
.replace("{stellium}", format.format(data.getStellium())).replace("{max_stellium}", "" + StatType.MAX_STELLIUM.format(data.getStats().getStat(StatType.MAX_STELLIUM)))
|
||||
.replace("{class}", data.getProfess().getName()).replace("{xp}", "" + data.getExperience()).replace("{armor}", "" + StatType.ARMOR.format(data.getStats().getStat(StatType.ARMOR)))
|
||||
.replace("{level}", "" + data.getLevel()).replace("{name}", data.getPlayer().getDisplayName()))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(MMOCore.plugin, 100, getConfig().getInt("action-bar.ticks-to-update"));
|
||||
}
|
||||
|
||||
/*
|
||||
* enable debug mode for extra debug tools.
|
||||
*/
|
||||
@ -293,19 +318,19 @@ public class MMOCore extends JavaPlugin {
|
||||
|
||||
FileConfiguration config = new ConfigFile("commands").getConfig();
|
||||
|
||||
commandMap.register("mmocore", new PlayerStatsCommand(config.getConfigurationSection("player")));
|
||||
commandMap.register("mmocore", new AttributesCommand(config.getConfigurationSection("attributes")));
|
||||
commandMap.register("mmocore", new ClassCommand(config.getConfigurationSection("class")));
|
||||
commandMap.register("mmocore", new WaypointsCommand(config.getConfigurationSection("waypoints")));
|
||||
commandMap.register("mmocore", new QuestsCommand(config.getConfigurationSection("quests")));
|
||||
commandMap.register("mmocore", new SkillsCommand(config.getConfigurationSection("skills")));
|
||||
commandMap.register("mmocore", new FriendsCommand(config.getConfigurationSection("friends")));
|
||||
commandMap.register("mmocore", new PartyCommand(config.getConfigurationSection("party")));
|
||||
commandMap.register("mmocore", new GuildCommand(config.getConfigurationSection("guild")));
|
||||
if(config.contains("player")) commandMap.register("mmocore", new PlayerStatsCommand(config.getConfigurationSection("player")));
|
||||
if(config.contains("attributes")) commandMap.register("mmocore", new AttributesCommand(config.getConfigurationSection("attributes")));
|
||||
if(config.contains("class")) commandMap.register("mmocore", new ClassCommand(config.getConfigurationSection("class")));
|
||||
if(config.contains("waypoints")) commandMap.register("mmocore", new WaypointsCommand(config.getConfigurationSection("waypoints")));
|
||||
if(config.contains("quests")) commandMap.register("mmocore", new QuestsCommand(config.getConfigurationSection("quests")));
|
||||
if(config.contains("skills")) commandMap.register("mmocore", new SkillsCommand(config.getConfigurationSection("skills")));
|
||||
if(config.contains("friends")) commandMap.register("mmocore", new FriendsCommand(config.getConfigurationSection("friends")));
|
||||
if(config.contains("party")) commandMap.register("mmocore", new PartyCommand(config.getConfigurationSection("party")));
|
||||
if(config.contains("guild")) commandMap.register("mmocore", new GuildCommand(config.getConfigurationSection("guild")));
|
||||
|
||||
if (hasEconomy() && economy.isValid()) {
|
||||
commandMap.register("mmocore", new WithdrawCommand(config.getConfigurationSection("withdraw")));
|
||||
commandMap.register("mmocore", new DepositCommand(config.getConfigurationSection("deposit")));
|
||||
if(config.contains("withdraw")) commandMap.register("mmocore", new WithdrawCommand(config.getConfigurationSection("withdraw")));
|
||||
if(config.contains("deposit")) commandMap.register("mmocore", new DepositCommand(config.getConfigurationSection("deposit")));
|
||||
}
|
||||
}
|
||||
catch(NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) {
|
||||
|
@ -38,7 +38,7 @@ public class Withdraw implements Listener {
|
||||
return;
|
||||
|
||||
withdrawing.add(player.getUniqueId());
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("withdrawing"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("withdrawing").send(player);
|
||||
Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin);
|
||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> close(), 20 * 20);
|
||||
}
|
||||
@ -60,7 +60,7 @@ public class Withdraw implements Listener {
|
||||
if (!event.getPlayer().equals(player))
|
||||
return;
|
||||
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("withdraw-cancel"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("withdraw-cancel").send(player);
|
||||
close();
|
||||
}
|
||||
|
||||
@ -75,13 +75,13 @@ public class Withdraw implements Listener {
|
||||
try {
|
||||
worth = Integer.parseInt(event.getMessage());
|
||||
} catch (Exception e) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("wrong-number", "arg", event.getMessage()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("wrong-number", "arg", event.getMessage()).send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int left = (int) (MMOCore.plugin.economy.getEconomy().getBalance(player) - worth);
|
||||
if (left < 0) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-enough-money", "left", "" + -left));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-enough-money", "left", "" + -left).send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public class Withdraw implements Listener {
|
||||
MMOCore.plugin.economy.getEconomy().withdrawPlayer(player, worth);
|
||||
withdrawAlgorythm(worth);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("withdrew", "worth", "" + worth));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("withdrew", "worth", "" + worth).send(player);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,6 @@ public class Profession {
|
||||
if (config.contains("on-mine"))
|
||||
MMOCore.plugin.mineManager.loadDropTables(config.getConfigurationSection("on-mine"));
|
||||
|
||||
if (config.contains("on-mine-playerhead"))
|
||||
MMOCore.plugin.mineManager.loadPHDropTables(config.getConfigurationSection("on-mine-playerhead"));
|
||||
|
||||
if (config.contains("alchemy-experience")) {
|
||||
|
||||
MMOCore.plugin.alchemyManager.splash = 1 + config.getDouble("alchemy-experience.special.splash") / 100;
|
||||
|
@ -22,7 +22,7 @@ public class AnvilGUI extends PlayerInput {
|
||||
|
||||
ItemStack paper = new ItemStack(Material.PAPER);
|
||||
ItemMeta paperMeta = paper.getItemMeta();
|
||||
paperMeta.setDisplayName(MMOCore.plugin.configManager.getSimpleMessage("player-input.anvil." + type.getLowerCaseName()));
|
||||
paperMeta.setDisplayName(MMOCore.plugin.configManager.getSimpleMessage("player-input.anvil." + type.getLowerCaseName()).message());
|
||||
paper.setItemMeta(paperMeta);
|
||||
|
||||
MMOCore.plugin.nms.handleInventoryCloseEvent(player);
|
||||
|
@ -15,8 +15,8 @@ public class ChatInput extends PlayerInput {
|
||||
super(player, output);
|
||||
|
||||
player.closeInventory();
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("player-input.chat." + type.getLowerCaseName()));
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("player-input.chat.cancel"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("player-input.chat." + type.getLowerCaseName()).send(player);
|
||||
MMOCore.plugin.configManager.getSimpleMessage("player-input.chat.cancel").send(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,7 @@ public class CombatRunnable extends BukkitRunnable {
|
||||
|
||||
config = MMOCore.plugin.configManager;
|
||||
|
||||
if(!config.getSimpleMessage("now-in-combat").isEmpty()) player.getPlayer().sendMessage(config.getSimpleMessage("now-in-combat"));
|
||||
config.getSimpleMessage("now-in-combat").send(player.getPlayer());
|
||||
Bukkit.getPluginManager().callEvent(new PlayerCombatEvent(player, true));
|
||||
runTaskTimer(MMOCore.plugin, 20, 20);
|
||||
}
|
||||
@ -31,7 +31,7 @@ public class CombatRunnable extends BukkitRunnable {
|
||||
public void run() {
|
||||
if (lastHit + 10000 < System.currentTimeMillis()) {
|
||||
Bukkit.getPluginManager().callEvent(new PlayerCombatEvent(player, false));
|
||||
if(!config.getSimpleMessage("leave-combat").isEmpty()) player.getPlayer().sendMessage(config.getSimpleMessage("leave-combat"));
|
||||
config.getSimpleMessage("leave-combat").send(player.getPlayer());
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
@ -437,19 +437,18 @@ public class PlayerData {
|
||||
giveStellium(-waypoint.getStelliumCost());
|
||||
|
||||
new BukkitRunnable() {
|
||||
String message = MMOCore.plugin.configManager.getSimpleMessage("warping-comencing");
|
||||
int x = player.getLocation().getBlockX(), y = player.getLocation().getBlockY(), z = player.getLocation().getBlockZ(), t;
|
||||
|
||||
public void run() {
|
||||
if (player.getLocation().getBlockX() != x || player.getLocation().getBlockY() != y || player.getLocation().getBlockZ() != z) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, .5f);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("warping-canceled"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("warping-canceled").send(player);
|
||||
giveStellium(waypoint.getStelliumCost());
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
displayActionBar(message.replace("{left}", "" + ((120 - t) / 20)));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("warping-comencing", "left", "" + ((120 - t) / 20)).send(player);
|
||||
if (t++ >= 100) {
|
||||
player.teleport(waypoint.getLocation());
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false));
|
||||
@ -739,10 +738,10 @@ public class PlayerData {
|
||||
if (!cast.isSuccessful()) {
|
||||
|
||||
if (cast.getCancelReason() == CancelReason.MANA)
|
||||
getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("casting.no-mana"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("casting.no-mana").send(player);
|
||||
|
||||
if (cast.getCancelReason() == CancelReason.COOLDOWN)
|
||||
getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("casting.on-cooldown"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("casting.on-cooldown").send(player);
|
||||
|
||||
return cast;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class Professions {
|
||||
|
||||
// display hologram
|
||||
if (loc != null && MMOCore.plugin.hologramSupport != null)
|
||||
MMOCore.plugin.hologramSupport.displayIndicator(loc, MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value), playerData.getPlayer());
|
||||
MMOCore.plugin.hologramSupport.displayIndicator(loc, MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), playerData.getPlayer());
|
||||
|
||||
int needed, exp, level;
|
||||
boolean check = false;
|
||||
@ -108,6 +108,6 @@ public class Professions {
|
||||
int chars = (int) ((double) exp / needed * 20);
|
||||
for (int j = 0; j < 20; j++)
|
||||
bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|";
|
||||
playerData.displayActionBar(MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar, "ratio", MMOCore.plugin.configManager.decimal.format((double) exp / needed * 100)));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar, "ratio", MMOCore.plugin.configManager.decimal.format((double) exp / needed * 100)).send(playerData.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ public class FriendRequest extends Request {
|
||||
getCreator().setLastFriendRequest(0);
|
||||
getCreator().addFriend(target.getUniqueId());
|
||||
target.addFriend(getCreator().getUniqueId());
|
||||
getCreator().getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", target.getPlayer().getName()));
|
||||
target.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", getCreator().getPlayer().getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", target.getPlayer().getName()).send(getCreator().getPlayer());
|
||||
MMOCore.plugin.configManager.getSimpleMessage("now-friends", "player", getCreator().getPlayer().getName()).send(target.getPlayer());
|
||||
MMOCore.plugin.requestManager.unregisterRequest(getUniqueId());
|
||||
}
|
||||
}
|
@ -67,7 +67,7 @@ public class Party {
|
||||
// transfer ownership
|
||||
if (owner.equals(data)) {
|
||||
owner = members.get(0);
|
||||
owner.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("transfer-party-ownership"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("transfer-party-ownership").send(owner.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,8 @@ public class PartyInvite extends Request {
|
||||
|
||||
public void accept() {
|
||||
party.removeLastInvite(getCreator().getPlayer());
|
||||
party.getMembers().forEach(member -> member.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("party-joined-other", "player", target.getPlayer().getName())));
|
||||
target.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("party-joined", "owner", party.getOwner().getPlayer().getName()));
|
||||
party.getMembers().forEach(member -> MMOCore.plugin.configManager.getSimpleMessage("party-joined-other", "player", target.getPlayer().getName()).send(member.getPlayer()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("party-joined", "owner", party.getOwner().getPlayer().getName()).send(target.getPlayer());
|
||||
party.addMember(target);
|
||||
InventoryManager.PARTY_VIEW.newInventory(target).open();
|
||||
MMOCore.plugin.requestManager.unregisterRequest(getUniqueId());
|
||||
|
@ -74,7 +74,7 @@ public class Guild {
|
||||
// transfer ownership
|
||||
if (owner.equals(data)) {
|
||||
owner = members.get(0);
|
||||
owner.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("transfer-guild-ownership"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("transfer-guild-ownership").send(owner.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@ public class GuildInvite extends Request {
|
||||
|
||||
public void accept() {
|
||||
guild.removeLastInvite(getCreator().getPlayer());
|
||||
guild.getMembers().forEach(member -> member.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("guild-joined-other", "player", target.getPlayer().getName())));
|
||||
target.getPlayer().sendMessage(MMOCore.plugin.configManager.getSimpleMessage("guild-joined", "owner", guild.getOwner().getPlayer().getName()));
|
||||
guild.getMembers().forEach(member -> MMOCore.plugin.configManager.getSimpleMessage("guild-joined-other", "player", target.getPlayer().getName()).send(member.getPlayer()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("guild-joined", "owner", guild.getOwner().getPlayer().getName()).send(target.getPlayer());
|
||||
guild.addMember(target);
|
||||
InventoryManager.GUILD_VIEW.newInventory(target).open();
|
||||
MMOCore.plugin.requestManager.unregisterRequest(getUniqueId());
|
||||
|
@ -22,7 +22,7 @@ public class SkillsCommand extends BukkitCommand {
|
||||
if (sender instanceof Player) {
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
if (data.getProfess().getSkills().size() < 1) {
|
||||
sender.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("no-class-skill"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("no-class-skill").send((Player) sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class WithdrawCommand extends BukkitCommand {
|
||||
amount = Integer.parseInt(amountArgument);
|
||||
Validate.isTrue(amount >= 0);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
sender.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("wrong-number", "arg", "" + args[0]));
|
||||
sender.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("wrong-number", "arg", "" + args[0]).message());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -52,14 +52,14 @@ public class WithdrawCommand extends BukkitCommand {
|
||||
|
||||
int left = (int) MMOCore.plugin.economy.getEconomy().getBalance(player) - amount;
|
||||
if (left < 0) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-enough-money", "left", "" + -left));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-enough-money", "left", "" + -left).send(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
MMOCore.plugin.economy.getEconomy().withdrawPlayer(player, amount);
|
||||
request.withdrawAlgorythm(amount);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("withdrew", "worth", "" + amount));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("withdrew", "worth", "" + amount).send(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -89,13 +89,13 @@ public class AttributeView extends EditableInventory {
|
||||
if (item.getFunction().equalsIgnoreCase("reallocation")) {
|
||||
int spent = playerData.getAttributes().countSkillPoints();
|
||||
if (spent < 1) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("no-attribute-points-spent"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("no-attribute-points-spent").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerData.getAttributeReallocationPoints() < 1) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-attribute-reallocation-point"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-reallocation-point").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return;
|
||||
}
|
||||
@ -103,7 +103,7 @@ public class AttributeView extends EditableInventory {
|
||||
playerData.getAttributes().getAttributeInstances().forEach(ins -> ins.setBase(0));
|
||||
playerData.giveAttributePoints(spent);
|
||||
playerData.giveAttributeReallocationPoints(-1);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("attribute-points-reallocated", "points", "" + playerData.getAttributePoints()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("attribute-points-reallocated", "points", "" + playerData.getAttributePoints()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
|
||||
open();
|
||||
}
|
||||
@ -112,21 +112,21 @@ public class AttributeView extends EditableInventory {
|
||||
PlayerAttribute attribute = ((AttributeItem) item).attribute;
|
||||
|
||||
if (playerData.getAttributePoints() < 1) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
AttributeInstance ins = playerData.getAttributes().getInstance(attribute);
|
||||
if (attribute.hasMax() && ins.getBase() >= attribute.getMax()) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("attribute-max-points-hit"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("attribute-max-points-hit").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
ins.addBase(1);
|
||||
playerData.giveAttributePoints(-1);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("attribute-level-up", "attribute", attribute.getName(), "level", "" + ins.getBase()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("attribute-level-up", "attribute", attribute.getName(), "level", "" + ins.getBase()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
|
||||
open();
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class ClassConfirmation extends EditableInventory {
|
||||
(playerData.hasSavedClass(profess) ? playerData.getClassInfo(profess) : new SavedClassInformation(1, 0, 0, 0, 0)).load(profess, playerData);
|
||||
while (playerData.hasSkillBound(0))
|
||||
playerData.unbindSkill(0);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("class-select", "class", profess.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("class-select", "class", profess.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1);
|
||||
player.closeInventory();
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class ClassSelect extends EditableInventory {
|
||||
PlayerClass profess = MMOCore.plugin.classManager.get(tag);
|
||||
if (profess.equals(playerData.getProfess())) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("already-on-class", "class", profess.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("already-on-class", "class", profess.getName()).send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ public class QuestViewer extends EditableInventory {
|
||||
if (event.getAction() == InventoryAction.PICKUP_HALF) {
|
||||
playerData.getQuestData().start(null);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("cancel-quest"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("cancel-quest").send(player);
|
||||
open();
|
||||
}
|
||||
return;
|
||||
@ -221,7 +221,7 @@ public class QuestViewer extends EditableInventory {
|
||||
* the player cannot start a new quest if he is already
|
||||
* doing one.
|
||||
*/
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("already-on-quest"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("already-on-quest").send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -230,13 +230,13 @@ public class QuestViewer extends EditableInventory {
|
||||
*/
|
||||
int level;
|
||||
if (playerData.getLevel() < (level = quest.getLevelRestriction(null))) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("quest-level-restriction", "level", "Lvl", "count", "" + level));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("quest-level-restriction", "level", "Lvl", "count", "" + level).send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
for (Profession profession : quest.getLevelRestrictions())
|
||||
if (playerData.getCollectionSkills().getLevel(profession) < (level = quest.getLevelRestriction(profession))) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("quest-level-restriction", "level", profession.getName() + " Lvl", "count", "" + level));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("quest-level-restriction", "level", profession.getName() + " Lvl", "count", "" + level).send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ public class QuestViewer extends EditableInventory {
|
||||
* start it again.
|
||||
*/
|
||||
if (!quest.isRedoable()) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("cant-redo-quest"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("cant-redo-quest").send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ public class QuestViewer extends EditableInventory {
|
||||
*
|
||||
*/
|
||||
if (!playerData.getQuestData().checkCooldownAvailability(quest)) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("quest-cooldown", "delay", new DelayFormat(2).format(playerData.getQuestData().getDelayFeft(quest))));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("quest-cooldown", "delay", new DelayFormat(2).format(playerData.getQuestData().getDelayFeft(quest))).send(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -263,7 +263,7 @@ public class QuestViewer extends EditableInventory {
|
||||
/*
|
||||
* eventually start a new quest.
|
||||
*/
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("start-quest", "quest", quest.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("start-quest", "quest", quest.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
playerData.getQuestData().start(quest);
|
||||
open();
|
||||
|
@ -336,7 +336,7 @@ public class SkillList extends EditableInventory {
|
||||
// unbind if there is a current spell.
|
||||
if (event.getAction() == InventoryAction.PICKUP_HALF) {
|
||||
if (!playerData.hasSkillBound(index)) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("no-skill-bound"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("no-skill-bound").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
return;
|
||||
}
|
||||
@ -351,13 +351,13 @@ public class SkillList extends EditableInventory {
|
||||
return;
|
||||
|
||||
if (selected.getSkill().isPassive()) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-active-skill"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-active-skill").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selected.isUnlocked(playerData)) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-skill"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-skill").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
return;
|
||||
}
|
||||
@ -382,26 +382,26 @@ public class SkillList extends EditableInventory {
|
||||
*/
|
||||
} else if (item.getFunction().equals("upgrade")) {
|
||||
if (!selected.isUnlocked(playerData)) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-skill"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-skill").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerData.getSkillPoints() < 1) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-enough-skill-points"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-enough-skill-points").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerData.getSkillLevel(selected.getSkill()) >= selected.getMaxLevel()) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("skill-max-level-hit"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("skill-max-level-hit").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
playerData.giveSkillPoints(-1);
|
||||
playerData.setSkillLevel(selected.getSkill(), playerData.getSkillLevel(selected.getSkill()) + 1);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("upgrade-skill", "skill", selected.getSkill().getName(), "level", "" + playerData.getSkillLevel(selected.getSkill())));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("upgrade-skill", "skill", selected.getSkill().getName(), "level", "" + playerData.getSkillLevel(selected.getSkill())).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
|
||||
open();
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class SubclassConfirmation extends EditableInventory {
|
||||
return;
|
||||
|
||||
playerData.setClass(profess);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("class-select", "class", profess.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("class-select", "class", profess.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1);
|
||||
player.closeInventory();
|
||||
}
|
||||
|
@ -179,29 +179,29 @@ public class WaypointViewer extends EditableInventory {
|
||||
|
||||
Waypoint waypoint = MMOCore.plugin.waypointManager.get(tag);
|
||||
if (!playerData.hasWaypoint(waypoint)) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-waypoint"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-waypoint").send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (waypoint.equals(current)) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("standing-on-waypoint"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("standing-on-waypoint").send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (current == null && !waypoint.isDynamic()) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-dynamic-waypoint"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-dynamic-waypoint").send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
double left = waypoint.getStelliumCost() - playerData.getStellium();
|
||||
if (left > 0) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-enough-stellium", "more", decimal.format(left)));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-enough-stellium", "more", decimal.format(left)).send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
double next = (double) playerData.getNextWaypointMillis() / 1000;
|
||||
if (next < 0) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-enough-stellium", "cooldown", decimal.format(next)));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-enough-stellium", "cooldown", decimal.format(next)).send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class DepositMenu extends PluginInventory {
|
||||
event.getInventory().clear();
|
||||
player.closeInventory();
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("deposit", "worth", "" + deposit));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("deposit", "worth", "" + deposit).send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -197,35 +197,35 @@ public class EditableFriendList extends EditableInventory {
|
||||
|
||||
long remaining = playerData.getLastFriendRequest() + 60 * 2 * 1000 - System.currentTimeMillis();
|
||||
if (remaining > 0) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("friend-request-cooldown", "cooldown", new DelayFormat().format(remaining)));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("friend-request-cooldown", "cooldown", new DelayFormat().format(remaining)).send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
MMOCore.plugin.configManager.newPlayerInput(player, InputType.FRIEND_REQUEST, (input) -> {
|
||||
Player target = Bukkit.getPlayer(input);
|
||||
if (target == null) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerData.hasFriend(target.getUniqueId())) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("already-friends", "player", target.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("already-friends", "player", target.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerData.getUniqueId().equals(target.getUniqueId())) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("cant-request-to-yourself"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("cant-request-to-yourself").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
playerData.sendFriendRequest(PlayerData.get(target));
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("sent-friend-request", "player", target.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("sent-friend-request", "player", target.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
open();
|
||||
});
|
||||
|
@ -55,7 +55,7 @@ public class EditableFriendRemoval extends EditableInventory {
|
||||
playerData.removeFriend(friend.getUniqueId());
|
||||
new OfflinePlayerData(friend.getUniqueId()).removeFriend(playerData.getUniqueId());
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("no-longer-friends", "unfriend", friend.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("no-longer-friends", "unfriend", friend.getName()).send(player);
|
||||
last.open();
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class EditableGuildView extends EditableInventory {
|
||||
if (item.getFunction().equals("invite")) {
|
||||
|
||||
if (playerData.getGuild().getMembers().count() >= max) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("guild-is-full"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("guild-is-full").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return;
|
||||
}
|
||||
@ -143,7 +143,7 @@ public class EditableGuildView extends EditableInventory {
|
||||
MMOCore.plugin.configManager.newPlayerInput(player, InputType.GUILD_INVITE, (input) -> {
|
||||
Player target = Bukkit.getPlayer(input);
|
||||
if (target == null) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
open();
|
||||
return;
|
||||
@ -151,21 +151,21 @@ public class EditableGuildView extends EditableInventory {
|
||||
|
||||
long remaining = playerData.getGuild().getLastInvite(target) + 60 * 2 * 1000 - System.currentTimeMillis();
|
||||
if (remaining > 0) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("guild-invite-cooldown", "player", target.getName(), "cooldown", new DelayFormat().format(remaining)));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("guild-invite-cooldown", "player", target.getName(), "cooldown", new DelayFormat().format(remaining)).send(player);
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData targetData = PlayerData.get(target);
|
||||
if (playerData.getGuild().getMembers().has(targetData)) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("already-in-guild", "player", target.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("already-in-guild", "player", target.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
playerData.getGuild().sendGuildInvite(playerData, targetData);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("sent-guild-invite", "player", target.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("sent-guild-invite", "player", target.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
open();
|
||||
});
|
||||
@ -180,7 +180,7 @@ public class EditableGuildView extends EditableInventory {
|
||||
return;
|
||||
|
||||
playerData.getGuild().removeMember(PlayerData.get(target));
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("kick-from-guild", "player", target.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("kick-from-guild", "player", target.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public class EditablePartyView extends EditableInventory {
|
||||
if (item.getFunction().equals("invite")) {
|
||||
|
||||
if (playerData.getParty().getMembers().count() >= max) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("party-is-full"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("party-is-full").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return;
|
||||
}
|
||||
@ -143,7 +143,7 @@ public class EditablePartyView extends EditableInventory {
|
||||
MMOCore.plugin.configManager.newPlayerInput(player, InputType.PARTY_INVITE, (input) -> {
|
||||
Player target = Bukkit.getPlayer(input);
|
||||
if (target == null) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
open();
|
||||
return;
|
||||
@ -151,21 +151,21 @@ public class EditablePartyView extends EditableInventory {
|
||||
|
||||
long remaining = playerData.getParty().getLastInvite(target) + 60 * 2 * 1000 - System.currentTimeMillis();
|
||||
if (remaining > 0) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("party-invite-cooldown", "player", target.getName(), "cooldown", new DelayFormat().format(remaining)));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("party-invite-cooldown", "player", target.getName(), "cooldown", new DelayFormat().format(remaining)).send(player);
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData targetData = PlayerData.get(target);
|
||||
if (playerData.getParty().getMembers().has(targetData)) {
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("already-in-party", "player", target.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("already-in-party", "player", target.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
playerData.getParty().sendPartyInvite(playerData, targetData);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("sent-party-invite", "player", target.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("sent-party-invite", "player", target.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
open();
|
||||
});
|
||||
@ -180,7 +180,7 @@ public class EditablePartyView extends EditableInventory {
|
||||
return;
|
||||
|
||||
playerData.getParty().removeMember(PlayerData.get(target));
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("kick-from-party", "player", target.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("kick-from-party", "player", target.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class BlockListener implements Listener {
|
||||
* enable block regen.
|
||||
*/
|
||||
if (info.hasRegen())
|
||||
MMOCore.plugin.mineManager.initialize(info.generateRegenInfo(event.getBlock().getLocation()));
|
||||
MMOCore.plugin.mineManager.initialize(info.generateRegenInfo(event.getBlock()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.social.GuildChatEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.ConfigManager.SimpleMessage;
|
||||
|
||||
public class GuildListener implements Listener {
|
||||
|
||||
@ -27,13 +28,13 @@ public class GuildListener implements Listener {
|
||||
* running it in a delayed task is recommended
|
||||
*/
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, () -> {
|
||||
String format = MMOCore.plugin.configManager.getSimpleMessage("guild-chat", "player", data.getPlayer().getName(), "message", event.getMessage().substring(MMOCore.plugin.configManager.guildChatPrefix.length()));
|
||||
GuildChatEvent called = new GuildChatEvent(data, format);
|
||||
SimpleMessage format = MMOCore.plugin.configManager.getSimpleMessage("guild-chat", "player", data.getPlayer().getName(), "message", event.getMessage().substring(MMOCore.plugin.configManager.guildChatPrefix.length()));
|
||||
GuildChatEvent called = new GuildChatEvent(data, format.message());
|
||||
Bukkit.getPluginManager().callEvent(called);
|
||||
if (!called.isCancelled()) ; //remove
|
||||
//data.getGuild().members.forEach(member -> {
|
||||
//if (member.isOnline())
|
||||
// member.getPlayer().sendMessage(format);
|
||||
// format.send(member.getPlayer());
|
||||
//});
|
||||
});
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.social.PartyChatEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.ConfigManager.SimpleMessage;
|
||||
|
||||
public class PartyListener implements Listener {
|
||||
|
||||
@ -27,13 +28,13 @@ public class PartyListener implements Listener {
|
||||
* running it in a delayed task is recommended
|
||||
*/
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, () -> {
|
||||
String format = MMOCore.plugin.configManager.getSimpleMessage("party-chat", "player", data.getPlayer().getName(), "message", event.getMessage().substring(MMOCore.plugin.configManager.partyChatPrefix.length()));
|
||||
PartyChatEvent called = new PartyChatEvent(data, format);
|
||||
SimpleMessage format = MMOCore.plugin.configManager.getSimpleMessage("party-chat", "player", data.getPlayer().getName(), "message", event.getMessage().substring(MMOCore.plugin.configManager.partyChatPrefix.length()));
|
||||
PartyChatEvent called = new PartyChatEvent(data, format.message());
|
||||
Bukkit.getPluginManager().callEvent(called);
|
||||
if (!called.isCancelled())
|
||||
data.getParty().getMembers().forEach(member -> {
|
||||
if (member.isOnline())
|
||||
member.getPlayer().sendMessage(format);
|
||||
format.send(member.getPlayer());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -48,10 +48,10 @@ public class SpellCast implements Listener {
|
||||
public class SkillCasting extends BukkitRunnable implements Listener {
|
||||
private final PlayerData playerData;
|
||||
|
||||
private final String ready = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.ready");
|
||||
private final String onCooldown = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.on-cooldown");
|
||||
private final String noMana = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.no-mana");
|
||||
private final String split = MMOCore.plugin.configManager.getSimpleMessage("casting.split");
|
||||
private final String ready = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.ready").message();
|
||||
private final String onCooldown = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.on-cooldown").message();
|
||||
private final String noMana = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.no-mana").message();
|
||||
private final String split = MMOCore.plugin.configManager.getSimpleMessage("casting.split").message();
|
||||
|
||||
private int j;
|
||||
|
||||
@ -93,7 +93,7 @@ public class SpellCast implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getPlayer().equals(playerData.getPlayer()) && !player.isSneaking()) {
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1, 2);
|
||||
playerData.displayActionBar(MMOCore.plugin.configManager.getSimpleMessage("casting.no-longer"));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("casting.no-longer").send(playerData.getPlayer());
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class WaypointsListener implements Listener {
|
||||
if (!data.hasWaypoint(waypoint)) {
|
||||
data.unlockWaypoint(waypoint);
|
||||
new SmallParticleEffect(player, Particle.SPELL_WITCH);
|
||||
player.sendMessage(MMOCore.plugin.configManager.getSimpleMessage("new-waypoint", "waypoint", waypoint.getName()));
|
||||
MMOCore.plugin.configManager.getSimpleMessage("new-waypoint", "waypoint", waypoint.getName()).send(player);
|
||||
player.playSound(player.getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1.2f);
|
||||
return;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class FishingListener implements Listener {
|
||||
|
||||
new FishingData(player, hook, table);
|
||||
if (MMOCore.plugin.hasHolograms())
|
||||
MMOCore.plugin.hologramSupport.displayIndicator(hook.getLocation(), MMOCore.plugin.configManager.getSimpleMessage("caught-fish"));
|
||||
MMOCore.plugin.hologramSupport.displayIndicator(hook.getLocation(), MMOCore.plugin.configManager.getSimpleMessage("caught-fish").message());
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ public class FishingListener implements Listener {
|
||||
// calculate velocity
|
||||
Item item = hook.getWorld().dropItemNaturally(hook.getLocation(), collect);
|
||||
if (MMOCore.plugin.hasHolograms())
|
||||
MMOCore.plugin.hologramSupport.displayIndicator(location, MMOCore.plugin.configManager.getSimpleMessage("fish-out-water" + (isCrit() ? "-crit" : "")));
|
||||
MMOCore.plugin.hologramSupport.displayIndicator(location, MMOCore.plugin.configManager.getSimpleMessage("fish-out-water" + (isCrit() ? "-crit" : "")).message());
|
||||
Vector vec = player.getLocation().subtract(hook.getLocation()).toVector();
|
||||
vec.setY(vec.getY() * .031 + vec.length() * .05);
|
||||
vec.setX(vec.getX() * .08);
|
||||
|
@ -22,6 +22,7 @@ import net.Indyuce.mmocore.api.input.AnvilGUI;
|
||||
import net.Indyuce.mmocore.api.input.ChatInput;
|
||||
import net.Indyuce.mmocore.api.input.PlayerInput;
|
||||
import net.Indyuce.mmocore.api.input.PlayerInput.InputType;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
public class ConfigManager {
|
||||
|
||||
@ -31,7 +32,7 @@ public class ConfigManager {
|
||||
public String partyChatPrefix, guildChatPrefix;
|
||||
public ChatColor manaFull, manaHalf, manaEmpty, staminaFull, staminaHalf, staminaEmpty;
|
||||
|
||||
private final DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols();
|
||||
public final DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols();
|
||||
public final DecimalFormat decimal = new DecimalFormat("0.#", formatSymbols), decimals = new DecimalFormat("0.##", formatSymbols);
|
||||
|
||||
private List<Integer> neededExp = new ArrayList<>();
|
||||
@ -176,10 +177,29 @@ public class ConfigManager {
|
||||
return messages.getStringList(key);
|
||||
}
|
||||
|
||||
public String getSimpleMessage(String key, String... placeholders) {
|
||||
String format = messages.getString(key);
|
||||
public SimpleMessage getSimpleMessage(String key, String... placeholders) {
|
||||
String format = messages.getString(key, "");
|
||||
for (int j = 0; j < placeholders.length - 1; j += 2)
|
||||
format = format.replace("{" + placeholders[j] + "}", placeholders[j + 1]);
|
||||
return ChatColor.translateAlternateColorCodes('&', format);
|
||||
return new SimpleMessage(ChatColor.translateAlternateColorCodes('&', format));
|
||||
}
|
||||
|
||||
public class SimpleMessage {
|
||||
String message;
|
||||
|
||||
SimpleMessage(String m) {
|
||||
message = m;
|
||||
}
|
||||
|
||||
public String message()
|
||||
{ return message.startsWith("%") ? message.substring(1) : message; }
|
||||
|
||||
public boolean send(Player player) {
|
||||
if(!message.isEmpty()) {
|
||||
if(message.startsWith("%")) PlayerData.get(player.getUniqueId()).displayActionBar(message.substring(1));
|
||||
else player.sendMessage(message);
|
||||
}
|
||||
return !message.isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,11 @@ package net.Indyuce.mmocore.manager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
@ -29,7 +31,7 @@ import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
|
||||
public class CustomBlockManager extends MMOManager {
|
||||
private final Map<String, BlockInfo> map = new HashMap<>();
|
||||
private final Map<RegenInfo, BlockData> active = new HashMap<>();
|
||||
private final Set<RegenInfo> active = new HashSet<>();
|
||||
|
||||
/* list in which both block regen and block permissions are enabled. */
|
||||
private final List<Condition> customMineConditions = new ArrayList<>();
|
||||
@ -38,7 +40,7 @@ public class CustomBlockManager extends MMOManager {
|
||||
for (String key : config.getKeys(false))
|
||||
try {
|
||||
BlockInfo info = new BlockInfo(config.getConfigurationSection(key));
|
||||
register(info.getBlock() == Material.PLAYER_HEAD ? info.getHeadValue() : info.getBlock().name(), info);
|
||||
register(info.getHeadValue().isEmpty() ? info.getBlock().name() : info.getHeadValue(), info);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.log(Level.WARNING, "Could not load custom block '" + key + "': " + exception.getMessage());
|
||||
}
|
||||
@ -51,7 +53,7 @@ public class CustomBlockManager extends MMOManager {
|
||||
public BlockInfo getInfo(Block block) {
|
||||
if(isPlayerSkull(block.getType())) {
|
||||
String skullValue = MMOCore.plugin.nms.getSkullValue(block);
|
||||
return map.getOrDefault(skullValue, null);
|
||||
return map.getOrDefault(skullValue, map.getOrDefault(block.getType().name(), null));
|
||||
}
|
||||
|
||||
return map.getOrDefault(block.getType().name(), null);
|
||||
@ -62,21 +64,21 @@ public class CustomBlockManager extends MMOManager {
|
||||
* are reset and put back in place.
|
||||
*/
|
||||
public void resetRemainingBlocks() {
|
||||
active.keySet().forEach(info -> {
|
||||
info.getLocation().getBlock().setType(info.getRegen().getBlock());
|
||||
active.forEach(info -> {
|
||||
regen(info);
|
||||
});
|
||||
}
|
||||
|
||||
public void initialize(RegenInfo info) {
|
||||
active.put(info, info.getLocation().getBlock().getBlockData());
|
||||
active.add(info);
|
||||
|
||||
info.getLocation().getBlock().setType(info.getRegen().getTemporaryBlock());
|
||||
if(isPlayerSkull(info.getLocation().getBlock().getType())) {
|
||||
if(!isPlayerSkull(info.getRegen().getTemporaryBlock())) info.getLocation().getBlock().setType(info.getRegen().getTemporaryBlock());
|
||||
MMOCore.plugin.nms.setSkullValue(info.getLocation().getBlock(), info.getRegen().regenHeadValue);
|
||||
info.getLocation().getBlock().getState().update();
|
||||
if(isPlayerSkull(info.getRegen().getBlock())) info.getLocation().getBlock().setBlockData(info.getBlockData());
|
||||
MMOCore.plugin.nms.setSkullValue(info.getLocation().getBlock(), info.getRegen().getRegenHeadValue());
|
||||
}
|
||||
else info.getLocation().getBlock().setType(info.getRegen().getTemporaryBlock());
|
||||
|
||||
System.out.println("Regen Time: " + info.getRegen().getRegenTime());
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
regen(info);
|
||||
@ -85,12 +87,11 @@ public class CustomBlockManager extends MMOManager {
|
||||
}
|
||||
|
||||
private void regen(RegenInfo info) {
|
||||
info.getLocation().getBlock().setType(info.getRegen().getBlock());
|
||||
|
||||
if(isPlayerSkull(info.getRegen().getBlock()))
|
||||
MMOCore.plugin.nms.setSkullValue(info.getLocation().getBlock(), info.getRegen().headValue);
|
||||
|
||||
info.getLocation().getBlock().setBlockData(active.get(info));
|
||||
System.out.println("Material: " + info.getBlockData().getMaterial());
|
||||
//info.getLocation().getBlock().setType(info.getRegen().getBlock());
|
||||
info.getLocation().getBlock().setBlockData(info.getBlockData());
|
||||
if(isPlayerSkull(info.getLocation().getBlock().getType()))
|
||||
MMOCore.plugin.nms.setSkullValue(info.getLocation().getBlock(), info.getRegen().getHeadValue());
|
||||
active.remove(info);
|
||||
}
|
||||
|
||||
@ -108,7 +109,8 @@ public class CustomBlockManager extends MMOManager {
|
||||
}
|
||||
|
||||
private boolean isPlayerSkull(Material block) {
|
||||
return block == VersionMaterial.PLAYER_HEAD.toMaterial() || block == VersionMaterial.PLAYER_WALL_HEAD.toMaterial();
|
||||
return block == VersionMaterial.PLAYER_HEAD.toMaterial() ||
|
||||
block == VersionMaterial.PLAYER_WALL_HEAD.toMaterial();
|
||||
}
|
||||
|
||||
public class BlockInfo {
|
||||
@ -157,18 +159,6 @@ public class CustomBlockManager extends MMOManager {
|
||||
experience = opt.isPresent() ? (ExperienceTrigger) opt.get() : null;
|
||||
}
|
||||
|
||||
public BlockInfo(Material block, DropTable table, boolean vanillaDrops, List<Trigger> triggers, ExperienceTrigger experience, Material temporary, int regenTime, String headValue, String regenHeadValue) {
|
||||
this.block = block;
|
||||
this.headValue = headValue;
|
||||
this.table = table;
|
||||
this.vanillaDrops = vanillaDrops;
|
||||
this.temporary = temporary;
|
||||
this.regenHeadValue = regenHeadValue;
|
||||
this.regenTime = regenTime;
|
||||
this.triggers.addAll(triggers);
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
public String getHeadValue() {
|
||||
return headValue;
|
||||
}
|
||||
@ -209,8 +199,8 @@ public class CustomBlockManager extends MMOManager {
|
||||
return regenHeadValue;
|
||||
}
|
||||
|
||||
public RegenInfo generateRegenInfo(Location loc) {
|
||||
return new RegenInfo(loc, this);
|
||||
public RegenInfo generateRegenInfo(Block b) {
|
||||
return new RegenInfo(b, this);
|
||||
}
|
||||
|
||||
public boolean hasExperience() {
|
||||
@ -231,13 +221,15 @@ public class CustomBlockManager extends MMOManager {
|
||||
}
|
||||
|
||||
public class RegenInfo {
|
||||
private final BlockData blockData;
|
||||
private final Location loc;
|
||||
private final BlockInfo regen;
|
||||
|
||||
private final long date = System.currentTimeMillis();
|
||||
|
||||
public RegenInfo(Location loc, BlockInfo regen) {
|
||||
this.loc = loc;
|
||||
public RegenInfo(Block block, BlockInfo regen) {
|
||||
this.blockData = block.getBlockData().clone();
|
||||
this.loc = block.getLocation();
|
||||
this.regen = regen;
|
||||
}
|
||||
|
||||
@ -245,6 +237,10 @@ public class CustomBlockManager extends MMOManager {
|
||||
return date + regen.getRegenTime() * 50 < System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public BlockData getBlockData() {
|
||||
return blockData;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return loc;
|
||||
}
|
||||
|
@ -203,5 +203,6 @@ public class NMSHandler_1_12_R1 implements NMSHandler {
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", value));
|
||||
skullTile.setGameProfile(profile);
|
||||
skullTile.update();
|
||||
}
|
||||
}
|
||||
|
@ -201,5 +201,6 @@ public class NMSHandler_1_13_R1 implements NMSHandler {
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", value));
|
||||
skullTile.setGameProfile(profile);
|
||||
skullTile.update();
|
||||
}
|
||||
}
|
||||
|
@ -202,5 +202,6 @@ public class NMSHandler_1_13_R2 implements NMSHandler {
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", value));
|
||||
skullTile.setGameProfile(profile);
|
||||
skullTile.update();
|
||||
}
|
||||
}
|
||||
|
@ -224,5 +224,6 @@ public class NMSHandler_1_14_R1 implements NMSHandler {
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", value));
|
||||
skullTile.setGameProfile(profile);
|
||||
skullTile.update();
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,17 @@ lootsplosion:
|
||||
offset: .2
|
||||
height: .6
|
||||
|
||||
# settings for the default action bar
|
||||
action-bar:
|
||||
# Whether or not to use the default action bar. (This doesn't change any other action bars provided by MMOCore.)
|
||||
enabled: true
|
||||
# the decimal format for stats (not including stat formats in stats.yml)
|
||||
decimal: "0.#"
|
||||
# The amount of ticks before updating the info
|
||||
ticks-to-update: 5
|
||||
# how to display the data.
|
||||
format: "&c❤ {health}/{max_health} &f| &9⭐ {mana}/{max_mana} &f| &7⛨ {armor}"
|
||||
|
||||
party:
|
||||
|
||||
# Edit party buffs here. You may
|
||||
|
Loading…
Reference in New Issue
Block a user