This commit is contained in:
Aria 2019-10-21 06:55:06 +02:00
commit e6bb5fbdd4
2 changed files with 70 additions and 59 deletions

View File

@ -9,6 +9,7 @@ import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.command.CommandMap; import org.bukkit.command.CommandMap;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -95,7 +96,6 @@ import net.Indyuce.mmocore.manager.social.PartyManager;
import net.Indyuce.mmocore.manager.social.RequestManager; import net.Indyuce.mmocore.manager.social.RequestManager;
import net.Indyuce.mmocore.version.ServerVersion; import net.Indyuce.mmocore.version.ServerVersion;
import net.Indyuce.mmocore.version.nms.NMSHandler; import net.Indyuce.mmocore.version.nms.NMSHandler;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -241,23 +241,24 @@ public class MMOCore extends JavaPlugin {
} }
}.runTaskTimerAsynchronously(MMOCore.plugin, 100, 20); }.runTaskTimerAsynchronously(MMOCore.plugin, 100, 20);
//For the sake of the lord, make sure they aren't using MMOItems Mana and Stamina Addon... /*
//This should prevent a couple error reports produced by people not reading the installation guide... * For the sake of the lord, make sure they aren't using MMOItems Mana
* and Stamina Addon...This should prevent a couple error reports
* produced by people not reading the installation guide...
*/
if (Bukkit.getPluginManager().getPlugin("MMOItemsMana") != null) { if (Bukkit.getPluginManager().getPlugin("MMOItemsMana") != null) {
new BukkitRunnable() { Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "[MMOCore] MMOCore is not meant to be used with the Mana & Stamina MMOItems!!!");
public void run() { Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "[MMOCore] Please read the installation guide!");
Bukkit.broadcastMessage(ChatColor.DARK_RED + "MMOCore is not compatible with the Mana and Stamina addon of MMOItems!!!"); Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] MMOCore is not meant to be used with the Mana & Stamina MMOItems!!!");
Bukkit.broadcastMessage(ChatColor.DARK_RED + "Please read the installation guide!"); Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] Please read the installation guide!");
} return;
}.runTaskTimer(MMOCore.plugin, 1200, 1200);
} }
saveDefaultConfig(); saveDefaultConfig();
reloadPlugin(); reloadPlugin();
/* /*
* default action bar. * default action bar. only ran if the action bar is enabled
* only ran if the action bar is enabled
*/ */
if (getConfig().getBoolean("action-bar.enabled")) { if (getConfig().getBoolean("action-bar.enabled")) {
DecimalFormat format = new DecimalFormat(getConfig().getString("action-bar.decimal"), configManager.formatSymbols); DecimalFormat format = new DecimalFormat(getConfig().getString("action-bar.decimal"), configManager.formatSymbols);
@ -265,18 +266,18 @@ public class MMOCore extends JavaPlugin {
new BukkitRunnable() { new BukkitRunnable() {
public void run() { public void run() {
//System.out.println("Tick!");
for (PlayerData data : PlayerData.getAll()) { for (PlayerData data : PlayerData.getAll()) {
if (data.isOnline() && !data.getPlayer().isDead() && !data.isCasting() && !pausePlayers.contains(data.getUniqueId())) { if (!data.isCasting() && !pausePlayers.contains(data.getUniqueId())) {
//System.out.println("Display!"); data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(placeholderParser.parse(data.getPlayer(),
data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(placeholderParser.parse(data.getPlayer(), ChatColor.translateAlternateColorCodes('&', getConfig().getString("action-bar.format") ChatColor.translateAlternateColorCodes('&', getConfig().getString("action-bar.format").replace("{health}", format.format(data.getPlayer().getHealth()))
.replace("{health}", format.format(data.getPlayer().getHealth())).replace("{max_health}", "" + StatType.MAX_HEALTH.format(data.getStats().getStat(StatType.MAX_HEALTH))) .replace("{max_health}", "" + StatType.MAX_HEALTH.format(data.getStats().getStat(StatType.MAX_HEALTH))).replace("{mana}", format.format(data.getMana()))
.replace("{mana}", format.format(data.getMana())).replace("{max_mana}", "" + StatType.MAX_MANA.format(data.getStats().getStat(StatType.MAX_MANA))) .replace("{max_mana}", "" + StatType.MAX_MANA.format(data.getStats().getStat(StatType.MAX_MANA))).replace("{stamina}", format.format(data.getStamina()))
.replace("{stamina}", format.format(data.getStamina())).replace("{max_stamina}", "" + StatType.MAX_STAMINA.format(data.getStats().getStat(StatType.MAX_STAMINA))) .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("{stellium}", format.format(data.getStellium()))
.replace("{class}", data.getProfess().getName()).replace("{xp}", "" + data.getExperience()).replace("{armor}", "" + StatType.ARMOR.format(data.getPlayer().getAttribute(Attribute.GENERIC_ARMOR).getValue())) .replace("{max_stellium}", "" + StatType.MAX_STELLIUM.format(data.getStats().getStat(StatType.MAX_STELLIUM)))
.replace("{level}", "" + data.getLevel()).replace("{name}", data.getPlayer().getDisplayName()))))); .replace("{class}", data.getProfess().getName()).replace("{xp}", "" + data.getExperience())
.replace("{armor}", "" + StatType.ARMOR.format(data.getPlayer().getAttribute(Attribute.GENERIC_ARMOR).getValue())).replace("{level}", "" + data.getLevel())
.replace("{name}", data.getPlayer().getDisplayName())))));
} }
} }
} }
@ -330,22 +331,32 @@ public class MMOCore extends JavaPlugin {
FileConfiguration config = new ConfigFile("commands").getConfig(); FileConfiguration config = new ConfigFile("commands").getConfig();
if(config.contains("player")) commandMap.register("mmocore", new PlayerStatsCommand(config.getConfigurationSection("player"))); if (config.contains("player"))
if(config.contains("attributes")) commandMap.register("mmocore", new AttributesCommand(config.getConfigurationSection("attributes"))); commandMap.register("mmocore", new PlayerStatsCommand(config.getConfigurationSection("player")));
if(config.contains("class")) commandMap.register("mmocore", new ClassCommand(config.getConfigurationSection("class"))); if (config.contains("attributes"))
if(config.contains("waypoints")) commandMap.register("mmocore", new WaypointsCommand(config.getConfigurationSection("waypoints"))); commandMap.register("mmocore", new AttributesCommand(config.getConfigurationSection("attributes")));
if(config.contains("quests")) commandMap.register("mmocore", new QuestsCommand(config.getConfigurationSection("quests"))); if (config.contains("class"))
if(config.contains("skills")) commandMap.register("mmocore", new SkillsCommand(config.getConfigurationSection("skills"))); commandMap.register("mmocore", new ClassCommand(config.getConfigurationSection("class")));
if(config.contains("friends")) commandMap.register("mmocore", new FriendsCommand(config.getConfigurationSection("friends"))); if (config.contains("waypoints"))
if(config.contains("party")) commandMap.register("mmocore", new PartyCommand(config.getConfigurationSection("party"))); commandMap.register("mmocore", new WaypointsCommand(config.getConfigurationSection("waypoints")));
if(config.contains("guild")) commandMap.register("mmocore", new GuildCommand(config.getConfigurationSection("guild"))); 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()) { if (hasEconomy() && economy.isValid()) {
if(config.contains("withdraw")) commandMap.register("mmocore", new WithdrawCommand(config.getConfigurationSection("withdraw"))); if (config.contains("withdraw"))
if(config.contains("deposit")) commandMap.register("mmocore", new DepositCommand(config.getConfigurationSection("deposit"))); 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) {
catch(NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }

View File

@ -25,10 +25,10 @@ import net.Indyuce.mmocore.manager.RestrictionManager.BlockPermissions;
public class BlockListener implements Listener { public class BlockListener implements Listener {
private static final BlockFace[] order = { BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH }; private static final BlockFace[] order = { BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH };
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void a(BlockBreakEvent event) { public void a(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE || event.isCancelled()) if (player.getGameMode() == GameMode.CREATIVE)
return; return;
String savedData = event.getBlock().getBlockData().getAsString(); String savedData = event.getBlock().getBlockData().getAsString();
@ -69,7 +69,6 @@ public class BlockListener implements Listener {
return; return;
} }
/* /*
* remove vanilla drops if needed * remove vanilla drops if needed
*/ */
@ -79,8 +78,8 @@ public class BlockListener implements Listener {
} }
/* /*
* apply triggers, add experience info to the event so the other events * apply triggers, add experience info to the event so the other
* can give exp to other TOOLS and display HOLOGRAMS * events can give exp to other TOOLS and display HOLOGRAMS
*/ */
if (info.hasTriggers()) { if (info.hasTriggers()) {
PlayerData playerData = PlayerData.get(player); PlayerData playerData = PlayerData.get(player);
@ -89,7 +88,8 @@ public class BlockListener implements Listener {
trigger.apply(playerData); trigger.apply(playerData);
}); });
if (!block.hasMetadata("player_placed") && info.hasExperience() && MMOCore.plugin.hasHolograms()) if (!block.hasMetadata("player_placed") && info.hasExperience() && MMOCore.plugin.hasHolograms())
MMOCore.plugin.hologramSupport.displayIndicator(block.getLocation().add(.5, 1.5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + called.getGainedExperience().getValue()).message(), player); MMOCore.plugin.hologramSupport.displayIndicator(block.getLocation().add(.5, 1.5, .5),
MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + called.getGainedExperience().getValue()).message(), player);
} }
/* /*