diff --git a/mcmmo-api/build.gradle.kts b/mcmmo-api/build.gradle.kts index 681865fc7..b414be054 100644 --- a/mcmmo-api/build.gradle.kts +++ b/mcmmo-api/build.gradle.kts @@ -5,4 +5,5 @@ plugins { dependencies { api("org.jetbrains:annotations:17.0.0") + api("co.aikar:acf-core:0.5.0-SNAPSHOT") //Don't change without updating the artifacts for its dependencies (see the other comments) } \ No newline at end of file diff --git a/mcmmo-api/src/main/java/com/gmail/nossr50/mcmmo/api/platform/PlatformProvider.java b/mcmmo-api/src/main/java/com/gmail/nossr50/mcmmo/api/platform/PlatformProvider.java index 195c4c8dd..7f3750300 100644 --- a/mcmmo-api/src/main/java/com/gmail/nossr50/mcmmo/api/platform/PlatformProvider.java +++ b/mcmmo-api/src/main/java/com/gmail/nossr50/mcmmo/api/platform/PlatformProvider.java @@ -1,12 +1,18 @@ package com.gmail.nossr50.mcmmo.api.platform; +import com.gmail.nossr50.mcmmo.api.data.MMOEntity; import com.gmail.nossr50.mcmmo.api.platform.scheduler.PlatformScheduler; import com.gmail.nossr50.mcmmo.api.platform.util.MetadataStore; import com.gmail.nossr50.mcmmo.api.platform.util.MobHealthBarManager; import java.io.File; +import java.util.UUID; import java.util.logging.Logger; +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.CommandManager; +import co.aikar.commands.CommandOperationContext; + public interface PlatformProvider { Logger getLogger(); @@ -38,4 +44,19 @@ public interface PlatformProvider { void checkMetrics(); MobHealthBarManager getHealthBarManager(); + + @Deprecated + void registerCustomRecipes(); + + CommandManager getCommandManager(); + + + + // EVIL - EVILNESS FROM BEYOND THIS POINT - EVIL + // THOU HAST BEEN WARNED + @Deprecated + MMOEntity getEntity(UUID uniqueId); + + @Deprecated + Object getChimaeraWing(); } diff --git a/mcmmo-api/src/main/java/com/gmail/nossr50/mcmmo/api/platform/scheduler/PlatformScheduler.java b/mcmmo-api/src/main/java/com/gmail/nossr50/mcmmo/api/platform/scheduler/PlatformScheduler.java index cb78552ec..b437f1d62 100644 --- a/mcmmo-api/src/main/java/com/gmail/nossr50/mcmmo/api/platform/scheduler/PlatformScheduler.java +++ b/mcmmo-api/src/main/java/com/gmail/nossr50/mcmmo/api/platform/scheduler/PlatformScheduler.java @@ -9,9 +9,9 @@ public interface PlatformScheduler { Task scheduleTask(TaskBuilder taskBuilder); - class TaskBuilder { - Integer delay; - Integer repeatTime; + abstract class TaskBuilder { + Long delay; + Long repeatTime; public boolean isAsync() { return isAsync; @@ -25,20 +25,20 @@ public interface PlatformScheduler { boolean isAsync = false; Consumer task; - public Integer getDelay() { + public Long getDelay() { return delay; } - public TaskBuilder setDelay(Integer delay) { + public TaskBuilder setDelay(Long delay) { this.delay = delay; return this; } - public Integer getRepeatTime() { + public Long getRepeatTime() { return repeatTime; } - public TaskBuilder setRepeatTime(Integer repeatTime) { + public TaskBuilder setRepeatTime(Long repeatTime) { this.repeatTime = repeatTime; return this; } @@ -51,5 +51,13 @@ public interface PlatformScheduler { this.task = task; return this; } + + @Deprecated + public TaskBuilder setTask(Runnable runnableTask) { + this.setTask(task -> runnableTask.run()); + return this; + } + + public abstract Task schedule(); } } diff --git a/mcmmo-bukkit/build.gradle.kts b/mcmmo-bukkit/build.gradle.kts index 04ab4ccd4..6967c0ab4 100644 --- a/mcmmo-bukkit/build.gradle.kts +++ b/mcmmo-bukkit/build.gradle.kts @@ -12,10 +12,14 @@ tasks { } shadowJar { + /* dependencies { include(dependency("org.bstats:bstats-bukkit")) - exclude(dependency("org.spigotmc:spigot")) + include(project(":mcmmo-api")) + include(project(":mcmmo-core")) + include(project(":mcmmo-bukkit")) } + */ relocate("org.apache.commons.logging", "com.gmail.nossr50.commons.logging") relocate("org.apache.juli", "com.gmail.nossr50.database.tomcat.juli") relocate("org.apache.tomcat", "com.gmail.nossr50.database.tomcat") @@ -29,14 +33,15 @@ tasks { dependencies { - api(project(":mcmmo-api")) - implementation(project(":mcmmo-core")) + compile(project(":mcmmo-api")) + compile(project(":mcmmo-core")) api("org.apache.tomcat:tomcat-jdbc:7.0.52") api("net.kyori:event-api:3.0.0") implementation("org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1") + implementation("co.aikar:acf-paper:0.5.0-SNAPSHOT") //Don't change without updating the artifacts for its dependencies (see the other comments) implementation("org.bstats:bstats-bukkit:1.4") - implementation("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT") + compileOnly("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT") implementation("com.sk89q.worldguard:worldguard-legacy:7.0.0-SNAPSHOT") testImplementation("junit:junit:4.10") } diff --git a/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/BukkitBoostrap.java b/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/BukkitBootstrap.java similarity index 58% rename from mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/BukkitBoostrap.java rename to mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/BukkitBootstrap.java index 98cd5e11b..aee4b2ce5 100644 --- a/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/BukkitBoostrap.java +++ b/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/BukkitBootstrap.java @@ -1,29 +1,50 @@ package com.gmail.nossr50.mcmmo.bukkit; +import com.gmail.nossr50.datatypes.player.BukkitMMOPlayer; import com.gmail.nossr50.listeners.*; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcmmo.api.data.MMOEntity; import com.gmail.nossr50.mcmmo.api.platform.PlatformProvider; import com.gmail.nossr50.mcmmo.api.platform.ServerSoftwareType; import com.gmail.nossr50.mcmmo.api.platform.scheduler.PlatformScheduler; import com.gmail.nossr50.mcmmo.api.platform.util.MetadataStore; import com.gmail.nossr50.mcmmo.api.platform.util.MobHealthBarManager; +import com.gmail.nossr50.mcmmo.bukkit.platform.entity.BukkitMMOEntity; import com.gmail.nossr50.mcmmo.bukkit.platform.scheduler.BukkitPlatformScheduler; import com.gmail.nossr50.mcmmo.bukkit.platform.util.BukkitMobHealthBarManager; import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.ShapelessRecipe; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.List; import java.util.Locale; +import java.util.UUID; import java.util.logging.Logger; -public class BukkitBoostrap extends JavaPlugin implements PlatformProvider { +import co.aikar.commands.CommandManager; +import co.aikar.commands.PaperCommandManager; + +public class BukkitBootstrap extends JavaPlugin implements PlatformProvider { private mcMMO core = new mcMMO(this); private final BukkitPlatformScheduler scheduler = new BukkitPlatformScheduler(this); - private final MobHealthBarManager healthBarManager = new BukkitMobHealthBarManager(core); + private final MobHealthBarManager healthBarManager = new BukkitMobHealthBarManager(this, core); + private PaperCommandManager paperCommandManager; + @Override public @NotNull Logger getLogger() { @@ -45,7 +66,7 @@ public class BukkitBoostrap extends JavaPlugin implements PlatformProvider { @Override public String getVersion() { - return this.getVersion(); + return getDescription().getVersion(); } @Override @@ -57,7 +78,8 @@ public class BukkitBoostrap extends JavaPlugin implements PlatformProvider { } registerEvents(); - + paperCommandManager = new PaperCommandManager(this); + paperCommandManager.registerDependency(mcMMO.class, core); } @Override @@ -122,9 +144,77 @@ public class BukkitBoostrap extends JavaPlugin implements PlatformProvider { @Override public MobHealthBarManager getHealthBarManager() { + return healthBarManager; + } + + @Override + public void registerCustomRecipes() { + getServer().getScheduler().scheduleSyncDelayedTask(this, () -> { + if (core.getConfigManager().getConfigItems().isChimaeraWingEnabled()) { + Recipe recipe = getChimaeraWingRecipe(); + + if(!core.getSkillTools().hasRecipeBeenRegistered(recipe)) + getServer().addRecipe(getChimaeraWingRecipe()); + } + }, 40); + } + + @Override + public CommandManager getCommandManager() { + return paperCommandManager; + } + + @Override + @Deprecated // TODO: This needs proper registration... + public MMOEntity getEntity(UUID uniqueId) { + final Entity entity = Bukkit.getEntity(uniqueId); + if (entity instanceof Player) { + core.getUserManager().getPlayer((Player) entity); + } else if (entity instanceof LivingEntity) { + return new BukkitMMOEntity(entity); + } else if (entity != null){ + return new BukkitMMOEntity(entity); + } return null; } + //TODO: Add this stuff to DSM, this location is temporary + //TODO: even more temp here.... + private ShapelessRecipe getChimaeraWingRecipe() { + Material ingredient = Material.matchMaterial(core.getConfigManager().getConfigItems().getChimaeraWingRecipeMats()); + + if(ingredient == null) + ingredient = Material.FEATHER; + + int amount = core.getConfigManager().getConfigItems().getChimaeraWingUseCost(); + + ShapelessRecipe chimaeraWing = new ShapelessRecipe(new NamespacedKey(this, "Chimaera"), getChimaeraWing()); + chimaeraWing.addIngredient(amount, ingredient); + return chimaeraWing; + } + + + //TODO: Add this stuff to DSM, this location is temporary + public ItemStack getChimaeraWing() { + Material ingredient = Material.matchMaterial(core.getConfigManager().getConfigItems().getChimaeraWingRecipeMats()); + + if(ingredient == null) + ingredient = Material.FEATHER; + + //TODO: Make it so Chimaera wing amounts made is customizeable + ItemStack itemStack = new ItemStack(ingredient, 1); + + ItemMeta itemMeta = itemStack.getItemMeta(); + itemMeta.setDisplayName(ChatColor.GOLD + core.getLocaleManager().getString("Item.ChimaeraWing.Name")); + + List itemLore = new ArrayList<>(); + itemLore.add("mcMMO Item"); + itemLore.add(core.getLocaleManager().getString("Item.ChimaeraWing.Lore")); + itemMeta.setLore(itemLore); + + itemStack.setItemMeta(itemMeta); + return itemStack; + } private void registerEvents() { PluginManager pluginManager = getServer().getPluginManager(); @@ -137,4 +227,9 @@ public class BukkitBoostrap extends JavaPlugin implements PlatformProvider { pluginManager.registerEvents(new SelfListener(core), this); pluginManager.registerEvents(new WorldListener(core), this); } + + @Override + public void onEnable() { + core.onEnable(); + } } diff --git a/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/entity/BukkitMMOEntity.java b/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/entity/BukkitMMOEntity.java new file mode 100644 index 000000000..904576cf2 --- /dev/null +++ b/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/entity/BukkitMMOEntity.java @@ -0,0 +1,19 @@ +package com.gmail.nossr50.mcmmo.bukkit.platform.entity; + +import com.gmail.nossr50.mcmmo.api.data.MMOEntity; + +import org.bukkit.entity.Entity; + +public class BukkitMMOEntity implements MMOEntity { + + Entity entity; + + public BukkitMMOEntity(Entity entity) { + this.entity = entity; + } + + @Override + public Entity getNative() { + return null; + } +} diff --git a/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/entity/living/BukkitMMOLivingEntity.java b/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/entity/living/BukkitMMOLivingEntity.java new file mode 100644 index 000000000..6b16dba6a --- /dev/null +++ b/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/entity/living/BukkitMMOLivingEntity.java @@ -0,0 +1,19 @@ +package com.gmail.nossr50.mcmmo.bukkit.platform.entity.living; + +import com.gmail.nossr50.mcmmo.api.data.MMOEntity; + +import org.bukkit.entity.LivingEntity; + +public class BukkitMMOLivingEntity implements MMOEntity { + + LivingEntity entity; + + public BukkitMMOLivingEntity(LivingEntity entity) { + this.entity = entity; + } + + @Override + public LivingEntity getNative() { + return entity; + } +} diff --git a/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/scheduler/BukkitPlatformScheduler.java b/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/scheduler/BukkitPlatformScheduler.java index 8d84ef185..3f80309e0 100644 --- a/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/scheduler/BukkitPlatformScheduler.java +++ b/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/scheduler/BukkitPlatformScheduler.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.mcmmo.bukkit.platform.scheduler; import com.gmail.nossr50.mcmmo.api.platform.scheduler.PlatformScheduler; import com.gmail.nossr50.mcmmo.api.platform.scheduler.Task; -import com.gmail.nossr50.mcmmo.bukkit.BukkitBoostrap; +import com.gmail.nossr50.mcmmo.bukkit.BukkitBootstrap; import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitTask; @@ -11,21 +11,26 @@ import java.util.function.Consumer; public class BukkitPlatformScheduler implements PlatformScheduler { - private final BukkitBoostrap bukkitBoostrap; + private final BukkitBootstrap bukkitBootstrap; - public BukkitPlatformScheduler(BukkitBoostrap bukkitBoostrap) { - this.bukkitBoostrap = bukkitBoostrap; + public BukkitPlatformScheduler(BukkitBootstrap bukkitBootstrap) { + this.bukkitBootstrap = bukkitBootstrap; } @Override public TaskBuilder getTaskBuilder() { - return new TaskBuilder(); + return new TaskBuilder() { + @Override + public Task schedule() { + return BukkitPlatformScheduler.this.scheduleTask(this); + } + }; } @Override public Task scheduleTask(TaskBuilder taskBuilder) { - final Integer repeatTime = taskBuilder.getRepeatTime(); - final Integer delay = taskBuilder.getDelay(); + final Long repeatTime = taskBuilder.getRepeatTime(); + final Long delay = taskBuilder.getDelay(); final boolean isAsync = taskBuilder.isAsync(); final Consumer taskConsumer = taskBuilder.getTask(); @@ -35,19 +40,19 @@ public class BukkitPlatformScheduler implements PlatformScheduler { final BukkitTask bukkitTask; if (!isAsync) { if (delay == null && repeatTime == null) { - bukkitTask = bukkitScheduler.runTask(bukkitBoostrap, task); + bukkitTask = bukkitScheduler.runTask(bukkitBootstrap, task); } else if (delay != null && repeatTime == null) { - bukkitTask = bukkitScheduler.runTaskLater(bukkitBoostrap, task, delay); + bukkitTask = bukkitScheduler.runTaskLater(bukkitBootstrap, task, delay); } else { - bukkitTask = bukkitScheduler.runTaskTimer(bukkitBoostrap, task, delay != null ? delay : 0, repeatTime); + bukkitTask = bukkitScheduler.runTaskTimer(bukkitBootstrap, task, delay != null ? delay : 0, repeatTime); } } else { if (delay == null && repeatTime == null) { - bukkitTask = bukkitScheduler.runTaskAsynchronously(bukkitBoostrap, task); + bukkitTask = bukkitScheduler.runTaskAsynchronously(bukkitBootstrap, task); } else if (delay != null && repeatTime == null) { - bukkitTask = bukkitScheduler.runTaskLaterAsynchronously(bukkitBoostrap, task, delay); + bukkitTask = bukkitScheduler.runTaskLaterAsynchronously(bukkitBootstrap, task, delay); } else { - bukkitTask = bukkitScheduler.runTaskTimerAsynchronously(bukkitBoostrap, task, delay != null ? delay : 0, repeatTime); + bukkitTask = bukkitScheduler.runTaskTimerAsynchronously(bukkitBootstrap, task, delay != null ? delay : 0, repeatTime); } } diff --git a/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/util/BukkitMobHealthBarManager.java b/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/util/BukkitMobHealthBarManager.java index 21902d8a7..7e54f5461 100644 --- a/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/util/BukkitMobHealthBarManager.java +++ b/mcmmo-bukkit/src/main/java/com/gmail/nossr50/mcmmo/bukkit/platform/util/BukkitMobHealthBarManager.java @@ -16,13 +16,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; public final class BukkitMobHealthBarManager implements MobHealthBarManager { + private final Plugin plugin; private final mcMMO pluginRef; private final boolean healthBarPluginEnabled; - public BukkitMobHealthBarManager(mcMMO pluginRef) { + public BukkitMobHealthBarManager(Plugin plugin, mcMMO pluginRef) { + this.plugin = plugin; this.pluginRef = pluginRef; PluginManager pluginManager = Bukkit.getServer().getPluginManager(); healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null; @@ -51,7 +54,7 @@ public final class BukkitMobHealthBarManager implements MobHealthBarManager author: nossr50 authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1, Riking, electronicboy, kashike] website: https://www.mcmmo.org -main: com.gmail.nossr50.mcMMO +main: com.gmail.nossr50.mcmmo.bukkit.BukkitBootstrap softdepend: [WorldGuard, WorldEdit, CombatTag, HealthBar] load: POSTWORLD api-version: 1.13 diff --git a/mcmmo-core/build.gradle.kts b/mcmmo-core/build.gradle.kts index 6d3e231fd..a5db523e1 100644 --- a/mcmmo-core/build.gradle.kts +++ b/mcmmo-core/build.gradle.kts @@ -9,6 +9,7 @@ plugins { tasks { shadowJar { + /* dependencies { include(dependency("org.spongepowered:configurate-yaml")) include(dependency("org.spongepowered:configurate-hocon")) @@ -24,6 +25,7 @@ tasks { include(dependency("net.kyori:text-serializer-gson")) exclude(dependency("org.spigotmc:spigot")) } + */ relocate("org.apache.commons.logging", "com.gmail.nossr50.commons.logging") relocate("org.apache.juli", "com.gmail.nossr50.database.tomcat.juli") relocate("org.apache.tomcat", "com.gmail.nossr50.database.tomcat") @@ -58,21 +60,19 @@ tasks.named("shadowJar") { dependencies { api(project(":mcmmo-api")) - api("org.apache.tomcat:tomcat-jdbc:7.0.52") - api("com.typesafe:config:1.3.2") - api("org.spongepowered:configurate-core:3.7-SNAPSHOT") - api("org.spongepowered:configurate-yaml:3.7-SNAPSHOT") - api("org.spongepowered:configurate-hocon:3.7-SNAPSHOT") - api("co.aikar:acf-core:0.5.0-SNAPSHOT") //Don't change without updating the artifacts for its dependencies (see the other comments) - api("co.aikar:acf-paper:0.5.0-SNAPSHOT") //Don't change without updating the artifacts for its dependencies (see the other comments) - api("net.kyori:text-api:3.0.2") - api("net.kyori:text-serializer-gson:3.0.2") - api("net.kyori:text-adapter-bukkit:3.0.4-SNAPSHOT") - implementation("org.jetbrains:annotations:17.0.0") - implementation("org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1") - implementation("org.bstats:bstats-bukkit:1.4") - implementation("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT") - implementation("com.sk89q.worldguard:worldguard-legacy:7.0.0-SNAPSHOT") + compile("org.apache.tomcat:tomcat-jdbc:7.0.52") + compile("com.typesafe:config:1.3.2") + compile("org.spongepowered:configurate-core:3.7-SNAPSHOT") + compile("org.spongepowered:configurate-yaml:3.7-SNAPSHOT") + compile("org.spongepowered:configurate-hocon:3.7-SNAPSHOT") + compile("net.kyori:text-api:3.0.2") + compile("net.kyori:text-serializer-gson:3.0.2") + compile("net.kyori:text-adapter-bukkit:3.0.4-SNAPSHOT") + compile("org.jetbrains:annotations:17.0.0") + compile("org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1") + compile("org.bstats:bstats-bukkit:1.4") + compileOnly("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT") + compileOnly("com.sk89q.worldguard:worldguard-legacy:7.0.0-SNAPSHOT") testImplementation("junit:junit:4.10") } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/chat/ChatManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/chat/ChatManager.java index cfa6037ea..df031ed5d 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/chat/ChatManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/chat/ChatManager.java @@ -5,8 +5,11 @@ import com.gmail.nossr50.datatypes.player.BukkitMMOPlayer; import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; import com.gmail.nossr50.mcMMO; + +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -14,29 +17,32 @@ import java.util.regex.Pattern; public class ChatManager { private final String ADMIN_CHAT_PERMISSION = "mcmmo.chat.adminchat"; private final mcMMO pluginRef; + @Deprecated + private final Plugin legacyPlugin; public ChatManager(mcMMO pluginRef) { this.pluginRef = pluginRef; + this.legacyPlugin = (Plugin) pluginRef.getPlatformProvider(); } public void processAdminChat(Player player, String message) { - sendAdminChatMessage(new McMMOAdminChatEvent(pluginRef, player.getName(), player.getDisplayName(), message)); + sendAdminChatMessage(new McMMOAdminChatEvent(legacyPlugin, player.getName(), player.getDisplayName(), message)); } public void processAdminChat(String senderName, String displayName, String message) { - sendAdminChatMessage(new McMMOAdminChatEvent(pluginRef, senderName, displayName, message)); + sendAdminChatMessage(new McMMOAdminChatEvent(legacyPlugin, senderName, displayName, message)); } public void processPartyChat(Party party, Player sender, String message) { - sendPartyChatMessage(new McMMOPartyChatEvent(pluginRef, sender.getName(), sender.getDisplayName(), party, message)); + sendPartyChatMessage(new McMMOPartyChatEvent(legacyPlugin, sender.getName(), sender.getDisplayName(), party, message)); } public void processPartyChat(Party party, String senderName, String message) { - sendPartyChatMessage(new McMMOPartyChatEvent(pluginRef, senderName, senderName, party, message)); + sendPartyChatMessage(new McMMOPartyChatEvent(legacyPlugin, senderName, senderName, party, message)); } private void sendAdminChatMessage(McMMOAdminChatEvent event) { - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; @@ -47,11 +53,11 @@ public class ChatManager { String displayName = pluginRef.getConfigManager().getConfigCommands().isUseDisplayNames() ? event.getDisplayName() : senderName; String message = pluginRef.getLocaleManager().formatString(chatPrefix, displayName) + " " + event.getMessage(); - pluginRef.getServer().broadcast(message, ADMIN_CHAT_PERMISSION); + Bukkit.getServer().broadcast(message, ADMIN_CHAT_PERMISSION); } private void sendPartyChatMessage(McMMOPartyChatEvent event) { - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; @@ -79,7 +85,7 @@ public class ChatManager { } } - pluginRef.getServer().getConsoleSender().sendMessage(ChatColor.stripColor("[mcMMO] [P]<" + party.getName() + ">" + message)); + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.stripColor("[mcMMO] [P]<" + party.getName() + ">" + message)); /* * Party Chat Spying diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/ExperienceRateCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/ExperienceRateCommand.java index 702de81fd..dd2df958a 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/ExperienceRateCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/ExperienceRateCommand.java @@ -4,6 +4,8 @@ import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; import com.google.common.collect.ImmutableList; + +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -37,15 +39,15 @@ public class ExperienceRateCommand implements TabExecutor { if (pluginRef.isXPEventEnabled()) { if (pluginRef.getConfigManager().getConfigEvent().isSendTitleMessages()) { - pluginRef.getNotificationManager().broadcastTitle(pluginRef.getServer(), + pluginRef.getNotificationManager().broadcastTitle(Bukkit.getServer(), pluginRef.getLocaleManager().getString("Commands.Event.Stop"), pluginRef.getLocaleManager().getString("Commands.Event.Stop.Subtitle"), 10, 10 * 20, 20); } if (pluginRef.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) { - pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Stop")); - pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Stop.Subtitle")); + Bukkit.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Stop")); + Bukkit.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Stop.Subtitle")); } //Admin notification @@ -85,15 +87,15 @@ public class ExperienceRateCommand implements TabExecutor { pluginRef.getDynamicSettingsManager().getExperienceManager().setGlobalXpMult(newXpRate); if (pluginRef.getConfigManager().getConfigEvent().isSendTitleMessages()) { - pluginRef.getNotificationManager().broadcastTitle(pluginRef.getServer(), + pluginRef.getNotificationManager().broadcastTitle(Bukkit.getServer(), pluginRef.getLocaleManager().getString("Commands.Event.Start"), pluginRef.getLocaleManager().getString("Commands.Event.XP", newXpRate), 10, 10 * 20, 20); } if (pluginRef.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) { - pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Start")); - pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.XP", newXpRate)); + Bukkit.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Start")); + Bukkit.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.XP", newXpRate)); } //Admin notification diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/McMMOCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/McMMOCommand.java index 466fc0cb6..8d9922e8b 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/McMMOCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/McMMOCommand.java @@ -6,6 +6,7 @@ import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; public class McMMOCommand implements CommandExecutor { @@ -34,7 +35,7 @@ public class McMMOCommand implements CommandExecutor { sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal"); } - sender.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version", pluginRef.getDescription().getVersion())); + sender.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version", ((Plugin) pluginRef.getPlatformProvider()).getDescription().getVersion())); // mcMMO.getHolidayManager().anniversaryCheck(sender); return true; diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java index 1e5816ff3..6befdbd9b 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java @@ -6,6 +6,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.database.DatabaseConversionTask; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; + +import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -57,17 +59,24 @@ public class ConvertDatabaseCommand implements CommandExecutor { pluginRef.getUserManager().saveAll(); pluginRef.getUserManager().clearAll(); - for (Player player : pluginRef.getServer().getOnlinePlayers()) { + for (Player player : Bukkit.getServer().getOnlinePlayers()) { PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId()); if (profile.isLoaded()) { pluginRef.getDatabaseManager().saveUser(profile); } - new PlayerProfileLoadingTask(pluginRef, player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setAsync(true) + .setDelay(1L) // 1 Tick delay to ensure the player is marked as online before we begin loading + .setTask(new PlayerProfileLoadingTask(pluginRef, player)) + .schedule(); } - new DatabaseConversionTask(pluginRef, oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(pluginRef); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setAsync(true) + .setTask(new DatabaseConversionTask(pluginRef, oldDatabase, sender, previousType.toString(), newType.toString())) + .schedule(); return true; default: diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java index c652fb7b2..24d6f84d2 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java @@ -4,6 +4,8 @@ import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.database.FormulaConversionTask; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; + +import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -31,10 +33,17 @@ public class ConvertExperienceCommand implements CommandExecutor { pluginRef.getUserManager().saveAll(); pluginRef.getUserManager().clearAll(); - new FormulaConversionTask(pluginRef, sender, previousType).runTaskLater(pluginRef, 1); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(1L) + .setTask(new FormulaConversionTask(pluginRef, sender, previousType)) + .schedule(); - for (Player player : pluginRef.getServer().getOnlinePlayers()) { - new PlayerProfileLoadingTask(pluginRef, player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + for (Player player : Bukkit.getServer().getOnlinePlayers()) { + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setAsync(true) + .setDelay(1L) // 1 Tick delay to ensure the player is marked as online before we begin loading + .setTask(new PlayerProfileLoadingTask(pluginRef, player)) + .schedule(); } return true; diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java index b20eee624..de4d07d64 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java @@ -5,6 +5,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import com.google.common.collect.ImmutableList; + +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -101,7 +103,7 @@ public abstract class ExperienceCommand implements TabExecutor { // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. if (mcMMOPlayer == null) { UUID uuid = null; - OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(playerName); + OfflinePlayer player = Bukkit.getServer().getOfflinePlayer(playerName); if (player != null) { uuid = player.getUniqueId(); } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/SkillResetCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/SkillResetCommand.java index 105555bc7..63c100689 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/SkillResetCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/experience/SkillResetCommand.java @@ -6,6 +6,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import com.google.common.collect.ImmutableList; + +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -86,7 +88,7 @@ public class SkillResetCommand implements TabExecutor { // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. if (mcMMOPlayer == null) { UUID uuid = null; - OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(playerName); + OfflinePlayer player = Bukkit.getServer().getOfflinePlayer(playerName); if (player != null) { uuid = player.getUniqueId(); } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java index cc99ac127..0ac5d2302 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java @@ -2,6 +2,8 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.mcMMO; + +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -28,7 +30,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor { Party playerParty = pluginRef.getUserManager().getPlayer((Player) sender).getParty(); String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]); - OfflinePlayer target = pluginRef.getServer().getOfflinePlayer(targetName); + OfflinePlayer target = Bukkit.getServer().getOfflinePlayer(targetName); if (!playerParty.hasMember(target.getUniqueId())) { sender.sendMessage(pluginRef.getLocaleManager().getString("Party.NotInYourParty", targetName)); diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java index 0251b20c9..745052e77 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java @@ -3,6 +3,8 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.mcMMO; + +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -34,7 +36,7 @@ public class PartyKickCommand implements CommandExecutor { return true; } - OfflinePlayer target = pluginRef.getServer().getOfflinePlayer(targetName); + OfflinePlayer target = Bukkit.getServer().getOfflinePlayer(targetName); if (target.isOnline()) { Player onlineTarget = target.getPlayer(); diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/player/LeaderboardCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/player/LeaderboardCommand.java index 76164dff0..b9841a990 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/player/LeaderboardCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/player/LeaderboardCommand.java @@ -13,6 +13,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.plugin.Plugin; import org.bukkit.util.StringUtil; import java.util.ArrayList; @@ -103,11 +104,11 @@ public class LeaderboardCommand implements TabExecutor { return; } - if (((Player) sender).hasMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY)) { + if (((Player) sender).hasMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY.getKey())) { sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Database.Processing")); return; } else { - ((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(pluginRef, null)); + ((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY.getKey(), new FixedMetadataValue((Plugin) pluginRef.getPlatformProvider(), null)); } mcMMOPlayer.actualizeDatabaseATS(); @@ -120,7 +121,10 @@ public class LeaderboardCommand implements TabExecutor { boolean useBoard = (sender instanceof Player) && (pluginRef.getScoreboardSettings().isScoreboardEnabled(SidebarType.TOP_BOARD)); boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(SidebarType.TOP_BOARD); - new LeaderboardsCommandAsyncTask(pluginRef, page, skill, sender, useBoard, useChat).runTaskAsynchronously(pluginRef); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setAsync(true) + .setTask(new LeaderboardsCommandAsyncTask(pluginRef, page, skill, sender, useBoard, useChat)) + .schedule(); } private PrimarySkillType extractSkill(CommandSender sender, String skillName) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/player/RankCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/player/RankCommand.java index 9f3f8e6b6..245625520 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/player/RankCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/player/RankCommand.java @@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.plugin.Plugin; import org.bukkit.util.StringUtil; import java.util.ArrayList; @@ -103,11 +104,11 @@ public class RankCommand implements TabExecutor { return; } - if (((Player) sender).hasMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY)) { + if (((Player) sender).hasMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY.getKey())) { sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Database.Processing")); return; } else { - ((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(pluginRef, null)); + ((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY.getKey(), new FixedMetadataValue((Plugin) pluginRef.getPlatformProvider(), null)); } mcMMOPlayer.actualizeDatabaseATS(); @@ -117,7 +118,10 @@ public class RankCommand implements TabExecutor { && (pluginRef.getScoreboardSettings().isScoreboardEnabled(SidebarType.RANK_BOARD)); boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(SidebarType.RANK_BOARD); - new RankCommandAsyncTask(pluginRef, playerName, sender, useBoard, useChat).runTaskAsynchronously(pluginRef); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setAsync(true) + .setTask(new RankCommandAsyncTask(pluginRef, playerName, sender, useBoard, useChat)) + .schedule(); } private long getCDSeconds(BukkitMMOPlayer mcMMOPlayer, long cooldownMillis) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/core/MetadataConstants.java b/mcmmo-core/src/main/java/com/gmail/nossr50/core/MetadataConstants.java index a01576ae3..f67b5882f 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/core/MetadataConstants.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/core/MetadataConstants.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.core; +import com.gmail.nossr50.mcmmo.api.data.MMOPlayer; import com.gmail.nossr50.mcmmo.api.platform.util.MetadataKey; import org.bukkit.metadata.FixedMetadataValue; @@ -28,7 +29,7 @@ public class MetadataConstants { public final static MetadataKey ARROW_TRACKER_METAKEY = new MetadataKey<>("mcMMO: Arrow Tracker"); public final static MetadataKey BONUS_DROPS_METAKEY = new MetadataKey<>("mcMMO: Bonus Drops"); public final static MetadataKey DISARMED_ITEM_METAKEY = new MetadataKey<>("mcMMO: Disarmed Item"); - public final static MetadataKey PLAYER_DATA_METAKEY = new MetadataKey<>("mcMMO: Player Data"); + public final static MetadataKey PLAYER_DATA_METAKEY = new MetadataKey<>("mcMMO: Player Data"); public final static MetadataKey GREEN_THUMB_METAKEY = new MetadataKey<>("mcMMO: Green Thumb"); public final static MetadataKey DATABASE_PROCESSING_COMMAND_METAKEY = new MetadataKey<>("mcMMO: Processing Database Command"); public final static MetadataKey PETS_ANIMAL_TRACKING_METAKEY = new MetadataKey<>("mcMMO: Pet Animal"); diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java index 7b087b9ac..db34fe994 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java @@ -9,6 +9,8 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; + +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import java.io.*; @@ -179,7 +181,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager { e.printStackTrace(); } if (lastPlayed == 0) { - OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(name); + OfflinePlayer player = Bukkit.getServer().getOfflinePlayer(name); lastPlayed = player.getLastPlayed(); rewrite = true; } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/meta/BonusDropMeta.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/meta/BonusDropMeta.java index a9d093a56..e4d289b1d 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/meta/BonusDropMeta.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/meta/BonusDropMeta.java @@ -2,6 +2,7 @@ package com.gmail.nossr50.datatypes.meta; import com.gmail.nossr50.mcMMO; import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.plugin.Plugin; /** * Stores how many bonus drops a block should give @@ -9,6 +10,6 @@ import org.bukkit.metadata.FixedMetadataValue; public class BonusDropMeta extends FixedMetadataValue { public BonusDropMeta(int value, mcMMO plugin) { - super(plugin, value); + super((Plugin) plugin.getPlatformProvider(), value); } } \ No newline at end of file diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/meta/OldName.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/meta/OldName.java index 9aac9b224..617f62797 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/meta/OldName.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/meta/OldName.java @@ -2,6 +2,7 @@ package com.gmail.nossr50.datatypes.meta; import com.gmail.nossr50.mcMMO; import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.plugin.Plugin; /** * This class is for storing mob names since we switch them to heart values @@ -9,7 +10,7 @@ import org.bukkit.metadata.FixedMetadataValue; public class OldName extends FixedMetadataValue { public OldName(String oldName, mcMMO plugin) { - super(plugin, oldName); + super((Plugin) plugin.getPlatformProvider(), oldName); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index 6ea79ba5f..577ca5edf 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -250,7 +250,7 @@ public class Party { } if (!pluginRef.getConfigManager().getConfigParty().getPartyXP().getPartyLevel().isInformPartyMembersOnLevelup()) { - Player leader = pluginRef.getServer().getPlayer(this.leader.getUniqueId()); + Player leader = Bukkit.getServer().getPlayer(this.leader.getUniqueId()); if (leader != null) { leader.sendMessage(pluginRef.getLocaleManager().getString("Party.LevelUp", levelsGained, getLevel())); diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/player/BukkitMMOPlayer.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/player/BukkitMMOPlayer.java index dd7b086ab..0fcf262b1 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/player/BukkitMMOPlayer.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/player/BukkitMMOPlayer.java @@ -85,7 +85,7 @@ public class BukkitMMOPlayer implements MMOPlayer { UUID uuid = player.getUniqueId(); this.player = player; - playerMetadata = new FixedMetadataValue(pluginRef, playerName); + playerMetadata = new FixedMetadataValue((Plugin) pluginRef.getPlatformProvider(), playerName); this.profile = profile; if (profile.getUniqueId() == null) { @@ -656,7 +656,7 @@ public class BukkitMMOPlayer implements MMOPlayer { return; if (getSkillXpLevelRaw(primarySkillType) < getXpToLevel(primarySkillType)) { - processPostXpEvent(primarySkillType, pluginRef, xpGainSource); + processPostXpEvent(primarySkillType, (Plugin) pluginRef.getPlatformProvider(), xpGainSource); return; } @@ -687,7 +687,7 @@ public class BukkitMMOPlayer implements MMOPlayer { pluginRef.getNotificationManager().sendPlayerLevelUpNotification(this, primarySkillType, levelsGained, profile.getSkillLevel(primarySkillType)); //UPDATE XP BARS - processPostXpEvent(primarySkillType, pluginRef, xpGainSource); + processPostXpEvent(primarySkillType, (Plugin) pluginRef.getPlatformProvider(), xpGainSource); } /* @@ -951,7 +951,10 @@ public class BukkitMMOPlayer implements MMOPlayer { } setToolPreparationMode(tool, false); - new AbilityDisableTask(pluginRef, this, superAbility).runTaskLater(pluginRef, abilityLength * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(abilityLength * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR) + .setTask(new AbilityDisableTask(pluginRef, this, superAbility)) + .schedule(); } public void processAbilityActivation(PrimarySkillType primarySkillType) { @@ -998,7 +1001,10 @@ public class BukkitMMOPlayer implements MMOPlayer { } setToolPreparationMode(tool, true); - new ToolLowerTask(pluginRef,this, tool).runTaskLater(pluginRef, 4 * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(4 * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR) + .setTask(new ToolLowerTask(pluginRef,this, tool)) + .schedule(); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 877c7c9a6..cad0306b5 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -76,20 +76,32 @@ public class PlayerProfile { } public void scheduleAsyncSave() { - new PlayerProfileSaveTask(this, false).runTaskAsynchronously(pluginRef); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setAsync(true) + .setTask(new PlayerProfileSaveTask(this, false)) + .schedule(); } public void scheduleSyncSave() { - new PlayerProfileSaveTask(this, true).runTask(pluginRef); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setTask(new PlayerProfileSaveTask(this, true)) + .schedule(); } public void scheduleAsyncSaveDelay() { - new PlayerProfileSaveTask(this, false).runTaskLaterAsynchronously(pluginRef, 20); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setAsync(true) + .setDelay(20L) + .setTask(new PlayerProfileSaveTask(this, false)) + .schedule(); } @Deprecated public void scheduleSyncSaveDelay() { - new PlayerProfileSaveTask(this, true).runTaskLater(pluginRef, 20); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(20L) + .setTask(new PlayerProfileSaveTask(this, true)) + .schedule(); } public void save(boolean useSync) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/ArcheryBehaviour.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/ArcheryBehaviour.java index f0533fb95..8e764e225 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/ArcheryBehaviour.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/ArcheryBehaviour.java @@ -9,6 +9,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.plugin.Plugin; /** * These behaviour classes are a band-aid fix for a larger problem @@ -31,17 +32,17 @@ public class ArcheryBehaviour { * @param livingEntity The entity hit by the arrows */ public void arrowRetrievalCheck(LivingEntity livingEntity) { - if(livingEntity.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY)) { - pluginRef.getMiscTools().dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY).get(0).asInt()); + if(livingEntity.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey())) { + pluginRef.getMiscTools().dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey()).get(0).asInt()); } } public void incrementArrowCount(LivingEntity livingEntity) { - if(livingEntity.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY)) { - int arrowCount = livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY).get(0).asInt(); - livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY).set(0, new FixedMetadataValue(pluginRef, arrowCount + 1)); + if(livingEntity.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey())) { + int arrowCount = livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey()).get(0).asInt(); + livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey()).set(0, new FixedMetadataValue((Plugin) pluginRef.getPlatformProvider(), arrowCount + 1)); } else { - livingEntity.setMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, new TrackedArrowMeta(pluginRef, 1)); + livingEntity.setMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey(), new TrackedArrowMeta((Plugin) pluginRef.getPlatformProvider(), 1)); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/MiningBehaviour.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/MiningBehaviour.java index 7d30afc9e..3e6a5da49 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/MiningBehaviour.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/MiningBehaviour.java @@ -4,6 +4,8 @@ import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.mining.MiningManager; + +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; @@ -63,12 +65,12 @@ public class MiningBehaviour { } public boolean processBlastMiningExplosion(EntityDamageByEntityEvent event, TNTPrimed tnt, Player defender) { - if (!tnt.hasMetadata(MetadataConstants.TNT_TRACKING_METAKEY) || !pluginRef.getUserManager().hasPlayerDataKey(defender)) { + if (!tnt.hasMetadata(MetadataConstants.TNT_TRACKING_METAKEY.getKey()) || !pluginRef.getUserManager().hasPlayerDataKey(defender)) { return false; } // We can make this assumption because we (should) be the only ones using this exact metadata - Player player = pluginRef.getServer().getPlayerExact(tnt.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString()); + Player player = Bukkit.getServer().getPlayerExact(tnt.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY.getKey()).get(0).asString()); if (!player.equals(defender)) { return false; diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 231a068ad..54eeee0ff 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -14,6 +14,8 @@ import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.sounds.SoundType; + +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; @@ -30,6 +32,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.*; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.MetadataValue; +import org.bukkit.plugin.Plugin; import java.util.HashSet; import java.util.List; @@ -81,8 +84,8 @@ public class BlockListener implements Listener { } } - if (event.getBlock().getMetadata(MetadataConstants.BONUS_DROPS_METAKEY).size() > 0) { - BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(MetadataConstants.BONUS_DROPS_METAKEY).get(0); + if (event.getBlock().getMetadata(MetadataConstants.BONUS_DROPS_METAKEY.getKey()).size() > 0) { + BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(MetadataConstants.BONUS_DROPS_METAKEY.getKey()).get(0); int bonusCount = bonusDropMeta.asInt(); for (int i = 0; i < bonusCount; i++) { @@ -92,8 +95,8 @@ public class BlockListener implements Listener { } } - if(event.getBlock().hasMetadata(MetadataConstants.BONUS_DROPS_METAKEY)) - event.getBlock().removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY, pluginRef); + if(event.getBlock().hasMetadata(MetadataConstants.BONUS_DROPS_METAKEY.getKey())) + event.getBlock().removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } /** @@ -397,7 +400,7 @@ public class BlockListener implements Listener { return; } - McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); + BukkitMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); BlockState blockState = event.getBlock().getState(); ItemStack heldItem = player.getInventory().getItemInMainHand(); @@ -511,13 +514,13 @@ public class BlockListener implements Listener { } private Player getPlayerFromFurnace(Block furnaceBlock) { - List metadata = furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY); + List metadata = furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey()); if (metadata.isEmpty()) { return null; } - return pluginRef.getServer().getPlayerExact(metadata.get(0).asString()); + return Bukkit.getServer().getPlayerExact(metadata.get(0).asString()); } /** @@ -639,7 +642,7 @@ public class BlockListener implements Listener { if (blockState instanceof Furnace) { Furnace furnace = (Furnace) blockState; - if (furnace.hasMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY)) { + if (furnace.hasMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey())) { player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner"); Player furnacePlayer = getPlayerFromFurnace(furnace.getBlock()); if (furnacePlayer != null) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index b0ee65eae..bcdd36d90 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -8,10 +8,13 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.events.fake.FakeEntityTameEvent; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcmmo.api.data.MMOPlayer; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.util.skills.SkillActivationType; + +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; @@ -26,6 +29,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.plugin.Plugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.projectiles.ProjectileSource; @@ -40,10 +44,10 @@ public class EntityListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onEntityTransform(EntityTransformEvent event) { //Transfer metadata keys from mob-spawned mobs to new mobs - if (event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY) - || event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY).size() >= 1) { + if (event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey()) + || event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey()).size() >= 1) { for (Entity entity : event.getTransformedEntities()) { - entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); + entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey(), MetadataConstants.metadataValue); } } } @@ -60,8 +64,8 @@ public class EntityListener implements Listener { //Prevent entities from giving XP if they target endermite if (event.getTarget() instanceof Endermite) { - if (!event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) - event.getEntity().setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); + if (!event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey())) + event.getEntity().setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey(), MetadataConstants.metadataValue); } } @@ -91,14 +95,14 @@ public class EntityListener implements Listener { if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) { - projectile.setMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, MetadataConstants.metadataValue); + projectile.setMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey(), MetadataConstants.metadataValue); } - projectile.setMetadata(MetadataConstants.BOW_FORCE_METAKEY, - new FixedMetadataValue(pluginRef, + projectile.setMetadata(MetadataConstants.BOW_FORCE_METAKEY.getKey(), + new FixedMetadataValue((Plugin) pluginRef.getPlatformProvider(), Math.min(event.getForce() * pluginRef.getConfigManager().getConfigExperience().getExperienceArchery().getForceMultiplier(), 1.0))); - projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(pluginRef, projectile.getLocation())); + projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY.getKey(), new FixedMetadataValue((Plugin) pluginRef.getPlatformProvider(), projectile.getLocation())); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -122,8 +126,8 @@ public class EntityListener implements Listener { if(!(projectile instanceof Arrow)) return; - projectile.setMetadata(MetadataConstants.BOW_FORCE_METAKEY, new FixedMetadataValue(pluginRef, 1.0)); - projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(pluginRef, projectile.getLocation())); + projectile.setMetadata(MetadataConstants.BOW_FORCE_METAKEY.getKey(), new FixedMetadataValue((Plugin) pluginRef.getPlatformProvider(), 1.0)); + projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY.getKey(), new FixedMetadataValue((Plugin) pluginRef.getPlatformProvider(), projectile.getLocation())); for(Enchantment enchantment : player.getInventory().getItemInMainHand().getEnchantments().keySet()) { if(enchantment.getName().equalsIgnoreCase("piercing")) @@ -131,7 +135,7 @@ public class EntityListener implements Listener { } if (pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) { - projectile.setMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, MetadataConstants.metadataValue); + projectile.setMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey(), MetadataConstants.metadataValue); } } } @@ -161,11 +165,11 @@ public class EntityListener implements Listener { Entity entity = event.getEntity(); if (entity instanceof FallingBlock || entity instanceof Enderman) { - boolean isTracked = entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY); + boolean isTracked = entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey()); if (pluginRef.getPlaceStore().isTrue(block) && !isTracked) { pluginRef.getPlaceStore().setFalse(block); - entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); + entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey(), MetadataConstants.metadataValue); } else if (isTracked) { pluginRef.getPlaceStore().setTrue(block); } @@ -287,7 +291,7 @@ public class EntityListener implements Listener { // Don't process this event for marked entities, for players this is handled above, // However, for entities, we do not wanna cancel this event to allow plugins to observe changes // properly - if (defender.getMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY).size() > 0) { + if (defender.getMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY.getKey()).size() > 0) { return; } @@ -299,7 +303,7 @@ public class EntityListener implements Listener { return; } - if (event.getDamager().hasMetadata(MetadataConstants.SPAWNED_FIREWORKS_METAKEY)) { + if (event.getDamager().hasMetadata(MetadataConstants.SPAWNED_FIREWORKS_METAKEY.getKey())) { event.setCancelled(true); return; } @@ -352,7 +356,7 @@ public class EntityListener implements Listener { } //Deflect checks - final McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(defendingPlayer); + final BukkitMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(defendingPlayer); if (mcMMOPlayer != null) { UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager(); @@ -615,18 +619,18 @@ public class EntityListener implements Listener { return; } - if (entity.hasMetadata(MetadataConstants.CUSTOM_NAME_METAKEY)) { - entity.setCustomName(entity.getMetadata(MetadataConstants.CUSTOM_NAME_METAKEY).get(0).asString()); - entity.removeMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, pluginRef); + if (entity.hasMetadata(MetadataConstants.CUSTOM_NAME_METAKEY.getKey())) { + entity.setCustomName(entity.getMetadata(MetadataConstants.CUSTOM_NAME_METAKEY.getKey()).get(0).asString()); + entity.removeMetadata(MetadataConstants.CUSTOM_NAME_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } - if (entity.hasMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY)) { - entity.setCustomNameVisible(entity.getMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY).get(0).asBoolean()); - entity.removeMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, pluginRef); + if (entity.hasMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY.getKey())) { + entity.setCustomNameVisible(entity.getMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY.getKey()).get(0).asBoolean()); + entity.removeMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } - if (entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) { - entity.removeMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, pluginRef); + if (entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey())) { + entity.removeMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } } @@ -668,18 +672,18 @@ public class EntityListener implements Listener { case SPAWNER: case SPAWNER_EGG: if (pluginRef.getConfigManager().getConfigExploitPrevention().doSpawnedEntitiesGiveModifiedXP()) { - entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); + entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey(), MetadataConstants.metadataValue); Entity passenger = entity.getPassenger(); if (passenger != null) { - passenger.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); + passenger.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey(), MetadataConstants.metadataValue); } } return; case BREEDING: - entity.setMetadata(MetadataConstants.PETS_ANIMAL_TRACKING_METAKEY, MetadataConstants.metadataValue); + entity.setMetadata(MetadataConstants.PETS_ANIMAL_TRACKING_METAKEY.getKey(), MetadataConstants.metadataValue); return; default: @@ -690,7 +694,7 @@ public class EntityListener implements Listener { public void onEntityBreed(EntityBreedEvent event) { if(pluginRef.getConfigManager().getConfigExploitPrevention().areSummonsBreedable()) { //TODO: Change to NBT - if(event.getFather().hasMetadata(MetadataConstants.COTW_TEMPORARY_SUMMON) || event.getMother().hasMetadata(MetadataConstants.COTW_TEMPORARY_SUMMON)) { + if(event.getFather().hasMetadata(MetadataConstants.COTW_TEMPORARY_SUMMON.getKey()) || event.getMother().hasMetadata(MetadataConstants.COTW_TEMPORARY_SUMMON.getKey())) { event.setCancelled(true); Animals mom = (Animals) event.getMother(); Animals father = (Animals) event.getFather(); @@ -722,13 +726,13 @@ public class EntityListener implements Listener { Entity entity = event.getEntity(); - if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.TNT_TRACKING_METAKEY)) { + if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.TNT_TRACKING_METAKEY.getKey())) { return; } // We can make this assumption because we (should) be the only ones // using this exact metadata - Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString()); + Player player = Bukkit.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY.getKey()).get(0).asString()); if (!pluginRef.getUserManager().hasPlayerDataKey(player)) { return; @@ -765,13 +769,13 @@ public class EntityListener implements Listener { Entity entity = event.getEntity(); - if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.TNT_TRACKING_METAKEY)) { + if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.TNT_TRACKING_METAKEY.getKey())) { return; } // We can make this assumption because we (should) be the only ones // using this exact metadata - Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString()); + Player player = Bukkit.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY.getKey()).get(0).asString()); if (!pluginRef.getUserManager().hasPlayerDataKey(player)) { return; @@ -929,12 +933,12 @@ public class EntityListener implements Listener { LivingEntity entity = event.getEntity(); - if (!pluginRef.getUserManager().hasPlayerDataKey(player) || pluginRef.getMiscTools().isNPCEntityExcludingVillagers(entity) || entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) { + if (!pluginRef.getUserManager().hasPlayerDataKey(player) || pluginRef.getMiscTools().isNPCEntityExcludingVillagers(entity) || entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey())) { return; } if (pluginRef.getConfigManager().getConfigExploitPrevention().doTamedEntitiesGiveXP()) - entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); + entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey(), MetadataConstants.metadataValue); //Profile not loaded //TODO: Redundant @@ -1017,8 +1021,8 @@ public class EntityListener implements Listener { if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getEntity().getWorld().getName())) return; - if (event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) { - event.getPigZombie().setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); + if (event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey())) { + event.getPigZombie().setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey(), MetadataConstants.metadataValue); } } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 1019cad60..d46d03685 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -5,6 +5,8 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask; + +import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.BrewingStand; @@ -17,6 +19,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.inventory.*; import org.bukkit.inventory.*; import org.bukkit.metadata.MetadataValue; +import org.bukkit.plugin.Plugin; import java.util.List; @@ -50,8 +53,8 @@ public class InventoryListener implements Listener { return; } - if (!furnaceBlock.hasMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY) && furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY).size() == 0) - furnaceBlock.setMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, pluginRef.getUserManager().getPlayer((Player) player).getPlayerMetadata()); + if (!furnaceBlock.hasMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey()) && furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey()).size() == 0) + furnaceBlock.setMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey(), pluginRef.getUserManager().getPlayer((Player) player).getPlayerMetadata()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -62,7 +65,7 @@ public class InventoryListener implements Listener { Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); - if (furnaceBlock == null || furnaceBlock.hasMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY)) { + if (furnaceBlock == null || furnaceBlock.hasMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey())) { return; } @@ -72,7 +75,7 @@ public class InventoryListener implements Listener { return; } - furnaceBlock.removeMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, pluginRef); + furnaceBlock.removeMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -189,15 +192,15 @@ public class InventoryListener implements Listener { Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); if (furnaceBlock != null) { - if (furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY).size() > 0) - furnaceBlock.removeMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, pluginRef); + if (furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey()).size() > 0) + furnaceBlock.removeMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); //Profile not loaded if (pluginRef.getUserManager().getPlayer(player) == null) { return; } - furnaceBlock.setMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, pluginRef.getUserManager().getPlayer(player).getPlayerMetadata()); + furnaceBlock.setMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey(), pluginRef.getUserManager().getPlayer(player).getPlayerMetadata()); } } @@ -452,7 +455,7 @@ public class InventoryListener implements Listener { final HumanEntity whoClicked = event.getWhoClicked(); - if (!whoClicked.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY)) { + if (!whoClicked.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY.getKey())) { return; } @@ -470,7 +473,9 @@ public class InventoryListener implements Listener { return; } - new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(pluginRef, 0); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setTask(new PlayerUpdateInventoryTask((Player) whoClicked)) + .schedule(); } private Block processInventoryOpenOrCloseEvent(Inventory inventory) { @@ -488,12 +493,12 @@ public class InventoryListener implements Listener { } private Player getPlayerFromFurnace(Block furnaceBlock) { - List metadata = furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY); + List metadata = furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY.getKey()); if (metadata.isEmpty()) { return null; } - return pluginRef.getServer().getPlayerExact(metadata.get(0).asString()); + return Bukkit.getServer().getPlayerExact(metadata.get(0).asString()); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 1a2adcc2e..7f5cd626f 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -33,6 +33,7 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.*; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; import java.util.Locale; @@ -117,7 +118,7 @@ public class PlayerListener implements Listener { } Player player = event.getEntity(); - event.setDeathMessage(pluginRef.getMobHealthBarManager().fixDeathMessage(deathMessage, player)); + event.setDeathMessage(pluginRef.getPlatformProvider().getHealthBarManager().fixDeathMessage(deathMessage, pluginRef.getUserManager().getPlayer(player))); } /** @@ -145,7 +146,7 @@ public class PlayerListener implements Listener { Player killedPlayer = event.getEntity(); - if (!killedPlayer.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY) || pluginRef.getPermissionTools().hardcoreBypass(killedPlayer)) { + if (!killedPlayer.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY.getKey()) || pluginRef.getPermissionTools().hardcoreBypass(killedPlayer)) { return; } @@ -225,7 +226,7 @@ public class PlayerListener implements Listener { ItemStack dropStack = drop.getItemStack(); if (pluginRef.getItemTools().isSharable(dropStack)) { - drop.setMetadata(MetadataConstants.DROPPED_ITEM_TRACKING_METAKEY, MetadataConstants.metadataValue); + drop.setMetadata(MetadataConstants.DROPPED_ITEM_TRACKING_METAKEY.getKey(), MetadataConstants.metadataValue); } pluginRef.getSkillTools().removeAbilityBuff(dropStack); @@ -342,7 +343,7 @@ public class PlayerListener implements Listener { //Track the hook if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits()) { - if (event.getHook().getMetadata(MetadataConstants.FISH_HOOK_REF_METAKEY).size() == 0) { + if (event.getHook().getMetadata(MetadataConstants.FISH_HOOK_REF_METAKEY.getKey()).size() == 0) { fishingManager.setFishHookReference(event.getHook()); } @@ -443,12 +444,12 @@ public class PlayerListener implements Listener { Item drop = event.getItem(); //Remove tracking ItemStack dropStack = drop.getItemStack(); - if(drop.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY)) { - drop.removeMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, pluginRef); + if(drop.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey())) { + drop.removeMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } - if (drop.hasMetadata(MetadataConstants.DISARMED_ITEM_METAKEY)) { - if (!player.getName().equals(drop.getMetadata(MetadataConstants.DISARMED_ITEM_METAKEY).get(0).asString())) { + if (drop.hasMetadata(MetadataConstants.DISARMED_ITEM_METAKEY.getKey())) { + if (!player.getName().equals(drop.getMetadata(MetadataConstants.DISARMED_ITEM_METAKEY.getKey()).get(0).asString())) { event.setCancelled(true); } @@ -456,7 +457,7 @@ public class PlayerListener implements Listener { } - if (!drop.hasMetadata(MetadataConstants.DROPPED_ITEM_TRACKING_METAKEY) && mcMMOPlayer.inParty() && pluginRef.getItemTools().isSharable(dropStack)) { + if (!drop.hasMetadata(MetadataConstants.DROPPED_ITEM_TRACKING_METAKEY.getKey()) && mcMMOPlayer.inParty() && pluginRef.getItemTools().isSharable(dropStack)) { event.setCancelled(mcMMOPlayer.getParty().getShareHandler().handleItemShare(drop, mcMMOPlayer)); pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.POP); @@ -517,7 +518,11 @@ public class PlayerListener implements Listener { Player player = event.getPlayer(); //Delay loading for 3 seconds in case the player has a save task running, its hacky but it should do the trick - new PlayerProfileLoadingTask(pluginRef, player).runTaskLaterAsynchronously(pluginRef, 60); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setAsync(true) + .setDelay(60L) + .setTask(new PlayerProfileLoadingTask(pluginRef, player)) + .schedule(); if (pluginRef.getConfigManager().getConfigMOTD().isEnableMOTD()) { pluginRef.getMessageOfTheDayUtils().displayAll(player); @@ -528,7 +533,7 @@ public class PlayerListener implements Listener { } //TODO: Remove this warning after 2.2 is done - if (pluginRef.getDescription().getVersion().contains("SNAPSHOT")) { + if (pluginRef.getPlatformProvider().getVersion().contains("SNAPSHOT")) { event.getPlayer().sendMessage(ChatColor.RED + "WARNING: " + ChatColor.WHITE + "This dev build version of mcMMO is in the MIDDLE of completely rewriting the configs, there may be game breaking bugs. It is not recommended to play on this version of mcMMO, please grab the latest stable release from https://www.mcmmo.org and use that instead!"); } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/mcMMO.java b/mcmmo-core/src/main/java/com/gmail/nossr50/mcMMO.java index 04306004d..d4611a61d 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/mcMMO.java @@ -129,7 +129,7 @@ public class mcMMO implements McMMOApi { */ public void onEnable() { try { - platformProvider.getLogger().setFilter(new LogFilter(this)); + //platformProvider.getLogger().setFilter(new LogFilter(this)); //Init Permission Tools permissionTools = new PermissionTools(this); @@ -168,6 +168,7 @@ public class mcMMO implements McMMOApi { CompatibilityCheck.checkForOutdatedAPI(this, serverAPIOutdated, platformProvider.getServerType().getFriendlyName()); if (!platformProvider.isSupported(true)) { + org.bukkit.Bukkit.getLogger().info("WE DEAD"); return; } else { platformProvider.earlyInit(); @@ -177,9 +178,10 @@ public class mcMMO implements McMMOApi { formulaManager = new FormulaManager(this); - for (Player player : getServer().getOnlinePlayers()) { - new PlayerProfileLoadingTask(this, player).runTaskLaterAsynchronously(this, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading - } + // Don't do this for now + //for (Player player : getServer().getOnlinePlayers()) { + // new PlayerProfileLoadingTask(this, player).runTaskLaterAsynchronously(this, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + //} debug("Version " + getVersion() + " is enabled!"); @@ -227,9 +229,6 @@ public class mcMMO implements McMMOApi { //Init Chat Manager chatManager = new ChatManager(this); - //Init Mob Health Bar Manager - bukkitMobHealthBarManager = new BukkitMobHealthBarManager(this); - //Init Event Manager eventManager = new EventManager(this); @@ -277,6 +276,8 @@ public class mcMMO implements McMMOApi { platformProvider.onLoad(); worldGuardUtils = new WorldGuardUtils(this); //Init WGU + // TODO: 2.2 - MIGRATE + /* if(getServer().getPluginManager().getPlugin("WorldGuard") != null) { if(worldGuardUtils.isWorldGuardLoaded()) { @@ -286,6 +287,7 @@ public class mcMMO implements McMMOApi { worldGuardManager.registerFlags(); } } + */ } /** @@ -450,6 +452,10 @@ public class mcMMO implements McMMOApi { return configManager; } + public PlatformProvider getPlatformProvider() { + return platformProvider; + } + /** * The directory in which override locales are kept * @@ -566,35 +572,49 @@ public class mcMMO implements McMMOApi { } private void registerCustomRecipes() { - getServer().getScheduler().scheduleSyncDelayedTask(this, () -> { - if (configManager.getConfigItems().isChimaeraWingEnabled()) { - Recipe recipe = getChimaeraWingRecipe(); - - if(!getSkillTools().hasRecipeBeenRegistered(recipe)) - getServer().addRecipe(getChimaeraWingRecipe()); - } - }, 40); + getPlatformProvider().registerCustomRecipes(); } private void scheduleTasks() { // Periodic save timer (Saves every 10 minutes by default) long saveIntervalTicks = Math.max(1200, (getConfigManager().getConfigDatabase().getConfigSectionDatabaseGeneral().getSaveIntervalMinutes() * (20 * 60))); - new SaveTimerTask(this).runTaskTimer(this, saveIntervalTicks, saveIntervalTicks); + platformProvider.getScheduler().getTaskBuilder() + .setDelay(saveIntervalTicks) + .setRepeatTime(saveIntervalTicks) + .setTask(new SaveTimerTask(this)) + .schedule(); // Cleanup the backups folder - new CleanBackupFilesTask(this).runTaskAsynchronously(this); + platformProvider.getScheduler().getTaskBuilder() + .setAsync(true) + .setTask(new CleanBackupFilesTask(this)) + .schedule(); // Bleed timer (Runs every 0.5 seconds) bleedTimerTask = new BleedTimerTask(this); - bleedTimerTask.runTaskTimer(this, miscTools.TICK_CONVERSION_FACTOR, (miscTools.TICK_CONVERSION_FACTOR / 2)); + platformProvider.getScheduler().getTaskBuilder() + .setDelay(miscTools.TICK_CONVERSION_FACTOR) + .setRepeatTime((miscTools.TICK_CONVERSION_FACTOR /2)) + .setTask(bleedTimerTask) + .schedule(); // Old & Powerless User remover long purgeIntervalTicks = getConfigManager().getConfigDatabase().getConfigSectionCleaning().getPurgeInterval() * 60L * 60L * miscTools.TICK_CONVERSION_FACTOR; if (getDatabaseCleaningSettings().isOnlyPurgeAtStartup()) { - new UserPurgeTask(this).runTaskLaterAsynchronously(this, 2 * miscTools.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. + platformProvider.getScheduler().getTaskBuilder() + .setAsync(true) + .setDelay(2 * miscTools.TICK_CONVERSION_FACTOR) + .setTask(new UserPurgeTask(this)) + .schedule(); + } else if (purgeIntervalTicks > 0) { - new UserPurgeTask(this).runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks); + platformProvider.getScheduler().getTaskBuilder() + .setAsync(true) + .setDelay(purgeIntervalTicks) + .setRepeatTime(purgeIntervalTicks) + .setTask(new UserPurgeTask(this)) + .schedule(); } //Party System Stuff @@ -603,61 +623,44 @@ public class mcMMO implements McMMOApi { long kickIntervalTicks = getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval() * 60L * 60L * miscTools.TICK_CONVERSION_FACTOR; if (kickIntervalTicks == 0) { - new PartyAutoKickTask(this).runTaskLater(this, 2 * miscTools.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. + platformProvider.getScheduler().getTaskBuilder() + .setDelay(2 * miscTools.TICK_CONVERSION_FACTOR) + .setTask(new PartyAutoKickTask(this)) + .schedule(); } else if (kickIntervalTicks > 0) { - new PartyAutoKickTask(this).runTaskTimer(this, kickIntervalTicks, kickIntervalTicks); + platformProvider.getScheduler().getTaskBuilder() + .setDelay(kickIntervalTicks) + .setRepeatTime(kickIntervalTicks) + .setTask(new PartyAutoKickTask(this)) + .schedule(); } } // Update power level tag scoreboards - new PowerLevelUpdatingTask(this).runTaskTimer(this, 2 * miscTools.TICK_CONVERSION_FACTOR, 2 * miscTools.TICK_CONVERSION_FACTOR); + platformProvider.getScheduler().getTaskBuilder() + .setDelay(2 * miscTools.TICK_CONVERSION_FACTOR) + .setRepeatTime(2 * miscTools.TICK_CONVERSION_FACTOR) + .setTask(new PowerLevelUpdatingTask(this)) + .schedule(); // Clear the registered XP data so players can earn XP again if (getConfigManager().getConfigLeveling().getConfigLevelingDiminishedReturns().isDiminishedReturnsEnabled()) { - new ClearRegisteredXPGainTask(this).runTaskTimer(this, 60, 60); + platformProvider.getScheduler().getTaskBuilder() + .setDelay(60L) + .setRepeatTime(60L) + .setTask(new ClearRegisteredXPGainTask(this)) + .schedule(); } if (configManager.getConfigNotifications().getConfigNotificationGeneral().isPlayerTips()) { - new NotifySquelchReminderTask(this).runTaskTimer(this, 60, ((20 * 60) * 60)); + platformProvider.getScheduler().getTaskBuilder() + .setDelay(60L) + .setRepeatTime((20 * 60) * 60L) + .setTask(new NotifySquelchReminderTask(this)) + .schedule(); } } - //TODO: Add this stuff to DSM, this location is temporary - private ShapelessRecipe getChimaeraWingRecipe() { - Material ingredient = Material.matchMaterial(configManager.getConfigItems().getChimaeraWingRecipeMats()); - - if(ingredient == null) - ingredient = Material.FEATHER; - - int amount = configManager.getConfigItems().getChimaeraWingUseCost(); - - ShapelessRecipe chimaeraWing = new ShapelessRecipe(new NamespacedKey(this, "Chimaera"), getChimaeraWing()); - chimaeraWing.addIngredient(amount, ingredient); - return chimaeraWing; - } - - //TODO: Add this stuff to DSM, this location is temporary - public ItemStack getChimaeraWing() { - Material ingredient = Material.matchMaterial(configManager.getConfigItems().getChimaeraWingRecipeMats()); - - if(ingredient == null) - ingredient = Material.FEATHER; - - //TODO: Make it so Chimaera wing amounts made is customizeable - ItemStack itemStack = new ItemStack(ingredient, 1); - - ItemMeta itemMeta = itemStack.getItemMeta(); - itemMeta.setDisplayName(ChatColor.GOLD + localeManager.getString("Item.ChimaeraWing.Name")); - - List itemLore = new ArrayList<>(); - itemLore.add("mcMMO Item"); - itemLore.add(localeManager.getString("Item.ChimaeraWing.Lore")); - itemMeta.setLore(itemLore); - - itemStack.setItemMeta(itemMeta); - return itemStack; - } - public DynamicSettingsManager getDynamicSettingsManager() { return dynamicSettingsManager; } @@ -778,4 +781,13 @@ public class mcMMO implements McMMOApi { public ParticleEffectUtils getParticleEffectUtils() { return particleEffectUtils; } + + public File getDataFolder() { + return platformProvider.getDataFolder(); + } + + @Deprecated + public Object getChimaeraWing() { + return platformProvider.getChimaeraWing(); + } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/party/PartyManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/party/PartyManager.java index 2d6d6d17b..f5c9d05d6 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -10,6 +10,8 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.items.TeleportationWarmup; import com.gmail.nossr50.util.sounds.SoundType; + +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.YamlConfiguration; @@ -85,7 +87,10 @@ public final class PartyManager { if (warmup > 0) { teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Teleport.Commencing", warmup)); - new TeleportationWarmup(pluginRef, mcMMOPlayer, mcMMOTarget).runTaskLater(pluginRef, 20 * warmup); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(20 * warmup) + .setTask(new TeleportationWarmup(pluginRef, mcMMOPlayer, mcMMOTarget)) + .schedule(); } else { pluginRef.getEventManager().handlePartyTeleportEvent(teleportingPlayer, targetPlayer); } @@ -621,7 +626,7 @@ public final class PartyManager { * @param party The party */ public void setPartyLeader(UUID uuid, Party party) { - OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(uuid); + OfflinePlayer player = Bukkit.getServer().getOfflinePlayer(uuid); UUID leaderUniqueId = party.getLeader().getUniqueId(); for (Player member : party.getOnlineMembers()) { @@ -842,7 +847,7 @@ public final class PartyManager { */ public boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return !event.isCancelled(); } @@ -858,7 +863,7 @@ public final class PartyManager { */ public boolean handlePartyChangeAllianceEvent(Player player, String oldAllyName, String newAllyName, McMMOPartyAllianceChangeEvent.EventReason reason) { McMMOPartyAllianceChangeEvent event = new McMMOPartyAllianceChangeEvent(player, oldAllyName, newAllyName, reason); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return !event.isCancelled(); } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java index b156a5972..b7dc43815 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.runnables; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.mcMMO; import org.bukkit.entity.LivingEntity; +import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; public class MobHealthDisplayUpdaterTask extends BukkitRunnable { @@ -16,14 +17,14 @@ public class MobHealthDisplayUpdaterTask extends BukkitRunnable { @Override public void run() { - if (target.hasMetadata(MetadataConstants.CUSTOM_NAME_METAKEY)) { - target.setCustomName(target.getMetadata(MetadataConstants.CUSTOM_NAME_METAKEY).get(0).asString()); - target.removeMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, pluginRef); + if (target.hasMetadata(MetadataConstants.CUSTOM_NAME_METAKEY.getKey())) { + target.setCustomName(target.getMetadata(MetadataConstants.CUSTOM_NAME_METAKEY.getKey()).get(0).asString()); + target.removeMetadata(MetadataConstants.CUSTOM_NAME_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } - if (target.hasMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY)) { - target.setCustomNameVisible(target.getMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY).get(0).asBoolean()); - target.removeMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, pluginRef); + if (target.hasMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY.getKey())) { + target.setCustomNameVisible(target.getMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY.getKey()).get(0).asBoolean()); + target.removeMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java index 05567b97e..03f6d0140 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.mcMMO; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; import java.util.List; @@ -35,9 +36,9 @@ public class PistonTrackerTask extends BukkitRunnable { for (Block b : blocks) { Block nextBlock = b.getRelative(direction); - if (nextBlock.hasMetadata(MetadataConstants.PISTON_TRACKING_METAKEY)) { + if (nextBlock.hasMetadata(MetadataConstants.PISTON_TRACKING_METAKEY.getKey())) { pluginRef.getPlaceStore().setTrue(nextBlock); - nextBlock.removeMetadata(MetadataConstants.PISTON_TRACKING_METAKEY, pluginRef); + nextBlock.removeMetadata(MetadataConstants.PISTON_TRACKING_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } else if (pluginRef.getPlaceStore().isTrue(nextBlock)) { // Block doesn't have metadatakey but isTrue - set it to false pluginRef.getPlaceStore().setFalse(nextBlock); diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java index 95abcc9d2..aaccd63f3 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java @@ -5,7 +5,7 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask; import org.bukkit.scheduler.BukkitRunnable; -public class SaveTimerTask extends BukkitRunnable { +public class SaveTimerTask implements Runnable { private final mcMMO pluginRef; @@ -19,7 +19,7 @@ public class SaveTimerTask extends BukkitRunnable { int count = 1; for (BukkitMMOPlayer mcMMOPlayer : pluginRef.getUserManager().getPlayers()) { - new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(pluginRef, count); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder().setAsync(true).setDelay((long) count).setTask(new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false)).schedule(); count++; } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/LeaderboardsCommandAsyncTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/LeaderboardsCommandAsyncTask.java index 06827b91f..de5021379 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/LeaderboardsCommandAsyncTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/LeaderboardsCommandAsyncTask.java @@ -38,6 +38,9 @@ public class LeaderboardsCommandAsyncTask extends BukkitRunnable { public void run() { final List userStats = pluginRef.getDatabaseManager().readLeaderboard(skill, page, 10); - new LeaderboardsCommandDisplayTask(pluginRef, userStats, page, skill, sender, useBoard, useChat).runTaskLater(pluginRef, 1); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(1L) + .setTask(new LeaderboardsCommandDisplayTask(pluginRef, userStats, page, skill, sender, useBoard, useChat)) + .schedule(); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/LeaderboardsCommandDisplayTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/LeaderboardsCommandDisplayTask.java index 0b7346cce..01da87f5e 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/LeaderboardsCommandDisplayTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/LeaderboardsCommandDisplayTask.java @@ -7,6 +7,7 @@ import com.gmail.nossr50.mcMMO; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; import java.util.List; @@ -43,7 +44,7 @@ public class LeaderboardsCommandDisplayTask extends BukkitRunnable { } if (sender instanceof Player) { - ((Player) sender).removeMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, pluginRef); + ((Player) sender).removeMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } if (sender instanceof Player) sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mctop.Tip")); diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/RankCommandAsyncTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/RankCommandAsyncTask.java index 3a5814b31..ec18409f6 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/RankCommandAsyncTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/RankCommandAsyncTask.java @@ -34,7 +34,10 @@ public class RankCommandAsyncTask extends BukkitRunnable { public void run() { Map skills = pluginRef.getDatabaseManager().readRank(playerName); - new RankCommandDisplayTask(pluginRef, skills, sender, playerName, useBoard, useChat).runTaskLater(pluginRef, 1); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(1L) + .setTask(new RankCommandDisplayTask(pluginRef, skills, sender, playerName, useBoard, useChat)) + .schedule(); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/RankCommandDisplayTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/RankCommandDisplayTask.java index 988aaa903..0aac2c39c 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/RankCommandDisplayTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/commands/RankCommandDisplayTask.java @@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; import java.util.Map; @@ -37,7 +38,7 @@ public class RankCommandDisplayTask extends BukkitRunnable { if (useChat) { displayChat(); } - ((Player) sender).removeMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, pluginRef); + ((Player) sender).removeMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } private void displayChat() { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java index ed0bdf62f..28137c945 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java @@ -2,10 +2,14 @@ package com.gmail.nossr50.runnables.database; import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcmmo.api.platform.scheduler.Task; + import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitRunnable; -public class DatabaseConversionTask extends BukkitRunnable { +import java.util.function.Consumer; + +public class DatabaseConversionTask implements Consumer { private final mcMMO pluginRef; private final DatabaseManager sourceDatabase; private final CommandSender sender; @@ -19,9 +23,8 @@ public class DatabaseConversionTask extends BukkitRunnable { } @Override - public void run() { + public void accept(Task task) { sourceDatabase.convertUsers(pluginRef.getDatabaseManager()); - - pluginRef.getServer().getScheduler().runTask(pluginRef, () -> sender.sendMessage(message)); + sender.sendMessage(message); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java index b7212e1e7..4146fa811 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java @@ -27,7 +27,7 @@ public class ChimaeraWingWarmup extends BukkitRunnable { Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation(); ChimaeraWing chimaeraWing = new ChimaeraWing(pluginRef, mcMMOPlayer); - if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(pluginRef.getChimaeraWing(), 1)) { + if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast((ItemStack) pluginRef.getChimaeraWing(), 1)) { player.sendMessage(pluginRef.getLocaleManager().getString("Teleport.Cancelled")); mcMMOPlayer.setTeleportCommenceLocation(null); return; diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java index 510a62e64..0f7a2ec6f 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java @@ -2,6 +2,9 @@ package com.gmail.nossr50.runnables.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcmmo.api.platform.scheduler.Task; + +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.scheduler.BukkitRunnable; @@ -10,8 +13,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import java.util.UUID; +import java.util.function.Consumer; -public class PartyAutoKickTask extends BukkitRunnable { +public class PartyAutoKickTask implements Consumer { private final mcMMO pluginRef; private final long KICK_TIME; @@ -21,7 +25,7 @@ public class PartyAutoKickTask extends BukkitRunnable { } @Override - public void run() { + public void accept(Task task) { HashMap toRemove = new HashMap<>(); List processedPlayers = new ArrayList<>(); @@ -29,7 +33,7 @@ public class PartyAutoKickTask extends BukkitRunnable { for (Party party : pluginRef.getPartyManager().getParties()) { for (UUID memberUniqueId : party.getMembers().keySet()) { - OfflinePlayer member = pluginRef.getServer().getOfflinePlayer(memberUniqueId); + OfflinePlayer member = Bukkit.getServer().getOfflinePlayer(memberUniqueId); boolean isProcessed = processedPlayers.contains(memberUniqueId); if ((!member.isOnline() && (currentTime - member.getLastPlayed() > KICK_TIME)) || isProcessed) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java index 75ccbb2e0..236537e7b 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java @@ -4,6 +4,8 @@ import com.gmail.nossr50.datatypes.player.BukkitMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.commands.ScoreboardKeepTask; + +import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -42,7 +44,9 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true); // If successful, schedule the apply if (profile.isLoaded()) { - new ApplySuccessfulProfile(new BukkitMMOPlayer(player, profile, pluginRef)).runTask(pluginRef); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setTask(new ApplySuccessfulProfile(new BukkitMMOPlayer(player, profile, pluginRef))) + .schedule(); pluginRef.getEventManager().callPlayerProfileLoadEvent(player, profile); return; } @@ -54,7 +58,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { player.getName(), String.valueOf(attempt))); //Notify the admins - pluginRef.getServer().broadcast(pluginRef.getLocaleManager().getString("Profile.Loading.FailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE); + Bukkit.getServer().broadcast(pluginRef.getLocaleManager().getString("Profile.Loading.FailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE); //Notify the player player.sendMessage(pluginRef.getLocaleManager().getString("Profile.Loading.FailurePlayer", String.valueOf(attempt)).split("\n")); @@ -62,8 +66,11 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { // Increment attempt counter and try attempt++; - - new PlayerProfileLoadingTask(pluginRef, player, attempt).runTaskLaterAsynchronously(pluginRef, (100 + (attempt * 100))); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setAsync(true) + .setDelay((long) (100 + (attempt * 100))) + .setTask(new PlayerProfileLoadingTask(pluginRef, player, attempt)) + .schedule(); } private class ApplySuccessfulProfile extends BukkitRunnable { @@ -91,7 +98,10 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { if (pluginRef.getScoreboardSettings().getShowStatsAfterLogin()) { pluginRef.getScoreboardManager().enablePlayerStatsScoreboard(player); - new ScoreboardKeepTask(pluginRef, player).runTaskLater(pluginRef, pluginRef.getMiscTools().TICK_CONVERSION_FACTOR); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(pluginRef.getMiscTools().TICK_CONVERSION_FACTOR) + .setTask(new ScoreboardKeepTask(pluginRef, player)) + .schedule(); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java index 83d9b9466..5293d945b 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java @@ -56,9 +56,11 @@ public class AbilityDisableTask extends BukkitRunnable { pluginRef.getSkillTools().sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, pluginRef.getSkillTools().getSuperAbilityOtherPlayerDeactivationLocaleKey(superAbilityType)); - new AbilityCooldownTask(pluginRef, mcMMOPlayer, superAbilityType).runTaskLater(pluginRef, - pluginRef.getPerkUtils().handleCooldownPerks(player, - pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType) * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR)); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(pluginRef.getPerkUtils().handleCooldownPerks(player, (pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType) * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR))) + .setTask(new AbilityCooldownTask(pluginRef, mcMMOPlayer, superAbilityType)) + .schedule(); + } private void resendChunkRadiusAt(Player player) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index 12ad2ec13..f2b8ef1c9 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -136,7 +136,7 @@ public class BleedTimerTask extends BukkitRunnable { // debugMessage+="Rank4Bonus=["+String.valueOf(containerEntry.getValue().bleedRank >= 3)+"], "; - pluginRef.getMobHealthBarManager().handleMobHealthbars(target, damage, pluginRef); //Update health bars + pluginRef.getPlatformProvider().getHealthBarManager().handleMobHealthbars(pluginRef.getPlatformProvider().getEntity(target.getUniqueId()), damage); //Update health bars } // debugMessage+="FullArmor=["+String.valueOf(armorCount > 3)+"], "; diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java index 373fd12ee..b2dcc1478 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java @@ -12,6 +12,7 @@ import org.bukkit.block.data.Ageable; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Directional; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; public class DelayedCropReplant extends BukkitRunnable { @@ -52,7 +53,10 @@ public class DelayedCropReplant extends BukkitRunnable { BlockState currentState = cropBlock.getState(); //Remove the metadata marking the block as recently replanted - new markPlantAsOld(blockBreakEvent.getBlock().getLocation()).runTaskLater(pluginRef, 10); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(10L) + .setTask(new markPlantAsOld(blockBreakEvent.getBlock().getLocation())) + .schedule(); if(blockBreakEvent.isCancelled()) { wasImmaturePlant = true; @@ -112,8 +116,8 @@ public class DelayedCropReplant extends BukkitRunnable { public void run() { Block cropBlock = cropLoc.getBlock(); - if(cropBlock.getMetadata(MetadataConstants.REPLANT_META_KEY).size() > 0) { - cropBlock.setMetadata(MetadataConstants.REPLANT_META_KEY, new RecentlyReplantedCropMeta(pluginRef, false)); + if(cropBlock.getMetadata(MetadataConstants.REPLANT_META_KEY.getKey()).size() > 0) { + cropBlock.setMetadata(MetadataConstants.REPLANT_META_KEY.getKey(), new RecentlyReplantedCropMeta((Plugin) pluginRef.getPlatformProvider(), false)); pluginRef.getParticleEffectUtils().playFluxEffect(cropLocation); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 98c9e045d..37beab31e 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -16,6 +16,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; +import org.bukkit.plugin.Plugin; public class AcrobaticsManager extends SkillManager { @@ -95,18 +96,18 @@ public class AcrobaticsManager extends SkillManager { if (pluginRef.getSkillTools().cooldownExpired(mcMMOPlayer.getRespawnATS(), pluginRef.getMiscTools().PLAYER_RESPAWN_COOLDOWN_SECONDS)) { if(!(attacker instanceof Player)) { //Check to see how many dodge XP rewards this mob has handed out - if(attacker.hasMetadata(MetadataConstants.DODGE_TRACKER) && pluginRef.getConfigManager().getConfigExploitPrevention().isPreventAcrobaticsAbuse()) { + if(attacker.hasMetadata(MetadataConstants.DODGE_TRACKER.getKey()) && pluginRef.getConfigManager().getConfigExploitPrevention().isPreventAcrobaticsAbuse()) { //If Dodge XP has been handed out 5 times then consider it being exploited - MetadataValue metadataValue = attacker.getMetadata(MetadataConstants.DODGE_TRACKER).get(0); - int count = attacker.getMetadata(MetadataConstants.DODGE_TRACKER).get(0).asInt(); + MetadataValue metadataValue = attacker.getMetadata(MetadataConstants.DODGE_TRACKER.getKey()).get(0); + int count = attacker.getMetadata(MetadataConstants.DODGE_TRACKER.getKey()).get(0).asInt(); if(count <= 5) { applyXpGain((float) (damage * acrobaticsBehaviour.getDodgeXpModifier()), XPGainReason.PVE); - attacker.setMetadata(MetadataConstants.DODGE_TRACKER, new FixedMetadataValue(pluginRef, count + 1)); + attacker.setMetadata(MetadataConstants.DODGE_TRACKER.getKey(), new FixedMetadataValue((Plugin) pluginRef.getPlatformProvider(), count + 1)); } } else { applyXpGain((float) (damage * acrobaticsBehaviour.getDodgeXpModifier()), XPGainReason.PVE); - attacker.setMetadata(MetadataConstants.DODGE_TRACKER, new FixedMetadataValue(pluginRef, 1)); + attacker.setMetadata(MetadataConstants.DODGE_TRACKER.getKey(), new FixedMetadataValue((Plugin) pluginRef.getPlatformProvider(), 1)); } } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 10f2a5a05..48c54d034 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -14,6 +14,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; +import org.bukkit.plugin.Plugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -57,10 +58,10 @@ public class ArcheryManager extends SkillManager { */ public double distanceXpBonusMultiplier(LivingEntity target, Entity damager) { //Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires - if(!damager.hasMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY)) + if(!damager.hasMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY.getKey())) return damager.getLocation().distance(target.getLocation()); - Location firedLocation = (Location) damager.getMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY).get(0).value(); + Location firedLocation = (Location) damager.getMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY.getKey()).get(0).value(); Location targetLocation = target.getLocation(); if (firedLocation.getWorld() != targetLocation.getWorld()) { @@ -76,9 +77,9 @@ public class ArcheryManager extends SkillManager { * @param target The {@link LivingEntity} damaged by the arrow */ public void processArrowRetrievalActivation(LivingEntity target, Projectile projectile) { - if(projectile.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY)) { + if(projectile.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey())) { archeryBehaviour.incrementArrowCount(target); - projectile.removeMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, pluginRef); //Only 1 entity per projectile + projectile.removeMetadata(MetadataConstants.ARROW_TRACKER_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); //Only 1 entity per projectile } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index bf52abcd3..1cf6fa0a6 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -76,10 +76,10 @@ public class FishingManager extends SkillManager { } public void setFishHookReference(FishHook fishHook) { - if (fishHook.getMetadata(MetadataConstants.FISH_HOOK_REF_METAKEY).size() > 0) + if (fishHook.getMetadata(MetadataConstants.FISH_HOOK_REF_METAKEY.getKey()).size() > 0) return; - fishHook.setMetadata(MetadataConstants.FISH_HOOK_REF_METAKEY, MetadataConstants.metadataValue); + fishHook.setMetadata(MetadataConstants.FISH_HOOK_REF_METAKEY.getKey(), MetadataConstants.metadataValue); fishHookSpawnTimestamp = System.currentTimeMillis(); fishingRodCastTimestamp = System.currentTimeMillis(); } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 0d903a210..dd98f6b10 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -29,6 +29,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.plugin.Plugin; import java.util.ArrayList; import java.util.Collection; @@ -139,10 +140,10 @@ public class HerbalismManager extends SkillManager { if(blockBreakEvent.getBlock().getBlockData() instanceof Ageable) { Ageable ageableCrop = (Ageable) blockBreakEvent.getBlock().getBlockData(); - if(blockBreakEvent.getBlock().getMetadata(MetadataConstants.REPLANT_META_KEY).size() >= 1) { - if(blockBreakEvent.getBlock().getMetadata(MetadataConstants.REPLANT_META_KEY).get(0).asBoolean()) { + if(blockBreakEvent.getBlock().getMetadata(MetadataConstants.REPLANT_META_KEY.getKey()).size() >= 1) { + if(blockBreakEvent.getBlock().getMetadata(MetadataConstants.REPLANT_META_KEY.getKey()).get(0).asBoolean()) { if(isAgeableMature(ageableCrop)) { - blockBreakEvent.getBlock().removeMetadata(MetadataConstants.REPLANT_META_KEY, pluginRef); + blockBreakEvent.getBlock().removeMetadata(MetadataConstants.REPLANT_META_KEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } else { //Crop is recently replanted to back out of destroying it blockBreakEvent.setCancelled(true); @@ -239,10 +240,10 @@ public class HerbalismManager extends SkillManager { if(delayedChorusBlocks.size() > 0) { //Check XP for chorus blocks - DelayedHerbalismXPCheckTask delayedHerbalismXPCheckTask = new DelayedHerbalismXPCheckTask(mcMMOPlayer, delayedChorusBlocks); - - //Large delay because the tree takes a while to break - delayedHerbalismXPCheckTask.runTaskLater(pluginRef, 20); //Calculate Chorus XP + Bonus Drops 1 tick later + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(20L) //Large delay because the tree takes a while to break + .setTask(new DelayedHerbalismXPCheckTask(mcMMOPlayer, delayedChorusBlocks)) + .schedule(); } } @@ -416,8 +417,8 @@ public class HerbalismManager extends SkillManager { BlockState brokenBlockNewState = blockSnapshot.getBlockRef().getState(); //Remove metadata from the snapshot of blocks - if(brokenBlockNewState.hasMetadata(MetadataConstants.BONUS_DROPS_METAKEY)) { - brokenBlockNewState.removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY, pluginRef); + if(brokenBlockNewState.hasMetadata(MetadataConstants.BONUS_DROPS_METAKEY.getKey())) { + brokenBlockNewState.removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); } //If the block is not AIR that means it wasn't broken @@ -676,8 +677,11 @@ public class HerbalismManager extends SkillManager { */ private void startReplantTask(int desiredCropAge, BlockBreakEvent blockBreakEvent, BlockState cropState, boolean isImmature) { //Mark the plant as recently replanted to avoid accidental breakage - new DelayedCropReplant(pluginRef, blockBreakEvent, cropState, desiredCropAge, isImmature).runTaskLater(pluginRef, 20 * 2); - blockBreakEvent.getBlock().setMetadata(MetadataConstants.REPLANT_META_KEY, new RecentlyReplantedCropMeta(pluginRef, true)); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(20 * 2L) + .setTask(new DelayedCropReplant(pluginRef, blockBreakEvent, cropState, desiredCropAge, isImmature)) + .schedule(); + blockBreakEvent.getBlock().setMetadata(MetadataConstants.REPLANT_META_KEY.getKey(), new RecentlyReplantedCropMeta((Plugin) pluginRef.getPlatformProvider(), true)); } /** diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index e26e57756..48746588c 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -124,15 +124,16 @@ public class MiningManager extends SkillManager { pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "miningBehaviour.Blast.Boom"); //player.sendMessage(pluginRef.getLocaleManager().getString("miningBehaviour.Blast.Boom")); - tnt.setMetadata(MetadataConstants.TNT_TRACKING_METAKEY, mcMMOPlayer.getPlayerMetadata()); + tnt.setMetadata(MetadataConstants.TNT_TRACKING_METAKEY.getKey(), mcMMOPlayer.getPlayerMetadata()); tnt.setFuseTicks(0); targetBlock.setType(Material.AIR); mcMMOPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis()); mcMMOPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false); - new AbilityCooldownTask(pluginRef, mcMMOPlayer, SuperAbilityType.BLAST_MINING) - .runTaskLater(pluginRef, pluginRef.getSkillTools().getSuperAbilityCooldown(SuperAbilityType.BLAST_MINING) - * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay( pluginRef.getSkillTools().getSuperAbilityCooldown(SuperAbilityType.BLAST_MINING) * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR) + .setTask(new AbilityCooldownTask(pluginRef, mcMMOPlayer, SuperAbilityType.BLAST_MINING)) + .schedule(); } /** diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index 8f0a1b0c3..fa620e3bb 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -417,10 +417,10 @@ public class TamingManager extends SkillManager { private void applyMetaDataToCOTWEntity(LivingEntity callOfWildEntity) { //This is used to prevent XP gains for damaging this entity - callOfWildEntity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); + callOfWildEntity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey(), MetadataConstants.metadataValue); //This helps identify the entity as being summoned by COTW - callOfWildEntity.setMetadata(MetadataConstants.COTW_TEMPORARY_SUMMON, MetadataConstants.metadataValue); + callOfWildEntity.setMetadata(MetadataConstants.COTW_TEMPORARY_SUMMON.getKey(), MetadataConstants.metadataValue); } /** diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java index d440d1917..832c718bf 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java @@ -2,6 +2,8 @@ package com.gmail.nossr50.skills.taming; import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcmmo.api.platform.scheduler.Task; + import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; @@ -9,12 +11,12 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.scheduler.BukkitRunnable; import java.util.UUID; +import java.util.function.Consumer; -public class TrackedTamingEntity extends BukkitRunnable { +public class TrackedTamingEntity implements Consumer { private LivingEntity livingEntity; private final CallOfTheWildType callOfTheWildType; private UUID id; - private int length; private final TamingManager tamingManagerRef; private final mcMMO pluginRef; @@ -28,13 +30,15 @@ public class TrackedTamingEntity extends BukkitRunnable { int tamingCOTWLength = pluginRef.getConfigManager().getConfigTaming().getSubSkills().getCallOfTheWild().getCOTWSummon(callOfTheWildType).getSummonLifespan(); if (tamingCOTWLength > 0) { - this.length = tamingCOTWLength * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR; - this.runTaskLater(pluginRef, length); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(tamingCOTWLength * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR) + .setTask(this) + .schedule(); } } @Override - public void run() { + public void accept(Task task) { if (livingEntity.isValid()) { Location location = livingEntity.getLocation(); location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F); @@ -48,7 +52,7 @@ public class TrackedTamingEntity extends BukkitRunnable { livingEntity.remove(); } - this.cancel(); + task.cancel(); } public CallOfTheWildType getCallOfTheWildType() { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index b1a58fa54..c88979f81 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -110,7 +110,7 @@ public class UnarmedManager extends SkillManager { Item item = pluginRef.getMiscTools().dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand()); if (item != null && pluginRef.getConfigManager().getConfigUnarmed().doesDisarmPreventTheft()) { - item.setMetadata(MetadataConstants.DISARMED_ITEM_METAKEY, pluginRef.getUserManager().getPlayer(defender).getPlayerMetadata()); + item.setMetadata(MetadataConstants.DISARMED_ITEM_METAKEY.getKey(), pluginRef.getUserManager().getPlayer(defender).getPlayerMetadata()); } defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/BlockTools.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/BlockTools.java index ffa71b655..cddde5d40 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/BlockTools.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/BlockTools.java @@ -30,9 +30,9 @@ public final class BlockTools { */ public void markDropsAsBonus(BlockState blockState, boolean triple) { if (triple) - blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(2, pluginRef)); + blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY.getKey(), new BonusDropMeta(2, pluginRef)); else - blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(1, pluginRef)); + blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY.getKey(), new BonusDropMeta(1, pluginRef)); } /** @@ -42,7 +42,7 @@ public final class BlockTools { * @param amount amount of extra items to drop */ public void markDropsAsBonus(BlockState blockState, int amount) { - blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(amount, pluginRef)); + blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY.getKey(), new BonusDropMeta(amount, pluginRef)); } /** diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index d46176cf9..1f0d24410 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -94,7 +94,10 @@ public final class ChimaeraWing { if (warmup > 0) { pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Teleport.Commencing", String.valueOf(warmup)); - new ChimaeraWingWarmup(pluginRef, mcMMOPlayer).runTaskLater(pluginRef, 20 * warmup); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(20 * warmup) + .setTask(new ChimaeraWingWarmup(pluginRef, mcMMOPlayer)) + .schedule(); } else { chimaeraExecuteTeleport(); } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/EventManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/EventManager.java index a6a02213d..48e0f28c3 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/EventManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/EventManager.java @@ -165,14 +165,14 @@ public class EventManager { public McMMOPlayerAbilityActivateEvent callPlayerAbilityActivateEvent(Player player, PrimarySkillType primarySkillType, SuperAbilityType superAbilityType) { McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, primarySkillType, superAbilityType); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return event; } public McMMOPlayerProfileLoadEvent callPlayerProfileLoadEvent(Player player, PlayerProfile profile){ McMMOPlayerProfileLoadEvent event = new McMMOPlayerProfileLoadEvent(player, profile); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return event; } @@ -187,7 +187,7 @@ public class EventManager { @Deprecated public SubSkillEvent callSubSkillEvent(Player player, SubSkillType subSkillType, PrimarySkillType primarySkillType) { SubSkillEvent event = new SubSkillEvent(player, subSkillType, primarySkillType); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return event; } @@ -201,20 +201,20 @@ public class EventManager { */ public SubSkillEvent callSubSkillEvent(Player player, AbstractSubSkill abstractSubSkill) { SubSkillEvent event = new SubSkillEvent(player, abstractSubSkill); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return event; } public void callFakeArmSwingEvent(Player player) { FakePlayerAnimationEvent event = new FakePlayerAnimationEvent(player); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); } public boolean tryLevelChangeEvent(Player player, PrimarySkillType skill, int levelsChanged, double xpRemoved, boolean isLevelUp, XPGainReason xpGainReason) { McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -230,7 +230,7 @@ public class EventManager { public boolean tryLevelEditEvent(Player player, PrimarySkillType skill, int levelsChanged, double xpRemoved, boolean isLevelUp, XPGainReason xpGainReason, int oldLevel) { McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged - oldLevel, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -253,7 +253,7 @@ public class EventManager { * @return true if the event wasn't cancelled, false otherwise */ public boolean simulateBlockBreak(Block block, Player player, boolean shouldArmSwing) { - PluginManager pluginManager = pluginRef.getServer().getPluginManager(); + PluginManager pluginManager = Bukkit.getServer().getPluginManager(); // Support for NoCheat if (shouldArmSwing) { @@ -276,7 +276,7 @@ public class EventManager { return; McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName()); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; @@ -292,7 +292,7 @@ public class EventManager { public boolean handlePartyXpGainEvent(Party party, double xpGained) { McMMOPartyXpGainEvent event = new McMMOPartyXpGainEvent(party, xpGained); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -305,7 +305,7 @@ public class EventManager { public boolean handlePartyLevelChangeEvent(Party party, int levelsChanged, double xpRemoved) { McMMOPartyLevelUpEvent event = new McMMOPartyLevelUpEvent(party, levelsChanged); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -320,7 +320,7 @@ public class EventManager { public boolean handleXpGainEvent(Player player, PrimarySkillType skill, double xpGained, XPGainReason xpGainReason) { McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skill, getSkillLevel(player, skill), xpGained, xpGainReason); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -337,7 +337,7 @@ public class EventManager { return true; McMMOPlayerStatLossEvent event = new McMMOPlayerStatLossEvent(player, levelChanged, experienceChanged); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -369,8 +369,8 @@ public class EventManager { public boolean handleVampirismEvent(Player killer, Player victim, HashMap levelChanged, HashMap experienceChanged) { McMMOPlayerVampirismEvent eventKiller = new McMMOPlayerVampirismEvent(killer, false, levelChanged, experienceChanged); McMMOPlayerVampirismEvent eventVictim = new McMMOPlayerVampirismEvent(victim, true, levelChanged, experienceChanged); - pluginRef.getServer().getPluginManager().callEvent(eventKiller); - pluginRef.getServer().getPluginManager().callEvent(eventVictim); + Bukkit.getServer().getPluginManager().callEvent(eventKiller); + Bukkit.getServer().getPluginManager().callEvent(eventVictim); boolean isCancelled = eventKiller.isCancelled() || eventVictim.isCancelled(); @@ -418,47 +418,47 @@ public class EventManager { public void callAbilityDeactivateEvent(Player player, SuperAbilityType superAbilityType) { McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, pluginRef.getSkillTools().getPrimarySkillBySuperAbility(superAbilityType), superAbilityType); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); } public McMMOPlayerFishingTreasureEvent callFishingTreasureEvent(Player player, ItemStack treasureDrop, int treasureXp, Map enchants) { McMMOPlayerFishingTreasureEvent event = enchants.isEmpty() ? new McMMOPlayerFishingTreasureEvent(player, treasureDrop, treasureXp) : new McMMOPlayerMagicHunterEvent(player, treasureDrop, treasureXp, enchants); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return event; } public void callFakeFishEvent(Player player, FishHook hook) { FakePlayerFishEvent event = new FakePlayerFishEvent(player, null, hook, PlayerFishEvent.State.FISHING); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); } public McMMOPlayerRepairCheckEvent callRepairCheckEvent(Player player, short durability, ItemStack repairMaterial, ItemStack repairedObject) { McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, durability, repairMaterial, repairedObject); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return event; } public McMMOPlayerPreDeathPenaltyEvent callPreDeathPenaltyEvent(Player player) { McMMOPlayerPreDeathPenaltyEvent event = new McMMOPlayerPreDeathPenaltyEvent(player); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return event; } public McMMOPlayerDisarmEvent callDisarmEvent(Player defender) { McMMOPlayerDisarmEvent event = new McMMOPlayerDisarmEvent(defender); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return event; } public McMMOPlayerSalvageCheckEvent callSalvageCheckEvent(Player player, ItemStack salvageMaterial, ItemStack salvageResults, ItemStack enchantedBook) { McMMOPlayerSalvageCheckEvent event = new McMMOPlayerSalvageCheckEvent(player, salvageMaterial, salvageResults, enchantedBook); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); return event; } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/ItemTools.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/ItemTools.java index 64398857e..f57bb39c4 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/ItemTools.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/ItemTools.java @@ -3,6 +3,8 @@ package com.gmail.nossr50.util; import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory; import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.mcMMO; + +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -636,7 +638,7 @@ public final class ItemTools { return false; } - for (Recipe recipe : pluginRef.getServer().getRecipesFor(item)) { + for (Recipe recipe : Bukkit.getServer().getRecipesFor(item)) { if (recipe instanceof FurnaceRecipe && ((FurnaceRecipe) recipe).getInput().getType().isBlock() && MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getType())) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/LogFilter.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/LogFilter.java deleted file mode 100644 index fde20cd1e..000000000 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/LogFilter.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.gmail.nossr50.util; - -import com.gmail.nossr50.mcMMO; - -import java.util.logging.Filter; -import java.util.logging.LogRecord; - -public class LogFilter implements Filter { - private boolean debug; - - public LogFilter(mcMMO plugin) { - // Doing a config loading lite here, because we can't depend on the config loader to have loaded before any debug messages are sent - debug = plugin.getConfig().getBoolean("General.Verbose_Logging"); - } - - @Override - public boolean isLoggable(LogRecord record) { - return !(record.getMessage().contains("[Debug]") && !debug); - } -} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/MessageOfTheDayUtils.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/MessageOfTheDayUtils.java index 6f020f813..b5668b3ed 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/MessageOfTheDayUtils.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/MessageOfTheDayUtils.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.util; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import java.text.DecimalFormat; @@ -15,7 +16,7 @@ public final class MessageOfTheDayUtils { public MessageOfTheDayUtils(mcMMO pluginRef) { this.pluginRef = pluginRef; PERK_PREFIX = pluginRef.getLocaleManager().getString("MOTD.PerksPrefix") + " "; - pluginDescription = pluginRef.getDescription(); + pluginDescription = ((Plugin) pluginRef.getPlatformProvider()).getDescription(); } public void displayAll(Player player) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/MiscTools.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/MiscTools.java index 564379715..ca097d747 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/MiscTools.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/MiscTools.java @@ -4,6 +4,8 @@ import com.gmail.nossr50.events.items.McMMOItemSpawnEvent; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.google.common.collect.ImmutableSet; + +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.BlockState; @@ -18,7 +20,7 @@ import java.util.Set; public final class MiscTools { public final int TIME_CONVERSION_FACTOR = 1000; - public final int TICK_CONVERSION_FACTOR = 20; + public final long TICK_CONVERSION_FACTOR = 20; public final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5; public final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0; public final Set modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION"); @@ -124,7 +126,7 @@ public final class MiscTools { // We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event. McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return null; @@ -169,7 +171,7 @@ public final class MiscTools { // We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event. McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(spawnLocation, clonedItem); - pluginRef.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event); //Something cancelled the event so back out if (event.isCancelled() || event.getItemStack() == null) { @@ -191,11 +193,14 @@ public final class MiscTools { } public void profileCleanup(String playerName) { - Player player = pluginRef.getServer().getPlayerExact(playerName); + Player player = Bukkit.getServer().getPlayerExact(playerName); if (player != null) { pluginRef.getUserManager().remove(player); - new PlayerProfileLoadingTask(pluginRef, player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(1L) // 1 Tick delay to ensure the player is marked as online before we begin loading + .setTask(new PlayerProfileLoadingTask(pluginRef, player)) + .schedule(); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/PermissionTools.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/PermissionTools.java index 784291b93..2373fa61d 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/PermissionTools.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/PermissionTools.java @@ -8,6 +8,8 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.mcMMO; + +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.World; @@ -512,7 +514,7 @@ public final class PermissionTools { } public void generateWorldTeleportPermissions() { - Server server = pluginRef.getServer(); + Server server = Bukkit.getServer(); PluginManager pluginManager = server.getPluginManager(); for (World world : server.getWorlds()) { @@ -526,7 +528,7 @@ public final class PermissionTools { */ public void addCustomXPPerks() { pluginRef.getLogger().info("Registering custom XP perks with server software..."); - PluginManager pluginManager = pluginRef.getServer().getPluginManager(); + PluginManager pluginManager = Bukkit.getServer().getPluginManager(); for (CustomXPPerk customXPPerk : pluginRef.getConfigManager().getConfigExperience().getCustomXPBoosts()) { Permission permission = new Permission(customXPPerk.getPerkPermissionAddress()); diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java index c090f93fa..2f3043814 100755 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -1,6 +1,8 @@ package com.gmail.nossr50.util.blockmeta; import com.gmail.nossr50.mcMMO; + +import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.block.Block; @@ -165,7 +167,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void saveAll() { - for (World world : pluginRef.getServer().getWorlds()) { + for (World world : Bukkit.getServer().getWorlds()) { saveWorld(world); } } @@ -173,7 +175,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void unloadAll() { saveAll(); - for (World world : pluginRef.getServer().getWorlds()) { + for (World world : Bukkit.getServer().getWorlds()) { unloadWorld(world); } } @@ -274,7 +276,7 @@ public class HashChunkletManager implements ChunkletManager { for (String key : store.keySet()) { if (store.get(key).isEmpty()) { String[] info = key.split(","); - File dataDir = new File(pluginRef.getServer().getWorld(info[0]).getWorldFolder(), "mcmmo_data"); + File dataDir = new File(Bukkit.getServer().getWorld(info[0]).getWorldFolder(), "mcmmo_data"); File cxDir = new File(dataDir, "" + info[1]); if (!cxDir.exists()) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index 344b417c8..ca3a8d2b1 100755 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -2,6 +2,8 @@ package com.gmail.nossr50.util.blockmeta.chunkmeta; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory; + +import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -255,7 +257,7 @@ public class HashChunkManager implements ChunkManager { public synchronized void saveAll() { closeAll(); - for (World world : pluginRef.getServer().getWorlds()) { + for (World world : Bukkit.getServer().getWorlds()) { saveWorld(world); } } @@ -264,7 +266,7 @@ public class HashChunkManager implements ChunkManager { public synchronized void unloadAll() { closeAll(); - for (World world : pluginRef.getServer().getWorlds()) { + for (World world : Bukkit.getServer().getWorlds()) { unloadWorld(world); } } @@ -434,7 +436,7 @@ public class HashChunkManager implements ChunkManager { continue; } - if (converter.taskID >= 0) { + if (converter.task != null) { continue; } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java index 65ae647e5..d16ceeda4 100755 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java @@ -2,24 +2,25 @@ package com.gmail.nossr50.util.blockmeta.conversion; import com.gmail.nossr50.core.ChunkConversionOptions; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcmmo.api.platform.scheduler.Task; + import org.bukkit.scheduler.BukkitScheduler; import java.io.File; public class BlockStoreConversionMain implements Runnable { - BukkitScheduler scheduler; File dataDir; File[] xDirs; BlockStoreConversionXDirectory[] converters; private int taskID; private org.bukkit.World world; private final mcMMO pluginRef; + private Task task; public BlockStoreConversionMain(mcMMO pluginRef, org.bukkit.World world) { this.pluginRef = pluginRef; this.taskID = -1; this.world = world; - this.scheduler = pluginRef.getServer().getScheduler(); this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data"); this.converters = new BlockStoreConversionXDirectory[ChunkConversionOptions.getConversionRate()]; } @@ -29,7 +30,10 @@ public class BlockStoreConversionMain implements Runnable { return; } - this.taskID = this.scheduler.runTaskLater(pluginRef, this, 1).getTaskId(); + this.task = pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(1L) + .setTask(this) + .schedule(); } @Override @@ -69,7 +73,7 @@ public class BlockStoreConversionMain implements Runnable { return; } - this.scheduler.cancelTask(this.taskID); + this.task.cancel(); this.taskID = -1; } @@ -86,7 +90,7 @@ public class BlockStoreConversionMain implements Runnable { this.dataDir = null; this.xDirs = null; this.world = null; - this.scheduler = null; + this.task = null; this.converters = null; } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java index 4416ac199..564271ce4 100755 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java @@ -2,6 +2,8 @@ package com.gmail.nossr50.util.blockmeta.conversion; import com.gmail.nossr50.core.ChunkConversionOptions; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcmmo.api.platform.scheduler.Task; + import org.bukkit.scheduler.BukkitScheduler; import java.io.File; @@ -11,26 +13,27 @@ public class BlockStoreConversionXDirectory implements Runnable { File dataDir; File[] zDirs; BlockStoreConversionZDirectory[] converters; - private int taskID; + private Task task; private org.bukkit.World world; private final mcMMO pluginRef; public BlockStoreConversionXDirectory(mcMMO pluginRef) { this.pluginRef = pluginRef; - this.taskID = -1; } public void start(org.bukkit.World world, File dataDir) { this.world = world; - this.scheduler = pluginRef.getServer().getScheduler(); this.converters = new BlockStoreConversionZDirectory[ChunkConversionOptions.getConversionRate()]; this.dataDir = dataDir; - if (this.taskID >= 0) { + if (this.task != null) { return; } - this.taskID = this.scheduler.runTaskLater(pluginRef, this, 1).getTaskId(); + this.task = pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(1L) + .setTask(this) + .schedule(); } @Override @@ -66,12 +69,12 @@ public class BlockStoreConversionXDirectory implements Runnable { } public void stop() { - if (this.taskID < 0) { + if (this.task == null) { return; } - this.scheduler.cancelTask(this.taskID); - this.taskID = -1; + this.task.cancel(); + this.task = null; this.dataDir = null; this.zDirs = null; diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java index 6e897c6d2..c33445865 100755 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java @@ -1,18 +1,23 @@ package com.gmail.nossr50.util.blockmeta.conversion; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcmmo.api.platform.scheduler.Task; import com.gmail.nossr50.util.blockmeta.ChunkletStore; import com.gmail.nossr50.util.blockmeta.HashChunkletManager; import com.gmail.nossr50.util.blockmeta.PrimitiveChunkletStore; import com.gmail.nossr50.util.blockmeta.PrimitiveExChunkletStore; import com.gmail.nossr50.util.blockmeta.chunkmeta.HashChunkManager; import com.gmail.nossr50.util.blockmeta.chunkmeta.PrimitiveChunkStore; + +import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitScheduler; import java.io.File; +import java.util.function.Consumer; -public class BlockStoreConversionZDirectory implements Runnable { - public int taskID, cx, cz, x, y, z, y2, xPos, zPos, cxPos, czPos; +public class BlockStoreConversionZDirectory implements Consumer { + public int cx, cz, x, y, z, y2, xPos, zPos, cxPos, czPos; + public Task task; private String cxs, czs, chunkletName, chunkName; private org.bukkit.World world; private BukkitScheduler scheduler; @@ -27,26 +32,28 @@ public class BlockStoreConversionZDirectory implements Runnable { public BlockStoreConversionZDirectory(mcMMO pluginRef) { this.pluginRef = pluginRef; - this.taskID = -1; } public void start(org.bukkit.World world, File xDir, File dataDir) { this.world = world; - this.scheduler = pluginRef.getServer().getScheduler(); + this.scheduler = Bukkit.getServer().getScheduler(); this.manager = new HashChunkletManager(pluginRef); this.newManager = (HashChunkManager) pluginRef.getPlaceStore(); this.dataDir = dataDir; this.xDir = xDir; - if (this.taskID >= 0) { + if (this.task != null) { return; } - this.taskID = this.scheduler.runTaskLater(pluginRef, this, 1).getTaskId(); + this.task = pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(1L) + .setTask(this) + .schedule(); } @Override - public void run() { + public void accept(Task task) { if (!this.dataDir.exists()) { stop(); return; @@ -165,12 +172,12 @@ public class BlockStoreConversionZDirectory implements Runnable { } public void stop() { - if (this.taskID < 0) { + if (this.task == null) { return; } - this.scheduler.cancelTask(taskID); - this.taskID = -1; + this.task.cancel(); + this.task = null; this.cxs = null; this.czs = null; diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java index dc42788b0..bb70b33c5 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.util.commands; -import co.aikar.commands.PaperCommandManager; +import co.aikar.commands.CommandManager; import com.gmail.nossr50.commands.*; import com.gmail.nossr50.commands.admin.NBTToolsCommand; import com.gmail.nossr50.commands.admin.PlayerDebugCommand; @@ -24,6 +24,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; import org.bukkit.command.PluginCommand; +import org.bukkit.plugin.java.JavaPlugin; import java.util.ArrayList; import java.util.List; @@ -34,12 +35,12 @@ public final class CommandRegistrationManager { private final mcMMO pluginRef; private String permissionsMessage; //NOTE: Does not actually require paper, will work for bukkit - private PaperCommandManager commandManager; + private CommandManager commandManager; public CommandRegistrationManager(mcMMO pluginRef) { this.pluginRef = pluginRef; permissionsMessage = pluginRef.getLocaleManager().getString("mcMMO.NoPermission"); - commandManager = new PaperCommandManager(pluginRef); + commandManager = pluginRef.getPlatformProvider().getCommandManager(); } /** @@ -102,7 +103,7 @@ public final class CommandRegistrationManager { PluginCommand command; - command = pluginRef.getCommand(commandName); + command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand(commandName); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.Skill", StringUtils.getCapitalized(localizedName))); command.setPermission("mcmmo.commands." + commandName); command.setPermissionMessage(permissionsMessage); @@ -177,7 +178,7 @@ public final class CommandRegistrationManager { } private void registerAddlevelsCommand() { - PluginCommand command = pluginRef.getCommand("addlevels"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("addlevels"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.addlevels")); command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others"); command.setPermissionMessage(permissionsMessage); @@ -186,7 +187,7 @@ public final class CommandRegistrationManager { } private void registerAddxpCommand() { - PluginCommand command = pluginRef.getCommand("addxp"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("addxp"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.addxp")); command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others"); command.setPermissionMessage(permissionsMessage); @@ -195,7 +196,7 @@ public final class CommandRegistrationManager { } private void registerMcgodCommand() { - PluginCommand command = pluginRef.getCommand("mcgod"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcgod"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcgod")); command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others"); command.setPermissionMessage(permissionsMessage); @@ -204,7 +205,7 @@ public final class CommandRegistrationManager { } private void registerMmoInfoCommand() { - PluginCommand command = pluginRef.getCommand("mmoinfo"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mmoinfo"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mmoinfo")); command.setPermission("mcmmo.commands.mmoinfo"); command.setPermissionMessage(permissionsMessage); @@ -213,7 +214,7 @@ public final class CommandRegistrationManager { } private void registerMcChatSpyCommand() { - PluginCommand command = pluginRef.getCommand("mcchatspy"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcchatspy"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcchatspy")); command.setPermission("mcmmo.commands.mcchatspy;mcmmo.commands.mcchatspy.others"); command.setPermissionMessage(permissionsMessage); @@ -222,7 +223,7 @@ public final class CommandRegistrationManager { } private void registerMcrefreshCommand() { - PluginCommand command = pluginRef.getCommand("mcrefresh"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcrefresh"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcrefresh")); command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others"); command.setPermissionMessage(permissionsMessage); @@ -231,7 +232,7 @@ public final class CommandRegistrationManager { } private void registerMmoeditCommand() { - PluginCommand command = pluginRef.getCommand("mmoedit"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mmoedit"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mmoedit")); command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others"); command.setPermissionMessage(permissionsMessage); @@ -240,7 +241,7 @@ public final class CommandRegistrationManager { } private void registerMcmmoReloadCommand() { - PluginCommand command = pluginRef.getCommand("mcmmoreload"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcmmoreload"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcmmoreload")); command.setPermission("mcmmo.commands.reload"); command.setPermissionMessage(permissionsMessage); @@ -249,7 +250,7 @@ public final class CommandRegistrationManager { } private void registerSkillresetCommand() { - PluginCommand command = pluginRef.getCommand("skillreset"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("skillreset"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.skillreset")); command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones command.setPermissionMessage(permissionsMessage); @@ -261,7 +262,7 @@ public final class CommandRegistrationManager { List aliasList = new ArrayList<>(); aliasList.add("mcxprate"); - PluginCommand command = pluginRef.getCommand("xprate"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("xprate"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.xprate")); command.setPermission("mcmmo.commands.xprate;mcmmo.commands.xprate.reset;mcmmo.commands.xprate.set"); command.setPermissionMessage(permissionsMessage); @@ -272,7 +273,7 @@ public final class CommandRegistrationManager { } private void registerInspectCommand() { - PluginCommand command = pluginRef.getCommand("inspect"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("inspect"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.inspect")); command.setPermission("mcmmo.commands.inspect;mcmmo.commands.inspect.far;mcmmo.commands.inspect.offline"); command.setPermissionMessage(permissionsMessage); @@ -281,7 +282,7 @@ public final class CommandRegistrationManager { } private void registerMccooldownCommand() { - PluginCommand command = pluginRef.getCommand("mccooldown"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mccooldown"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mccooldown")); command.setPermission("mcmmo.commands.mccooldown"); command.setPermissionMessage(permissionsMessage); @@ -290,7 +291,7 @@ public final class CommandRegistrationManager { } private void registerMcabilityCommand() { - PluginCommand command = pluginRef.getCommand("mcability"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcability"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcability")); command.setPermission("mcmmo.commands.mcability;mcmmo.commands.mcability.others"); command.setPermissionMessage(permissionsMessage); @@ -299,7 +300,7 @@ public final class CommandRegistrationManager { } private void registerMcmmoCommand() { - PluginCommand command = pluginRef.getCommand("mcmmo"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcmmo"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcmmo")); command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help"); command.setPermissionMessage(permissionsMessage); @@ -309,7 +310,7 @@ public final class CommandRegistrationManager { } private void registerMcrankCommand() { - PluginCommand command = pluginRef.getCommand("mcrank"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcrank"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcrank")); command.setPermission("mcmmo.commands.mcrank;mcmmo.commands.mcrank.others;mcmmo.commands.mcrank.others.far;mcmmo.commands.mcrank.others.offline"); command.setPermissionMessage(permissionsMessage); @@ -318,7 +319,7 @@ public final class CommandRegistrationManager { } private void registerMcstatsCommand() { - PluginCommand command = pluginRef.getCommand("mcstats"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcstats"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcstats")); command.setPermission("mcmmo.commands.mcstats"); command.setPermissionMessage(permissionsMessage); @@ -327,7 +328,7 @@ public final class CommandRegistrationManager { } private void registerMctopCommand() { - PluginCommand command = pluginRef.getCommand("mctop"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mctop"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mctop")); command.setPermission("mcmmo.commands.mctop"); // Only need the main one, not the individual skill ones command.setPermissionMessage(permissionsMessage); @@ -336,7 +337,7 @@ public final class CommandRegistrationManager { } private void registerMcpurgeCommand() { - PluginCommand command = pluginRef.getCommand("mcpurge"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcpurge"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcpurge", pluginRef.getDatabaseCleaningSettings().getOldUserCutoffMonths())); command.setPermission("mcmmo.commands.mcpurge"); command.setPermissionMessage(permissionsMessage); @@ -345,7 +346,7 @@ public final class CommandRegistrationManager { } private void registerMcremoveCommand() { - PluginCommand command = pluginRef.getCommand("mcremove"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcremove"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcremove")); command.setPermission("mcmmo.commands.mcremove"); command.setPermissionMessage(permissionsMessage); @@ -354,7 +355,7 @@ public final class CommandRegistrationManager { } private void registerMmoshowdbCommand() { - PluginCommand command = pluginRef.getCommand("mmoshowdb"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mmoshowdb"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mmoshowdb")); command.setPermission("mcmmo.commands.mmoshowdb"); command.setPermissionMessage(permissionsMessage); @@ -363,7 +364,7 @@ public final class CommandRegistrationManager { } private void registerMcconvertCommand() { - PluginCommand command = pluginRef.getCommand("mcconvert"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcconvert"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcconvert")); command.setPermission("mcmmo.commands.mcconvert;mcmmo.commands.mcconvert.experience;mcmmo.commands.mcconvert.database"); command.setPermissionMessage(permissionsMessage); @@ -373,7 +374,7 @@ public final class CommandRegistrationManager { } private void registerAdminChatCommand() { - PluginCommand command = pluginRef.getCommand("adminchat"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("adminchat"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.adminchat")); command.setPermission("mcmmo.chat.adminchat"); command.setPermissionMessage(permissionsMessage); @@ -384,7 +385,7 @@ public final class CommandRegistrationManager { } private void registerPartyChatCommand() { - PluginCommand command = pluginRef.getCommand("partychat"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("partychat"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.partychat")); command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party"); command.setPermissionMessage(permissionsMessage); @@ -395,7 +396,7 @@ public final class CommandRegistrationManager { } private void registerPartyCommand() { - PluginCommand command = pluginRef.getCommand("party"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("party"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.party")); command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" + "mcmmo.commands.party.xpshare;mcmmo.commands.party.invite;mcmmo.commands.party.itemshare;mcmmo.commands.party.join;" + @@ -406,7 +407,7 @@ public final class CommandRegistrationManager { } private void registerPtpCommand() { - PluginCommand command = pluginRef.getCommand("ptp"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("ptp"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.ptp")); command.setPermission("mcmmo.commands.ptp"); // Only need the main one, not the individual ones for toggle/accept/acceptall command.setPermissionMessage(permissionsMessage); @@ -436,7 +437,7 @@ public final class CommandRegistrationManager { }*/ private void registerMcnotifyCommand() { - PluginCommand command = pluginRef.getCommand("mcnotify"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcnotify"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcnotify")); command.setPermission("mcmmo.commands.mcnotify"); command.setPermissionMessage(permissionsMessage); @@ -445,7 +446,7 @@ public final class CommandRegistrationManager { } private void registerMHDCommand() { - PluginCommand command = pluginRef.getCommand("mhd"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mhd"); command.setDescription("Resets all mob health bar settings for all players to the default"); //TODO: Localize command.setPermission("mcmmo.commands.mhd"); command.setPermissionMessage(permissionsMessage); @@ -454,7 +455,7 @@ public final class CommandRegistrationManager { } private void registerMcscoreboardCommand() { - PluginCommand command = pluginRef.getCommand("mcscoreboard"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcscoreboard"); command.setDescription("Change the current mcMMO scoreboard being displayed"); //TODO: Localize command.setPermission("mcmmo.commands.mcscoreboard"); command.setPermissionMessage(permissionsMessage); @@ -465,7 +466,7 @@ public final class CommandRegistrationManager { private void registerReloadLocaleCommand() { - PluginCommand command = pluginRef.getCommand("mcmmoreloadlocale"); + PluginCommand command = ((JavaPlugin) pluginRef.getPlatformProvider()).getCommand("mcmmoreloadlocale"); command.setDescription("Reloads locale"); // TODO: Localize command.setPermission("mcmmo.commands.reloadlocale"); command.setPermissionMessage(permissionsMessage); diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandTools.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandTools.java index 2d89ebd9c..eb521e27f 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandTools.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandTools.java @@ -6,6 +6,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; + +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -100,7 +102,7 @@ public final class CommandTools { return false; } - boolean hasPlayerDataKey = ((Player) sender).hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY); + boolean hasPlayerDataKey = ((Player) sender).hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY.getKey()); if (!hasPlayerDataKey) { sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.NotLoaded")); @@ -229,7 +231,7 @@ public final class CommandTools { Player player = sender instanceof Player ? (Player) sender : null; List onlinePlayerNames = new ArrayList<>(); - for (Player onlinePlayer : pluginRef.getServer().getOnlinePlayers()) { + for (Player onlinePlayer : Bukkit.getServer().getOnlinePlayers()) { if (player != null && player.canSee(onlinePlayer)) { onlinePlayerNames.add(onlinePlayer.getName()); } @@ -252,7 +254,7 @@ public final class CommandTools { partialName = matches.get(0); } } else { - Player player = pluginRef.getServer().getPlayer(partialName); + Player player = Bukkit.getServer().getPlayer(partialName); if (player != null) { partialName = player.getName(); @@ -274,7 +276,7 @@ public final class CommandTools { private List matchPlayer(String partialName) { List matchedPlayers = new ArrayList<>(); - for (OfflinePlayer offlinePlayer : pluginRef.getServer().getOfflinePlayers()) { + for (OfflinePlayer offlinePlayer : Bukkit.getServer().getOfflinePlayers()) { String playerName = offlinePlayer.getName(); if (playerName == null) { //Do null checking here to detect corrupted data before sending it throuogh .equals diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/player/UserManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/player/UserManager.java index 33bd49648..ec5f87574 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/player/UserManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -3,7 +3,10 @@ package com.gmail.nossr50.util.player; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.player.BukkitMMOPlayer; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcmmo.api.platform.util.MetadataKey; import com.google.common.collect.ImmutableList; + +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -31,7 +34,7 @@ public final class UserManager { * @param mcMMOPlayer the player profile to start tracking */ public void track(BukkitMMOPlayer mcMMOPlayer) { - mcMMOPlayer.getNative().setMetadata(MetadataConstants.PLAYER_DATA_METAKEY, new FixedMetadataValue(pluginRef, mcMMOPlayer)); + pluginRef.getPlatformProvider().getMetadataStore().setMetadata(mcMMOPlayer, MetadataConstants.PLAYER_DATA_METAKEY, mcMMOPlayer); if(playerDataSet == null) playerDataSet = new HashSet<>(); @@ -51,7 +54,7 @@ public final class UserManager { */ public void remove(Player player) { BukkitMMOPlayer mcMMOPlayer = getPlayer(player); - player.removeMetadata(MetadataConstants.PLAYER_DATA_METAKEY, pluginRef); + pluginRef.getPlatformProvider().getMetadataStore().removeMetadata(mcMMOPlayer, MetadataConstants.PLAYER_DATA_METAKEY); if(mcMMOPlayer != null) mcMMOPlayer.cleanup(); @@ -65,7 +68,7 @@ public final class UserManager { * Clear all users. */ public void clearAll() { - for (Player player : pluginRef.getServer().getOnlinePlayers()) { + for (Player player : Bukkit.getServer().getOnlinePlayers()) { remove(player); } @@ -102,7 +105,7 @@ public final class UserManager { public Collection getPlayers() { Collection playerCollection = new ArrayList<>(); - for (Player player : pluginRef.getServer().getOnlinePlayers()) { + for (Player player : Bukkit.getServer().getOnlinePlayers()) { if (hasPlayerDataKey(player)) { playerCollection.add(getPlayer(player)); } @@ -144,15 +147,15 @@ public final class UserManager { @Nullable public BukkitMMOPlayer getPlayer(Player player) { //Avoid Array Index out of bounds - if (player != null && player.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY)) - return (BukkitMMOPlayer) player.getMetadata(MetadataConstants.PLAYER_DATA_METAKEY).get(0).value(); + if (player != null && player.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY.getKey())) + return (BukkitMMOPlayer) player.getMetadata(MetadataConstants.PLAYER_DATA_METAKEY.getKey()).get(0).value(); else return null; } @Nullable private BukkitMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) { - Player player = pluginRef.getServer().getPlayerExact(playerName); + Player player = Bukkit.getServer().getPlayerExact(playerName); if (player == null) { if (!offlineValid) { @@ -166,6 +169,6 @@ public final class UserManager { } public boolean hasPlayerDataKey(Entity entity) { - return entity != null && entity.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY); + return entity != null && entity.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY.getKey()); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index 6e3e358d2..383b2a914 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -44,8 +44,8 @@ public class ScoreboardManager { //TODO: Christ... //Call our custom event - if(pluginRef.getServer().getScoreboardManager() != null) { - McMMOScoreboardMakeboardEvent event = new McMMOScoreboardMakeboardEvent(pluginRef.getServer().getScoreboardManager().getNewScoreboard(), player.getScoreboard(), player, ScoreboardEventReason.CREATING_NEW_SCOREBOARD); + if(Bukkit.getServer().getScoreboardManager() != null) { + McMMOScoreboardMakeboardEvent event = new McMMOScoreboardMakeboardEvent(Bukkit.getServer().getScoreboardManager().getNewScoreboard(), player.getScoreboard(), player, ScoreboardEventReason.CREATING_NEW_SCOREBOARD); player.getServer().getPluginManager().callEvent(event); return new ScoreboardWrapper(event.getTargetPlayer(), event.getTargetBoard(), scoreboardStrings, pluginRef); @@ -73,7 +73,7 @@ public class ScoreboardManager { // Called in onDisable() public void teardownAll() { - ImmutableList onlinePlayers = ImmutableList.copyOf(pluginRef.getServer().getOnlinePlayers()); + ImmutableList onlinePlayers = ImmutableList.copyOf(Bukkit.getServer().getOnlinePlayers()); pluginRef.debug("Tearing down scoreboards... (" + onlinePlayers.size() + ")"); for (Player player : onlinePlayers) { teardownPlayer(player); @@ -271,7 +271,7 @@ public class ScoreboardManager { */ public Objective getPowerLevelObjective() { if (!pluginRef.getScoreboardSettings().getPowerLevelTagsEnabled()) { - Objective objective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().getObjective(scoreboardStrings.POWER_OBJECTIVE); + Objective objective = Bukkit.getServer().getScoreboardManager().getMainScoreboard().getObjective(scoreboardStrings.POWER_OBJECTIVE); if (objective != null) { objective.unregister(); @@ -281,10 +281,10 @@ public class ScoreboardManager { return null; } - Objective powerObjective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().getObjective(scoreboardStrings.POWER_OBJECTIVE); + Objective powerObjective = Bukkit.getServer().getScoreboardManager().getMainScoreboard().getObjective(scoreboardStrings.POWER_OBJECTIVE); if (powerObjective == null) { - powerObjective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(scoreboardStrings.POWER_OBJECTIVE, "dummy"); + powerObjective = Bukkit.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(scoreboardStrings.POWER_OBJECTIVE, "dummy"); powerObjective.setDisplayName(scoreboardStrings.TAG_POWER_LEVEL); powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); } @@ -296,7 +296,7 @@ public class ScoreboardManager { if (displayTime == -1) { wrapper.showBoardWithNoRevert(); } else { - wrapper.showBoardAndScheduleRevert(displayTime * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR); + wrapper.showBoardAndScheduleRevert((int) (displayTime * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR)); } } @@ -313,7 +313,7 @@ public class ScoreboardManager { } public void setRevertTimer(String playerName, int seconds) { - PLAYER_SCOREBOARDS.get(playerName).showBoardAndScheduleRevert(seconds * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR); + PLAYER_SCOREBOARDS.get(playerName).showBoardAndScheduleRevert((int) (seconds * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR)); } public List getDirtyPowerLevels() { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java index 40919a5b4..de1297a3b 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java @@ -10,8 +10,10 @@ import com.gmail.nossr50.events.scoreboard.McMMOScoreboardRevertEvent; import com.gmail.nossr50.events.scoreboard.ScoreboardEventReason; import com.gmail.nossr50.events.scoreboard.ScoreboardObjectiveEventReason; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcmmo.api.platform.scheduler.Task; import com.gmail.nossr50.skills.child.FamilyTree; import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -35,9 +37,9 @@ public class ScoreboardWrapper { public String targetPlayer = null; public PrimarySkillType targetSkill = null; public int leaderboardPage = -1; - public BukkitTask updateTask = null; - public BukkitTask revertTask = null; - public BukkitTask cooldownTask = null; + public Task updateTask = null; + public Task revertTask = null; + public Task cooldownTask = null; private boolean tippedKeep = false; private boolean tippedClear = false; // Internal usage variables (should exist) @@ -73,7 +75,10 @@ public class ScoreboardWrapper { public void doSidebarUpdateSoon() { if (updateTask == null) { // To avoid spamming the scheduler, store the instance and run 2 ticks later - updateTask = new ScoreboardQuickUpdate().runTaskLater(pluginRef, 2L); + updateTask = pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(2L) + .setTask(new ScoreboardQuickUpdate()) + .schedule(); } } @@ -81,7 +86,12 @@ public class ScoreboardWrapper { if (cooldownTask == null) { // Repeat every 5 seconds. // Cancels once all cooldowns are done, using stopCooldownUpdating(). - cooldownTask = new ScoreboardCooldownTask().runTaskTimer(pluginRef, 5 * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR, 5 * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR); + + cooldownTask = pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(5 * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR) + .setRepeatTime(5 * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR) + .setTask(new ScoreboardCooldownTask()) + .schedule(); } } @@ -112,7 +122,7 @@ public class ScoreboardWrapper { * Set the old targetBoard, for use in reverting. */ public void setOldScoreboard() { - Player player = pluginRef.getServer().getPlayerExact(playerName); + Player player = Bukkit.getServer().getPlayerExact(playerName); if (player == null) { pluginRef.getScoreboardManager().cleanup(this); @@ -124,7 +134,7 @@ public class ScoreboardWrapper { if (oldBoard == scoreboard) { // Already displaying it if (this.oldBoard == null) { // (Shouldn't happen) Use failsafe value - we're already displaying our board, but we don't have the one we should revert to - this.oldBoard = pluginRef.getServer().getScoreboardManager().getMainScoreboard(); + this.oldBoard = Bukkit.getServer().getScoreboardManager().getMainScoreboard(); } } else { this.oldBoard = oldBoard; @@ -132,7 +142,7 @@ public class ScoreboardWrapper { } public void showBoardWithNoRevert() { - Player player = pluginRef.getServer().getPlayerExact(playerName); + Player player = Bukkit.getServer().getPlayerExact(playerName); if (player == null) { pluginRef.getScoreboardManager().cleanup(this); @@ -148,7 +158,7 @@ public class ScoreboardWrapper { } public void showBoardAndScheduleRevert(int ticks) { - Player player = pluginRef.getServer().getPlayerExact(playerName); + Player player = Bukkit.getServer().getPlayerExact(playerName); if (player == null) { pluginRef.getScoreboardManager().cleanup(this); @@ -160,7 +170,10 @@ public class ScoreboardWrapper { } player.setScoreboard(scoreboard); - revertTask = new ScoreboardChangeTask().runTaskLater(pluginRef, ticks); + revertTask = pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay((long) ticks) + .setTask(new ScoreboardChangeTask()) + .schedule(); // TODO is there any way to do the time that looks acceptable? // player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase(Locale.ENGLISH)), ticks / 20F)); @@ -185,7 +198,7 @@ public class ScoreboardWrapper { } public void tryRevertBoard() { - Player player = pluginRef.getServer().getPlayerExact(playerName); + Player player = Bukkit.getServer().getPlayerExact(playerName); if (player == null) { pluginRef.getScoreboardManager().cleanup(this); @@ -217,7 +230,7 @@ public class ScoreboardWrapper { } public boolean isBoardShown() { - Player player = pluginRef.getServer().getPlayerExact(playerName); + Player player = Bukkit.getServer().getPlayerExact(playerName); if (player == null) { pluginRef.getScoreboardManager().cleanup(this); @@ -386,7 +399,7 @@ public class ScoreboardWrapper { return; } - Player player = pluginRef.getServer().getPlayerExact(playerName); + Player player = Bukkit.getServer().getPlayerExact(playerName); if (player == null) { pluginRef.getScoreboardManager().cleanup(this); @@ -513,7 +526,7 @@ public class ScoreboardWrapper { public void acceptRankData(Map rankData) { Integer rank; - Player player = pluginRef.getServer().getPlayerExact(playerName); + Player player = Bukkit.getServer().getPlayerExact(playerName); for (PrimarySkillType primarySkillType : pluginRef.getSkillTools().NON_CHILD_SKILLS) { if (!pluginRef.getPermissionTools().skillEnabled(player, primarySkillType)) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/CombatTools.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/CombatTools.java index 448e63354..aa4b01218 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/CombatTools.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/CombatTools.java @@ -19,6 +19,8 @@ import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.google.common.collect.ImmutableMap; + +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.*; @@ -28,6 +30,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.MetadataValue; +import org.bukkit.plugin.Plugin; import org.bukkit.projectiles.ProjectileSource; import java.util.EnumMap; @@ -258,7 +261,7 @@ public final class CombatTools { finalDamage += archeryManager.daze((Player) target); } - if (!arrow.hasMetadata(MetadataConstants.INFINITE_ARROW_METAKEY) && archeryManager.canRetrieveArrows()) { + if (!arrow.hasMetadata(MetadataConstants.INFINITE_ARROW_METAKEY.getKey()) && archeryManager.canRetrieveArrows()) { archeryManager.processArrowRetrievalActivation(target, arrow); } @@ -270,8 +273,8 @@ public final class CombatTools { double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow); double forceMultiplier = 1.0; //Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires - if(arrow.hasMetadata(MetadataConstants.BOW_FORCE_METAKEY)) - forceMultiplier = arrow.getMetadata(MetadataConstants.BOW_FORCE_METAKEY).get(0).asDouble(); + if(arrow.hasMetadata(MetadataConstants.BOW_FORCE_METAKEY.getKey())) + forceMultiplier = arrow.getMetadata(MetadataConstants.BOW_FORCE_METAKEY.getKey()).get(0).asDouble(); applyScaledModifiers(initialDamage, finalDamage, event); startGainXp(mcMMOPlayer, target, PrimarySkillType.ARCHERY, forceMultiplier * distanceMultiplier); @@ -619,18 +622,18 @@ public final class CombatTools { // cause do have issues around plugin observability. This is not a perfect solution, but it appears to be the best one here // We also set no damage ticks to 0, to ensure that damage is applied for this case, and reset it back to the original value // Snapshot current state so we can pop up properly - boolean wasMetaSet = target.getMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY).size() != 0; - target.setMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY, MetadataConstants.metadataValue); + boolean wasMetaSet = target.getMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY.getKey()).size() != 0; + target.setMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY.getKey(), MetadataConstants.metadataValue); boolean wasProcessing = processingNoInvulnDamage; // set markers processingNoInvulnDamage = true; - target.setMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY, MetadataConstants.metadataValue); + target.setMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY.getKey(), MetadataConstants.metadataValue); int noDamageTicks = target.getNoDamageTicks(); target.setNoDamageTicks(0); target.damage(damage, attacker); target.setNoDamageTicks(noDamageTicks); if (!wasMetaSet) - target.removeMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY, pluginRef); + target.removeMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY.getKey(), (Plugin) pluginRef.getPlatformProvider()); if (!wasProcessing) processingNoInvulnDamage = false; } @@ -774,11 +777,11 @@ public final class CombatTools { } } - if (target.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY) || target.hasMetadata("ES")) { + if (target.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY.getKey()) || target.hasMetadata("ES")) { baseXPMultiplier *= pluginRef.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.SPAWNED); } - if (target.hasMetadata(MetadataConstants.PETS_ANIMAL_TRACKING_METAKEY)) { + if (target.hasMetadata(MetadataConstants.PETS_ANIMAL_TRACKING_METAKEY.getKey())) { baseXPMultiplier *= pluginRef.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.PETS); } @@ -790,7 +793,9 @@ public final class CombatTools { baseXPMultiplier *= multiplier; if (baseXPMultiplier != 0) { - new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXPMultiplier, target, xpGainReason).runTaskLater(pluginRef, 0); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setTask(new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXPMultiplier, target, xpGainReason)) + .schedule(); } } @@ -900,7 +905,7 @@ public final class CombatTools { public EntityDamageEvent sendEntityDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) { EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, damageCause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage); - pluginRef.getServer().getPluginManager().callEvent(damageEvent); + Bukkit.getServer().getPluginManager().callEvent(damageEvent); return damageEvent; } @@ -914,7 +919,7 @@ public final class CombatTools { public double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause cause, Map modifiers) { EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers); - pluginRef.getServer().getPluginManager().callEvent(damageEvent); + Bukkit.getServer().getPluginManager().callEvent(damageEvent); if (damageEvent.isCancelled()) { return 0; @@ -1006,10 +1011,11 @@ public final class CombatTools { return; } - if (!player.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY)) { + if (!player.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY.getKey())) { return; } - pluginRef.getMobHealthBarManager().handleMobHealthbars(target, damage, plugin); + + pluginRef.getPlatformProvider().getHealthBarManager().handleMobHealthbars(plugin.getPlatformProvider().getEntity(target.getUniqueId()), damage); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/PerkUtils.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/PerkUtils.java index 703e9a604..01a63167a 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/PerkUtils.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/PerkUtils.java @@ -13,7 +13,7 @@ public final class PerkUtils { this.pluginRef = pluginRef; } - public int handleCooldownPerks(Player player, int cooldown) { + public long handleCooldownPerks(Player player, long cooldown) { if (pluginRef.getPermissionTools().halvedCooldowns(player)) { cooldown *= 0.5; } else if (pluginRef.getPermissionTools().thirdedCooldowns(player)) { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/RankTools.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/RankTools.java index 38ef0278c..ab4f0dffa 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/RankTools.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/RankTools.java @@ -49,9 +49,10 @@ public class RankTools { //The players level is the exact level requirement for this skill if (newLevel == innerMap.get(playerRankInSkill)) { - SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(pluginRef, mcMMOPlayer, subSkillType); - - skillUnlockNotificationTask.runTaskLater(pluginRef, (count * 100)); + pluginRef.getPlatformProvider().getScheduler().getTaskBuilder() + .setDelay(count * 100L) + .setTask(new SkillUnlockNotificationTask(pluginRef, mcMMOPlayer, subSkillType)) + .schedule(); count++; }