Skip to content
Permalink
Browse files

1.13.2 bleeding update

  • Loading branch information...
MarcinWieczorek committed Dec 15, 2018
1 parent f5c3eee commit cbea57eda84d91c24baface18afc1bd3b680726b
@@ -93,7 +93,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -127,7 +127,7 @@ public void create() {
public void delete() {
hologram.delete();
NovaGuilds.getInstance().getHologramManager().getHolograms().remove(this);
location.getWorld().playEffect(location, Effect.POTION_SWIRL, 1000);
location.getWorld().playEffect(location, Effect.POTION_BREAK, 1000);
deleted = true;
}

@@ -19,10 +19,10 @@
package co.marcin.novaguilds.impl.util;

import co.marcin.novaguilds.api.util.BannerMetaSerializer;
import co.marcin.novaguilds.util.CompatibilityUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.inventory.meta.BannerMeta;
@@ -60,7 +60,7 @@ public String serialize(BannerMeta bannerMeta) {

@Override
public BannerMeta deserialize(String string) {
BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(Material.BANNER);
BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(CompatibilityUtils.Mat.WHITE_BANNER.get());

if(string == null || string.isEmpty()) {
return meta;
@@ -20,6 +20,7 @@

import co.marcin.novaguilds.NovaGuilds;
import co.marcin.novaguilds.api.util.Schematic;
import co.marcin.novaguilds.util.CompatibilityUtils;
import co.marcin.novaguilds.util.LoggerUtils;
import co.marcin.novaguilds.util.Meta;
import co.marcin.novaguilds.util.reflect.Reflections;
@@ -118,8 +119,8 @@ public void paste(Location location) {
Meta.protect(block);
Meta.setMetadata(block, "state", block.getState());

block.setTypeId(blocks[index] < 0 ? Material.SPONGE.getId() : blocks[index]);
block.setData(data[index]);
block.setType(blocks[index] < 0 ? Material.SPONGE : CompatibilityUtils.getMaterial(blocks[index]));
block.getState().setRawData(data[index]);
}
}
}
@@ -27,11 +27,11 @@
import co.marcin.novaguilds.impl.versionimpl.v1_7_R4.packet.PacketPlayInUpdateSign;
import co.marcin.novaguilds.impl.versionimpl.v1_7_R4.packet.PacketPlayOutOpenSignEditor;
import co.marcin.novaguilds.impl.versionimpl.v1_7_R4.packet.PacketPlayOutUpdateSign;
import co.marcin.novaguilds.util.CompatibilityUtils;
import co.marcin.novaguilds.util.LoggerUtils;
import co.marcin.novaguilds.util.reflect.PacketSender;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;

import java.lang.reflect.InvocationTargetException;
@@ -93,7 +93,7 @@ public void open(Player player, String[] defaultText, SignGUIListener response)
}

if(defaultText != null) {
packets.add(new PacketPlayOutBlockChange(location, Material.SIGN_POST, 0));
packets.add(new PacketPlayOutBlockChange(location, CompatibilityUtils.Mat.SIGN.get(), 0));
packets.add(new PacketPlayOutUpdateSign(location, defaultText));
}

@@ -27,11 +27,11 @@
import co.marcin.novaguilds.impl.versionimpl.v1_7_R4.packet.PacketPlayOutBlockChange;
import co.marcin.novaguilds.impl.versionimpl.v1_7_R4.packet.PacketPlayOutOpenSignEditor;
import co.marcin.novaguilds.impl.versionimpl.v1_7_R4.packet.PacketPlayOutUpdateSign;
import co.marcin.novaguilds.util.CompatibilityUtils;
import co.marcin.novaguilds.util.LoggerUtils;
import co.marcin.novaguilds.util.reflect.PacketSender;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;

import java.lang.reflect.InvocationTargetException;
@@ -93,7 +93,7 @@ public void open(Player player, String[] defaultText, SignGUIListener response)
}

if(defaultText != null) {
packets.add(new PacketPlayOutBlockChange(location, Material.SIGN_POST, 0));
packets.add(new PacketPlayOutBlockChange(location, CompatibilityUtils.Mat.SIGN.get(), 0));
packets.add(new PacketPlayOutUpdateSign(location, defaultText));
}

@@ -27,11 +27,11 @@
import co.marcin.novaguilds.impl.versionimpl.v1_8_R1.packet.PacketPlayOutBlockChange;
import co.marcin.novaguilds.impl.versionimpl.v1_8_R1.packet.PacketPlayOutUpdateSign;
import co.marcin.novaguilds.impl.versionimpl.v1_9_R2.packet.PacketPlayOutOpenSignEditor;
import co.marcin.novaguilds.util.CompatibilityUtils;
import co.marcin.novaguilds.util.LoggerUtils;
import co.marcin.novaguilds.util.reflect.PacketSender;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;

import java.lang.reflect.InvocationTargetException;
@@ -55,7 +55,7 @@ public void open(Player player, String[] defaultText, SignGUIListener response)
location.setY(0);

