mirror of
https://github.com/darksaid98/Builders-Utilities.git
synced 2026-12-02 06:28:53 +00:00
bug fixes :)
and added 1.13 support
This commit is contained in:
1 parent
cc80dfad7a
commit
009927e4f4
9 files changed
+74
-27
No files matched your search
@@ -6,6 +6,7 @@ import com.buildersrefuge.utilities.cmd.CommandHandler;
|
||||
import com.buildersrefuge.utilities.cmd.SecretBlockHandler;
|
||||
import com.buildersrefuge.utilities.listeners.*;
|
||||
import com.buildersrefuge.utilities.object.NoClipManager;
|
||||
import com.buildersrefuge.utilities.util.NmsManager;
|
||||
import com.massivestats.MassiveStats;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -35,15 +36,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main extends JavaPlugin implements Listener {
|
||||
public static String version;
|
||||
public static NmsManager nmsManager;
|
||||
public static List<String> ironTrapdoorNames;
|
||||
public static List<String> slabNames;
|
||||
public static List<String> terracottaNames;
|
||||
public static Main main;
|
||||
|
||||
public void onEnable() {
|
||||
String a = this.getServer().getClass().getPackage().getName();
|
||||
version = a.substring(a.lastIndexOf('.') + 1);
|
||||
nmsManager = new NmsManager();
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
CommandHandler commandHandler = new CommandHandler(this);
|
||||
@@ -150,7 +150,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||
}
|
||||
if (!e.getAction().equals(Action.LEFT_CLICK_BLOCK)){return;}
|
||||
Material type = e.getPlayer().getInventory().getItemInHand().getType();
|
||||
if (!version.contains("v1_8")){
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 9 ,0)){
|
||||
if (!(type.equals(Material.STEP)||type.equals(Material.WOOD_STEP)||type.equals(Material.STONE_SLAB2)||type.equals(Material.PURPUR_SLAB))){
|
||||
return;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!version.contains("v1_8")){
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 9 ,0)){
|
||||
if (e.getClickedBlock().getType().equals(Material.PURPUR_DOUBLE_SLAB)){
|
||||
if (e.getClickedBlock().getData()<=7){
|
||||
e.setCancelled(true);
|
||||
@@ -269,7 +269,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(final PlayerJoinEvent e) {
|
||||
if (!version.contains("v1_8")) {
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 9 ,0)){
|
||||
if (this.getConfig().getBoolean("fix-attackspeed")) {
|
||||
AttributeInstance attribute = e.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED);
|
||||
attribute.setBaseValue(1024.0D);
|
||||
@@ -299,10 +299,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void GlazedTerracottaInteract(final PlayerInteractEvent e) {
|
||||
if (!version.contains("v1_12") && (e.getHand() == null)) {
|
||||
return;
|
||||
}
|
||||
if (e.getHand() == null) {
|
||||
if (!Main.nmsManager.isAtLeastVersion(1, 12 ,0)){
|
||||
return;
|
||||
}
|
||||
if (!e.getHand().equals(EquipmentSlot.HAND)) {
|
||||
@@ -357,7 +354,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||
if (!e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)) {
|
||||
return;
|
||||
}
|
||||
if (!version.contains("v1_8")) {
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 9 ,0)){
|
||||
if (!e.getHand().equals(EquipmentSlot.HAND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,10 +33,8 @@ public class SecretBlocksInventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (name.equals("§1Secret Blocks") || e.getInventory().getName().equals("§1Secret Blocks")) {
|
||||
if (name.equals("§1Secret Blocks")) {
|
||||
e.getWhoClicked().getInventory().addItem(e.getCurrentItem());
|
||||
}
|
||||
if (name.contains("Secret Blocks")) {
|
||||
e.getWhoClicked().getInventory().addItem(e.getCurrentItem());
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.buildersrefuge.utilities.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -31,10 +30,9 @@ public class ToggleInventoryListener implements Listener{
|
||||
name = e.getClickedInventory().getName();
|
||||
}
|
||||
catch(Exception exc){
|
||||
exc.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (name.contains("Builders Utilities") || e.getInventory().getName().contains("Builders Utilities")) {
|
||||
if (name.contains("Builders Utilities")) {
|
||||
ToggleGUI gui = new ToggleGUI();
|
||||
e.setCancelled(true);
|
||||
if (slot==1||slot==10||slot==19){
|
||||
@@ -54,7 +52,7 @@ public class ToggleInventoryListener implements Listener{
|
||||
}
|
||||
}
|
||||
if (slot==3||slot==12||slot==21){
|
||||
if (Main.version.contains("v1_12")){
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 12 ,0)){
|
||||
if (Main.terracottaNames.contains(p.getName())){
|
||||
Main.terracottaNames.remove(p.getName());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.buildersrefuge.utilities.util;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
@@ -55,7 +56,7 @@ public class BannerUtil {
|
||||
Items i = new Items();
|
||||
ItemStack item = i.create(Material.BANNER, (short) 0, 1, name, "");
|
||||
BannerMeta meta = (BannerMeta) item.getItemMeta();
|
||||
if (com.buildersrefuge.utilities.Main.version.contains("v1_12") || com.buildersrefuge.utilities.Main.version.contains("v1_11")) {
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 11 ,0)){
|
||||
item.setDurability((short) allColors.indexOf(base));
|
||||
} else {
|
||||
meta.setBaseColor(base);
|
||||
@@ -79,7 +80,7 @@ public class BannerUtil {
|
||||
Items i = new Items();
|
||||
ItemStack item = i.create(Material.BANNER, (short) 0, 1, name, "");
|
||||
BannerMeta meta = (BannerMeta) item.getItemMeta();
|
||||
if (com.buildersrefuge.utilities.Main.version.contains("v1_12") || com.buildersrefuge.utilities.Main.version.contains("v1_11")) {
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 11 ,0)){
|
||||
item.setDurability((short) allColors.indexOf(base));
|
||||
} else {
|
||||
meta.setBaseColor(base);
|
||||
@@ -101,7 +102,7 @@ public class BannerUtil {
|
||||
Items i = new Items();
|
||||
ItemStack item = i.create(Material.BANNER, (short) 0, 1, name, "");
|
||||
BannerMeta meta = (BannerMeta) item.getItemMeta();
|
||||
if (com.buildersrefuge.utilities.Main.version.contains("v1_12") || com.buildersrefuge.utilities.Main.version.contains("v1_11")) {
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 11 ,0)){
|
||||
item.setDurability((short) allColors.indexOf(base));
|
||||
} else {
|
||||
meta.setBaseColor(base);
|
||||
@@ -143,7 +144,7 @@ public class BannerUtil {
|
||||
DyeColor getBaseColor(ItemStack i) {
|
||||
if (i.getType().equals(Material.BANNER)) {
|
||||
BannerMeta meta = (BannerMeta) i.getItemMeta();
|
||||
if (com.buildersrefuge.utilities.Main.version.contains("v1_12") || com.buildersrefuge.utilities.Main.version.contains("v1_11")) {
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 11 ,0)){
|
||||
return allColors.get(i.getDurability());
|
||||
} else {
|
||||
return meta.getBaseColor();
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.buildersrefuge.utilities.util;
|
||||
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
|
||||
public class NmsManager {
|
||||
|
||||
String version;
|
||||
|
||||
public NmsManager() {
|
||||
String a = Main.main.getServer().getClass().getPackage().getName();
|
||||
version = a.substring(a.lastIndexOf('.') + 1);
|
||||
}
|
||||
|
||||
public boolean isVersion(String v) {
|
||||
if (version.equalsIgnoreCase(v)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVersion(int gameV, int releaseV, int subReleaseV) {
|
||||
if (version.equalsIgnoreCase("v" + gameV + "_" + releaseV + "_R" + subReleaseV)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAtLeastVersion(int gameV, int releaseV, int subReleaseV) {
|
||||
String[] split = version.split("_");
|
||||
int game = Integer.parseInt(split[0].toLowerCase().replace("v", ""));
|
||||
int release = Integer.parseInt(split[1]);
|
||||
int subRelease = Integer.parseInt(split[2].toLowerCase().replace("r", ""));
|
||||
|
||||
if (game > gameV) {
|
||||
return true;
|
||||
} else if (game < gameV) {
|
||||
return false;
|
||||
} else {
|
||||
if (release > releaseV) {
|
||||
return true;
|
||||
} else if (release < releaseV) {
|
||||
return false;
|
||||
} else {
|
||||
if (subRelease >= subReleaseV) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class SecretBlockGUI {
|
||||
inv.setItem(18, i.create(Material.MOB_SPAWNER, (short) 0, 1, "§3Spawner Cage", ""));
|
||||
inv.setItem(19, i.create(Material.BARRIER, (short) 0, 1, "§3Barrier", ""));
|
||||
inv.setItem(20, i.create(Material.DRAGON_EGG, (short) 0, 1, "§3Dragon Egg", ""));
|
||||
if (!com.buildersrefuge.utilities.Main.version.contains("v1_8")) {
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 9 ,0)){
|
||||
inv.setItem(21, i.create(Material.GRASS_PATH, (short) 0, 1, "§3Grass Path", ""));
|
||||
if (!Main.main.getConfig().getBoolean("remove-end-gate-from-blocks")){
|
||||
inv.setItem(22, i.createHead(endGatewayB64, 1, "§3End Gateway", "§7§lID§7 209:0"));
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ToggleGUI {
|
||||
inv.setItem(11, i.create(Material.STEP, (short) 0, 1, "&6Custom Slab Breaking", "&c&lDisabled__&7__&7Click to toggle"));
|
||||
inv.setItem(20, RED_GLASS_PANE);
|
||||
}
|
||||
if (Main.version.contains("v1_12")) {
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 12 ,0)){
|
||||
if (Main.terracottaNames.contains(p.getName())) {
|
||||
inv.setItem(3, GREEN_GLASS_PANE);
|
||||
inv.setItem(12, i.create(Material.ORANGE_GLAZED_TERRACOTTA, (short) 0, 1, "&6Glazed Terracotta Rotating", "&a&lEnabled__&7__&7Click to toggle"));
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ disable-soil-trample: true
|
||||
|
||||
disable-leaves-decay: true
|
||||
|
||||
fix-attackspeed: true
|
||||
fix-attackspeed: false
|
||||
|
||||
prevent-dragon-egg-teleport: true
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
name: BuildersUtilities
|
||||
main: com.buildersrefuge.utilities.Main
|
||||
version: 1.2.6
|
||||
version: 1.2.7
|
||||
author: Arcaniax
|
||||
commands:
|
||||
banner:
|
||||
|
||||
Reference in new issue
Block a user