mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-30 04:34:43 +02:00
It compiles
running is a different matter, however...
This commit is contained in:
@ -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")
|
||||
}
|
||||
|
@ -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<String> 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();
|
||||
}
|
||||
}
|
@ -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 entity;
|
||||
|
||||
public BukkitMMOEntity(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getNative() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -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> {
|
||||
|
||||
LivingEntity entity;
|
||||
|
||||
public BukkitMMOLivingEntity(LivingEntity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getNative() {
|
||||
return entity;
|
||||
}
|
||||
}
|
@ -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<Task> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<Player, LivingEntity> {
|
||||
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<Play
|
||||
/**
|
||||
* Handle the creation of mob healthbars.
|
||||
*
|
||||
* @param target the targetted entity
|
||||
* @param mmoTarget the targetted entity
|
||||
* @param damage damage done by the attack triggering this
|
||||
*/
|
||||
@Override
|
||||
@ -96,14 +99,17 @@ public final class BukkitMobHealthBarManager implements MobHealthBarManager<Play
|
||||
boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName));
|
||||
|
||||
if (updateName) {
|
||||
target.setMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, new FixedMetadataValue(pluginRef, oldName));
|
||||
target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(pluginRef, oldNameVisible));
|
||||
} else if (!target.hasMetadata(MetadataConstants.CUSTOM_NAME_METAKEY)) {
|
||||
target.setMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, new FixedMetadataValue(pluginRef, ""));
|
||||
target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(pluginRef, false));
|
||||
target.setMetadata(MetadataConstants.CUSTOM_NAME_METAKEY.getKey(), new FixedMetadataValue(plugin, oldName));
|
||||
target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY.getKey(), new FixedMetadataValue(plugin, oldNameVisible));
|
||||
} else if (!target.hasMetadata(MetadataConstants.CUSTOM_NAME_METAKEY.getKey())) {
|
||||
target.setMetadata(MetadataConstants.CUSTOM_NAME_METAKEY.getKey(), new FixedMetadataValue(plugin, ""));
|
||||
target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY.getKey(), new FixedMetadataValue(plugin, false));
|
||||
}
|
||||
|
||||
new MobHealthDisplayUpdaterTask(pluginRef, target).runTaskLater(pluginRef, displayTime * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
|
||||
pluginRef.getPlatformProvider().getScheduler().getTaskBuilder()
|
||||
.setDelay(displayTime * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR) // Clear health display after 3 seconds
|
||||
.setTask(new MobHealthDisplayUpdaterTask(pluginRef, target))
|
||||
.schedule();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ description: >
|
||||
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
|
||||
|
Reference in New Issue
Block a user