if(defaultText != null) {
packets.add(new PacketPlayOutBlockChange(location, Material.SIGN_POST, 0));
packets.add(new PacketPlayOutBlockChange(location, CompatibilityUtils.Mat.SIGN.get(), 0));
packets.add(new PacketPlayOutUpdateSign(location, defaultText));
}

@@ -27,11 +27,11 @@
import co.marcin.novaguilds.impl.versionimpl.v1_9_R1.packet.PacketPlayOutBlockChange;
import co.marcin.novaguilds.impl.versionimpl.v1_9_R1.packet.PacketPlayOutOpenSignEditor;
import co.marcin.novaguilds.impl.versionimpl.v1_9_R1.packet.PacketPlayOutUpdateSign;
import co.marcin.novaguilds.util.CompatibilityUtils;
import co.marcin.novaguilds.util.LoggerUtils;
import co.marcin.novaguilds.util.reflect.PacketSender;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;

import java.lang.reflect.InvocationTargetException;
@@ -55,7 +55,7 @@ public void open(Player player, String[] defaultText, SignGUIListener response)
location.setY(0);

if(defaultText != null) {
packets.add(new PacketPlayOutBlockChange(location, Material.SIGN_POST, 0));
packets.add(new PacketPlayOutBlockChange(location, CompatibilityUtils.Mat.SIGN.get(), 0));
packets.add(new PacketPlayOutUpdateSign(location, defaultText));
}

@@ -27,11 +27,11 @@
import co.marcin.novaguilds.impl.versionimpl.v1_9_R1.packet.PacketPlayOutBlockChange;
import co.marcin.novaguilds.impl.versionimpl.v1_9_R1.packet.PacketPlayOutOpenSignEditor;
import co.marcin.novaguilds.impl.versionimpl.v1_9_R1.packet.PacketPlayOutUpdateSign;
import co.marcin.novaguilds.util.CompatibilityUtils;
import co.marcin.novaguilds.util.LoggerUtils;
import co.marcin.novaguilds.util.reflect.PacketSender;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;

import java.lang.reflect.InvocationTargetException;
@@ -55,7 +55,7 @@ public void open(Player player, String[] defaultText, SignGUIListener response)
location.setY(0);

if(defaultText != null) {
packets.add(new PacketPlayOutBlockChange(location, Material.SIGN_POST, 0));
packets.add(new PacketPlayOutBlockChange(location, CompatibilityUtils.Mat.SIGN.get(), 0));
packets.add(new PacketPlayOutUpdateSign(location, defaultText));
}

@@ -27,18 +27,17 @@
import co.marcin.novaguilds.impl.versionimpl.v1_9_R2.packet.PacketPlayOutBlockChange;
import co.marcin.novaguilds.impl.versionimpl.v1_9_R2.packet.PacketPlayOutOpenSignEditor;
import co.marcin.novaguilds.impl.versionimpl.v1_9_R2.packet.PacketPlayOutTileEntityData;
import co.marcin.novaguilds.util.CompatibilityUtils;
import co.marcin.novaguilds.util.LoggerUtils;
import co.marcin.novaguilds.util.reflect.PacketSender;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("ConstantConditions")
public class SignGUIImpl extends AbstractSignGui {
/**
* The constructor
@@ -55,7 +54,7 @@ public void open(Player player, String[] defaultText, SignGUIListener response)
location.setY(0);

if(defaultText != null) {
packets.add(new PacketPlayOutBlockChange(location, Material.SIGN_POST, 0));
packets.add(new PacketPlayOutBlockChange(location, CompatibilityUtils.Mat.SIGN.get(), 0));
packets.add(PacketPlayOutTileEntityData.getSignChange(location, defaultText));
}

@@ -320,7 +320,7 @@ public void onBlockFromTo(BlockFromToEvent event) {
if(!Config.REGION_WATERFLOW.getBoolean()) {
Material type = event.getBlock().getType();

if((type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA)
if((type == Material.WATER || type == CompatibilityUtils.Mat.WATER.get() || type == Material.LAVA || type == CompatibilityUtils.Mat.LAVA.get())
&& RegionManager.get(event.getBlock()) == null
&& RegionManager.get(event.getToBlock()) != null) {
event.setCancelled(true);
@@ -96,6 +96,8 @@ public static ServerVersion getServerVersion() {
MINECRAFT_1_10_R2,
MINECRAFT_1_11_R1,
MINECRAFT_1_12_R1,
MINECRAFT_1_13_R1,
MINECRAFT_1_13_R2,
;

/**
@@ -83,7 +83,7 @@ public void checkDependencies() throws MissingDependencyException {
additionalTask.run();
additionalTask.onSuccess();
}
catch(Exception e) {
catch(Exception | Error e) {
additionalTask.onFail();
AdditionalTaskException taskException = new AdditionalTaskException("Could not pass additional task '" + additionalTask.getClass().getSimpleName() + "' for " + dependency.getName(), e);

@@ -108,7 +108,10 @@ public void checkDependencies() throws MissingDependencyException {
}

//Set config values varying if dependencies are missing
Config.BOSSBAR_ENABLED.set(Config.BOSSBAR_ENABLED.getBoolean() && (ConfigManager.getServerVersion().isNewerThan(ConfigManager.ServerVersion.MINECRAFT_1_8_R2) || plugin.getDependencyManager().isEnabled(Dependency.BARAPI) || plugin.getDependencyManager().isEnabled(Dependency.BOSSBARAPI)));
Config.BOSSBAR_ENABLED.set(Config.BOSSBAR_ENABLED.getBoolean()
&& (ConfigManager.getServerVersion().isNewerThan(ConfigManager.ServerVersion.MINECRAFT_1_8_R2)
|| plugin.getDependencyManager().isEnabled(Dependency.BARAPI)
|| plugin.getDependencyManager().isEnabled(Dependency.BOSSBARAPI)));
Config.BOSSBAR_RAIDBAR_ENABLED.set(Config.BOSSBAR_RAIDBAR_ENABLED.getBoolean() && Config.BOSSBAR_ENABLED.getBoolean());
Config.HOLOGRAPHICDISPLAYS_ENABLED.set(Config.HOLOGRAPHICDISPLAYS_ENABLED.getBoolean() && plugin.getDependencyManager().isEnabled(Dependency.HOLOGRAPHICDISPLAYS));
}
@@ -128,6 +131,7 @@ public boolean isEnabled(Dependency dependency) {
*/
public void setupEconomy() {
RegisteredServiceProvider<Economy> rsp = Bukkit.getServicesManager().getRegistration(Economy.class);
Validate.notNull(rsp, "Could not find the Economy provider");
economy = rsp.getProvider();
Validate.notNull(economy);
}
@@ -150,7 +154,7 @@ private Plugin getPlugin(String name) {
* @param <T> class to cast
* @return plugin instance
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "unused"})
public <T extends Plugin> T get(Dependency dependency, Class<T> cast) {
return (T) pluginMap.get(dependency);
}
@@ -59,7 +59,7 @@ public static ItemStack randomBannerItemStack() {
return null;
}

