mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
!Moved many classes to MMOLib
This commit is contained in:
parent
280b48b857
commit
4e7a4b0bcf
@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
/**
|
||||
* @author Arnah
|
||||
|
@ -74,7 +74,6 @@ import net.Indyuce.mmocore.manager.ClassManager;
|
||||
import net.Indyuce.mmocore.manager.ConfigItemManager;
|
||||
import net.Indyuce.mmocore.manager.ConfigManager;
|
||||
import net.Indyuce.mmocore.manager.CustomBlockManager;
|
||||
import net.Indyuce.mmocore.manager.DamageManager;
|
||||
import net.Indyuce.mmocore.manager.DropTableManager;
|
||||
import net.Indyuce.mmocore.manager.EntityManager;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
@ -93,8 +92,6 @@ import net.Indyuce.mmocore.manager.social.BoosterManager;
|
||||
import net.Indyuce.mmocore.manager.social.GuildManager;
|
||||
import net.Indyuce.mmocore.manager.social.PartyManager;
|
||||
import net.Indyuce.mmocore.manager.social.RequestManager;
|
||||
import net.Indyuce.mmocore.version.ServerVersion;
|
||||
import net.Indyuce.mmocore.version.nms.NMSHandler;
|
||||
|
||||
public class MMOCore extends JavaPlugin {
|
||||
public static MMOCore plugin;
|
||||
@ -119,10 +116,7 @@ public class MMOCore extends JavaPlugin {
|
||||
public VaultEconomy economy;
|
||||
public HologramSupport hologramSupport;
|
||||
public PlaceholderParser placeholderParser = new DefaultParser();
|
||||
public final DamageManager damage = new DamageManager();
|
||||
public final EntityManager entities = new EntityManager();
|
||||
public NMSHandler nms;
|
||||
public ServerVersion version;
|
||||
public InventoryManager inventoryManager;
|
||||
public RegionHandler regionHandler;
|
||||
public PlayerActionBar actionBarManager ;
|
||||
@ -142,7 +136,6 @@ public class MMOCore extends JavaPlugin {
|
||||
|
||||
public void onLoad() {
|
||||
plugin = this;
|
||||
version = new ServerVersion(Bukkit.getServer().getClass());
|
||||
|
||||
/*
|
||||
* register extra objective, drop items...
|
||||
@ -164,14 +157,6 @@ public class MMOCore extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
try {
|
||||
getLogger().log(Level.INFO, "Detected Bukkit Version: " + version.toString());
|
||||
nms = (NMSHandler) Class.forName("net.Indyuce.mmocore.version.nms.NMSHandler_" + version.toString().substring(1)).newInstance();
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException exception) {
|
||||
getLogger().log(Level.INFO, "Your server version is not compatible.");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
new Metrics(this);
|
||||
|
||||
@ -285,7 +270,6 @@ public class MMOCore extends JavaPlugin {
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerAttackEventListener(), this);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new DamageManager(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new WaypointsListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new GoldPouchesListener(), this);
|
||||
|
@ -20,6 +20,8 @@ import org.bukkit.util.io.BukkitObjectInputStream;
|
||||
import org.bukkit.util.io.BukkitObjectOutputStream;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class MMOCoreUtils {
|
||||
public static boolean pluginItem(ItemStack item) {
|
||||
return item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName();
|
||||
@ -50,7 +52,7 @@ public class MMOCoreUtils {
|
||||
Validate.notNull(string, "String cannot be null");
|
||||
String[] split = string.split("\\:");
|
||||
Material material = Material.valueOf(split[0].toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
return split.length > 1 ? MMOCore.plugin.version.getTextureHandler().textureItem(material, Integer.parseInt(split[1])) : new ItemStack(material);
|
||||
return split.length > 1 ? MMOLib.plugin.getVersion().getWrapper().textureItem(material, Integer.parseInt(split[1])) : new ItemStack(material);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
return new ItemStack(Material.BARRIER);
|
||||
}
|
||||
@ -60,7 +62,7 @@ public class MMOCoreUtils {
|
||||
int t = 0;
|
||||
for (ItemStack item : items)
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
t += MMOCore.plugin.nms.getNBTItem(item).getInt("RpgWorth") * item.getAmount();
|
||||
t += MMOLib.plugin.getNMS().getNBTItem(item).getInteger("RpgWorth") * item.getAmount();
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class ConfigMessage {
|
||||
private final List<String> messages;
|
||||
@ -38,6 +39,6 @@ public class ConfigMessage {
|
||||
}
|
||||
|
||||
public void sendAsJSon(Player player) {
|
||||
messages.forEach(line -> MMOCore.plugin.nms.sendJson(player, ChatColor.translateAlternateColorCodes('&', line)));
|
||||
messages.forEach(line -> MMOLib.plugin.getNMS().sendJson(player, ChatColor.translateAlternateColorCodes('&', line)));
|
||||
}
|
||||
}
|
||||
|
@ -6,20 +6,20 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
public class PlayerAttackEvent extends PlayerDataEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final EntityDamageByEntityEvent event;
|
||||
private final DamageInfo info;
|
||||
private final AttackResult attack;
|
||||
|
||||
public PlayerAttackEvent(PlayerData data, EntityDamageByEntityEvent event, DamageInfo info) {
|
||||
public PlayerAttackEvent(PlayerData data, EntityDamageByEntityEvent event, AttackResult attack) {
|
||||
super(data);
|
||||
|
||||
this.event = event;
|
||||
this.info = info;
|
||||
this.attack = attack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -32,13 +32,13 @@ public class PlayerAttackEvent extends PlayerDataEvent implements Cancellable {
|
||||
event.setCancelled(value);
|
||||
}
|
||||
|
||||
public DamageInfo getDamageInfo() {
|
||||
return info;
|
||||
public AttackResult getAttackInfo() {
|
||||
return attack;
|
||||
}
|
||||
|
||||
// @Deprecated
|
||||
public boolean isWeapon() {
|
||||
return info.getTypes().contains(DamageType.WEAPON);
|
||||
return attack.getTypes().contains(DamageType.WEAPON);
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
|
@ -12,6 +12,7 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.load.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoadException;
|
||||
import net.Indyuce.mmocore.api.math.formula.LinearValue;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class Profession {
|
||||
private final String id, name;
|
||||
@ -71,7 +72,7 @@ public class Profession {
|
||||
if (config.contains("base-enchant-exp"))
|
||||
for (String key : config.getConfigurationSection("base-enchant-exp").getKeys(false))
|
||||
try {
|
||||
Enchantment enchant = MMOCore.plugin.version.getVersionWrapper().getEnchantmentFromString(key.toLowerCase().replace("-", "_"));
|
||||
Enchantment enchant = MMOLib.plugin.getVersion().getWrapper().getEnchantmentFromString(key.toLowerCase().replace("-", "_"));
|
||||
MMOCore.plugin.enchantManager.registerBaseExperience(enchant, config.getDouble("base-enchant-exp." + key));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.log(Level.WARNING, "[Professions:" + id + "] Could not read enchant from " + key);
|
||||
|
@ -18,6 +18,7 @@ import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmocore.api.load.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class EnchantItemExperienceSource extends ExperienceSource<Void> {
|
||||
private final List<Enchantment> enchants = new ArrayList<>();
|
||||
@ -27,7 +28,7 @@ public class EnchantItemExperienceSource extends ExperienceSource<Void> {
|
||||
|
||||
if (config.contains("enchant"))
|
||||
for (String key : config.getString("enchant").split("\\,"))
|
||||
enchants.add(MMOCore.plugin.version.getVersionWrapper().getEnchantmentFromString(key.toLowerCase().replace("-", "_")));
|
||||
enchants.add(MMOLib.plugin.getVersion().getWrapper().getEnchantmentFromString(key.toLowerCase().replace("-", "_")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,12 +8,12 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.api.load.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class MineBlockExperienceSource extends SpecificExperienceSource<Material> {
|
||||
public final Material material;
|
||||
@ -45,7 +45,7 @@ public class MineBlockExperienceSource extends SpecificExperienceSource<Material
|
||||
{
|
||||
if (source.silkTouch && hasSilkTouch(event.getPlayer().getInventory().getItemInMainHand()))
|
||||
continue;
|
||||
if (source.crop && !MMOCore.plugin.version.getVersionWrapper().isCropFullyGrown(event.getBlock()))
|
||||
if (source.crop && !MMOLib.plugin.getVersion().getWrapper().isCropFullyGrown(event.getBlock()))
|
||||
continue;
|
||||
if ((!source.playerPlaced) && event.getBlock().hasMetadata("player_placed"))
|
||||
continue;
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.Consumer;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class AnvilGUI extends PlayerInput {
|
||||
private final int containerId;
|
||||
@ -25,25 +26,25 @@ public class AnvilGUI extends PlayerInput {
|
||||
paperMeta.setDisplayName(MMOCore.plugin.configManager.getSimpleMessage("player-input.anvil." + type.getLowerCaseName()).message());
|
||||
paper.setItemMeta(paperMeta);
|
||||
|
||||
MMOCore.plugin.nms.handleInventoryCloseEvent(player);
|
||||
MMOCore.plugin.nms.setActiveContainerDefault(player);
|
||||
MMOLib.plugin.getNMS().handleInventoryCloseEvent(player);
|
||||
MMOLib.plugin.getNMS().setActiveContainerDefault(player);
|
||||
|
||||
final Object container = MMOCore.plugin.nms.newContainerAnvil(player);
|
||||
final Object container = MMOLib.plugin.getNMS().newContainerAnvil(player);
|
||||
|
||||
inventory = MMOCore.plugin.nms.toBukkitInventory(container);
|
||||
inventory = MMOLib.plugin.getNMS().toBukkitInventory(container);
|
||||
inventory.setItem(0, paper);
|
||||
|
||||
containerId = MMOCore.plugin.nms.getNextContainerId(player);
|
||||
MMOCore.plugin.nms.sendPacketOpenWindow(player, containerId);
|
||||
MMOCore.plugin.nms.setActiveContainer(player, container);
|
||||
MMOCore.plugin.nms.setActiveContainerId(container, containerId);
|
||||
MMOCore.plugin.nms.addActiveContainerSlotListener(container, player);
|
||||
containerId = MMOLib.plugin.getNMS().getNextContainerId(player);
|
||||
MMOLib.plugin.getNMS().sendPacketOpenWindow(player, containerId);
|
||||
MMOLib.plugin.getNMS().setActiveContainer(player, container);
|
||||
MMOLib.plugin.getNMS().setActiveContainerId(container, containerId);
|
||||
MMOLib.plugin.getNMS().addActiveContainerSlotListener(container, player);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
MMOCore.plugin.nms.handleInventoryCloseEvent(getPlayer());
|
||||
MMOCore.plugin.nms.setActiveContainerDefault(getPlayer());
|
||||
MMOCore.plugin.nms.sendPacketCloseWindow(getPlayer(), containerId);
|
||||
MMOLib.plugin.getNMS().handleInventoryCloseEvent(getPlayer());
|
||||
MMOLib.plugin.getNMS().setActiveContainerDefault(getPlayer());
|
||||
MMOLib.plugin.getNMS().sendPacketCloseWindow(getPlayer(), containerId);
|
||||
|
||||
InventoryClickEvent.getHandlerList().unregister(this);
|
||||
InventoryCloseEvent.getHandlerList().unregister(this);
|
||||
|
@ -21,8 +21,10 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class ConfigItem {
|
||||
private final String name, id, texture;
|
||||
@ -108,7 +110,7 @@ public class ConfigItem {
|
||||
if (meta instanceof Damageable)
|
||||
((Damageable) meta).setDamage(damage);
|
||||
|
||||
if(MMOCore.plugin.version.isStrictlyHigher(1, 13))
|
||||
if(MMOLib.plugin.getVersion().isStrictlyHigher(1, 13))
|
||||
meta.setCustomModelData(modeldata);
|
||||
|
||||
if (item.getType() == VersionMaterial.PLAYER_HEAD.toMaterial() && texture != null) {
|
||||
@ -131,7 +133,7 @@ public class ConfigItem {
|
||||
meta.setLore(lore);
|
||||
|
||||
item.setItemMeta(meta);
|
||||
return unbreakable ? NBTItem.get(item).add(new ItemTag("Unbreakable", true)).toItem() : item;
|
||||
return unbreakable ? NBTItem.get(item).addTag(new ItemTag("Unbreakable", true)).toItem() : item;
|
||||
}
|
||||
|
||||
protected String format(String string) {
|
||||
|
@ -7,8 +7,9 @@ import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class CurrencyItem extends ConfigItem {
|
||||
private final int worth, amount;
|
||||
@ -35,10 +36,10 @@ public class CurrencyItem extends ConfigItem {
|
||||
getLore().forEach(line -> lore.add(format(line)));
|
||||
meta.setLore(lore);
|
||||
|
||||
if(MMOCore.plugin.version.isStrictlyHigher(1, 13))
|
||||
if(MMOLib.plugin.getVersion().isStrictlyHigher(1, 13))
|
||||
meta.setCustomModelData(getModelData());
|
||||
|
||||
item.setItemMeta(meta);
|
||||
return NBTItem.get(item).add(new ItemTag("RpgWorth", worth)).toItem();
|
||||
return NBTItem.get(item).addTag(new ItemTag("RpgWorth", worth)).toItem();
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
package net.Indyuce.mmocore.api.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
|
||||
public abstract class NBTItem {
|
||||
protected ItemStack item;
|
||||
|
||||
public NBTItem(ItemStack item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public abstract String getString(String path);
|
||||
|
||||
public abstract boolean has(String path);
|
||||
|
||||
public abstract boolean getBoolean(String path);
|
||||
|
||||
public abstract double getDouble(String path);
|
||||
|
||||
public abstract int getInt(String path);
|
||||
|
||||
public abstract NBTItem add(ItemTag... tags);
|
||||
|
||||
public abstract NBTItem remove(String... paths);
|
||||
|
||||
public abstract Set<String> getTags();
|
||||
|
||||
public abstract ItemStack toItem();
|
||||
|
||||
public void add(List<ItemTag> tags) {
|
||||
for (ItemTag tag : tags)
|
||||
add(tag);
|
||||
}
|
||||
|
||||
public static NBTItem get(ItemStack item) {
|
||||
return MMOCore.plugin.nms.getNBTItem(item);
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class CastingParticle {
|
||||
private final Consumer<Location> display;
|
||||
@ -25,7 +25,7 @@ public class CastingParticle {
|
||||
final float size = (float) config.getDouble("size") == 0 ? 1 : (float) Math.max(config.getDouble("size"), 0);
|
||||
Color color = Color.fromRGB(config.getInt("color.red"), config.getInt("color.green"), config.getInt("color.blue"));
|
||||
|
||||
display = (loc) -> MMOCore.plugin.version.getVersionWrapper().spawnParticle(particle, loc, size, color);
|
||||
display = (loc) -> MMOLib.plugin.getVersion().getWrapper().spawnParticle(particle, loc, size, color);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public class CastingParticle {
|
||||
Validate.notNull(format, "Could not read material name");
|
||||
Material material = Material.valueOf(format.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
|
||||
display = (loc) -> MMOCore.plugin.version.getVersionWrapper().spawnParticle(particle, loc, material);
|
||||
display = (loc) -> MMOLib.plugin.getVersion().getWrapper().spawnParticle(particle, loc, material);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class ParabolicProjectile extends BukkitRunnable {
|
||||
private final Location target;
|
||||
@ -29,11 +30,11 @@ public class ParabolicProjectile extends BukkitRunnable {
|
||||
}
|
||||
|
||||
public ParabolicProjectile(Location source, Location target, Particle particle, Runnable end, int speed, Color color, float size) {
|
||||
this(source, target, target.clone().subtract(source).toVector().multiply(.1).setY(6).normalize().multiply(.3), end, speed, (loc) -> MMOCore.plugin.version.getVersionWrapper().spawnParticle(particle, loc, size, color));
|
||||
this(source, target, target.clone().subtract(source).toVector().multiply(.1).setY(6).normalize().multiply(.3), end, speed, (loc) -> MMOLib.plugin.getVersion().getWrapper().spawnParticle(particle, loc, size, color));
|
||||
}
|
||||
|
||||
public ParabolicProjectile(Location source, Location target, Runnable end, Color color) {
|
||||
this(source, target, target.clone().subtract(source).toVector().multiply(.1).setY(6).normalize().multiply(.3), end, 1, (loc) -> MMOCore.plugin.version.getVersionWrapper().spawnParticle(Particle.REDSTONE, loc, 1, color));
|
||||
this(source, target, target.clone().subtract(source).toVector().multiply(.1).setY(6).normalize().multiply(.3), end, 1, (loc) -> MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.REDSTONE, loc, 1, color));
|
||||
}
|
||||
|
||||
public ParabolicProjectile(Location source, Location target, Particle particle) {
|
||||
|
@ -49,9 +49,10 @@ import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult.CancelReason;
|
||||
import net.Indyuce.mmocore.listener.SpellCast.SkillCasting;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class PlayerData {
|
||||
|
||||
@ -503,7 +504,7 @@ public class PlayerData {
|
||||
player.playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound(), 1, (float) (t / Math.PI * .015 + .5));
|
||||
double r = Math.sin((double) t / 100 * Math.PI);
|
||||
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
|
||||
MMOCore.plugin.version.getVersionWrapper().spawnParticle(Particle.REDSTONE, player.getLocation().add(Math.cos((double) t / 20 + j) * r, (double) t / 50, Math.sin((double) t / 20 + j) * r), 1.25f, Color.PURPLE);
|
||||
MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.REDSTONE, player.getLocation().add(Math.cos((double) t / 20 + j) * r, (double) t / 50, Math.sin((double) t / 20 + j) * r), 1.25f, Color.PURPLE);
|
||||
}
|
||||
}.runTaskTimer(MMOCore.plugin, 0, 1);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.quest.Quest;
|
||||
import net.Indyuce.mmocore.api.quest.QuestProgress;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class PlayerQuests {
|
||||
private final PlayerData playerData;
|
||||
@ -26,7 +27,7 @@ public class PlayerQuests {
|
||||
|
||||
public PlayerQuests(PlayerData playerData) {
|
||||
this.playerData = playerData;
|
||||
bossbar = MMOCore.plugin.version.getVersionWrapper().createBossBar(new NamespacedKey(MMOCore.plugin, "quest_bar_" + playerData.getUniqueId().toString()), "", BarColor.PURPLE, BarStyle.SEGMENTED_20, new BarFlag[0]);
|
||||
bossbar = MMOLib.plugin.getVersion().getWrapper().createBossBar(new NamespacedKey(MMOCore.plugin, "quest_bar_" + playerData.getUniqueId().toString()), "", BarColor.PURPLE, BarStyle.SEGMENTED_20, new BarFlag[0]);
|
||||
bossbar.addPlayer(playerData.getPlayer());
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
||||
import net.Indyuce.mmocore.manager.ClassManager;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class PlayerClass {
|
||||
private final String name, id, fileName;
|
||||
|
@ -7,7 +7,7 @@ import net.Indyuce.mmocore.api.event.PlayerAttackEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.player.profess.event.EventTriggerHandler;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
public class AttackEventTrigger implements EventTriggerHandler {
|
||||
|
||||
@ -21,7 +21,7 @@ public class AttackEventTrigger implements EventTriggerHandler {
|
||||
PlayerData player = event.getData();
|
||||
PlayerClass profess = player.getProfess();
|
||||
|
||||
for (DamageType type : event.getDamageInfo().getTypes()) {
|
||||
for (DamageType type : event.getAttackInfo().getTypes()) {
|
||||
String path = type.getPath() + "-damage";
|
||||
if (profess.hasEventTriggers(path))
|
||||
profess.getEventTriggers(path).getTriggers().forEach(trigger -> trigger.apply(player));
|
||||
|
@ -6,9 +6,10 @@ import java.util.Map;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
public class TemporaryStats {
|
||||
private final PlayerData playerData;
|
||||
@ -37,6 +38,6 @@ public class TemporaryStats {
|
||||
}
|
||||
|
||||
public void damage(LivingEntity target, double value, DamageType... types) {
|
||||
MMOCore.plugin.damage.damage(playerData, target, value, types);
|
||||
MMOLib.plugin.getDamage().damage(playerData.getPlayer(), target, new AttackResult(true, value, types));
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package net.Indyuce.mmocore.api.skill;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.MMORayTraceResult;
|
||||
|
||||
public class TargetSkillResult extends SkillResult {
|
||||
private LivingEntity target;
|
||||
@ -14,11 +14,11 @@ public class TargetSkillResult extends SkillResult {
|
||||
super(data, skill);
|
||||
|
||||
if (isSuccessful()) {
|
||||
RayTraceResult result = MMOCore.plugin.version.getVersionWrapper().rayTraceEntities(data.getPlayer(), data.getPlayer().getEyeLocation().getDirection(), range);
|
||||
MMORayTraceResult result = MMOLib.plugin.getVersion().getWrapper().rayTrace(data.getPlayer(), data.getPlayer().getEyeLocation().getDirection(), range);
|
||||
if (result == null)
|
||||
abort(CancelReason.OTHER);
|
||||
else
|
||||
target = (LivingEntity) result.getHitEntity();
|
||||
target = (LivingEntity) result.getHit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import net.Indyuce.mmocore.api.experience.Booster;
|
||||
import net.Indyuce.mmocore.api.math.format.DelayFormat;
|
||||
import net.Indyuce.mmocore.command.api.CommandEnd;
|
||||
import net.Indyuce.mmocore.command.api.CommandMap;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class ListCommandMap extends CommandEnd {
|
||||
public ListCommandMap(CommandMap parent) {
|
||||
@ -23,7 +24,7 @@ public class ListCommandMap extends CommandEnd {
|
||||
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
|
||||
for (Booster booster : MMOCore.plugin.boosterManager.getBoosters())
|
||||
if (!booster.isTimedOut())
|
||||
MMOCore.plugin.nms.sendJson((Player) sender, "{\"text\":\"" + ChatColor.YELLOW + "- " + ChatColor.GOLD + MMOCore.plugin.configManager.decimal.format((1 + booster.getExtra())) + "x" + ChatColor.YELLOW + " Booster - " + ChatColor.GOLD + (!booster.hasProfession() ? "Main" : booster.getProfession().getName()) + ChatColor.YELLOW + " - " + ChatColor.GOLD + new DelayFormat().format(booster.getCreationDate() + booster.getLength() - System.currentTimeMillis()) + "\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/mmocore booster remove " + booster.getUniqueId().toString() + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to remove.\"}}}");
|
||||
MMOLib.plugin.getNMS().sendJson((Player) sender, "{\"text\":\"" + ChatColor.YELLOW + "- " + ChatColor.GOLD + MMOCore.plugin.configManager.decimal.format((1 + booster.getExtra())) + "x" + ChatColor.YELLOW + " Booster - " + ChatColor.GOLD + (!booster.hasProfession() ? "Main" : booster.getProfession().getName()) + ChatColor.YELLOW + " - " + ChatColor.GOLD + new DelayFormat().format(booster.getCreationDate() + booster.getLength() - System.currentTimeMillis()) + "\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/mmocore booster remove " + booster.getUniqueId().toString() + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to remove.\"}}}");
|
||||
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Item;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class LootColor extends BukkitRunnable {
|
||||
private final Item item;
|
||||
@ -27,6 +28,6 @@ public class LootColor extends BukkitRunnable {
|
||||
return;
|
||||
}
|
||||
|
||||
MMOCore.plugin.version.getVersionWrapper().spawnParticle(Particle.REDSTONE, item.getLocation(), 1.3f, color);
|
||||
MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.REDSTONE, item.getLocation(), 1.3f, color);
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,10 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ItemTier;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class Lootsplosion implements Listener {
|
||||
private static final Random random = new Random();
|
||||
@ -67,8 +68,8 @@ public class Lootsplosion implements Listener {
|
||||
|
||||
if (colored)
|
||||
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
|
||||
NBTItem nbt = MMOCore.plugin.nms.getNBTItem(item.getItemStack());
|
||||
if (nbt.has("MMOITEMS_TIER")) {
|
||||
NBTItem nbt = MMOLib.plugin.getNMS().getNBTItem(item.getItemStack());
|
||||
if (nbt.hasTag("MMOITEMS_TIER")) {
|
||||
ItemTier tier = MMOItems.plugin.getTiers().get(nbt.getString("MMOITEMS_TIER"));
|
||||
if (tier.hasColor())
|
||||
new LootColor(item, tier.getColor().toBukkit());
|
||||
|
@ -1,20 +0,0 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageHandler;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
|
||||
public class MythicMobsDamageHandler implements DamageHandler {
|
||||
|
||||
@Override
|
||||
public DamageInfo getDamage(Entity entity) {
|
||||
return new DamageInfo(DamageType.MAGICAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDamage(Entity entity) {
|
||||
return entity.hasMetadata("skill-damage");
|
||||
}
|
||||
}
|
@ -18,7 +18,6 @@ public class MythicMobsDrops implements Listener {
|
||||
if (MMOCore.plugin.getConfig().getBoolean("lootsplosion.enabled"))
|
||||
Bukkit.getPluginManager().registerEvents(new Lootsplosion(), MMOCore.plugin);
|
||||
registerPlaceholders();
|
||||
MMOCore.plugin.damage.registerHandler(new MythicMobsDamageHandler());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -15,8 +15,8 @@ import io.lumine.xikage.mythicmobs.io.MythicLineConfig;
|
||||
import net.Indyuce.mmocore.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.item.ConfigItem;
|
||||
import net.Indyuce.mmocore.api.item.CurrencyItem;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class GoldPouchDrop extends Drop implements IMultiDrop {
|
||||
private int min, max;
|
||||
@ -51,7 +51,7 @@ public class GoldPouchDrop extends Drop implements IMultiDrop {
|
||||
content[getAvailableSlot(content)] = new CurrencyItem("NOTE", a, 1).build();
|
||||
}
|
||||
|
||||
nbt.add(new ItemTag("RpgPouchSize", 18), new ItemTag("RpgPouchMob", true), new ItemTag("RpgPouchInventory", MMOCoreUtils.toBase64(content)));
|
||||
nbt.addTag(new ItemTag("RpgPouchSize", 18), new ItemTag("RpgPouchMob", true), new ItemTag("RpgPouchInventory", MMOCoreUtils.toBase64(content)));
|
||||
loot.add(new ItemDrop(this.getLine(), (MythicLineConfig) this.getConfig(), new BukkitItemStack(nbt.toItem())));
|
||||
return loot;
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
package net.Indyuce.mmocore.comp.rpg.damage;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public interface DamageHandler {
|
||||
public DamageInfo getDamage(Entity entity);
|
||||
|
||||
public boolean hasDamage(Entity entity);
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
package net.Indyuce.mmocore.comp.rpg.damage;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
|
||||
public class DamageInfo {
|
||||
private final Set<DamageType> types;
|
||||
private final double value;
|
||||
|
||||
public DamageInfo(DamageType... type) {
|
||||
this(0, type);
|
||||
}
|
||||
|
||||
public DamageInfo(double value, DamageType... types) {
|
||||
this(value, Arrays.asList(types));
|
||||
}
|
||||
|
||||
public DamageInfo(double value, List<DamageType> types) {
|
||||
this(value, new HashSet<>(types));
|
||||
}
|
||||
|
||||
public DamageInfo(double value, Set<DamageType> types) {
|
||||
// Validate.notEmpty(types, "Damage must have at least one damage
|
||||
// type!");
|
||||
|
||||
this.types = types;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public DamageInfo merge(DamageInfo info) {
|
||||
types.addAll(info.getTypes());
|
||||
return this;
|
||||
}
|
||||
|
||||
public Set<DamageType> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public boolean hasType(DamageType type) {
|
||||
return types.contains(type);
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public enum DamageType {
|
||||
|
||||
/*
|
||||
* skills or abilities dealing magic damage
|
||||
*/
|
||||
MAGICAL(StatType.MAGICAL_DAMAGE),
|
||||
|
||||
/*
|
||||
* skills or abilities dealing physical damage
|
||||
*/
|
||||
PHYSICAL(StatType.PHYSICAL_DAMAGE),
|
||||
|
||||
/*
|
||||
* weapons dealing damage
|
||||
*/
|
||||
WEAPON(StatType.WEAPON_DAMAGE),
|
||||
|
||||
/*
|
||||
* skill damage
|
||||
*/
|
||||
SKILL(StatType.SKILL_DAMAGE),
|
||||
|
||||
/*
|
||||
* projectile based weapons or skills
|
||||
*/
|
||||
PROJECTILE(StatType.PROJECTILE_DAMAGE);
|
||||
|
||||
private final StatType stat;
|
||||
|
||||
private DamageType(StatType stat) {
|
||||
this.stat = stat;
|
||||
}
|
||||
|
||||
public StatType getStat() {
|
||||
return stat;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return name().toLowerCase().replace("_", "-");
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass.ClassOption;
|
||||
@ -25,7 +24,8 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class ClassSelect extends EditableInventory {
|
||||
public ClassSelect() {
|
||||
@ -87,7 +87,7 @@ public class ClassSelect extends EditableInventory {
|
||||
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
return NBTItem.get(item).add(new ItemTag("classId", profess.getId())).toItem();
|
||||
return NBTItem.get(item).addTag(new ItemTag("classId", profess.getId())).toItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +21,7 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class PlayerStats extends EditableInventory {
|
||||
public PlayerStats() {
|
||||
|
@ -18,7 +18,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.math.format.DelayFormat;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.quest.Quest;
|
||||
@ -28,7 +27,8 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class QuestViewer extends EditableInventory {
|
||||
public QuestViewer() {
|
||||
@ -141,7 +141,7 @@ public class QuestViewer extends EditableInventory {
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
return NBTItem.get(item).add(new ItemTag("questId", quest.getId())).toItem();
|
||||
return NBTItem.get(item).addTag(new ItemTag("questId", quest.getId())).toItem();
|
||||
}
|
||||
|
||||
private Placeholders getPlaceholders(PlayerData data, Quest quest) {
|
||||
|
@ -17,7 +17,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
||||
@ -28,7 +27,8 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class SkillList extends EditableInventory {
|
||||
public SkillList() {
|
||||
@ -177,7 +177,7 @@ public class SkillList extends EditableInventory {
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
return NBTItem.get(item).add(new ItemTag("skillId", skill.getSkill().getId())).toItem();
|
||||
return NBTItem.get(item).addTag(new ItemTag("skillId", skill.getSkill().getId())).toItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -244,7 +244,7 @@ public class SkillList extends EditableInventory {
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
return NBTItem.get(item).add(new ItemTag("skillId", skill.getSkill().getId())).toItem();
|
||||
return NBTItem.get(item).addTag(new ItemTag("skillId", skill.getSkill().getId())).toItem();
|
||||
}
|
||||
|
||||
public Placeholders getPlaceholders(PlayerData player, SkillInfo skill) {
|
||||
|
@ -13,7 +13,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass.Subclass;
|
||||
@ -22,7 +21,8 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class SubclassSelect extends EditableInventory {
|
||||
public SubclassSelect() {
|
||||
@ -82,7 +82,7 @@ public class SubclassSelect extends EditableInventory {
|
||||
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
return NBTItem.get(item).add(new ItemTag("classId", profess.getId())).toItem();
|
||||
return NBTItem.get(item).addTag(new ItemTag("classId", profess.getId())).toItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.Waypoint;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
@ -20,7 +19,8 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class WaypointViewer extends EditableInventory {
|
||||
public WaypointViewer() {
|
||||
@ -82,7 +82,7 @@ public class WaypointViewer extends EditableInventory {
|
||||
if (inv.getPlayerData().getStellium() < waypoint.getStelliumCost() || (generated.current == null && !waypoint.isDynamic()))
|
||||
disp.setType(notReady);
|
||||
|
||||
return NBTItem.get(disp).add(new ItemTag("waypointId", waypoint.getId())).toItem();
|
||||
return NBTItem.get(disp).addTag(new ItemTag("waypointId", waypoint.getId())).toItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import net.Indyuce.mmocore.gui.api.PluginInventory;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public abstract class InventoryPlaceholderItem extends InventoryItem {
|
||||
private final ItemStack stack;
|
||||
@ -109,7 +110,7 @@ public abstract class InventoryPlaceholderItem extends InventoryItem {
|
||||
meta.setLore(lore);
|
||||
}
|
||||
|
||||
if (MMOCore.plugin.version.isStrictlyHigher(1, 13))
|
||||
if (MMOLib.plugin.getVersion().isStrictlyHigher(1, 13))
|
||||
meta.setCustomModelData(getModelData());
|
||||
|
||||
item.setItemMeta(meta);
|
||||
|
@ -13,9 +13,9 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.item.ConfigItem;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.item.SmartGive;
|
||||
import net.Indyuce.mmocore.gui.api.PluginInventory;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class DepositMenu extends PluginInventory {
|
||||
private ItemStack depositItem;
|
||||
@ -67,7 +67,7 @@ public class DepositMenu extends PluginInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
int worth = NBTItem.get(event.getCurrentItem()).getInt("RpgWorth");
|
||||
int worth = NBTItem.get(event.getCurrentItem()).getInteger("RpgWorth");
|
||||
if (worth < 1) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -11,9 +11,9 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.gui.api.PluginInventory;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class GoldPouch extends PluginInventory {
|
||||
private final boolean mob;
|
||||
@ -41,7 +41,7 @@ public class GoldPouch extends PluginInventory {
|
||||
|
||||
ItemStack item = event.getCurrentItem();
|
||||
NBTItem nbt = NBTItem.get(item);
|
||||
if (!nbt.has("RpgWorth")) {
|
||||
if (!nbt.hasTag("RpgWorth")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class GoldPouch extends PluginInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nbt.has("RpgPouchInventory"))
|
||||
if (nbt.hasTag("RpgPouchInventory"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ public class GoldPouch extends PluginInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack updated = NBTItem.get(player.getEquipment().getItemInMainHand()).add(new ItemTag("RpgPouchInventory", MMOCoreUtils.toBase64(event.getInventory().getContents()))).toItem();
|
||||
ItemStack updated = NBTItem.get(player.getEquipment().getItemInMainHand()).addTag(new ItemTag("RpgPouchInventory", MMOCoreUtils.toBase64(event.getInventory().getContents()))).toItem();
|
||||
player.getEquipment().setItemInMainHand(updated);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.input.PlayerInput.InputType;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.math.format.DelayFormat;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
||||
@ -27,7 +26,8 @@ import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class EditableFriendList extends EditableInventory {
|
||||
public EditableFriendList() {
|
||||
@ -96,7 +96,7 @@ public class EditableFriendList extends EditableInventory {
|
||||
});
|
||||
}
|
||||
|
||||
return NBTItem.get(disp).add(new ItemTag("uuid", friend.getUniqueId().toString())).toItem();
|
||||
return NBTItem.get(disp).addTag(new ItemTag("uuid", friend.getUniqueId().toString())).toItem();
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ public class EditableFriendList extends EditableInventory {
|
||||
disp.setItemMeta(meta);
|
||||
}
|
||||
|
||||
return NBTItem.get(disp).add(new ItemTag("uuid", friend.getUniqueId().toString())).toItem();
|
||||
return NBTItem.get(disp).addTag(new ItemTag("uuid", friend.getUniqueId().toString())).toItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.input.PlayerInput.InputType;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.math.format.DelayFormat;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
||||
@ -26,7 +25,8 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class EditableGuildAdmin extends EditableInventory {
|
||||
public EditableGuildAdmin() {
|
||||
@ -70,7 +70,7 @@ public class EditableGuildAdmin extends EditableInventory {
|
||||
disp.setItemMeta(meta);
|
||||
}
|
||||
|
||||
return NBTItem.get(disp).add(new ItemTag("uuid", member.getUniqueId().toString())).toItem();
|
||||
return NBTItem.get(disp).addTag(new ItemTag("uuid", member.getUniqueId().toString())).toItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.input.PlayerInput.InputType;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.math.format.DelayFormat;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData.PlayerDataOfflineValues;
|
||||
@ -27,7 +26,8 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class EditableGuildView extends EditableInventory {
|
||||
public EditableGuildView() {
|
||||
@ -87,7 +87,7 @@ public class EditableGuildView extends EditableInventory {
|
||||
disp.setItemMeta(meta);
|
||||
}
|
||||
|
||||
return NBTItem.get(disp).add(new ItemTag("uuid", uuid.toString())).toItem();
|
||||
return NBTItem.get(disp).addTag(new ItemTag("uuid", uuid.toString())).toItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.input.PlayerInput.InputType;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.math.format.DelayFormat;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
||||
@ -26,7 +25,8 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
import net.mmogroup.mmolib.api.ItemTag;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class EditablePartyView extends EditableInventory {
|
||||
public EditablePartyView() {
|
||||
@ -70,7 +70,7 @@ public class EditablePartyView extends EditableInventory {
|
||||
disp.setItemMeta(meta);
|
||||
}
|
||||
|
||||
return NBTItem.get(disp).add(new ItemTag("uuid", member.getUniqueId().toString())).toItem();
|
||||
return NBTItem.get(disp).addTag(new ItemTag("uuid", member.getUniqueId().toString())).toItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.gui.eco.GoldPouch;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class GoldPouchesListener implements Listener {
|
||||
@EventHandler
|
||||
@ -18,7 +18,7 @@ public class GoldPouchesListener implements Listener {
|
||||
return;
|
||||
|
||||
NBTItem nbt = NBTItem.get(event.getItem());
|
||||
if (!nbt.has("RpgPouchInventory"))
|
||||
if (!nbt.hasTag("RpgPouchInventory"))
|
||||
return;
|
||||
|
||||
// that way ppl can't open a chest when right clicking a backpack
|
||||
@ -47,7 +47,7 @@ public class GoldPouchesListener implements Listener {
|
||||
return;
|
||||
|
||||
ItemStack item = event.getItem().getItemStack();
|
||||
if (NBTItem.get(item).has("RpgPouchInventory"))
|
||||
if (NBTItem.get(item).hasTag("RpgPouchInventory"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ import net.Indyuce.mmocore.api.event.PlayerCombatEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.stats.PlayerStats;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.Indyuce.mmocore.gui.api.PluginInventory;
|
||||
import net.Indyuce.mmoitems.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
@ -103,15 +103,15 @@ public class PlayerListener implements Listener {
|
||||
double d = 1, s = 1;
|
||||
|
||||
if(MMOCore.plugin.isMILoaded())
|
||||
for (DamageType type : event.getDamageInfo().getTypes())
|
||||
for (DamageType type : event.getAttackInfo().getTypes())
|
||||
s += (net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayer()).getStats()
|
||||
.getStat(AttackResult.DamageType.valueOf(type.name()).getStat()) / 100);
|
||||
|
||||
damage /= s;
|
||||
|
||||
PlayerStats stats = event.getData().getStats();
|
||||
for (DamageType type : event.getDamageInfo().getTypes())
|
||||
d += (stats.getStat(type.getStat())) / 100;
|
||||
for (DamageType type : event.getAttackInfo().getTypes())
|
||||
d += (stats.getStat((StatType) type.getMMOCoreStat())) / 100;
|
||||
|
||||
event.setDamage(damage * d);
|
||||
}
|
||||
|
@ -11,12 +11,12 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.EntityKillEntityEvent;
|
||||
import net.Indyuce.mmocore.api.event.PlayerAttackEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
public class PlayerAttackEventListener implements Listener {
|
||||
|
||||
@ -28,14 +28,14 @@ public class PlayerAttackEventListener implements Listener {
|
||||
/*
|
||||
* check for event.
|
||||
*/
|
||||
DamageInfo info = new DamageInfo();
|
||||
Entity damager = getDamager(info, event);
|
||||
AttackResult result = new AttackResult(true);
|
||||
Entity damager = getDamager(result, event);
|
||||
|
||||
/*
|
||||
* check for last damage
|
||||
*/
|
||||
if (damager == null && (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent))
|
||||
damager = getDamager(info, (EntityDamageByEntityEvent) event.getEntity().getLastDamageCause());
|
||||
damager = getDamager(result, (EntityDamageByEntityEvent) event.getEntity().getLastDamageCause());
|
||||
|
||||
/*
|
||||
* if the damage source cannot be found, just return.
|
||||
@ -48,7 +48,7 @@ public class PlayerAttackEventListener implements Listener {
|
||||
* register an attack damage for easier plugin calculations
|
||||
*/
|
||||
if (damager instanceof Player && !damager.hasMetadata("NPC"))
|
||||
Bukkit.getPluginManager().callEvent(new PlayerAttackEvent(PlayerData.get((Player) damager), event, MMOCore.plugin.damage.findInfo(event.getEntity()).merge(info)));
|
||||
Bukkit.getPluginManager().callEvent(new PlayerAttackEvent(PlayerData.get((Player) damager), event, MMOLib.plugin.getDamage().findInfo(event.getEntity()).mergeTypes(result)));
|
||||
|
||||
/*
|
||||
* checks for killing
|
||||
@ -57,7 +57,7 @@ public class PlayerAttackEventListener implements Listener {
|
||||
Bukkit.getPluginManager().callEvent(new EntityKillEntityEvent(damager, event.getEntity()));
|
||||
}
|
||||
|
||||
private Entity getDamager(DamageInfo damageInfo, EntityDamageByEntityEvent event) {
|
||||
private Entity getDamager(AttackResult result, EntityDamageByEntityEvent event) {
|
||||
|
||||
/*
|
||||
* check direct damager
|
||||
@ -72,7 +72,7 @@ public class PlayerAttackEventListener implements Listener {
|
||||
if (event.getDamager() instanceof Projectile) {
|
||||
Projectile proj = (Projectile) event.getDamager();
|
||||
if (proj.getShooter() instanceof Entity) {
|
||||
damageInfo.getTypes().add(DamageType.PROJECTILE);
|
||||
result.getTypes().add(DamageType.PROJECTILE);
|
||||
return (Entity) proj.getShooter();
|
||||
}
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class Alchemy implements Listener {
|
||||
private Set<String> runnables = new HashSet<>();
|
||||
|
@ -27,7 +27,8 @@ import net.Indyuce.mmocore.api.event.CustomPlayerFishEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.Indyuce.mmocore.manager.profession.FishingManager.FishingDropTable;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class FishingListener implements Listener {
|
||||
private Set<UUID> fishing = new HashSet<>();
|
||||
@ -116,7 +117,7 @@ public class FishingListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerFishEvent event) {
|
||||
if (event.getPlayer().equals(player) && (event.getState() == State.CAUGHT_FISH || event.getState() == State.FAILED_ATTEMPT || (MMOCore.plugin.version.isStrictlyHigher(1, 12) ? event.getState() == State.valueOf("REEL_IN") : false))) {
|
||||
if (event.getPlayer().equals(player) && (event.getState() == State.CAUGHT_FISH || event.getState() == State.FAILED_ATTEMPT || (MMOLib.plugin.getVersion().isStrictlyHigher(1, 12) ? event.getState() == State.valueOf("REEL_IN") : false))) {
|
||||
|
||||
/*
|
||||
* lose the catch if the current fish is gone!
|
||||
|
@ -11,10 +11,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.CustomBlockMineEvent;
|
||||
import net.Indyuce.mmocore.api.math.particle.SmallParticleEffect;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class PlayerCollectStats implements Listener {
|
||||
private static final Random random = new Random();
|
||||
@ -39,7 +39,7 @@ public class PlayerCollectStats implements Listener {
|
||||
item.setAmount(item.getAmount() + a);
|
||||
}
|
||||
|
||||
if(MMOCore.plugin.version.getVersionWrapper().isCropFullyGrown(event.getBlock()))
|
||||
if(MMOLib.plugin.getVersion().getWrapper().isCropFullyGrown(event.getBlock()))
|
||||
{
|
||||
// drop more items if fortune enchant
|
||||
double l = event.getData().getStats().getStat(StatType.LUCK_OF_THE_FIELD);
|
||||
|
@ -16,9 +16,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.NBTItem;
|
||||
|
||||
public class Smelting implements Listener {
|
||||
|
||||
@ -47,7 +48,7 @@ public class Smelting implements Listener {
|
||||
recipes.add(recipe);
|
||||
NamespacedKey vanillaKey = new NamespacedKey(MMOCore.plugin, "furnace_recipe_" + key.replace("-", "_").toLowerCase());
|
||||
vanillaKeys.add(vanillaKey);
|
||||
Bukkit.addRecipe(MMOCore.plugin.version.getVersionWrapper().getFurnaceRecipe(vanillaKey, new ItemStack(Material.BARRIER), recipe.getIngredientMaterial(), 0, recipe.getCookingTime()));
|
||||
Bukkit.addRecipe(MMOLib.plugin.getVersion().getWrapper().getFurnaceRecipe(vanillaKey, new ItemStack(Material.BARRIER), recipe.getIngredientMaterial(), 0, recipe.getCookingTime()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,10 @@ import net.Indyuce.mmocore.api.load.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoadException;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.ExperienceTrigger;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.CustomBlock;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class CustomBlockManager extends MMOManager {
|
||||
private final Map<String, BlockInfo> map = new HashMap<>();
|
||||
@ -54,7 +55,7 @@ public class CustomBlockManager extends MMOManager {
|
||||
|
||||
public BlockInfo getInfo(Block block) {
|
||||
if(isPlayerSkull(block.getType())) {
|
||||
String skullValue = MMOCore.plugin.nms.getSkullValue(block);
|
||||
String skullValue = MMOLib.plugin.getNMS().getSkullValue(block);
|
||||
return map.getOrDefault(skullValue, map.getOrDefault(block.getType().name(), null));
|
||||
}
|
||||
if(MMOCore.plugin.isMILoaded())
|
||||
@ -86,7 +87,7 @@ public class CustomBlockManager extends MMOManager {
|
||||
else info.getLocation().getBlock().setType(info.getRegen().getTemporaryBlock());
|
||||
if(isPlayerSkull(info.getLocation().getBlock().getType())) {
|
||||
if(isPlayerSkull(info.getRegen().getBlock())) info.getLocation().getBlock().setBlockData(info.getBlockData());
|
||||
MMOCore.plugin.nms.setSkullValue(info.getLocation().getBlock(), info.getRegen().getRegenHeadValue());
|
||||
MMOLib.plugin.getNMS().setSkullValue(info.getLocation().getBlock(), info.getRegen().getRegenHeadValue());
|
||||
}
|
||||
|
||||
new BukkitRunnable() {
|
||||
@ -97,7 +98,7 @@ public class CustomBlockManager extends MMOManager {
|
||||
private void regen(RegenInfo info) {
|
||||
info.getLocation().getBlock().setBlockData(info.getBlockData());
|
||||
if(isPlayerSkull(info.getLocation().getBlock().getType()))
|
||||
MMOCore.plugin.nms.setSkullValue(info.getLocation().getBlock(), info.getRegen().getHeadValue());
|
||||
MMOLib.plugin.getNMS().setSkullValue(info.getLocation().getBlock(), info.getRegen().getHeadValue());
|
||||
active.remove(info);
|
||||
|
||||
info.getLocation().getBlock().getState().update();
|
||||
|
@ -1,72 +0,0 @@
|
||||
package net.Indyuce.mmocore.manager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageHandler;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
|
||||
public class DamageManager implements Listener, DamageHandler {
|
||||
private final Map<Integer, DamageInfo> customDamage = new HashMap<>();
|
||||
private final List<DamageHandler> handlers = new ArrayList<>();
|
||||
|
||||
public DamageManager() {
|
||||
handlers.add(this);
|
||||
}
|
||||
|
||||
public void registerHandler(DamageHandler handler) {
|
||||
handlers.add(handler);
|
||||
}
|
||||
|
||||
public void damage(PlayerData data, LivingEntity target, double value, DamageType... types) {
|
||||
customDamage.put(target.getEntityId(), new DamageInfo(value, types));
|
||||
target.damage(value, data.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageInfo getDamage(Entity entity) {
|
||||
return customDamage.get(entity.getEntityId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDamage(Entity entity) {
|
||||
return customDamage.containsKey(entity.getEntityId());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isCustomDamaged(Entity target) {
|
||||
return findInfo(target) != null;
|
||||
}
|
||||
|
||||
public DamageInfo findInfo(Entity target) {
|
||||
|
||||
for (DamageHandler handler : handlers)
|
||||
if (handler.hasDamage(target))
|
||||
return handler.getDamage(target);
|
||||
|
||||
/*
|
||||
* any non registered damage source is considered weapon
|
||||
*/
|
||||
return new DamageInfo(DamageType.WEAPON);
|
||||
}
|
||||
|
||||
/*
|
||||
* remove custom damage info as soon as the event is finished to save
|
||||
* memory. if ignore cancelled, some can remain
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
|
||||
public void a(EntityDamageByEntityEvent event) {
|
||||
customDamage.remove(event.getEntity().getEntityId());
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
|
||||
public class Ambers extends Skill implements Listener {
|
||||
public Ambers() {
|
||||
@ -80,7 +81,7 @@ public class Ambers extends Skill implements Listener {
|
||||
|
||||
for (int j = 0; j < 5; j++)
|
||||
loc.getWorld().spawnParticle(Particle.SPELL_MOB, loc, 0, 1, 0.647, 0, 1);
|
||||
MMOCore.plugin.version.getVersionWrapper().spawnParticle(Particle.REDSTONE, loc, 1.3f, Color.ORANGE);
|
||||
MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.REDSTONE, loc, 1.3f, Color.ORANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,9 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
public class Combo_Attack extends Skill {
|
||||
public Combo_Attack() {
|
||||
@ -48,7 +50,7 @@ public class Combo_Attack extends Skill {
|
||||
|
||||
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_PLAYER_ATTACK_KNOCKBACK, 1, 2);
|
||||
target.getWorld().spawnParticle(Particle.CRIT, target.getLocation().add(0, target.getHeight() / 2, 0), 24, 0, 0, 0, .7);
|
||||
MMOCore.plugin.damage.damage(data, target, damage, DamageType.SKILL, DamageType.PHYSICAL);
|
||||
MMOLib.plugin.getDamage().damage(data.getPlayer(), target, new AttackResult(damage, DamageType.SKILL, DamageType.PHYSICAL));
|
||||
}
|
||||
}.runTaskTimer(MMOCore.plugin, 0, 5);
|
||||
return cast;
|
||||
|
@ -19,8 +19,8 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class Control extends Skill {
|
||||
public Control() {
|
||||
|
@ -7,13 +7,14 @@ import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
public class Deep_Wound extends Skill {
|
||||
public Deep_Wound() {
|
||||
@ -42,7 +43,7 @@ public class Deep_Wound extends Skill {
|
||||
double ratio = (max - target.getHealth()) / max;
|
||||
|
||||
double damage = cast.getModifier("damage") * (1 + cast.getModifier("extra") * ratio / 100);
|
||||
MMOCore.plugin.damage.damage(data, target, damage, DamageType.SKILL, DamageType.PHYSICAL);
|
||||
MMOLib.plugin.getDamage().damage(data.getPlayer(), target, new AttackResult(damage, DamageType.SKILL, DamageType.PHYSICAL));
|
||||
return cast;
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,11 @@ import net.Indyuce.mmocore.api.math.particle.SmallParticleEffect;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class Empowered_Attack extends Skill {
|
||||
private static final double perb = 5;
|
||||
@ -104,7 +106,7 @@ public class Empowered_Attack extends Skill {
|
||||
for (Entity entity : target.getNearbyEntities(rad, rad, rad))
|
||||
if (MMOCoreUtils.canTarget(player.getPlayer(), entity)) {
|
||||
drawVector(src, entity.getLocation().add(0, entity.getHeight() / 2, 0).subtract(src).toVector());
|
||||
MMOCore.plugin.damage.damage(player, (LivingEntity) entity, sweep, DamageType.SKILL, DamageType.PHYSICAL);
|
||||
MMOLib.plugin.getDamage().damage(player.getPlayer(), (LivingEntity) entity, new AttackResult(sweep, DamageType.SKILL, DamageType.PHYSICAL));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -16,7 +16,7 @@ import net.Indyuce.mmocore.api.math.particle.SmallParticleEffect;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class Evade extends Skill {
|
||||
public Evade() {
|
||||
|
@ -22,9 +22,11 @@ import net.Indyuce.mmocore.api.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class Fire_Rage extends Skill {
|
||||
public Fire_Rage() {
|
||||
@ -73,7 +75,7 @@ public class Fire_Rage extends Skill {
|
||||
Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin);
|
||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> close(), (long) (cast.getModifier("duration") * 20));
|
||||
runTaskTimer(MMOCore.plugin, 0, 1);
|
||||
|
||||
|
||||
data.getPlayer().removePotionEffect(PotionEffectType.SLOW);
|
||||
data.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (cast.getModifier("duration") * 20), 1));
|
||||
}
|
||||
@ -110,7 +112,7 @@ public class Fire_Rage extends Skill {
|
||||
data.getPlayer().removePotionEffect(PotionEffectType.SLOW);
|
||||
data.getPlayer().removePotionEffect(PotionEffectType.SLOW);
|
||||
}
|
||||
|
||||
|
||||
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, last ? 0 : 1);
|
||||
new BukkitRunnable() {
|
||||
int j = 0;
|
||||
@ -127,14 +129,14 @@ public class Fire_Rage extends Skill {
|
||||
loc.getWorld().playSound(loc, Sound.BLOCK_FIRE_AMBIENT, 2, 1);
|
||||
loc.getWorld().spawnParticle(Particle.FLAME, loc, 4, .1, .1, .1, 0);
|
||||
loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
|
||||
|
||||
|
||||
for (Entity target : MMOCoreUtils.getNearbyChunkEntities(loc))
|
||||
if (MMOCore.plugin.nms.getBoundingBox(target).expand(.2, .2, .2).contains(loc.toVector()) && MMOCoreUtils.canTarget(data.getPlayer(), target)) {
|
||||
if (target.getBoundingBox().expand(.2, .2, .2).contains(loc.toVector()) && MMOCoreUtils.canTarget(data.getPlayer(), target)) {
|
||||
loc.getWorld().spawnParticle(Particle.LAVA, loc, 8);
|
||||
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
|
||||
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
|
||||
target.setFireTicks((int) (target.getFireTicks() + ignite));
|
||||
MMOCore.plugin.damage.damage(data, (LivingEntity) target, damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
MMOLib.plugin.getDamage().damage(data.getPlayer(), (LivingEntity) target, new AttackResult(damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL));
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,10 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class Fire_Storm extends Skill {
|
||||
public Fire_Storm() {
|
||||
@ -58,7 +60,7 @@ public class Fire_Storm extends Skill {
|
||||
new ParabolicProjectile(data.getPlayer().getLocation().add(0, 1, 0), target.getLocation().add(0, target.getHeight() / 2, 0), randomVector(data.getPlayer()), () -> {
|
||||
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 1, 2);
|
||||
target.getWorld().spawnParticle(Particle.SMOKE_NORMAL, target.getLocation().add(0, target.getHeight() / 2, 0), 8, 0, 0, 0, .15);
|
||||
MMOCore.plugin.damage.damage(data, target, damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
MMOLib.plugin.getDamage().damage(data.getPlayer(), target, new AttackResult(damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL));
|
||||
target.setFireTicks(ignite);
|
||||
|
||||
}, 2, Particle.FLAME);
|
||||
|
@ -14,9 +14,11 @@ import net.Indyuce.mmocore.api.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class Fireball extends Skill {
|
||||
public Fireball() {
|
||||
@ -59,12 +61,12 @@ public class Fireball extends Skill {
|
||||
// loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
|
||||
|
||||
for (Entity target : MMOCoreUtils.getNearbyChunkEntities(loc))
|
||||
if (MMOCore.plugin.nms.getBoundingBox(target).expand(.2, .2, .2).contains(loc.toVector()) && MMOCoreUtils.canTarget(data.getPlayer(), target)) {
|
||||
if (target.getBoundingBox().expand(.2, .2, .2).contains(loc.toVector()) && MMOCoreUtils.canTarget(data.getPlayer(), target)) {
|
||||
loc.getWorld().spawnParticle(Particle.LAVA, loc, 8);
|
||||
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
|
||||
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
|
||||
target.setFireTicks((int) (target.getFireTicks() + cast.getModifier("ignite") * 20));
|
||||
MMOCore.plugin.damage.damage(data, (LivingEntity) target, cast.getModifier("damage"), DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
MMOLib.plugin.getDamage().damage(data.getPlayer(), (LivingEntity) target, new AttackResult(cast.getModifier("damage"), DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL));
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,15 @@ import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.api.math.particle.SmallParticleEffect;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
|
||||
public class Furtive_Strike extends Skill {
|
||||
public Furtive_Strike() {
|
||||
@ -46,7 +47,7 @@ public class Furtive_Strike extends Skill {
|
||||
damage *= 1 + cast.getModifier("extra") / 100;
|
||||
}
|
||||
|
||||
MMOCore.plugin.damage.damage(data, target, damage, DamageType.SKILL, DamageType.PHYSICAL);
|
||||
MMOLib.plugin.getDamage().damage(data.getPlayer(), target, new AttackResult(damage, DamageType.SKILL, DamageType.PHYSICAL));
|
||||
return cast;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class Human_Shield extends Skill {
|
||||
public Human_Shield() {
|
||||
|
@ -18,8 +18,10 @@ import net.Indyuce.mmocore.api.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.AttackResult;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class Ice_Spikes extends Skill {
|
||||
|
||||
@ -67,7 +69,7 @@ public class Ice_Spikes extends Skill {
|
||||
Line3D line = new Line3D(loc.toVector(), loc.toVector().add(new Vector(0, 1, 0)));
|
||||
for (Entity entity : MMOCoreUtils.getNearbyChunkEntities(loc1))
|
||||
if (line.distanceSquared(entity.getLocation().toVector()) < 3 && Math.abs(entity.getLocation().getY() - loc1.getY()) < 10 && MMOCoreUtils.canTarget(data.getPlayer(), entity)) {
|
||||
MMOCore.plugin.damage.damage(data, (LivingEntity) entity, damage, DamageType.SKILL, DamageType.MAGICAL);
|
||||
MMOLib.plugin.getDamage().damage(data.getPlayer(), (LivingEntity) entity, new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL));
|
||||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, slow, 0));
|
||||
}
|
||||
}
|
||||
@ -84,7 +86,8 @@ public class Ice_Spikes extends Skill {
|
||||
|
||||
public IceSpikesCast(PlayerData data, SkillInfo skill) {
|
||||
super(data, skill);
|
||||
if (isSuccessful() && (loc = MMOCore.plugin.version.getVersionWrapper().rayTrace(data.getPlayer(), 30)) == null)
|
||||
if (isSuccessful() && (loc = data.getPlayer().getWorld().rayTraceEntities(data.getPlayer().getEyeLocation(),
|
||||
data.getPlayer().getEyeLocation().getDirection(), 30, (entity) -> MMOCoreUtils.canTarget(data.getPlayer(), entity))) == null)
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.stats.TemporaryStats;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.mmogroup.mmolib.api.DamageType;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class Power_Mark extends Skill implements Listener {
|
||||
public Power_Mark() {
|
||||
|
@ -18,8 +18,8 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class Telekinesy extends Skill {
|
||||
public Telekinesy() {
|
||||
|
@ -11,7 +11,7 @@ import net.Indyuce.mmocore.api.math.particle.ParabolicProjectile;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.version.VersionSound;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class Warp extends Skill {
|
||||
public Warp() {
|
||||
|
@ -18,7 +18,7 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||
|
||||
public class Weaken extends Skill {
|
||||
public Weaken() {
|
||||
|
@ -1,58 +0,0 @@
|
||||
package net.Indyuce.mmocore.version;
|
||||
|
||||
import net.Indyuce.mmocore.version.texture.CustomModelDataHandler;
|
||||
import net.Indyuce.mmocore.version.texture.TextureByDurabilityHandler;
|
||||
import net.Indyuce.mmocore.version.texture.TextureHandler;
|
||||
import net.Indyuce.mmocore.version.wrapper.DefaultVersionWrapper;
|
||||
import net.Indyuce.mmocore.version.wrapper.LegacyVersionWrapper;
|
||||
import net.Indyuce.mmocore.version.wrapper.VersionWrapper;
|
||||
|
||||
public class ServerVersion {
|
||||
private final String version;
|
||||
private final int[] integers;
|
||||
private final TextureHandler textureHandler;
|
||||
private final VersionWrapper versionWrapper;
|
||||
|
||||
public ServerVersion(Class<?> clazz) {
|
||||
this.version = clazz.getPackage().getName().replace(".", ",").split(",")[3];
|
||||
String[] split = version.substring(1).split("\\_");
|
||||
this.integers = new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]) };
|
||||
|
||||
versionWrapper = isBelowOrEqual(1, 12) ? new LegacyVersionWrapper() : new DefaultVersionWrapper();
|
||||
textureHandler = isBelowOrEqual(1, 13) ? new TextureByDurabilityHandler() : new CustomModelDataHandler();
|
||||
}
|
||||
|
||||
public boolean isBelowOrEqual(int... version) {
|
||||
return version[0] > integers[0] ? true : version[1] >= integers[1];
|
||||
}
|
||||
|
||||
public boolean isStrictlyHigher(int... version) {
|
||||
return version[0] < integers[0] ? true : version[1] < integers[1];
|
||||
// return !isBelowOrEqual(version);
|
||||
}
|
||||
|
||||
public int getRevisionNumber() {
|
||||
return Integer.parseInt(version.split("\\_")[2].replaceAll("[^0-9]", ""));
|
||||
}
|
||||
|
||||
public int[] toNumbers() {
|
||||
return integers;
|
||||
}
|
||||
|
||||
public boolean isTextureByDurability() {
|
||||
return textureHandler instanceof TextureByDurabilityHandler;
|
||||
}
|
||||
|
||||
public TextureHandler getTextureHandler() {
|
||||
return textureHandler;
|
||||
}
|
||||
|
||||
public VersionWrapper getVersionWrapper() {
|
||||
return versionWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return version;
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package net.Indyuce.mmocore.version;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class SpigotPlugin {
|
||||
private JavaPlugin plugin;
|
||||
private int id;
|
||||
private String version;
|
||||
|
||||
public SpigotPlugin(int id, JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/*
|
||||
* the request is executed asynchronously as not to block the main thread.
|
||||
*/
|
||||
public void checkForUpdate() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
try {
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=" + id).openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
version = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().log(Level.INFO, "Couldn't check the latest plugin version :/");
|
||||
return;
|
||||
}
|
||||
|
||||
if (version.equals(plugin.getDescription().getVersion()))
|
||||
return;
|
||||
|
||||
plugin.getLogger().log(Level.INFO, "A new build is available: " + version + " (you are running " + plugin.getDescription().getVersion() + ")");
|
||||
plugin.getLogger().log(Level.INFO, "Download it here: " + getResourceUrl());
|
||||
|
||||
/*
|
||||
* registers the event to notify op players when they join only if
|
||||
* the corresponding option is enabled
|
||||
*/
|
||||
if (plugin.getConfig().getBoolean("update-notify"))
|
||||
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().registerEvents(new Listener() {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPermission(plugin.getName().toLowerCase() + ".update-notify"))
|
||||
getOutOfDateMessage().forEach(msg -> player.sendMessage(ChatColor.translateAlternateColorCodes('&', msg)));
|
||||
}
|
||||
}, plugin));
|
||||
});
|
||||
}
|
||||
|
||||
private List<String> getOutOfDateMessage() {
|
||||
return Arrays.asList("&8--------------------------------------------", "&a" + plugin.getName() + " " + version + " is available!", "&a" + getResourceUrl(), "&7&oYou can disable this notification in the config file.", "&8--------------------------------------------");
|
||||
}
|
||||
public String getResourceUrl() {
|
||||
return "https://www.spigotmc.org/resources/" + id + "/";
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package net.Indyuce.mmocore.version;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
||||
public enum VersionMaterial {
|
||||
|
||||
/*
|
||||
* the enum object name corresponds to the 1.14 material name. the first
|
||||
* argument corresponds to the 1.13 name. second argument corresponds to
|
||||
* legacy, third is DURABILITY if needed only.
|
||||
*/
|
||||
|
||||
OAK_SIGN("SIGN", "SIGN"),
|
||||
LAPIS_LAZULI("LAPIS_LAZULI", "INK_SACK", 4),
|
||||
LIME_DYE("LIME_DYE", "INK_SACK", 5),
|
||||
LIGHT_GRAY_DYE("LIGHT_GRAY_DYE", "INK_SACK", 7),
|
||||
GRAY_DYE("GRAY_DYE", "INK_SACK", 8),
|
||||
LIGHT_BLUE_DYE("LIGHT_BLUE_DYE", "INK_SACK", 12),
|
||||
RED_DYE("ROSE_RED", "INK_SACK", 14),
|
||||
BONE_MEAL("BONE_MEAL", "INK_SACK", 18),
|
||||
MAGENTA_DYE("MAGENTA_DYE", "INK_SACK", 13),
|
||||
GRAY_STAINED_GLASS_PANE("GRAY_STAINED_GLASS_PANE", "STAINED_GLASS_PANE", 7),
|
||||
RED_STAINED_GLASS_PANE("RED_STAINED_GLASS_PANE", "STAINED_GLASS_PANE", 14),
|
||||
GREEN_STAINED_GLASS_PANE("GREEN_STAINED_GLASS_PANE", "STAINED_GLASS_PANE", 13),
|
||||
LIME_STAINED_GLASS("LIME_STAINED_GLASS", "STAINED_GLASS", 5),
|
||||
PINK_STAINED_GLASS("PINK_STAINED_GLASS", "STAINED_GLASS", 6),
|
||||
PLAYER_HEAD("PLAYER_HEAD", "SKULL_ITEM", 3),
|
||||
PLAYER_WALL_HEAD("PLAYER_WALL_HEAD", "SKULL_ITEM", 3),
|
||||
SKELETON_SKULL("SKELETON_SKULL", "SKULL_ITEM"),
|
||||
WITHER_SKELETON_SKULL("WITHER_SKELETON_SKULL", "SKULL_ITEM", 1),
|
||||
NETHER_WART("NETHER_WART", "NETHER_STALK"),
|
||||
WRITABLE_BOOK("WRITABLE_BOOK", "BOOK_AND_QUILL"),
|
||||
CRAFTING_TABLE("CRAFTING_TABLE", "WORKBENCH"),
|
||||
SNOWBALL("SNOWBALL", "SNOW_BALL"),
|
||||
LILY_PAD("LILY_PAD", "WATER_LILY"),
|
||||
GUNPOWDER("GUNPOWDER", "SULPHUR"),
|
||||
OAK_SAPLING("OAK_SAPLING", "SAPLING"),
|
||||
COMPARATOR("COMPARATOR", "REDSTONE_COMPARATOR"),
|
||||
EXPERIENCE_BOTTLE("EXPERIENCE_BOTTLE", "EXP_BOTTLE"),
|
||||
IRON_HORSE_ARMOR("IRON_HORSE_ARMOR", "IRON_BARDING"),
|
||||
MUSIC_DISC_MALL("MUSIC_DISC_MALL", "RECORD_8"),
|
||||
COBBLESTONE_WALL("COBBLESTONE_WALL", "COBBLE_WALL"),
|
||||
ENDER_EYE("ENDER_EYE", "EYE_OF_ENDER"),
|
||||
GRASS_BLOCK("GRASS_BLOCK", "GRASS"),
|
||||
ENCHANTING_TABLE("ENCHANTING_TABLE", "ENCHANTMENT_TABLE"),
|
||||
PORKCHOP("PORKCHOP", "PORK"),
|
||||
GOLDEN_CHESTPLATE("GOLDEN_CHESTPLATE", "GOLD_CHESTPLATE"),
|
||||
GOLDEN_HORSE_ARMOR("GOLDEN_HORSE_ARMOR", "GOLD_BARDING"),
|
||||
COMMAND_BLOCK_MINECART("COMMAND_BLOCK_MINECART", "COMMAND_MINECART"),
|
||||
OAK_PLANKS("OAK_PLANKS", "WOOD"),
|
||||
CAULDRON("CAULDRON", "CAULDRON_ITEM"),
|
||||
FIRE_CHARGE("FIRE_CHARGE", "FIREBALL"),
|
||||
TOTEM_OF_UNDYING("TOTEM_OF_UNDYING", "SHIELD"),
|
||||
|
||||
;
|
||||
|
||||
private Material material;
|
||||
private ItemStack item;
|
||||
|
||||
private VersionMaterial(String name_1_13, String legacy) {
|
||||
material = Material.valueOf(MMOCore.plugin.version.isStrictlyHigher(1, 13) ? name() : MMOCore.plugin.version.isStrictlyHigher(1, 12) ? name_1_13 : legacy);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private VersionMaterial(String name_1_13, String legacy, int legacyDurability) {
|
||||
if (MMOCore.plugin.version.isStrictlyHigher(1, 12))
|
||||
material = Material.valueOf(MMOCore.plugin.version.isStrictlyHigher(1, 13) ? name() : name_1_13);
|
||||
else
|
||||
item = new ItemStack(material = Material.valueOf(legacy), 1, (short) legacyDurability);
|
||||
}
|
||||
|
||||
public Material toMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public boolean hasItem() {
|
||||
return item != null;
|
||||
}
|
||||
|
||||
public ItemStack toItem() {
|
||||
return hasItem() ? item.clone() : new ItemStack(material);
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package net.Indyuce.mmocore.version;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
||||
public enum VersionSound {
|
||||
ENTITY_ENDERMAN_HURT("ENTITY_ENDERMEN_HURT"),
|
||||
ENTITY_ENDERMAN_DEATH("ENTITY_ENDERMEN_DEATH"),
|
||||
ENTITY_ENDERMAN_TELEPORT("ENTITY_ENDERMEN_TELEPORT"),
|
||||
ENTITY_FIREWORK_ROCKET_LARGE_BLAST("ENTITY_FIREWORK_LARGE_BLAST"),
|
||||
ENTITY_FIREWORK_ROCKET_TWINKLE("ENTITY_FIREWORK_TWINKLE"),
|
||||
ENTITY_FIREWORK_ROCKET_BLAST("ENTITY_FIREWORK_BLAST"),
|
||||
ENTITY_ZOMBIE_PIGMAN_ANGRY("ENTITY_ZOMBIE_PIG_ANGRY"),
|
||||
BLOCK_NOTE_BLOCK_HAT("BLOCK_NOTE_HAT"),
|
||||
BLOCK_NOTE_BLOCK_PLING("BLOCK_NOTE_PLING"),
|
||||
BLOCK_NOTE_BLOCK_BELL("BLOCK_NOTE_BELL"),
|
||||
ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR("ENTITY_ZOMBIE_ATTACK_DOOR_WOOD"),
|
||||
ENTITY_ENDER_DRAGON_GROWL("ENTITY_ENDERDRAGON_GROWL"),
|
||||
ENTITY_ENDER_DRAGON_FLAP("ENTITY_ENDERDRAGON_FLAP"),
|
||||
|
||||
;
|
||||
|
||||
private final Sound sound;
|
||||
|
||||
private VersionSound(String legacy) {
|
||||
sound = Sound.valueOf(MMOCore.plugin.version.isStrictlyHigher(1, 12) ? name() : legacy);
|
||||
}
|
||||
|
||||
public Sound toSound() {
|
||||
return sound;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.nms;
|
||||
|
||||
public class ItemTag {
|
||||
private final String path;
|
||||
private final Object value;
|
||||
|
||||
public ItemTag(String path, Object value) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.nms;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
|
||||
public interface NMSHandler {
|
||||
NBTItem getNBTItem(ItemStack item);
|
||||
|
||||
void sendTitle(Player player, String title, String subtitle, int fadeIn, int ticks, int fadeOut);
|
||||
|
||||
void sendActionBar(Player player, String message);
|
||||
|
||||
void sendJson(Player player, String message);
|
||||
|
||||
int getNextContainerId(Player player);
|
||||
|
||||
void handleInventoryCloseEvent(Player player);
|
||||
|
||||
void sendPacketOpenWindow(Player player, int containerId);
|
||||
|
||||
void sendPacketCloseWindow(Player player, int containerId);
|
||||
|
||||
void setActiveContainerDefault(Player player);
|
||||
|
||||
void setActiveContainer(Player player, Object container);
|
||||
|
||||
void setActiveContainerId(Object container, int containerId);
|
||||
|
||||
void addActiveContainerSlotListener(Object container, Player player);
|
||||
|
||||
Inventory toBukkitInventory(Object container);
|
||||
|
||||
Object newContainerAnvil(Player player);
|
||||
|
||||
BoundingBox getBoundingBox(Entity target);
|
||||
|
||||
String getSkullValue(Block block);
|
||||
|
||||
void setSkullValue(Block block, String value);
|
||||
}
|
@ -1,208 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.nms;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.minecraft.server.v1_12_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_12_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_12_R1.Blocks;
|
||||
import net.minecraft.server.v1_12_R1.ChatMessage;
|
||||
import net.minecraft.server.v1_12_R1.ChatMessageType;
|
||||
import net.minecraft.server.v1_12_R1.Container;
|
||||
import net.minecraft.server.v1_12_R1.ContainerAnvil;
|
||||
import net.minecraft.server.v1_12_R1.Entity;
|
||||
import net.minecraft.server.v1_12_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_12_R1.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_12_R1.ItemStack;
|
||||
import net.minecraft.server.v1_12_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutChat;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutCloseWindow;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutTitle;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutTitle.EnumTitleAction;
|
||||
import net.minecraft.server.v1_12_R1.TileEntitySkull;
|
||||
|
||||
public class NMSHandler_1_12_R1 implements NMSHandler {
|
||||
@Override
|
||||
public void sendJson(Player player, String message) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a(message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(Player player, String msgTitle, String msgSubTitle, int fadeIn, int ticks, int fadeOut) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("{\"text\": \"" + msgTitle + "\"}")));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, ChatSerializer.a("{\"text\": \"" + msgSubTitle + "\"}")));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.TIMES, null, fadeIn, ticks, fadeOut));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(Player player, String message) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a("{\"text\": \"" + message + "\"}"), ChatMessageType.GAME_INFO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextContainerId(Player player) {
|
||||
return ((CraftPlayer) player).getHandle().nextContainerCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInventoryCloseEvent(Player player) {
|
||||
CraftEventFactory.handleInventoryCloseEvent(((CraftPlayer) player).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketOpenWindow(Player player, int containerId) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerId, "minecraft:anvil", new ChatMessage(Blocks.ANVIL.a() + ".name")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketCloseWindow(Player player, int containerId) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutCloseWindow(containerId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainerDefault(Player player) {
|
||||
((CraftPlayer) player).getHandle().activeContainer = ((CraftPlayer) player).getHandle().defaultContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainer(Player player, Object container) {
|
||||
((CraftPlayer) player).getHandle().activeContainer = (Container) container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainerId(Object container, int containerId) {
|
||||
((Container) container).windowId = containerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addActiveContainerSlotListener(Object container, Player player) {
|
||||
((Container) container).addSlotListener(((CraftPlayer) player).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory toBukkitInventory(Object container) {
|
||||
return ((Container) container).getBukkitView().getTopInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object newContainerAnvil(Player player) {
|
||||
return new AnvilContainer(((CraftPlayer) player).getHandle());
|
||||
}
|
||||
|
||||
private class AnvilContainer extends ContainerAnvil {
|
||||
public AnvilContainer(EntityHuman entityhuman) {
|
||||
super(entityhuman.inventory, entityhuman.world, new BlockPosition(0, 0, 0), entityhuman);
|
||||
this.checkReachable = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem getNBTItem(org.bukkit.inventory.ItemStack item) {
|
||||
return new NBTItem_v1_13_1(item);
|
||||
}
|
||||
|
||||
public class NBTItem_v1_13_1 extends NBTItem {
|
||||
private final ItemStack nms;
|
||||
private final NBTTagCompound compound;
|
||||
|
||||
public NBTItem_v1_13_1(org.bukkit.inventory.ItemStack item) {
|
||||
super(item);
|
||||
nms = CraftItemStack.asNMSCopy(item);
|
||||
compound = nms.hasTag() ? nms.getTag() : new NBTTagCompound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String path) {
|
||||
return compound.getString(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String path) {
|
||||
return compound.hasKey(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(String path) {
|
||||
return compound.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String path) {
|
||||
return compound.getDouble(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(String path) {
|
||||
return compound.getInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem add(ItemTag... tags) {
|
||||
for (ItemTag tag : tags) {
|
||||
if (tag.getValue() instanceof Boolean)
|
||||
compound.setBoolean(tag.getPath(), (boolean) tag.getValue());
|
||||
else if (tag.getValue() instanceof Double)
|
||||
compound.setDouble(tag.getPath(), (double) tag.getValue());
|
||||
else if (tag.getValue() instanceof String)
|
||||
compound.setString(tag.getPath(), (String) tag.getValue());
|
||||
else if (tag.getValue() instanceof Integer)
|
||||
compound.setInt(tag.getPath(), (int) tag.getValue());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem remove(String... paths) {
|
||||
for (String path : paths)
|
||||
compound.remove(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getTags() {
|
||||
return compound.c();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack toItem() {
|
||||
nms.setTag(compound);
|
||||
return CraftItemStack.asBukkitCopy(nms);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getBoundingBox(org.bukkit.entity.Entity target) {
|
||||
AxisAlignedBB aabb = ((Entity) target).getBoundingBox();
|
||||
return new BoundingBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkullValue(Block block) {
|
||||
TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||
if(skullTile.getGameProfile() == null) return "";
|
||||
return skullTile.getGameProfile().getProperties().get("textures").iterator().next().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullValue(Block block, String value) {
|
||||
TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", value));
|
||||
skullTile.setGameProfile(profile);
|
||||
skullTile.update();
|
||||
}
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.nms;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.minecraft.server.v1_13_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_13_R1.Blocks;
|
||||
import net.minecraft.server.v1_13_R1.ChatMessage;
|
||||
import net.minecraft.server.v1_13_R1.ChatMessageType;
|
||||
import net.minecraft.server.v1_13_R1.Container;
|
||||
import net.minecraft.server.v1_13_R1.ContainerAnvil;
|
||||
import net.minecraft.server.v1_13_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_13_R1.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_13_R1.ItemStack;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayOutChat;
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayOutCloseWindow;
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayOutTitle;
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayOutTitle.EnumTitleAction;
|
||||
import net.minecraft.server.v1_13_R1.TileEntitySkull;
|
||||
|
||||
public class NMSHandler_1_13_R1 implements NMSHandler {
|
||||
@Override
|
||||
public void sendJson(Player player, String message) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a(message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(Player player, String msgTitle, String msgSubTitle, int fadeIn, int ticks, int fadeOut) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("{\"text\": \"" + msgTitle + "\"}")));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, ChatSerializer.a("{\"text\": \"" + msgSubTitle + "\"}")));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.TIMES, null, fadeIn, ticks, fadeOut));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(Player player, String message) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a("{\"text\": \"" + message + "\"}"), ChatMessageType.GAME_INFO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextContainerId(Player player) {
|
||||
return ((CraftPlayer) player).getHandle().nextContainerCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInventoryCloseEvent(Player player) {
|
||||
CraftEventFactory.handleInventoryCloseEvent(((CraftPlayer) player).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketOpenWindow(Player player, int containerId) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerId, "minecraft:anvil", new ChatMessage(Blocks.ANVIL.a() + ".name")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketCloseWindow(Player player, int containerId) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutCloseWindow(containerId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainerDefault(Player player) {
|
||||
((CraftPlayer) player).getHandle().activeContainer = ((CraftPlayer) player).getHandle().defaultContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainer(Player player, Object container) {
|
||||
((CraftPlayer) player).getHandle().activeContainer = (Container) container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainerId(Object container, int containerId) {
|
||||
((Container) container).windowId = containerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addActiveContainerSlotListener(Object container, Player player) {
|
||||
((Container) container).addSlotListener(((CraftPlayer) player).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory toBukkitInventory(Object container) {
|
||||
return ((Container) container).getBukkitView().getTopInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object newContainerAnvil(Player player) {
|
||||
return new AnvilContainer(((CraftPlayer) player).getHandle());
|
||||
}
|
||||
|
||||
private class AnvilContainer extends ContainerAnvil {
|
||||
public AnvilContainer(EntityHuman entityhuman) {
|
||||
super(entityhuman.inventory, entityhuman.world, new BlockPosition(0, 0, 0), entityhuman);
|
||||
this.checkReachable = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem getNBTItem(org.bukkit.inventory.ItemStack item) {
|
||||
return new NBTItem_v1_13_1(item);
|
||||
}
|
||||
|
||||
public class NBTItem_v1_13_1 extends NBTItem {
|
||||
private final ItemStack nms;
|
||||
private final NBTTagCompound compound;
|
||||
|
||||
public NBTItem_v1_13_1(org.bukkit.inventory.ItemStack item) {
|
||||
super(item);
|
||||
nms = CraftItemStack.asNMSCopy(item);
|
||||
compound = nms.hasTag() ? nms.getTag() : new NBTTagCompound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String path) {
|
||||
return compound.getString(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String path) {
|
||||
return compound.hasKey(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(String path) {
|
||||
return compound.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String path) {
|
||||
return compound.getDouble(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(String path) {
|
||||
return compound.getInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem add(ItemTag... tags) {
|
||||
for (ItemTag tag : tags) {
|
||||
if (tag.getValue() instanceof Boolean)
|
||||
compound.setBoolean(tag.getPath(), (boolean) tag.getValue());
|
||||
else if (tag.getValue() instanceof Double)
|
||||
compound.setDouble(tag.getPath(), (double) tag.getValue());
|
||||
else if (tag.getValue() instanceof String)
|
||||
compound.setString(tag.getPath(), (String) tag.getValue());
|
||||
else if (tag.getValue() instanceof Integer)
|
||||
compound.setInt(tag.getPath(), (int) tag.getValue());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem remove(String... paths) {
|
||||
for (String path : paths)
|
||||
compound.remove(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getTags() {
|
||||
return compound.getKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack toItem() {
|
||||
nms.setTag(compound);
|
||||
return CraftItemStack.asBukkitCopy(nms);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getBoundingBox(Entity target) {
|
||||
return target.getBoundingBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkullValue(Block block) {
|
||||
TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||
if(skullTile.getGameProfile() == null) return "";
|
||||
return skullTile.getGameProfile().getProperties().get("textures").iterator().next().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullValue(Block block, String value) {
|
||||
TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", value));
|
||||
skullTile.setGameProfile(profile);
|
||||
skullTile.update();
|
||||
}
|
||||
}
|
@ -1,207 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.nms;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.minecraft.server.v1_13_R2.BlockPosition;
|
||||
import net.minecraft.server.v1_13_R2.Blocks;
|
||||
import net.minecraft.server.v1_13_R2.ChatMessage;
|
||||
import net.minecraft.server.v1_13_R2.ChatMessageType;
|
||||
import net.minecraft.server.v1_13_R2.Container;
|
||||
import net.minecraft.server.v1_13_R2.ContainerAnvil;
|
||||
import net.minecraft.server.v1_13_R2.EntityHuman;
|
||||
import net.minecraft.server.v1_13_R2.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_13_R2.ItemStack;
|
||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutChat;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutCloseWindow;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutTitle;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayOutTitle.EnumTitleAction;
|
||||
import net.minecraft.server.v1_13_R2.TileEntitySkull;
|
||||
|
||||
public class NMSHandler_1_13_R2 implements NMSHandler {
|
||||
@Override
|
||||
public void sendJson(Player player, String message) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a(message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(Player player, String msgTitle, String msgSubTitle, int fadeIn, int ticks, int fadeOut) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("{\"text\": \"" + msgTitle + "\"}")));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, ChatSerializer.a("{\"text\": \"" + msgSubTitle + "\"}")));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.TIMES, null, fadeIn, ticks, fadeOut));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(Player player, String message) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a("{\"text\": \"" + message + "\"}"), ChatMessageType.GAME_INFO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextContainerId(Player player) {
|
||||
return ((CraftPlayer) player).getHandle().nextContainerCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInventoryCloseEvent(Player player) {
|
||||
CraftEventFactory.handleInventoryCloseEvent(((CraftPlayer) player).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketOpenWindow(Player player, int containerId) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerId, "minecraft:anvil", new ChatMessage(Blocks.ANVIL.a() + ".name")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketCloseWindow(Player player, int containerId) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutCloseWindow(containerId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainerDefault(Player player) {
|
||||
((CraftPlayer) player).getHandle().activeContainer = ((CraftPlayer) player).getHandle().defaultContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainer(Player player, Object container) {
|
||||
((CraftPlayer) player).getHandle().activeContainer = (Container) container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainerId(Object container, int containerId) {
|
||||
((Container) container).windowId = containerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addActiveContainerSlotListener(Object container, Player player) {
|
||||
((Container) container).addSlotListener(((CraftPlayer) player).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory toBukkitInventory(Object container) {
|
||||
return ((Container) container).getBukkitView().getTopInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object newContainerAnvil(Player player) {
|
||||
return new AnvilContainer(((CraftPlayer) player).getHandle());
|
||||
}
|
||||
|
||||
private class AnvilContainer extends ContainerAnvil {
|
||||
public AnvilContainer(EntityHuman entityhuman) {
|
||||
super(entityhuman.inventory, entityhuman.world, new BlockPosition(0, 0, 0), entityhuman);
|
||||
this.checkReachable = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem getNBTItem(org.bukkit.inventory.ItemStack item) {
|
||||
return new NBTItem_v1_13_2(item);
|
||||
}
|
||||
|
||||
public class NBTItem_v1_13_2 extends NBTItem {
|
||||
private final ItemStack nms;
|
||||
private final NBTTagCompound compound;
|
||||
|
||||
public NBTItem_v1_13_2(org.bukkit.inventory.ItemStack item) {
|
||||
super(item);
|
||||
|
||||
nms = CraftItemStack.asNMSCopy(item);
|
||||
compound = nms.hasTag() ? nms.getTag() : new NBTTagCompound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String path) {
|
||||
return compound.getString(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String path) {
|
||||
return compound.hasKey(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(String path) {
|
||||
return compound.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String path) {
|
||||
return compound.getDouble(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(String path) {
|
||||
return compound.getInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem add(ItemTag... tags) {
|
||||
for (ItemTag tag : tags) {
|
||||
if (tag.getValue() instanceof Boolean)
|
||||
compound.setBoolean(tag.getPath(), (boolean) tag.getValue());
|
||||
else if (tag.getValue() instanceof Double)
|
||||
compound.setDouble(tag.getPath(), (double) tag.getValue());
|
||||
else if (tag.getValue() instanceof String)
|
||||
compound.setString(tag.getPath(), (String) tag.getValue());
|
||||
else if (tag.getValue() instanceof Integer)
|
||||
compound.setInt(tag.getPath(), (int) tag.getValue());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem remove(String... paths) {
|
||||
for (String path : paths)
|
||||
compound.remove(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getTags() {
|
||||
return compound.getKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack toItem() {
|
||||
nms.setTag(compound);
|
||||
return CraftItemStack.asBukkitCopy(nms);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getBoundingBox(Entity target) {
|
||||
return target.getBoundingBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkullValue(Block block) {
|
||||
TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||
if(skullTile.getGameProfile() == null) return "";
|
||||
return skullTile.getGameProfile().getProperties().get("textures").iterator().next().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullValue(Block block, String value) {
|
||||
TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", value));
|
||||
skullTile.setGameProfile(profile);
|
||||
skullTile.update();
|
||||
}
|
||||
}
|
@ -1,229 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.nms;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_14_R1.ChatMessage;
|
||||
import net.minecraft.server.v1_14_R1.ChatMessageType;
|
||||
import net.minecraft.server.v1_14_R1.Container;
|
||||
import net.minecraft.server.v1_14_R1.ContainerAccess;
|
||||
import net.minecraft.server.v1_14_R1.ContainerAnvil;
|
||||
import net.minecraft.server.v1_14_R1.Containers;
|
||||
import net.minecraft.server.v1_14_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_14_R1.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_14_R1.ItemStack;
|
||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutChat;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutCloseWindow;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutTitle;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayOutTitle.EnumTitleAction;
|
||||
import net.minecraft.server.v1_14_R1.TileEntitySkull;
|
||||
|
||||
public class NMSHandler_1_14_R1 implements NMSHandler {
|
||||
@Override
|
||||
public void sendJson(Player player, String message) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a(message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(Player player, String msgTitle, String msgSubTitle, int fadeIn, int ticks, int fadeOut) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("{\"text\": \"" + msgTitle + "\"}")));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, ChatSerializer.a("{\"text\": \"" + msgSubTitle + "\"}")));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.TIMES, null, fadeIn, ticks, fadeOut));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(Player player, String message) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a("{\"text\": \"" + message + "\"}"), ChatMessageType.GAME_INFO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextContainerId(Player player) {
|
||||
return toNMS(player).nextContainerCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInventoryCloseEvent(Player player) {
|
||||
CraftEventFactory.handleInventoryCloseEvent(toNMS(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketOpenWindow(Player player, int containerId) {
|
||||
toNMS(player).playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerId, Containers.ANVIL, new ChatMessage("Repair & Name")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketCloseWindow(Player player, int containerId) {
|
||||
toNMS(player).playerConnection.sendPacket(new PacketPlayOutCloseWindow(containerId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainerDefault(Player player) {
|
||||
toNMS(player).activeContainer = toNMS(player).defaultContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainer(Player player, Object container) {
|
||||
toNMS(player).activeContainer = (Container) container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainerId(Object container, int containerId) {
|
||||
Field field = null;
|
||||
|
||||
try {
|
||||
field = Container.class.getField("windowId");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
FieldUtils.removeFinalModifier(field);
|
||||
|
||||
try {
|
||||
FieldUtils.writeField(field, container, containerId);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addActiveContainerSlotListener(Object container, Player player) {
|
||||
((Container) container).addSlotListener(toNMS(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory toBukkitInventory(Object container) {
|
||||
return ((Container) container).getBukkitView().getTopInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object newContainerAnvil(Player player) {
|
||||
return new AnvilContainer(player);
|
||||
}
|
||||
|
||||
private EntityPlayer toNMS(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
|
||||
private class AnvilContainer extends ContainerAnvil {
|
||||
public AnvilContainer(Player player) {
|
||||
super(getNextContainerId(player), ((CraftPlayer) player).getHandle().inventory, ContainerAccess.at(((CraftWorld) player.getWorld()).getHandle(), new BlockPosition(0, 0, 0)));
|
||||
this.checkReachable = false;
|
||||
setTitle(new ChatMessage("Repair & Name"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem getNBTItem(org.bukkit.inventory.ItemStack item) {
|
||||
return new NBTItem_v1_13_2(item);
|
||||
}
|
||||
|
||||
public class NBTItem_v1_13_2 extends NBTItem {
|
||||
private final ItemStack nms;
|
||||
private final NBTTagCompound compound;
|
||||
|
||||
public NBTItem_v1_13_2(org.bukkit.inventory.ItemStack item) {
|
||||
super(item);
|
||||
|
||||
nms = CraftItemStack.asNMSCopy(item);
|
||||
compound = nms.hasTag() ? nms.getTag() : new NBTTagCompound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String path) {
|
||||
return compound.getString(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String path) {
|
||||
return compound.hasKey(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(String path) {
|
||||
return compound.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String path) {
|
||||
return compound.getDouble(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(String path) {
|
||||
return compound.getInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem add(ItemTag... tags) {
|
||||
for (ItemTag tag : tags) {
|
||||
if (tag.getValue() instanceof Boolean)
|
||||
compound.setBoolean(tag.getPath(), (boolean) tag.getValue());
|
||||
else if (tag.getValue() instanceof Double)
|
||||
compound.setDouble(tag.getPath(), (double) tag.getValue());
|
||||
else if (tag.getValue() instanceof String)
|
||||
compound.setString(tag.getPath(), (String) tag.getValue());
|
||||
else if (tag.getValue() instanceof Integer)
|
||||
compound.setInt(tag.getPath(), (int) tag.getValue());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem remove(String... paths) {
|
||||
for (String path : paths)
|
||||
compound.remove(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getTags() {
|
||||
return compound.getKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack toItem() {
|
||||
nms.setTag(compound);
|
||||
return CraftItemStack.asBukkitCopy(nms);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getBoundingBox(Entity target) {
|
||||
return target.getBoundingBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkullValue(Block block) {
|
||||
TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||
if(skullTile.gameProfile == null) return "";
|
||||
return skullTile.gameProfile.getProperties().get("textures").iterator().next().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullValue(Block block, String value) {
|
||||
TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", value));
|
||||
skullTile.setGameProfile(profile);
|
||||
skullTile.update();
|
||||
}
|
||||
}
|
@ -1,229 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.nms;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_15_R1.ChatMessage;
|
||||
import net.minecraft.server.v1_15_R1.ChatMessageType;
|
||||
import net.minecraft.server.v1_15_R1.Container;
|
||||
import net.minecraft.server.v1_15_R1.ContainerAccess;
|
||||
import net.minecraft.server.v1_15_R1.ContainerAnvil;
|
||||
import net.minecraft.server.v1_15_R1.Containers;
|
||||
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_15_R1.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_15_R1.ItemStack;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutChat;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutCloseWindow;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutTitle;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayOutTitle.EnumTitleAction;
|
||||
import net.minecraft.server.v1_15_R1.TileEntitySkull;
|
||||
|
||||
public class NMSHandler_1_15_R1 implements NMSHandler {
|
||||
@Override
|
||||
public void sendJson(Player player, String message) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a(message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(Player player, String msgTitle, String msgSubTitle, int fadeIn, int ticks, int fadeOut) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("{\"text\": \"" + msgTitle + "\"}")));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, ChatSerializer.a("{\"text\": \"" + msgSubTitle + "\"}")));
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(EnumTitleAction.TIMES, null, fadeIn, ticks, fadeOut));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(Player player, String message) {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a("{\"text\": \"" + message + "\"}"), ChatMessageType.GAME_INFO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextContainerId(Player player) {
|
||||
return toNMS(player).nextContainerCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInventoryCloseEvent(Player player) {
|
||||
CraftEventFactory.handleInventoryCloseEvent(toNMS(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketOpenWindow(Player player, int containerId) {
|
||||
toNMS(player).playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerId, Containers.ANVIL, new ChatMessage("Repair & Name")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketCloseWindow(Player player, int containerId) {
|
||||
toNMS(player).playerConnection.sendPacket(new PacketPlayOutCloseWindow(containerId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainerDefault(Player player) {
|
||||
toNMS(player).activeContainer = toNMS(player).defaultContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainer(Player player, Object container) {
|
||||
toNMS(player).activeContainer = (Container) container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveContainerId(Object container, int containerId) {
|
||||
Field field = null;
|
||||
|
||||
try {
|
||||
field = Container.class.getField("windowId");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
FieldUtils.removeFinalModifier(field);
|
||||
|
||||
try {
|
||||
FieldUtils.writeField(field, container, containerId);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addActiveContainerSlotListener(Object container, Player player) {
|
||||
((Container) container).addSlotListener(toNMS(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory toBukkitInventory(Object container) {
|
||||
return ((Container) container).getBukkitView().getTopInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object newContainerAnvil(Player player) {
|
||||
return new AnvilContainer(player);
|
||||
}
|
||||
|
||||
private EntityPlayer toNMS(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
|
||||
private class AnvilContainer extends ContainerAnvil {
|
||||
public AnvilContainer(Player player) {
|
||||
super(getNextContainerId(player), ((CraftPlayer) player).getHandle().inventory, ContainerAccess.at(((CraftWorld) player.getWorld()).getHandle(), new BlockPosition(0, 0, 0)));
|
||||
this.checkReachable = false;
|
||||
setTitle(new ChatMessage("Repair & Name"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem getNBTItem(org.bukkit.inventory.ItemStack item) {
|
||||
return new NBTItem_v1_13_2(item);
|
||||
}
|
||||
|
||||
public class NBTItem_v1_13_2 extends NBTItem {
|
||||
private final ItemStack nms;
|
||||
private final NBTTagCompound compound;
|
||||
|
||||
public NBTItem_v1_13_2(org.bukkit.inventory.ItemStack item) {
|
||||
super(item);
|
||||
|
||||
nms = CraftItemStack.asNMSCopy(item);
|
||||
compound = nms.hasTag() ? nms.getTag() : new NBTTagCompound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String path) {
|
||||
return compound.getString(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String path) {
|
||||
return compound.hasKey(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(String path) {
|
||||
return compound.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String path) {
|
||||
return compound.getDouble(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(String path) {
|
||||
return compound.getInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem add(ItemTag... tags) {
|
||||
for (ItemTag tag : tags) {
|
||||
if (tag.getValue() instanceof Boolean)
|
||||
compound.setBoolean(tag.getPath(), (boolean) tag.getValue());
|
||||
else if (tag.getValue() instanceof Double)
|
||||
compound.setDouble(tag.getPath(), (double) tag.getValue());
|
||||
else if (tag.getValue() instanceof String)
|
||||
compound.setString(tag.getPath(), (String) tag.getValue());
|
||||
else if (tag.getValue() instanceof Integer)
|
||||
compound.setInt(tag.getPath(), (int) tag.getValue());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem remove(String... paths) {
|
||||
for (String path : paths)
|
||||
compound.remove(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getTags() {
|
||||
return compound.getKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack toItem() {
|
||||
nms.setTag(compound);
|
||||
return CraftItemStack.asBukkitCopy(nms);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getBoundingBox(Entity target) {
|
||||
return target.getBoundingBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkullValue(Block block) {
|
||||
TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||
if(skullTile.gameProfile == null) return "";
|
||||
return skullTile.gameProfile.getProperties().get("textures").iterator().next().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullValue(Block block, String value) {
|
||||
TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", value));
|
||||
skullTile.setGameProfile(profile);
|
||||
skullTile.update();
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.texture;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
|
||||
public class CustomModelDataHandler implements TextureHandler {
|
||||
@Override
|
||||
public NBTItem copyTexture(NBTItem item) {
|
||||
return MMOCore.plugin.nms.getNBTItem(new ItemStack(item.getItem().getType())).add(new ItemTag("CustomModelData", item.getInt("CustomModelData")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack textureItem(Material material, int model) {
|
||||
return MMOCore.plugin.nms.getNBTItem(new ItemStack(material)).add(new ItemTag("CustomModelData", model)).toItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem applyTexture(NBTItem item, int model) {
|
||||
return item.add(new ItemTag("CustomModelData", model));
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.texture;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||
|
||||
public class TextureByDurabilityHandler implements TextureHandler {
|
||||
@Override
|
||||
public NBTItem copyTexture(NBTItem item) {
|
||||
return MMOCore.plugin.nms.getNBTItem(new ItemStack(item.getItem().getType())).add(new ItemTag("Damage", item.getInt("Damage")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack textureItem(Material material, int model) {
|
||||
return MMOCore.plugin.nms.getNBTItem(new ItemStack(material)).add(new ItemTag("Damage", model), new ItemTag("Unbreakable", true)).toItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTItem applyTexture(NBTItem item, int model) {
|
||||
return item.add(new ItemTag("Damage", model));
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.texture;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||
|
||||
public interface TextureHandler {
|
||||
public NBTItem copyTexture(NBTItem item);
|
||||
|
||||
public ItemStack textureItem(Material material, int model);
|
||||
|
||||
public NBTItem applyTexture(NBTItem item, int model);
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.wrapper;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarFlag;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCoreUtils;
|
||||
|
||||
public class DefaultVersionWrapper implements VersionWrapper {
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Particle particle, Location loc, int amount, double x, double y, double z, double speed, float size, Color color) {
|
||||
loc.getWorld().spawnParticle(particle, loc, amount, x, y, z, speed, new Particle.DustOptions(color, size));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Particle particle, Location loc, int amount, double x, double y, double z, double speed, Material material) {
|
||||
loc.getWorld().spawnParticle(particle, loc, amount, x, y, z, 0, material.createBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enchantment getEnchantmentFromString(String s) {
|
||||
return Enchantment.getByKey(NamespacedKey.minecraft(s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FurnaceRecipe getFurnaceRecipe(NamespacedKey key, ItemStack item, Material material, float exp, int cook) {
|
||||
return new FurnaceRecipe(key, item, material, exp, cook);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(Player player, Vector direction, double range) {
|
||||
return player.getWorld().rayTraceEntities(player.getEyeLocation(), direction, range, (entity) -> MMOCoreUtils.canTarget(player, entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTrace(Player player, Vector direction, double range) {
|
||||
return player.rayTraceBlocks(range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossBar createBossBar(NamespacedKey key, String title, BarColor color, BarStyle style, BarFlag... flags) {
|
||||
return Bukkit.createBossBar(key, title, color, style, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCropFullyGrown(Block block) {
|
||||
if (block.getBlockData() instanceof Ageable) {
|
||||
Ageable ageable = (Ageable) block.getBlockData();
|
||||
return ageable.getAge() == ageable.getMaximumAge();
|
||||
} return false;
|
||||
}
|
||||
}
|
@ -1,224 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.wrapper;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarFlag;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Crops;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCoreUtils;
|
||||
import net.minecraft.server.v1_12_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_12_R1.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_12_R1.Vec3D;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class LegacyVersionWrapper implements VersionWrapper {
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Particle particle, Location loc, int amount, double x, double y, double z, double speed, float size, Color color) {
|
||||
loc.getWorld().spawnParticle(particle, loc, 0, (double) color.getRed() / 255, (double) color.getGreen() / 255, (double) color.getBlue() / 255, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Particle particle, Location loc, int amount, double x, double y, double z, double speed, Material material) {
|
||||
loc.getWorld().spawnParticle(particle, loc, amount, x, y, z, 0, new MaterialData(material));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BossBar createBossBar(NamespacedKey key, String title, BarColor color, BarStyle style, BarFlag... flags) {
|
||||
return Bukkit.createBossBar(title, color, style, flags);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Enchantment getEnchantmentFromString(String s) {
|
||||
if(s.equals("protection")) s = "PROTECTION_ENVIRONMENTAL";
|
||||
if(s.equals("fire_protection")) s = "PROTECTION_FIRE";
|
||||
if(s.equals("feather_falling")) s = "PROTECTION_FALL";
|
||||
if(s.equals("blast_protection")) s = "PROTECTION_EXPLOSIONS";
|
||||
if(s.equals("projectile_protection")) s = "PROTECTION_PROJECTILE";
|
||||
if(s.equals("respiration")) s = "OXYGEN";
|
||||
if(s.equals("aqua_affinity")) s = "WATER_WORKER";
|
||||
if(s.equals("sharpness")) s = "DAMAGE_ALL";
|
||||
if(s.equals("smite")) s = "DAMAGE_UNDEAD";
|
||||
if(s.equals("bane_of_arthropods")) s = "DAMAGE_ARTHROPODS";
|
||||
if(s.equals("looting")) s = "LOOT_BONUS_MOBS";
|
||||
if(s.equals("sweeping")) s = "SWEEPING_EDGE";
|
||||
if(s.equals("efficiency")) s = "DIG_SPEED";
|
||||
if(s.equals("unbreaking")) s = "DURABILITY";
|
||||
if(s.equals("fortune")) s = "LOOT_BONUS_BLOCKS";
|
||||
if(s.equals("power")) s = "ARROW_DAMAGE";
|
||||
if(s.equals("punch")) s = "ARROW_KNOCKBACK";
|
||||
if(s.equals("flame")) s = "ARROW_FIRE";
|
||||
if(s.equals("infinity")) s = "ARROW_INFINITE";
|
||||
if(s.equals("luck_of_the_sea")) s = "LUCK";
|
||||
|
||||
return Enchantment.getByName(s.toUpperCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public FurnaceRecipe getFurnaceRecipe(NamespacedKey key, ItemStack item, Material material, float exp, int cook) {
|
||||
try {
|
||||
return (FurnaceRecipe) Class.forName("org.bukkit.inventory.FurnaceRecipe").getConstructor(ItemStack.class, Material.class, Integer.TYPE, Integer.TYPE).newInstance(item, material, 0, (int) exp);
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException exception) {
|
||||
exception.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//I'm so sorry Indy.
|
||||
//I have no fucking clue what I'm doing :(
|
||||
@Override
|
||||
public RayTraceResult rayTrace(Player player, Vector direction, double range) {
|
||||
BlockIterator blocksToAdd = new BlockIterator(player.getWorld(), player.getLocation().toVector(), direction, 0.0d, (int) range);
|
||||
Location location = null;
|
||||
|
||||
while(blocksToAdd.hasNext()) {
|
||||
location = blocksToAdd.next().getLocation();
|
||||
}
|
||||
|
||||
if(location != null) return new RayTraceResult(location.toVector());
|
||||
|
||||
return new RayTraceResult(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(Player player, Vector direction, double range) {
|
||||
|
||||
Location loc = player.getEyeLocation();
|
||||
Vec3D vec = new Vec3D(loc.getDirection().getX(), loc.getDirection().getY(), loc.getDirection().getZ());
|
||||
MovingObjectPosition block = ((CraftPlayer) player).getHandle().getBoundingBox().b(vec, new Vec3D(vec.x, vec.y, vec.z).add(range * vec.x, range * vec.y, range * vec.z));
|
||||
|
||||
double d = block == null ? range : Math.sqrt(block.pos.distanceSquared(new Vec3D(loc.getX(), loc.getY(), loc.getZ())));
|
||||
Ray3D line = new Ray3D(player.getEyeLocation());
|
||||
for (Entity entity : player.getNearbyEntities(d, d, d))
|
||||
if (line.intersectsRay(((CraftEntity) entity).getHandle().getBoundingBox()) && MMOCoreUtils.canTarget(player, entity))
|
||||
return new RayTraceResult(entity.getLocation().toVector(), (LivingEntity) entity);
|
||||
|
||||
return new RayTraceResult(null);
|
||||
}
|
||||
|
||||
public class Ray3D extends Vec3D {
|
||||
public final Vec3D dir;
|
||||
|
||||
/*
|
||||
* warning, direction is not normalized
|
||||
*/
|
||||
public Ray3D(Vec3D origin, Vec3D direction) {
|
||||
super(origin.x, origin.y, origin.z);
|
||||
dir = direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a 3D ray from a location.
|
||||
*
|
||||
* @param loc
|
||||
* - the Bukkit location.
|
||||
*/
|
||||
public Ray3D(Location loc) {
|
||||
this(new Vec3D(loc.getX(), loc.getY(), loc.getZ()), new Vec3D(loc.getDirection().getX(), loc.getDirection().getY(), loc.getDirection().getZ()));
|
||||
}
|
||||
|
||||
public Vec3D getDirection() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "origin: " + super.toString() + " dir: " + dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates intersection with the given ray between a certain distance
|
||||
* interval.
|
||||
* <p>
|
||||
* Ray-box intersection is using IEEE numerical properties to ensure the
|
||||
* test is both robust and efficient, as described in: <br>
|
||||
* <code>Amy Williams, Steve Barrus, R. Keith Morley, and Peter Shirley: "An
|
||||
* Efficient and Robust Ray-Box Intersection Algorithm" Journal of graphics
|
||||
* tools, 10(1):49-54, 2005</code>
|
||||
*
|
||||
* @param ray
|
||||
* incident ray
|
||||
* @param minDist
|
||||
* @param maxDist
|
||||
* @return intersection point on the bounding box (only the first is
|
||||
* returned) or null if no intersection
|
||||
*/
|
||||
public boolean intersectsRay(AxisAlignedBB box) {
|
||||
Vec3D invDir = new Vec3D(1f / dir.x, 1f / dir.y, 1f / dir.z);
|
||||
|
||||
Vec3D min = new Vec3D(box.a, box.b, box.c);
|
||||
Vec3D max = new Vec3D(box.d, box.e, box.f);
|
||||
|
||||
boolean signDirX = invDir.x < 0;
|
||||
boolean signDirY = invDir.y < 0;
|
||||
boolean signDirZ = invDir.z < 0;
|
||||
|
||||
Vec3D bbox = signDirX ? max : min;
|
||||
double tmin = (bbox.x - x) * invDir.x;
|
||||
bbox = signDirX ? min : max;
|
||||
double tmax = (bbox.x - x) * invDir.x;
|
||||
bbox = signDirY ? max : min;
|
||||
double tymin = (bbox.y - y) * invDir.y;
|
||||
bbox = signDirY ? min : max;
|
||||
double tymax = (bbox.y - y) * invDir.y;
|
||||
|
||||
if ((tmin > tymax) || (tymin > tmax)) {
|
||||
return false;
|
||||
}
|
||||
if (tymin > tmin) {
|
||||
tmin = tymin;
|
||||
}
|
||||
if (tymax < tmax) {
|
||||
tmax = tymax;
|
||||
}
|
||||
|
||||
bbox = signDirZ ? max : min;
|
||||
double tzmin = (bbox.z - z) * invDir.z;
|
||||
bbox = signDirZ ? min : max;
|
||||
double tzmax = (bbox.z - z) * invDir.z;
|
||||
|
||||
if ((tmin > tzmax) || (tzmin > tmax)) {
|
||||
return false;
|
||||
}
|
||||
if (tzmin > tmin) {
|
||||
tmin = tzmin;
|
||||
}
|
||||
if (tzmax < tmax) {
|
||||
tmax = tzmax;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCropFullyGrown(Block block) {
|
||||
if(block.getState().getData() instanceof Crops) {
|
||||
Crops ageable = (Crops) block.getState().getData();
|
||||
return ageable.getState().equals(CropState.RIPE);
|
||||
} return false;
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package net.Indyuce.mmocore.version.wrapper;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarFlag;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public interface VersionWrapper {
|
||||
default void spawnParticle(Particle particle, Location loc, Color color) {
|
||||
spawnParticle(particle, loc, 1, 0, 0, 0, 0, 1, color);
|
||||
}
|
||||
|
||||
default void spawnParticle(Particle particle, Location loc, float size, Color color) {
|
||||
spawnParticle(particle, loc, 1, 0, 0, 0, 0, size, color);
|
||||
}
|
||||
|
||||
default void spawnParticle(Particle particle, Location loc, Material material) {
|
||||
spawnParticle(particle, loc, 1, 0, 0, 0, 0, material);
|
||||
}
|
||||
|
||||
void spawnParticle(Particle particle, Location loc, int amount, double x, double y, double z, double speed, float size, Color color);
|
||||
|
||||
void spawnParticle(Particle particle, Location loc, int amount, double x, double y, double z, double speed, Material material);
|
||||
|
||||
BossBar createBossBar(NamespacedKey key, String title, BarColor color, BarStyle style, BarFlag... flags);
|
||||
|
||||
Enchantment getEnchantmentFromString(String s);
|
||||
|
||||
FurnaceRecipe getFurnaceRecipe(NamespacedKey key, ItemStack item, Material material, float exp, int cook);
|
||||
|
||||
|
||||
default RayTraceResult rayTrace(Player player, double range) {
|
||||
return rayTrace(player, player.getEyeLocation().getDirection(), range);
|
||||
}
|
||||
|
||||
RayTraceResult rayTrace(Player player, Vector direction, double range);
|
||||
|
||||
|
||||
default RayTraceResult rayTraceEntities(Player player, double range) {
|
||||
return rayTraceEntities(player, player.getEyeLocation().getDirection(), range);
|
||||
}
|
||||
|
||||
RayTraceResult rayTraceEntities(Player player, Vector direction, double range);
|
||||
|
||||
boolean isCropFullyGrown(Block block);
|
||||
}
|
Loading…
Reference in New Issue
Block a user