1.13 support
- Added initial support for version 1.13 of Minecraft.
This commit is contained in:
parent
511a0c85f9
commit
c3546c777c
60
pom.xml
60
pom.xml
@ -1,10 +1,8 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>nl.pim16aap2</groupId>
|
||||
<artifactId>ArmoredElytra</artifactId>
|
||||
<version>2.4-SNAPSHOT</version>
|
||||
|
||||
<version>2.4.2-SNAPSHOT</version>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
@ -17,57 +15,29 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!--Spigot API -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<artifactId>spigot-1.10</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<artifactId>spigot-1.11</artifactId>
|
||||
<version>1.11.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-1.12</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--Bukkit API -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.11.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<artifactId>spigot-1.13</artifactId>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -79,8 +49,6 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -19,6 +19,7 @@ import nl.pim16aap2.armoredElytra.nms.NBTEditor;
|
||||
import nl.pim16aap2.armoredElytra.nms.NBTEditor_V1_10_R1;
|
||||
import nl.pim16aap2.armoredElytra.nms.NBTEditor_V1_11_R1;
|
||||
import nl.pim16aap2.armoredElytra.nms.NBTEditor_V1_12_R1;
|
||||
import nl.pim16aap2.armoredElytra.nms.NBTEditor_V1_13_R1;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
import nl.pim16aap2.armoredElytra.util.ConfigLoader;
|
||||
import nl.pim16aap2.armoredElytra.util.Metrics;
|
||||
@ -41,10 +42,10 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
||||
{
|
||||
readConfigValues();
|
||||
|
||||
|
||||
// Check if the user allows checking for updates.
|
||||
if (config.getBool("checkForUpdates"))
|
||||
{
|
||||
// Check for updates in a new thread, so the server won't hang when it cannot contact the update servers.
|
||||
Thread thread = new Thread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -99,7 +100,7 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
||||
}
|
||||
else
|
||||
// Y u do dis? :(
|
||||
myLogger(Level.INFO, "Stats disabled, not laoding stats ::(... Please consider enabling it! I am a simple man, seeing higher user numbers helps me stay motivated!");
|
||||
myLogger(Level.INFO, "Stats disabled, not laoding stats :(... Please consider enabling it! I am a simple man, seeing higher user numbers helps me stay motivated!");
|
||||
|
||||
|
||||
|
||||
@ -111,7 +112,10 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
||||
getCommand("ArmoredElytra").setExecutor(new CommandHandler(this, nbtEditor));
|
||||
}
|
||||
else
|
||||
myLogger(Level.WARNING, "Trying to load the plugin on an incompatible version of Minecraft!");
|
||||
{
|
||||
myLogger(Level.WARNING, "Trying to load the plugin on an incompatible version of Minecraft! This plugin will NOT be enabled!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -260,7 +264,9 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
||||
else if (version.equals("v1_11_R1"))
|
||||
nbtEditor = new NBTEditor_V1_11_R1(this);
|
||||
else if (version.equals("v1_12_R1"))
|
||||
nbtEditor = new NBTEditor_V1_12_R1(this);
|
||||
nbtEditor = new NBTEditor_V1_12_R1(this);
|
||||
else if (version.equals("v1_13_R1"))
|
||||
nbtEditor = new NBTEditor_V1_13_R1(this);
|
||||
// Return true if compatible.
|
||||
return nbtEditor != null;
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ public class EventHandlers implements Listener
|
||||
if (player.getInventory().getChestplate() != null)
|
||||
{
|
||||
// If that chestplate is an (armored) elytra.
|
||||
if (chestplate.getType() == Material.ELYTRA && (nbtEditor.getArmorTier(chestplate) != ArmorTier.NONE))
|
||||
if (nbtEditor.getArmorTier(chestplate) != ArmorTier.NONE)
|
||||
{
|
||||
ArmorTier armorTier = nbtEditor.getArmorTier(chestplate);
|
||||
if ((chestplate.getDurability() >= chestplate.getType().getMaxDurability()))
|
||||
@ -493,7 +493,7 @@ public class EventHandlers implements Listener
|
||||
}
|
||||
|
||||
// Because the armored elytra doesn't actually give any armor, the damage received by players wearing an armored elytra is calculated here.
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerDamage(EntityDamageEvent e)
|
||||
{
|
||||
if(e.getEntity() instanceof Player)
|
||||
@ -502,10 +502,9 @@ public class EventHandlers implements Listener
|
||||
// If the player didn't die from the damage.
|
||||
if ((p.getHealth() - e.getFinalDamage()) > 0)
|
||||
{
|
||||
if (p.getInventory().getChestplate()!=null)
|
||||
if (p.getInventory().getChestplate() != null)
|
||||
{
|
||||
if (p.getInventory().getChestplate().getType() == Material.ELYTRA &&
|
||||
nbtEditor.getArmorTier(p.getInventory().getChestplate()) != ArmorTier.NONE)
|
||||
if (nbtEditor.getArmorTier(p.getInventory().getChestplate()) != ArmorTier.NONE)
|
||||
{
|
||||
ItemStack elytra = p.getInventory().getChestplate();
|
||||
DamageCause cause = e.getCause();
|
||||
|
@ -0,0 +1,116 @@
|
||||
package nl.pim16aap2.armoredElytra.nms;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.minecraft.server.v1_13_R1.NBTTagByte;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagInt;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_13_R1.NBTTagString;
|
||||
import nl.pim16aap2.armoredElytra.ArmoredElytra;
|
||||
import nl.pim16aap2.armoredElytra.util.ArmorTier;
|
||||
|
||||
public class NBTEditor_V1_13_R1 implements NBTEditor
|
||||
{
|
||||
private ArmoredElytra plugin;
|
||||
|
||||
// Get the names and lores for every tier of armor.
|
||||
public NBTEditor_V1_13_R1(ArmoredElytra plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// Add armor to the supplied item, based on the armorTier.
|
||||
@Override
|
||||
public ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable)
|
||||
{
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
int armorProtection = ArmorTier.getArmor (armorTier);
|
||||
int armorToughness = ArmorTier.getToughness(armorTier);
|
||||
|
||||
itemmeta.setDisplayName(plugin.getArmoredElytrName(armorTier));
|
||||
if (plugin.getElytraLore() != null)
|
||||
itemmeta.setLore(Arrays.asList(plugin.fillInArmorTierInStringNoColor(plugin.getElytraLore(), armorTier)));
|
||||
item.setItemMeta(itemmeta);
|
||||
|
||||
net.minecraft.server.v1_13_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
|
||||
NBTTagList modifiers = new NBTTagList();
|
||||
NBTTagCompound armor = new NBTTagCompound();
|
||||
armor.set("AttributeName", new NBTTagString("generic.armor"));
|
||||
armor.set("Name", new NBTTagString("generic.armor"));
|
||||
armor.set("Amount", new NBTTagInt(armorProtection));
|
||||
armor.set("Operation", new NBTTagInt(0));
|
||||
armor.set("UUIDLeast", new NBTTagInt(894654));
|
||||
armor.set("UUIDMost", new NBTTagInt(2872));
|
||||
armor.set("Slot", new NBTTagString("chest"));
|
||||
modifiers.add(armor);
|
||||
|
||||
NBTTagCompound armorTough = new NBTTagCompound();
|
||||
armorTough.set("AttributeName", new NBTTagString("generic.armorToughness"));
|
||||
armorTough.set("Name", new NBTTagString("generic.armorToughness"));
|
||||
armorTough.set("Amount", new NBTTagInt(armorToughness));
|
||||
armorTough.set("Operation", new NBTTagInt(0));
|
||||
armorTough.set("UUIDLeast", new NBTTagInt(894654));
|
||||
armorTough.set("UUIDMost", new NBTTagInt(2872));
|
||||
armorTough.set("Slot", new NBTTagString("chest"));
|
||||
modifiers.add(armorTough);
|
||||
|
||||
if (unbreakable)
|
||||
compound.set("Unbreakable", new NBTTagByte((byte) 1));
|
||||
|
||||
compound.set("AttributeModifiers", modifiers);
|
||||
item = CraftItemStack.asBukkitCopy(nmsStack);
|
||||
return item;
|
||||
}
|
||||
|
||||
// Get the armor tier of the supplied item.
|
||||
@Override
|
||||
public ArmorTier getArmorTier(ItemStack item)
|
||||
{
|
||||
if (item == null)
|
||||
return ArmorTier.NONE;
|
||||
if (item.getType() != Material.ELYTRA)
|
||||
return ArmorTier.NONE;
|
||||
|
||||
// Get the NBT tags from the item.
|
||||
NBTTagCompound compound = CraftItemStack.asNMSCopy(item).getTag();
|
||||
if (compound == null)
|
||||
return ArmorTier.NONE;
|
||||
String nbtTags = compound.toString();
|
||||
|
||||
// Check if the item has the generic.armor attribute.
|
||||
// Format = <level>,Slot:"chest",AttributeName:"generic.armor so get pos of char before
|
||||
// The start of the string, as that's the value of the generic.armor attribute.
|
||||
int pos = nbtTags.indexOf(",Slot:\"chest\",AttributeName:\"generic.armor\"");
|
||||
int armorValue = 0;
|
||||
if (pos > 0)
|
||||
{
|
||||
// If so, get the value of the generic.armor attribute.
|
||||
pos--;
|
||||
String stringAtPos = nbtTags.substring(pos, pos+1);
|
||||
armorValue = Integer.parseInt(stringAtPos);
|
||||
} else
|
||||
// Otherwise, the item has no armor, so return 0;
|
||||
return ArmorTier.NONE;
|
||||
|
||||
switch (armorValue)
|
||||
{
|
||||
case 3:
|
||||
return ArmorTier.LEATHER;
|
||||
case 5:
|
||||
return ArmorTier.GOLD;
|
||||
case 6:
|
||||
return ArmorTier.IRON;
|
||||
case 8:
|
||||
return ArmorTier.DIAMOND;
|
||||
default:
|
||||
return ArmorTier.NONE;
|
||||
}
|
||||
}
|
||||
}
|
@ -139,9 +139,11 @@ public class Update
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// There was an error reading the query
|
||||
// There was an error reading the query.
|
||||
// Does not print stacktrace, so people won't see any errors from this plugin when Bukkit Dev's servers are down,
|
||||
// So people won't think the plugin is broken, while the actualy problem is much, much smaller. latestVersion will be null, though, which will prompt a warning in the log instead.
|
||||
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: ArmoredElytra
|
||||
main: nl.pim16aap2.armoredElytra.ArmoredElytra
|
||||
version: 2.4
|
||||
version: 2.4.2
|
||||
author: Pim
|
||||
commands:
|
||||
ArmoredElytra:
|
||||
|
Loading…
x
Reference in New Issue
Block a user