ItemStack itemStack = new ItemStack(Material.BANNER);
ItemStack itemStack = new ItemStack(CompatibilityUtils.Mat.WHITE_BANNER.get());
itemStack.setItemMeta(getRandomMeta());
return itemStack;
}
@@ -74,7 +74,7 @@ public static BannerMeta getRandomMeta() {
return null;
}

BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(Material.BANNER);
BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(CompatibilityUtils.Mat.WHITE_BANNER.get());
meta.setBaseColor(randomDyeColor());

for(int i = NumberUtils.randInt(0, PatternType.values().length) + 2; i > 0; i--) {
@@ -161,7 +161,7 @@ public static Banner applyMeta(Banner banner, BannerMeta meta) {
* @return shield item
*/
public static ItemStack applyMeta(ItemStack itemStack, BannerMeta bannerMeta) {
if(itemStack.getType() != Material.SHIELD && itemStack.getType() != Material.BANNER) {
if(itemStack.getType() != Material.SHIELD && itemStack.getType() != CompatibilityUtils.Mat.WHITE_BANNER.get()) {
throw new IllegalArgumentException("Passed ItemStack is not a shield nor a banner");
}

@@ -186,7 +186,7 @@ public static BannerMeta getBannerMeta(Banner banner) {
return null;
}

BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(Material.BANNER);
BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(CompatibilityUtils.Mat.WHITE_BANNER.get());

meta.setBaseColor(banner.getBaseColor());
for(Pattern pattern : banner.getPatterns()) {
@@ -194,4 +194,55 @@ public static Block getTargetBlock(Player player, Set<Material> transparent, int
return getTargetBlockMethod.invoke(player, transparent, maxDistance);
}
}

/**
* Gets material by id
*
* @param id id
* @return material enum
*/
public static Material getMaterial(int id) {
for(Material material : Material.values()) {
if(material.getId() == id) {
return material;
}
}

return null;
}

public enum Mat {
WATER("STATIONARY_WATER"),
LAVA("STATIONARY_LAVA"),
PLAYER_HEAD("SKULL_ITEM"),
FIREWORK_ROCKET("FIREWORK"),
INK_SAC("INK_SACK"),
WHITE_BANNER("BANNER"),
SIGN("SIGN_POST")
;

private final String legacyName;

/**
* The constructor
*
* @param legacyName pre 1.13 material name
*/
Mat(String legacyName) {
this.legacyName = legacyName;
}

/**
* Gets material enum depending on the version
*
* @return material enum
*/
public Material get() {
if(ConfigManager.getServerVersion().isNewerThan(ConfigManager.ServerVersion.MINECRAFT_1_12_R1)) {
return Material.getMaterial("LEGACY_" + legacyName);
}

return Material.getMaterial(legacyName);
}
}
}
@@ -18,17 +18,18 @@

package co.marcin.novaguilds.util;

import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.inventory.ItemStack;

public class EnchantmentGlow extends Enchantment {
/**
* Glow enchantment constructor
* Registers it as ID 150
* Registers it as 'ngglow'
*/
public EnchantmentGlow() {
super(150);
super(NamespacedKey.minecraft("ngglow"));
}

@Override
Oops, something went wrong.

0 comments on commit cbea57e

Please sign in to comment.
You can’t perform that action at this time.