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;
@ -217,7 +217,7 @@ public class MMOCore extends JavaPlugin {
Bukkit.getServer().getPluginManager().registerEvents(new MythicMobsDrops(), this); Bukkit.getServer().getPluginManager().registerEvents(new MythicMobsDrops(), this);
getLogger().log(Level.INFO, "Hooked onto MythicMobs"); getLogger().log(Level.INFO, "Hooked onto MythicMobs");
} }
/* /*
* resource regeneration. must check if entity is dead otherwise regen * resource regeneration. must check if entity is dead otherwise regen
* will make the 'respawn' button glitched plus HURT entity effect bug * will make the 'respawn' button glitched plus HURT entity effect bug
@ -240,49 +240,50 @@ 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
if(Bukkit.getPluginManager().getPlugin("MMOItemsMana") != null) { * and Stamina Addon...This should prevent a couple error reports
new BukkitRunnable() { * produced by people not reading the installation guide...
public void run() { */
Bukkit.broadcastMessage(ChatColor.DARK_RED + "MMOCore is not compatible with the Mana and Stamina addon of MMOItems!!!"); if (Bukkit.getPluginManager().getPlugin("MMOItemsMana") != null) {
Bukkit.broadcastMessage(ChatColor.DARK_RED + "Please read the installation guide!"); Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "[MMOCore] MMOCore is not meant to be used with the Mana & Stamina MMOItems!!!");
} Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "[MMOCore] Please read the installation guide!");
}.runTaskTimer(MMOCore.plugin, 1200, 1200); Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] MMOCore is not meant to be used with the Mana & Stamina MMOItems!!!");
Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] Please read the installation guide!");
return;
} }
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);
int ticks = getConfig().getInt("action-bar.ticks-to-update"); int ticks = getConfig().getInt("action-bar.ticks-to-update");
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())))));
} }
} }
} }
}.runTaskTimerAsynchronously(MMOCore.plugin, 100, ticks); }.runTaskTimerAsynchronously(MMOCore.plugin, 100, ticks);
} }
/* /*
* enable debug mode for extra debug tools. * enable debug mode for extra debug tools.
*/ */
@ -324,28 +325,38 @@ public class MMOCore extends JavaPlugin {
// commands // commands
try { try {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap"); final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true); bukkitCommandMap.setAccessible(true);
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer()); CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
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();
} }
@ -430,7 +441,7 @@ public class MMOCore extends JavaPlugin {
public void pauseDefaultActionBar(UUID uuid, int ticks) { public void pauseDefaultActionBar(UUID uuid, int ticks) {
pausePlayers.add(uuid); pausePlayers.add(uuid);
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {

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();
@ -38,7 +38,7 @@ public class BlockListener implements Listener {
*/ */
boolean customMine = MMOCore.plugin.mineManager.isEnabled(player, block.getLocation()); boolean customMine = MMOCore.plugin.mineManager.isEnabled(player, block.getLocation());
ItemStack item = player.getInventory().getItemInMainHand(); ItemStack item = player.getInventory().getItemInMainHand();
if (customMine) { if (customMine) {
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block); BlockInfo info = MMOCore.plugin.mineManager.getInfo(block);
@ -56,7 +56,7 @@ public class BlockListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
BlockPermissions perms = MMOCore.plugin.restrictionManager.getPermissions(item.getType()); BlockPermissions perms = MMOCore.plugin.restrictionManager.getPermissions(item.getType());
if (perms == null) { if (perms == null) {
event.setCancelled(true); event.setCancelled(true);
@ -68,7 +68,6 @@ public class BlockListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
/* /*
* remove vanilla drops if needed * remove vanilla drops if needed
@ -79,19 +78,20 @@ 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);
info.getTriggers().forEach(trigger -> { info.getTriggers().forEach(trigger -> {
if(!block.hasMetadata("player_placed") && trigger instanceof ExperienceTrigger) if (!block.hasMetadata("player_placed") && trigger instanceof ExperienceTrigger)
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);
} }
/* /*
* apply drop tables * apply drop tables
*/ */
@ -101,7 +101,7 @@ public class BlockListener implements Listener {
if (drop.getType() != Material.AIR && drop.getAmount() > 0) if (drop.getType() != Material.AIR && drop.getAmount() > 0)
block.getWorld().dropItemNaturally(dropLocation, drop); block.getWorld().dropItemNaturally(dropLocation, drop);
} }
/* /*
* enable block regen. * enable block regen.
*/ */