forked from Upstream/mmocore
1.12.2 support (still needs legacy configs!)
This commit is contained in:
parent
0edbbd977a
commit
ea48b9616b
@ -7,6 +7,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Arnah
|
* @author Arnah
|
||||||
* @since Jul 30, 2015
|
* @since Jul 30, 2015
|
||||||
@ -46,7 +48,7 @@ public enum ArmorType {
|
|||||||
|
|
||||||
Material type = item.getType();
|
Material type = item.getType();
|
||||||
String name = type.name();
|
String name = type.name();
|
||||||
if (name.endsWith("HELMET") || name.endsWith("SKULL") || name.endsWith("HEAD") || type == Material.PLAYER_HEAD || type == Material.PUMPKIN)
|
if (name.endsWith("HELMET") || name.endsWith("SKULL") || name.endsWith("HEAD") || type == VersionMaterial.PLAYER_HEAD.toMaterial() || type == Material.PUMPKIN)
|
||||||
return HELMET;
|
return HELMET;
|
||||||
|
|
||||||
else if (name.endsWith("CHESTPLATE"))
|
else if (name.endsWith("CHESTPLATE"))
|
||||||
|
@ -4,7 +4,6 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.potion.PotionType;
|
import org.bukkit.potion.PotionType;
|
||||||
@ -72,7 +71,7 @@ public class Profession {
|
|||||||
if (config.contains("base-enchant-exp"))
|
if (config.contains("base-enchant-exp"))
|
||||||
for (String key : config.getConfigurationSection("base-enchant-exp").getKeys(false))
|
for (String key : config.getConfigurationSection("base-enchant-exp").getKeys(false))
|
||||||
try {
|
try {
|
||||||
Enchantment enchant = Enchantment.getByKey(NamespacedKey.minecraft(key.toLowerCase().replace("-", "_")));
|
Enchantment enchant = MMOCore.plugin.version.getVersionWrapper().getEnchantmentFromString(key.toLowerCase().replace("-", "_"));
|
||||||
MMOCore.plugin.enchantManager.registerBaseExperience(enchant, config.getDouble("base-enchant-exp." + key));
|
MMOCore.plugin.enchantManager.registerBaseExperience(enchant, config.getDouble("base-enchant-exp." + key));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.log(Level.WARNING, "[Professions:" + id + "] Could not read enchant from " + key);
|
MMOCore.log(Level.WARNING, "[Professions:" + id + "] Could not read enchant from " + key);
|
||||||
|
@ -7,7 +7,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -28,7 +27,7 @@ public class EnchantItemExperienceSource extends ExperienceSource<Void> {
|
|||||||
|
|
||||||
if (config.contains("enchant"))
|
if (config.contains("enchant"))
|
||||||
for (String key : config.getString("enchant").split("\\,"))
|
for (String key : config.getString("enchant").split("\\,"))
|
||||||
enchants.add(Enchantment.getByKey(NamespacedKey.minecraft(key.toLowerCase().replace("-", "_"))));
|
enchants.add(MMOCore.plugin.version.getVersionWrapper().getEnchantmentFromString(key.toLowerCase().replace("-", "_")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +21,7 @@ import com.mojang.authlib.GameProfile;
|
|||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
import net.Indyuce.mmocore.version.nms.ItemTag;
|
import net.Indyuce.mmocore.version.nms.ItemTag;
|
||||||
|
|
||||||
public class ConfigItem {
|
public class ConfigItem {
|
||||||
@ -101,7 +102,7 @@ public class ConfigItem {
|
|||||||
if (meta instanceof Damageable)
|
if (meta instanceof Damageable)
|
||||||
((Damageable) meta).setDamage(damage);
|
((Damageable) meta).setDamage(damage);
|
||||||
|
|
||||||
if (item.getType() == Material.PLAYER_HEAD && texture != null) {
|
if (item.getType() == VersionMaterial.PLAYER_HEAD.toMaterial() && texture != null) {
|
||||||
try {
|
try {
|
||||||
Field profileField = meta.getClass().getDeclaredField("profile");
|
Field profileField = meta.getClass().getDeclaredField("profile");
|
||||||
profileField.setAccessible(true);
|
profileField.setAccessible(true);
|
||||||
|
@ -9,6 +9,8 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
|
||||||
public class CastingParticle {
|
public class CastingParticle {
|
||||||
private final Consumer<Location> display;
|
private final Consumer<Location> display;
|
||||||
|
|
||||||
@ -23,7 +25,7 @@ public class CastingParticle {
|
|||||||
final float size = (float) config.getDouble("size") == 0 ? 1 : (float) Math.max(config.getDouble("size"), 0);
|
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"));
|
Color color = Color.fromRGB(config.getInt("color.red"), config.getInt("color.green"), config.getInt("color.blue"));
|
||||||
|
|
||||||
display = (loc) -> loc.getWorld().spawnParticle(particle, loc, 0, new Particle.DustOptions(color, size));
|
display = (loc) -> MMOCore.plugin.version.getVersionWrapper().spawnParticle(particle, loc, size, color);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +34,7 @@ public class CastingParticle {
|
|||||||
Validate.notNull(format, "Could not read material name");
|
Validate.notNull(format, "Could not read material name");
|
||||||
Material material = Material.valueOf(format.toUpperCase().replace("-", "_").replace(" ", "_"));
|
Material material = Material.valueOf(format.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||||
|
|
||||||
display = (loc) -> loc.getWorld().spawnParticle(particle, loc, 0, material.createBlockData());
|
display = (loc) -> MMOCore.plugin.version.getVersionWrapper().spawnParticle(particle, loc, material);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ public class ParabolicProjectile extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ParabolicProjectile(Location source, Location target, Particle particle, Runnable end, int speed, Color color, float size) {
|
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) -> loc.getWorld().spawnParticle(particle, loc, 1, new Particle.DustOptions(color, 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParabolicProjectile(Location source, Location target, Runnable end, Color 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) -> loc.getWorld().spawnParticle(Particle.REDSTONE, loc, 1, new Particle.DustOptions(color, 1)));
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParabolicProjectile(Location source, Location target, Particle particle) {
|
public ParabolicProjectile(Location source, Location target, Particle particle) {
|
||||||
|
@ -45,6 +45,7 @@ import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
|||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult.CancelReason;
|
import net.Indyuce.mmocore.api.skill.SkillResult.CancelReason;
|
||||||
import net.Indyuce.mmocore.listener.SpellCast.SkillCasting;
|
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.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
@ -433,15 +434,15 @@ public class PlayerData {
|
|||||||
if (t++ >= 100) {
|
if (t++ >= 100) {
|
||||||
player.teleport(waypoint.getLocation());
|
player.teleport(waypoint.getLocation());
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false));
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1, .5f);
|
player.playSound(player.getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, .5f);
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BELL, 1, (float) (t / Math.PI * .015 + .5));
|
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);
|
double r = Math.sin((double) t / 100 * Math.PI);
|
||||||
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
|
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
|
||||||
player.getWorld().spawnParticle(Particle.REDSTONE, player.getLocation().add(Math.cos((double) t / 20 + j) * r, (double) t / 50, Math.sin((double) t / 20 + j) * r), 0, new Particle.DustOptions(Color.PURPLE, 1.25f));
|
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);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(MMOCore.plugin, 0, 1);
|
}.runTaskTimer(MMOCore.plugin, 0, 1);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.boss.BarColor;
|
import org.bukkit.boss.BarColor;
|
||||||
import org.bukkit.boss.BarFlag;
|
import org.bukkit.boss.BarFlag;
|
||||||
@ -27,7 +26,7 @@ public class PlayerQuests {
|
|||||||
|
|
||||||
public PlayerQuests(PlayerData playerData) {
|
public PlayerQuests(PlayerData playerData) {
|
||||||
this.playerData = playerData;
|
this.playerData = playerData;
|
||||||
bossbar = Bukkit.createBossBar(new NamespacedKey(MMOCore.plugin, "quest_bar_" + playerData.getUniqueId().toString()), "", BarColor.PURPLE, BarStyle.SEGMENTED_20, new BarFlag[0]);
|
bossbar = MMOCore.plugin.version.getVersionWrapper().createBossBar(new NamespacedKey(MMOCore.plugin, "quest_bar_" + playerData.getUniqueId().toString()), "", BarColor.PURPLE, BarStyle.SEGMENTED_20, new BarFlag[0]);
|
||||||
bossbar.addPlayer(playerData.getPlayer());
|
bossbar.addPlayer(playerData.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package net.Indyuce.mmocore.api.skill;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.util.RayTraceResult;
|
import org.bukkit.util.RayTraceResult;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCoreUtils;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ public class TargetSkillResult extends SkillResult {
|
|||||||
super(data, skill);
|
super(data, skill);
|
||||||
|
|
||||||
if (isSuccessful()) {
|
if (isSuccessful()) {
|
||||||
RayTraceResult result = data.getPlayer().getWorld().rayTraceEntities(data.getPlayer().getEyeLocation(), data.getPlayer().getEyeLocation().getDirection(), range, (entity) -> MMOCoreUtils.canTarget(data.getPlayer(), entity));
|
RayTraceResult result = MMOCore.plugin.version.getVersionWrapper().rayTraceEntities(data.getPlayer(), data.getPlayer().getEyeLocation().getDirection(), range);
|
||||||
if (result == null)
|
if (result == null)
|
||||||
abort(CancelReason.OTHER);
|
abort(CancelReason.OTHER);
|
||||||
else
|
else
|
||||||
|
@ -27,6 +27,6 @@ public class LootColor extends BukkitRunnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.getWorld().spawnParticle(Particle.REDSTONE, item.getLocation(), 0, new Particle.DustOptions(color, 1.3f));
|
MMOCore.plugin.version.getVersionWrapper().spawnParticle(Particle.REDSTONE, item.getLocation(), 1.3f, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package net.Indyuce.mmocore.gui;
|
|||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -22,6 +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.InventoryPlaceholderItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
|
||||||
public class PlayerStats extends EditableInventory {
|
public class PlayerStats extends EditableInventory {
|
||||||
public PlayerStats() {
|
public PlayerStats() {
|
||||||
@ -262,7 +262,7 @@ public class PlayerStats extends EditableInventory {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack display(GeneratedInventory inv, int n) {
|
public ItemStack display(GeneratedInventory inv, int n) {
|
||||||
ItemStack item = super.display(inv, n);
|
ItemStack item = super.display(inv, n);
|
||||||
if (item.getType() == Material.PLAYER_HEAD) {
|
if (item.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) {
|
||||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||||
meta.setOwningPlayer(inv.getPlayer());
|
meta.setOwningPlayer(inv.getPlayer());
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
@ -8,7 +8,6 @@ import java.util.UUID;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.FishHook;
|
import org.bukkit.entity.FishHook;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -28,6 +27,7 @@ import net.Indyuce.mmocore.api.event.CustomPlayerFishEvent;
|
|||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||||
import net.Indyuce.mmocore.manager.profession.FishingManager.FishingDropTable;
|
import net.Indyuce.mmocore.manager.profession.FishingManager.FishingDropTable;
|
||||||
|
import net.Indyuce.mmocore.version.VersionSound;
|
||||||
|
|
||||||
public class FishingListener implements Listener {
|
public class FishingListener implements Listener {
|
||||||
private Set<UUID> fishing = new HashSet<>();
|
private Set<UUID> fishing = new HashSet<>();
|
||||||
@ -116,7 +116,7 @@ public class FishingListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void a(PlayerFishEvent event) {
|
public void a(PlayerFishEvent event) {
|
||||||
if (event.getPlayer().equals(player) && (event.getState() == State.CAUGHT_FISH || event.getState() == State.FAILED_ATTEMPT || event.getState() == State.REEL_IN)) {
|
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))) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lose the catch if the current fish is gone!
|
* lose the catch if the current fish is gone!
|
||||||
@ -169,7 +169,7 @@ public class FishingListener implements Listener {
|
|||||||
vec.setX(vec.getX() * .08);
|
vec.setX(vec.getX() * .08);
|
||||||
vec.setZ(vec.getZ() * .08);
|
vec.setZ(vec.getZ() * .08);
|
||||||
item.setVelocity(vec);
|
item.setVelocity(vec);
|
||||||
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_HAT, 1, 0);
|
player.getWorld().playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 1, 0);
|
||||||
for (int j = 0; j < 16; j++)
|
for (int j = 0; j < 16; j++)
|
||||||
location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, 0, 4 * (random.nextDouble() - .5), 2, 4 * (random.nextDouble() - .5), .05);
|
location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, 0, 4 * (random.nextDouble() - .5), 2, 4 * (random.nextDouble() - .5), .05);
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import java.util.Random;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.block.data.Ageable;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -12,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.event.CustomBlockMineEvent;
|
import net.Indyuce.mmocore.api.event.CustomBlockMineEvent;
|
||||||
import net.Indyuce.mmocore.api.math.particle.SmallParticleEffect;
|
import net.Indyuce.mmocore.api.math.particle.SmallParticleEffect;
|
||||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||||
@ -39,11 +39,8 @@ public class PlayerCollectStats implements Listener {
|
|||||||
item.setAmount(item.getAmount() + a);
|
item.setAmount(item.getAmount() + a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getBlock().getBlockData() instanceof Ageable) {
|
if(MMOCore.plugin.version.getVersionWrapper().isCropFullyGrown(event.getBlock()))
|
||||||
Ageable ageable = (Ageable) event.getBlock().getBlockData();
|
{
|
||||||
if (ageable.getAge() < ageable.getMaximumAge())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// drop more items if fortune enchant
|
// drop more items if fortune enchant
|
||||||
double l = event.getData().getStats().getStat(StatType.LUCK_OF_THE_FIELD);
|
double l = event.getData().getStats().getStat(StatType.LUCK_OF_THE_FIELD);
|
||||||
if (l > 0 && random.nextDouble() < l * .045) {
|
if (l > 0 && random.nextDouble() < l * .045) {
|
||||||
|
@ -12,7 +12,6 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||||
import org.bukkit.inventory.FurnaceRecipe;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.Recipe;
|
import org.bukkit.inventory.Recipe;
|
||||||
|
|
||||||
@ -34,9 +33,9 @@ public class Smelting implements Listener {
|
|||||||
|
|
||||||
public Smelting(ConfigurationSection config) {
|
public Smelting(ConfigurationSection config) {
|
||||||
for (Iterator<Recipe> iterator = Bukkit.recipeIterator(); iterator.hasNext();) {
|
for (Iterator<Recipe> iterator = Bukkit.recipeIterator(); iterator.hasNext();) {
|
||||||
Recipe recipe = iterator.next();
|
//Recipe recipe = iterator.next();
|
||||||
if (recipe instanceof FurnaceRecipe && vanillaKeys.contains(((FurnaceRecipe) recipe).getKey()))
|
//if (recipe instanceof FurnaceRecipe && vanillaKeys.contains(((FurnaceRecipe) recipe).getKey()))
|
||||||
iterator.remove();
|
// iterator.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
Smelting.recipes.clear();
|
Smelting.recipes.clear();
|
||||||
@ -48,7 +47,7 @@ public class Smelting implements Listener {
|
|||||||
recipes.add(recipe);
|
recipes.add(recipe);
|
||||||
NamespacedKey vanillaKey = new NamespacedKey(MMOCore.plugin, "furnace_recipe_" + key.replace("-", "_").toLowerCase());
|
NamespacedKey vanillaKey = new NamespacedKey(MMOCore.plugin, "furnace_recipe_" + key.replace("-", "_").toLowerCase());
|
||||||
vanillaKeys.add(vanillaKey);
|
vanillaKeys.add(vanillaKey);
|
||||||
Bukkit.addRecipe(new FurnaceRecipe(vanillaKey, new ItemStack(Material.BARRIER), recipe.getIngredientMaterial(), 0, recipe.getCookingTime()));
|
Bukkit.addRecipe(MMOCore.plugin.version.getVersionWrapper().getFurnaceRecipe(vanillaKey, new ItemStack(Material.BARRIER), recipe.getIngredientMaterial(), 0, recipe.getCookingTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class Ambers extends Skill implements Listener {
|
|||||||
|
|
||||||
for (int j = 0; j < 5; j++)
|
for (int j = 0; j < 5; j++)
|
||||||
loc.getWorld().spawnParticle(Particle.SPELL_MOB, loc, 0, 1, 0.647, 0, 1);
|
loc.getWorld().spawnParticle(Particle.SPELL_MOB, loc, 0, 1, 0.647, 0, 1);
|
||||||
loc.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.ORANGE, 1.3f));
|
MMOCore.plugin.version.getVersionWrapper().spawnParticle(Particle.REDSTONE, loc, 1.3f, Color.ORANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.skill;
|
package net.Indyuce.mmocore.skill;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -20,11 +19,13 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
import net.Indyuce.mmocore.version.VersionSound;
|
||||||
|
|
||||||
public class Control extends Skill {
|
public class Control extends Skill {
|
||||||
public Control() {
|
public Control() {
|
||||||
super();
|
super();
|
||||||
setMaterial(Material.MAGENTA_DYE);
|
setMaterial(VersionMaterial.MAGENTA_DYE.toMaterial());
|
||||||
setLore("Your target is temporarily slowed for &8{duration} &7seconds.", "As soon as you left click, it gets", "pushed back where you are looking at.", "Knockback force: &f{knockback}%", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
setLore("Your target is temporarily slowed for &8{duration} &7seconds.", "As soon as you left click, it gets", "pushed back where you are looking at.", "Knockback force: &f{knockback}%", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
||||||
|
|
||||||
addModifier("cooldown", new LinearValue(18, -.3, 10, 20));
|
addModifier("cooldown", new LinearValue(18, -.3, 10, 20));
|
||||||
@ -79,7 +80,7 @@ public class Control extends Skill {
|
|||||||
entity.removePotionEffect(PotionEffectType.SLOW);
|
entity.removePotionEffect(PotionEffectType.SLOW);
|
||||||
|
|
||||||
entity.getWorld().spawnParticle(Particle.SPELL_WITCH, entity.getLocation().add(0, entity.getHeight() / 2, 0), 16);
|
entity.getWorld().spawnParticle(Particle.SPELL_WITCH, entity.getLocation().add(0, entity.getHeight() / 2, 0), 16);
|
||||||
entity.getWorld().playSound(entity.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 2, 1);
|
entity.getWorld().playSound(entity.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 1);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.Particle;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.math.formula.LinearValue;
|
import net.Indyuce.mmocore.api.math.formula.LinearValue;
|
||||||
@ -35,7 +36,7 @@ public class Deep_Wound extends Skill {
|
|||||||
LivingEntity target = cast.getTarget();
|
LivingEntity target = cast.getTarget();
|
||||||
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, 2);
|
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, 2);
|
||||||
target.getWorld().spawnParticle(Particle.CRIT, target.getLocation().add(0, target.getHeight() / 2, 0), 32, 0, 0, 0, .7);
|
target.getWorld().spawnParticle(Particle.CRIT, target.getLocation().add(0, target.getHeight() / 2, 0), 32, 0, 0, 0, .7);
|
||||||
target.getWorld().spawnParticle(Particle.BLOCK_CRACK, target.getLocation().add(0, target.getHeight() / 2, 0), 32, 0, 0, 0, 2, Material.REDSTONE_BLOCK.createBlockData());
|
target.getWorld().spawnParticle(Particle.BLOCK_CRACK, target.getLocation().add(0, target.getHeight() / 2, 0), 32, 0, 0, 0, 2, new ItemStack(Material.REDSTONE_BLOCK));
|
||||||
|
|
||||||
double max = target.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
double max = target.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||||
double ratio = (max - target.getHealth()) / max;
|
double ratio = (max - target.getHealth()) / max;
|
||||||
|
@ -2,7 +2,6 @@ package net.Indyuce.mmocore.skill;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -20,13 +19,15 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
import net.Indyuce.mmocore.version.VersionSound;
|
||||||
|
|
||||||
public class Empowered_Attack extends Skill {
|
public class Empowered_Attack extends Skill {
|
||||||
private static final double perb = 5;
|
private static final double perb = 5;
|
||||||
|
|
||||||
public Empowered_Attack() {
|
public Empowered_Attack() {
|
||||||
super();
|
super();
|
||||||
setMaterial(Material.BONE_MEAL);
|
setMaterial(VersionMaterial.BONE_MEAL.toMaterial());
|
||||||
setLore("You charge your weapon with lightning.", "Your next attack deals &f{extra}% &7extra damage", "and spreads to enemies within &f{radius} &7blocks", "for &f{ratio}% &7of the initial damage.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
setLore("You charge your weapon with lightning.", "Your next attack deals &f{extra}% &7extra damage", "and spreads to enemies within &f{radius} &7blocks", "for &f{ratio}% &7of the initial damage.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
||||||
|
|
||||||
addModifier("cooldown", new LinearValue(10, -.2, 5, 10));
|
addModifier("cooldown", new LinearValue(10, -.2, 5, 10));
|
||||||
@ -94,7 +95,7 @@ public class Empowered_Attack extends Skill {
|
|||||||
drawVector(clone, loc.clone().subtract(clone).toVector());
|
drawVector(clone, loc.clone().subtract(clone).toVector());
|
||||||
}
|
}
|
||||||
|
|
||||||
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 2, .5f);
|
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, .5f);
|
||||||
target.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, target.getLocation().add(0, target.getHeight() / 2, 0), 32, 0, 0, 0, .2);
|
target.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, target.getLocation().add(0, target.getHeight() / 2, 0), 32, 0, 0, 0, .2);
|
||||||
|
|
||||||
double sweep = event.getDamage() * r;
|
double sweep = event.getDamage() * r;
|
||||||
|
@ -3,7 +3,6 @@ package net.Indyuce.mmocore.skill;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -17,6 +16,7 @@ import net.Indyuce.mmocore.api.math.particle.SmallParticleEffect;
|
|||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
|
import net.Indyuce.mmocore.version.VersionSound;
|
||||||
|
|
||||||
public class Evade extends Skill {
|
public class Evade extends Skill {
|
||||||
public Evade() {
|
public Evade() {
|
||||||
@ -35,7 +35,7 @@ public class Evade extends Skill {
|
|||||||
if (!cast.isSuccessful())
|
if (!cast.isSuccessful())
|
||||||
return cast;
|
return cast;
|
||||||
|
|
||||||
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1, 2);
|
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 2);
|
||||||
new SmallParticleEffect(data.getPlayer(), Particle.CLOUD);
|
new SmallParticleEffect(data.getPlayer(), Particle.CLOUD);
|
||||||
new EvadeSkill(data, cast.getModifier("duration"));
|
new EvadeSkill(data, cast.getModifier("duration"));
|
||||||
return cast;
|
return cast;
|
||||||
|
@ -2,7 +2,6 @@ package net.Indyuce.mmocore.skill;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -24,11 +23,13 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
import net.Indyuce.mmocore.version.VersionSound;
|
||||||
|
|
||||||
public class Fire_Rage extends Skill {
|
public class Fire_Rage extends Skill {
|
||||||
public Fire_Rage() {
|
public Fire_Rage() {
|
||||||
super();
|
super();
|
||||||
setMaterial(Material.FIRE_CHARGE);
|
setMaterial(VersionMaterial.FIRE_CHARGE.toMaterial());
|
||||||
setLore("For {duration} seconds, you slow down and are able", "to cast up to {count} fireballs by left clicking.", "", "Fireballs deal &c{damage} &7damage upon contact", "and ignite your target for &c{ignite} &7seconds.", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
setLore("For {duration} seconds, you slow down and are able", "to cast up to {count} fireballs by left clicking.", "", "Fireballs deal &c{damage} &7damage upon contact", "and ignite your target for &c{ignite} &7seconds.", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
||||||
|
|
||||||
addModifier("duration", new LinearValue(8, 0));
|
addModifier("duration", new LinearValue(8, 0));
|
||||||
@ -110,7 +111,7 @@ public class Fire_Rage extends Skill {
|
|||||||
data.getPlayer().removePotionEffect(PotionEffectType.SLOW);
|
data.getPlayer().removePotionEffect(PotionEffectType.SLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1, last ? 0 : 1);
|
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, last ? 0 : 1);
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
Vector vec = data.getPlayer().getEyeLocation().getDirection();
|
Vector vec = data.getPlayer().getEyeLocation().getDirection();
|
||||||
@ -128,7 +129,7 @@ public class Fire_Rage extends Skill {
|
|||||||
loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
|
loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
|
||||||
|
|
||||||
for (Entity target : MMOCoreUtils.getNearbyChunkEntities(loc))
|
for (Entity target : MMOCoreUtils.getNearbyChunkEntities(loc))
|
||||||
if (target.getBoundingBox().expand(.2, .2, .2).contains(loc.toVector()) && MMOCoreUtils.canTarget(data.getPlayer(), target)) {
|
if (MMOCore.plugin.nms.getBoundingBox(target).expand(.2, .2, .2).contains(loc.toVector()) && MMOCoreUtils.canTarget(data.getPlayer(), target)) {
|
||||||
loc.getWorld().spawnParticle(Particle.LAVA, loc, 8);
|
loc.getWorld().spawnParticle(Particle.LAVA, loc, 8);
|
||||||
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
|
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
|
||||||
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
|
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
|
||||||
|
@ -16,6 +16,7 @@ import net.Indyuce.mmocore.api.skill.Skill;
|
|||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||||
|
import net.Indyuce.mmocore.version.VersionSound;
|
||||||
|
|
||||||
public class Fire_Storm extends Skill {
|
public class Fire_Storm extends Skill {
|
||||||
public Fire_Storm() {
|
public Fire_Storm() {
|
||||||
@ -40,7 +41,7 @@ public class Fire_Storm extends Skill {
|
|||||||
double damage = cast.getModifier("damage");
|
double damage = cast.getModifier("damage");
|
||||||
int ignite = (int) (20 * cast.getModifier("ignite"));
|
int ignite = (int) (20 * cast.getModifier("ignite"));
|
||||||
|
|
||||||
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1, 1);
|
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ public class Fire_Storm extends Skill {
|
|||||||
|
|
||||||
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.BLOCK_FIRE_AMBIENT, 1, 1);
|
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.BLOCK_FIRE_AMBIENT, 1, 1);
|
||||||
new ParabolicProjectile(data.getPlayer().getLocation().add(0, 1, 0), target.getLocation().add(0, target.getHeight() / 2, 0), randomVector(data.getPlayer()), () -> {
|
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(), Sound.ENTITY_FIREWORK_ROCKET_TWINKLE, 1, 2);
|
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);
|
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);
|
MMOCore.plugin.damage.damage(data, target, damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||||
target.setFireTicks(ignite);
|
target.setFireTicks(ignite);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.skill;
|
package net.Indyuce.mmocore.skill;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -16,11 +15,13 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
import net.Indyuce.mmocore.version.VersionSound;
|
||||||
|
|
||||||
public class Fireball extends Skill {
|
public class Fireball extends Skill {
|
||||||
public Fireball() {
|
public Fireball() {
|
||||||
super();
|
super();
|
||||||
setMaterial(Material.FIRE_CHARGE);
|
setMaterial(VersionMaterial.FIRE_CHARGE.toMaterial());
|
||||||
setLore("Casts a deadly fireball onto your", "target, dealing &c{damage} &7damage upon contact", "and igniting it for &c{ignite} &7seconds.", "", "Shatters into 3 blazing hot shards which stick", "to walls and explode 3 seconds later, dealing", "33% of the initial spell damage.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
setLore("Casts a deadly fireball onto your", "target, dealing &c{damage} &7damage upon contact", "and igniting it for &c{ignite} &7seconds.", "", "Shatters into 3 blazing hot shards which stick", "to walls and explode 3 seconds later, dealing", "33% of the initial spell damage.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
||||||
|
|
||||||
addModifier("mana", new LinearValue(15, 1));
|
addModifier("mana", new LinearValue(15, 1));
|
||||||
@ -35,7 +36,7 @@ public class Fireball extends Skill {
|
|||||||
if (!cast.isSuccessful())
|
if (!cast.isSuccessful())
|
||||||
return cast;
|
return cast;
|
||||||
|
|
||||||
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1, 1);
|
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
Vector vec = data.getPlayer().getEyeLocation().getDirection();
|
Vector vec = data.getPlayer().getEyeLocation().getDirection();
|
||||||
@ -58,7 +59,7 @@ public class Fireball extends Skill {
|
|||||||
// loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
|
// loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
|
||||||
|
|
||||||
for (Entity target : MMOCoreUtils.getNearbyChunkEntities(loc))
|
for (Entity target : MMOCoreUtils.getNearbyChunkEntities(loc))
|
||||||
if (target.getBoundingBox().expand(.2, .2, .2).contains(loc.toVector()) && MMOCoreUtils.canTarget(data.getPlayer(), target)) {
|
if (MMOCore.plugin.nms.getBoundingBox(target).expand(.2, .2, .2).contains(loc.toVector()) && MMOCoreUtils.canTarget(data.getPlayer(), target)) {
|
||||||
loc.getWorld().spawnParticle(Particle.LAVA, loc, 8);
|
loc.getWorld().spawnParticle(Particle.LAVA, loc, 8);
|
||||||
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
|
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
|
||||||
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
|
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.skill;
|
package net.Indyuce.mmocore.skill;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
@ -18,11 +17,12 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
|
||||||
public class Human_Shield extends Skill {
|
public class Human_Shield extends Skill {
|
||||||
public Human_Shield() {
|
public Human_Shield() {
|
||||||
super();
|
super();
|
||||||
setMaterial(Material.TOTEM_OF_UNDYING);
|
setMaterial(VersionMaterial.TOTEM_OF_UNDYING.toMaterial());
|
||||||
setLore("Casts a protection charm onto target ally,", "reducing damage taken by &a{reduction}%&7.", "&a{redirect}% &7of this damage is redirected to you.", "Charm is cancelled when reaching &c{low}%&7 health.", "Lasts &a{duration} &7seconds.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
setLore("Casts a protection charm onto target ally,", "reducing damage taken by &a{reduction}%&7.", "&a{redirect}% &7of this damage is redirected to you.", "Charm is cancelled when reaching &c{low}%&7 health.", "Lasts &a{duration} &7seconds.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
||||||
|
|
||||||
addModifier("cooldown", new LinearValue(18, -.3, 14, 18));
|
addModifier("cooldown", new LinearValue(18, -.3, 14, 18));
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.skill;
|
package net.Indyuce.mmocore.skill;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -20,6 +19,7 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
|
||||||
public class Ice_Spikes extends Skill {
|
public class Ice_Spikes extends Skill {
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ public class Ice_Spikes extends Skill {
|
|||||||
|
|
||||||
public Ice_Spikes() {
|
public Ice_Spikes() {
|
||||||
super();
|
super();
|
||||||
setMaterial(Material.SNOWBALL);
|
setMaterial(VersionMaterial.SNOWBALL.toMaterial());
|
||||||
setLore("Ice spikes summon from the ground", "and shatters, each dealing &9{damage} &7damage", "to hit enemies and slowing them down", "for &9{slow} &7seconds.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
setLore("Ice spikes summon from the ground", "and shatters, each dealing &9{damage} &7damage", "to hit enemies and slowing them down", "for &9{slow} &7seconds.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
||||||
|
|
||||||
addModifier("cooldown", new LinearValue(6, -.1, 2, 6));
|
addModifier("cooldown", new LinearValue(6, -.1, 2, 6));
|
||||||
@ -84,7 +84,7 @@ public class Ice_Spikes extends Skill {
|
|||||||
|
|
||||||
public IceSpikesCast(PlayerData data, SkillInfo skill) {
|
public IceSpikesCast(PlayerData data, SkillInfo skill) {
|
||||||
super(data, skill);
|
super(data, skill);
|
||||||
if (isSuccessful() && (loc = data.getPlayer().rayTraceBlocks(30)) == null)
|
if (isSuccessful() && (loc = MMOCore.plugin.version.getVersionWrapper().rayTrace(data.getPlayer(), 30)) == null)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package net.Indyuce.mmocore.skill;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -26,11 +25,13 @@ import net.Indyuce.mmocore.api.player.stats.TemporaryStats;
|
|||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
import net.Indyuce.mmocore.version.VersionSound;
|
||||||
|
|
||||||
public class Power_Mark extends Skill implements Listener {
|
public class Power_Mark extends Skill implements Listener {
|
||||||
public Power_Mark() {
|
public Power_Mark() {
|
||||||
super();
|
super();
|
||||||
setMaterial(Material.WITHER_SKELETON_SKULL);
|
setMaterial(VersionMaterial.WITHER_SKELETON_SKULL.toMaterial());
|
||||||
setLore("Attacking an enemy applies a deadly", "magical mark which spreads accross the", "ground. This mark accumulates &6{ratio}%", "of the damage dealt to the initial", "target over &6{duration} &7seconds.", "", "After this duration, the mark bursts, dealing", "accumulated damage to nearby enemies and", "stunning them for &6{stun}+ &7seconds.", "", "The more damage, the longer the stun.", "", "&e{cooldown}s Cooldown");
|
setLore("Attacking an enemy applies a deadly", "magical mark which spreads accross the", "ground. This mark accumulates &6{ratio}%", "of the damage dealt to the initial", "target over &6{duration} &7seconds.", "", "After this duration, the mark bursts, dealing", "accumulated damage to nearby enemies and", "stunning them for &6{stun}+ &7seconds.", "", "The more damage, the longer the stun.", "", "&e{cooldown}s Cooldown");
|
||||||
setPassive();
|
setPassive();
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ public class Power_Mark extends Skill implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (j % 2 == 0 && j > 20 * (duration - 2))
|
if (j % 2 == 0 && j > 20 * (duration - 2))
|
||||||
loc.getWorld().playSound(loc, Sound.BLOCK_NOTE_BLOCK_PLING, 1, (float) (1 + (j - 20 * (duration - 2)) / 40));
|
loc.getWorld().playSound(loc, VersionSound.BLOCK_NOTE_BLOCK_PLING.toSound(), 1, (float) (1 + (j - 20 * (duration - 2)) / 40));
|
||||||
|
|
||||||
double a = (double) j / 16;
|
double a = (double) j / 16;
|
||||||
double r = Math.sqrt(Math.min(duration * 2 - (double) j / 10, 4)) * 2;
|
double r = Math.sqrt(Math.min(duration * 2 - (double) j / 10, 4)) * 2;
|
||||||
|
@ -2,7 +2,6 @@ package net.Indyuce.mmocore.skill;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -19,11 +18,13 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
import net.Indyuce.mmocore.version.VersionSound;
|
||||||
|
|
||||||
public class Telekinesy extends Skill {
|
public class Telekinesy extends Skill {
|
||||||
public Telekinesy() {
|
public Telekinesy() {
|
||||||
super();
|
super();
|
||||||
setMaterial(Material.MAGENTA_DYE);
|
setMaterial(VersionMaterial.MAGENTA_DYE.toMaterial());
|
||||||
setLore("You take the control over your target", "for &9{duration} &7seconds. Left click to throw him.", "Knockback force: &f{knockback}%", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
setLore("You take the control over your target", "for &9{duration} &7seconds. Left click to throw him.", "Knockback force: &f{knockback}%", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
||||||
|
|
||||||
addModifier("cooldown", new LinearValue(20, -.3, 10, 20));
|
addModifier("cooldown", new LinearValue(20, -.3, 10, 20));
|
||||||
@ -68,7 +69,7 @@ public class Telekinesy extends Skill {
|
|||||||
public void a(PlayerInteractEvent event) {
|
public void a(PlayerInteractEvent event) {
|
||||||
if (event.getPlayer().equals(data.getPlayer()) && event.getAction().name().contains("LEFT_CLICK")) {
|
if (event.getPlayer().equals(data.getPlayer()) && event.getAction().name().contains("LEFT_CLICK")) {
|
||||||
entity.setVelocity(data.getPlayer().getEyeLocation().getDirection().multiply(1.5 * f));
|
entity.setVelocity(data.getPlayer().getEyeLocation().getDirection().multiply(1.5 * f));
|
||||||
entity.getWorld().playSound(entity.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 2, 1);
|
entity.getWorld().playSound(entity.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 1);
|
||||||
entity.getWorld().spawnParticle(Particle.SPELL_WITCH, entity.getLocation().add(0, entity.getHeight() / 2, 0), 16);
|
entity.getWorld().spawnParticle(Particle.SPELL_WITCH, entity.getLocation().add(0, entity.getHeight() / 2, 0), 16);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import net.Indyuce.mmocore.api.math.particle.ParabolicProjectile;
|
|||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
|
import net.Indyuce.mmocore.version.VersionSound;
|
||||||
|
|
||||||
public class Warp extends Skill {
|
public class Warp extends Skill {
|
||||||
public Warp() {
|
public Warp() {
|
||||||
@ -40,7 +41,7 @@ public class Warp extends Skill {
|
|||||||
data.getPlayer().teleport(loc);
|
data.getPlayer().teleport(loc);
|
||||||
data.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, data.getPlayer().getLocation().add(0, 1, 0), 0);
|
data.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, data.getPlayer().getLocation().add(0, 1, 0), 0);
|
||||||
data.getPlayer().getWorld().spawnParticle(Particle.SPELL_INSTANT, data.getPlayer().getLocation().add(0, 1, 0), 32, 0, 0, 0, .1);
|
data.getPlayer().getWorld().spawnParticle(Particle.SPELL_INSTANT, data.getPlayer().getLocation().add(0, 1, 0), 32, 0, 0, 0, .1);
|
||||||
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
|
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
|
||||||
}
|
}
|
||||||
}, 2, Particle.SPELL_INSTANT);
|
}, 2, Particle.SPELL_INSTANT);
|
||||||
return cast;
|
return cast;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.skill;
|
package net.Indyuce.mmocore.skill;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -19,11 +18,12 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import net.Indyuce.mmocore.api.skill.Skill;
|
import net.Indyuce.mmocore.api.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||||
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
import net.Indyuce.mmocore.api.skill.TargetSkillResult;
|
||||||
|
import net.Indyuce.mmocore.version.VersionMaterial;
|
||||||
|
|
||||||
public class Weaken extends Skill {
|
public class Weaken extends Skill {
|
||||||
public Weaken() {
|
public Weaken() {
|
||||||
super();
|
super();
|
||||||
setMaterial(Material.MAGENTA_DYE);
|
setMaterial(VersionMaterial.MAGENTA_DYE.toMaterial());
|
||||||
setLore("The target is weakened for", "&8{duration} &7seconds and is dealt", "&7extra &8{ratio}% &7damage.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
setLore("The target is weakened for", "&8{duration} &7seconds and is dealt", "&7extra &8{ratio}% &7damage.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
|
||||||
|
|
||||||
addModifier("cooldown", new LinearValue(20, -.1, 5, 20));
|
addModifier("cooldown", new LinearValue(20, -.1, 5, 20));
|
||||||
|
@ -3,17 +3,22 @@ package net.Indyuce.mmocore.version;
|
|||||||
import net.Indyuce.mmocore.version.texture.CustomModelDataHandler;
|
import net.Indyuce.mmocore.version.texture.CustomModelDataHandler;
|
||||||
import net.Indyuce.mmocore.version.texture.TextureByDurabilityHandler;
|
import net.Indyuce.mmocore.version.texture.TextureByDurabilityHandler;
|
||||||
import net.Indyuce.mmocore.version.texture.TextureHandler;
|
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 {
|
public class ServerVersion {
|
||||||
private final String version;
|
private final String version;
|
||||||
private final int[] integers;
|
private final int[] integers;
|
||||||
private final TextureHandler textureHandler;
|
private final TextureHandler textureHandler;
|
||||||
|
private final VersionWrapper versionWrapper;
|
||||||
|
|
||||||
public ServerVersion(Class<?> clazz) {
|
public ServerVersion(Class<?> clazz) {
|
||||||
this.version = clazz.getPackage().getName().replace(".", ",").split(",")[3];
|
this.version = clazz.getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
String[] split = version.substring(1).split("\\_");
|
String[] split = version.substring(1).split("\\_");
|
||||||
this.integers = new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]) };
|
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();
|
textureHandler = isBelowOrEqual(1, 13) ? new TextureByDurabilityHandler() : new CustomModelDataHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,6 +47,10 @@ public class ServerVersion {
|
|||||||
return textureHandler;
|
return textureHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VersionWrapper getVersionWrapper() {
|
||||||
|
return versionWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return version;
|
return version;
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
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),
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
33
src/main/java/net/Indyuce/mmocore/version/VersionSound.java
Normal file
33
src/main/java/net/Indyuce/mmocore/version/VersionSound.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
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,8 +1,10 @@
|
|||||||
package net.Indyuce.mmocore.version.nms;
|
package net.Indyuce.mmocore.version.nms;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.BoundingBox;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||||
|
|
||||||
@ -34,4 +36,6 @@ public interface NMSHandler {
|
|||||||
Inventory toBukkitInventory(Object container);
|
Inventory toBukkitInventory(Object container);
|
||||||
|
|
||||||
Object newContainerAnvil(Player player);
|
Object newContainerAnvil(Player player);
|
||||||
|
|
||||||
|
BoundingBox getBoundingBox(Entity target);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,185 @@
|
|||||||
|
package net.Indyuce.mmocore.version.nms;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
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.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.util.BoundingBox;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -5,8 +5,10 @@ import java.util.Set;
|
|||||||
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer;
|
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.event.CraftEventFactory;
|
||||||
import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.util.BoundingBox;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||||
import net.minecraft.server.v1_13_R1.BlockPosition;
|
import net.minecraft.server.v1_13_R1.BlockPosition;
|
||||||
@ -173,4 +175,9 @@ public class NMSHandler_1_13_R1 implements NMSHandler {
|
|||||||
return CraftItemStack.asBukkitCopy(nms);
|
return CraftItemStack.asBukkitCopy(nms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BoundingBox getBoundingBox(Entity target) {
|
||||||
|
return target.getBoundingBox();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,10 @@ import java.util.Set;
|
|||||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
|
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.event.CraftEventFactory;
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.util.BoundingBox;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||||
import net.minecraft.server.v1_13_R2.BlockPosition;
|
import net.minecraft.server.v1_13_R2.BlockPosition;
|
||||||
@ -174,4 +176,9 @@ public class NMSHandler_1_13_R2 implements NMSHandler {
|
|||||||
return CraftItemStack.asBukkitCopy(nms);
|
return CraftItemStack.asBukkitCopy(nms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BoundingBox getBoundingBox(Entity target) {
|
||||||
|
return target.getBoundingBox();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
|||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
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.event.CraftEventFactory;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.util.BoundingBox;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.item.NBTItem;
|
import net.Indyuce.mmocore.api.item.NBTItem;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
@ -197,4 +199,9 @@ public class NMSHandler_1_14_R1 implements NMSHandler {
|
|||||||
return CraftItemStack.asBukkitCopy(nms);
|
return CraftItemStack.asBukkitCopy(nms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BoundingBox getBoundingBox(Entity target) {
|
||||||
|
return target.getBoundingBox();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,224 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
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