mirror of
https://github.com/darksaid98/Builders-Utilities.git
synced 2026-12-01 14:38:46 +00:00
1.14+ support & Recode
This commit is contained in:
1 parent
08184b44da
commit
74a4eeb19f
23 files changed
+83
-2660
No files matched your search
@@ -1,360 +0,0 @@
|
||||
package com.buildersrefuge.utilities;
|
||||
|
||||
import com.buildersrefuge.utilities.cmd.BannerHandler;
|
||||
import com.buildersrefuge.utilities.cmd.ColorHandler;
|
||||
import com.buildersrefuge.utilities.cmd.CommandHandler;
|
||||
import com.buildersrefuge.utilities.cmd.SecretBlockHandler;
|
||||
import com.buildersrefuge.utilities.listeners.*;
|
||||
import com.buildersrefuge.utilities.object.Metrics;
|
||||
import com.buildersrefuge.utilities.object.NoClipManager;
|
||||
import com.buildersrefuge.utilities.util.NmsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.block.data.type.Slab;
|
||||
import org.bukkit.block.data.type.TrapDoor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main extends JavaPlugin implements Listener {
|
||||
public static Main main;
|
||||
public static NmsManager nmsManager;
|
||||
public static List<String> ironTrapdoorNames;
|
||||
public static List<String> slabNames;
|
||||
public static List<String> terracottaNames;
|
||||
|
||||
public void onEnable() {
|
||||
main = this;
|
||||
nmsManager = new NmsManager();
|
||||
|
||||
Metrics metrics = new Metrics(this);
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
CommandHandler commandHandler = new CommandHandler(this);
|
||||
|
||||
ironTrapdoorNames = new ArrayList<>();
|
||||
slabNames = new ArrayList<>();
|
||||
terracottaNames = new ArrayList<>();
|
||||
|
||||
this.saveDefaultConfig();
|
||||
new NoClipManager(this);
|
||||
|
||||
pm.registerEvents(new BannerInventoryListener(this), this);
|
||||
pm.registerEvents(new ColorInventoryListener(this), this);
|
||||
pm.registerEvents(new SecretBlocksInventoryListener(this), this);
|
||||
pm.registerEvents(new ToggleInventoryListener(this), this);
|
||||
pm.registerEvents(new PlayerMoveListener(this), this);
|
||||
pm.registerEvents(this, this);
|
||||
|
||||
getCommand("banner").setExecutor(new BannerHandler(this));
|
||||
getCommand("armorcolor").setExecutor(new ColorHandler(this));
|
||||
getCommand("blocks").setExecutor(new SecretBlockHandler(this));
|
||||
getCommand("n").setExecutor(commandHandler);
|
||||
getCommand("nc").setExecutor(commandHandler);
|
||||
getCommand("/1").setExecutor(commandHandler);
|
||||
getCommand("/2").setExecutor(commandHandler);
|
||||
getCommand("/cuboid").setExecutor(commandHandler);
|
||||
getCommand("/convex").setExecutor(commandHandler);
|
||||
getCommand("/s").setExecutor(commandHandler);
|
||||
getCommand("/r").setExecutor(commandHandler);
|
||||
getCommand("/f").setExecutor(commandHandler);
|
||||
getCommand("/pa").setExecutor(commandHandler);
|
||||
getCommand("/c").setExecutor(commandHandler);
|
||||
getCommand("ws").setExecutor(commandHandler);
|
||||
getCommand("fs").setExecutor(commandHandler);
|
||||
getCommand("af").setExecutor(commandHandler);
|
||||
getCommand("advfly").setExecutor(commandHandler);
|
||||
getCommand("/derot").setExecutor(commandHandler);
|
||||
getCommand("/scale").setExecutor(commandHandler);
|
||||
getCommand("/twist").setExecutor(commandHandler);
|
||||
getCommand("butil").setExecutor(commandHandler);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWeather(WeatherChangeEvent e) {
|
||||
if (this.getConfig().getBoolean("disable-weather-changes")) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPhysics(BlockPhysicsEvent e) {
|
||||
try {
|
||||
if (e.getChangedType().name().toLowerCase().contains("fence") ||
|
||||
e.getChangedType().name().toLowerCase().contains("pane") ||
|
||||
e.getChangedType().name().toLowerCase().contains("wall") ||
|
||||
e.getChangedType().name().toLowerCase().contains("bar")
|
||||
){return;}
|
||||
} catch (Exception ex){return;}
|
||||
if (!this.getConfig().getBoolean("disable-redstone")) {
|
||||
if (e.getChangedType().name().toLowerCase().contains("redstone") ||
|
||||
e.getChangedType().name().toLowerCase().contains("air") ||
|
||||
e.getChangedType().name().toLowerCase().contains("daylight") ||
|
||||
e.getChangedType().name().toLowerCase().contains("diode") ||
|
||||
e.getChangedType().name().toLowerCase().contains("note") ||
|
||||
e.getChangedType().name().toLowerCase().contains("lever") ||
|
||||
e.getChangedType().name().toLowerCase().contains("button") ||
|
||||
e.getChangedType().name().toLowerCase().contains("command") ||
|
||||
e.getChangedType().name().toLowerCase().contains("tripwire") ||
|
||||
e.getChangedType().name().toLowerCase().contains("plate") ||
|
||||
e.getChangedType().name().toLowerCase().contains("string") ||
|
||||
e.getChangedType().name().toLowerCase().contains("piston") ||
|
||||
e.getChangedType().name().toLowerCase().contains("observer")) {
|
||||
if (!e.getBlock().getType().name().contains("air")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!e.getChangedType().hasGravity()) {
|
||||
if (this.getConfig().getBoolean("disable-physics")) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
if (this.getConfig().getBoolean("disable-gravity-physics")) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onDragonEggTP(PlayerInteractEvent e) {
|
||||
if (e.isCancelled()){
|
||||
return;
|
||||
}
|
||||
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getType().equals(Material.DRAGON_EGG) && this.getConfig().getBoolean("prevent-dragon-egg-teleport")) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockBreak(BlockBreakEvent e)
|
||||
{
|
||||
if (e.isCancelled()){
|
||||
return;
|
||||
}
|
||||
if (slabNames.contains(e.getPlayer().getName())){
|
||||
return;
|
||||
}
|
||||
if (!e.getPlayer().getGameMode().equals(GameMode.CREATIVE)){
|
||||
return;
|
||||
}
|
||||
Material type = e.getPlayer().getInventory().getItemInMainHand().getType();
|
||||
if (type.toString().toLowerCase().contains("slab")) {
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (e.getBlock().getType().toString().toLowerCase().contains("slab")) {
|
||||
if (isTop(e.getPlayer(), e.getBlock())) {
|
||||
Slab blockdata = (Slab) e.getBlock().getBlockData();
|
||||
if (blockdata.getType().equals(Slab.Type.DOUBLE)) {
|
||||
blockdata.setType(Slab.Type.BOTTOM);
|
||||
e.getBlock().setBlockData(blockdata, true);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
Slab blockdata = (Slab) e.getBlock().getBlockData();
|
||||
if (blockdata.getType().equals(Slab.Type.DOUBLE)) {
|
||||
blockdata.setType(Slab.Type.TOP);
|
||||
e.getBlock().setBlockData(blockdata, true);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isTop(Player p, Block b) {
|
||||
Location start = p.getEyeLocation().clone();
|
||||
while ((!start.getBlock().equals(b)) && start.distance(p.getEyeLocation()) < 6) {
|
||||
start.add(p.getLocation().getDirection().multiply(0.05));
|
||||
}
|
||||
return start.getY() % 1 > 0.5;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent e) {
|
||||
if (this.getConfig().getBoolean("disable-explosions")) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||
if (e.isCancelled()){
|
||||
return;
|
||||
}
|
||||
if (this.getConfig().getBoolean("disable-soil-trample")) {
|
||||
if (e.getAction() == Action.PHYSICAL) {
|
||||
Block block = e.getClickedBlock();
|
||||
if (block == null) return;
|
||||
if (block.getType() == Material.FARMLAND) {
|
||||
e.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeafDecay(LeavesDecayEvent e) {
|
||||
if (this.getConfig().getBoolean("disable-leaves-decay")) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
NoClipManager.noClipPlayerNames.remove(p.getName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(final PlayerJoinEvent e) {
|
||||
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);
|
||||
e.getPlayer().saveData();
|
||||
} else {
|
||||
AttributeInstance attribute = e.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED);
|
||||
if (attribute.getBaseValue() == 1024.0D) {
|
||||
attribute.setBaseValue(attribute.getDefaultValue());
|
||||
e.getPlayer().saveData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTeleport(PlayerTeleportEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (event.getCause() == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.SPECTATE)) {
|
||||
if (!event.getPlayer().hasPermission("builders.util.tpgm3")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void GlazedTerracottaInteract(final PlayerInteractEvent e) {
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (terracottaNames.contains(e.getPlayer().getName())) {
|
||||
return;
|
||||
}
|
||||
if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
return;
|
||||
}
|
||||
if (!e.getHand().equals(EquipmentSlot.HAND)) {
|
||||
return;
|
||||
}
|
||||
if (!e.getClickedBlock().getType().name().contains("GLAZED")) {
|
||||
return;
|
||||
}
|
||||
if (!e.getPlayer().isSneaking()) {
|
||||
return;
|
||||
}
|
||||
Material type = e.getPlayer().getInventory().getItemInHand().getType();
|
||||
if (!(type.equals(Material.AIR))) {
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
Block b = e.getClickedBlock();
|
||||
Directional directional = (Directional) b.getBlockData();
|
||||
if (directional.getFacing().equals(BlockFace.NORTH)){
|
||||
directional.setFacing(BlockFace.EAST);
|
||||
}
|
||||
else if (directional.getFacing().equals(BlockFace.EAST)){
|
||||
directional.setFacing(BlockFace.SOUTH);
|
||||
}
|
||||
else if (directional.getFacing().equals(BlockFace.SOUTH)){
|
||||
directional.setFacing(BlockFace.WEST);
|
||||
}
|
||||
else if (directional.getFacing().equals(BlockFace.WEST)){
|
||||
directional.setFacing(BlockFace.NORTH);
|
||||
}
|
||||
b.setBlockData(directional);
|
||||
}, 0L);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void ironTrapDoorInteract(final PlayerInteractEvent e) {
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (ironTrapdoorNames.contains(e.getPlayer().getName())) {
|
||||
return;
|
||||
}
|
||||
if (!e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
|
||||
return;
|
||||
}
|
||||
if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
return;
|
||||
}
|
||||
if (!e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)) {
|
||||
return;
|
||||
}
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 9 ,0)){
|
||||
if (!e.getHand().equals(EquipmentSlot.HAND)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (e.getPlayer().isSneaking()) {
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Block b = e.getClickedBlock();
|
||||
TrapDoor trapDoor = (TrapDoor) b.getBlockData();
|
||||
if (trapDoor.isOpen()){
|
||||
trapDoor.setOpen(false);
|
||||
}
|
||||
else{
|
||||
trapDoor.setOpen(true);
|
||||
}
|
||||
b.setBlockData(trapDoor);
|
||||
}
|
||||
}, 0L);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.buildersrefuge.utilities.cmd;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.util.BannerGUI;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class BannerHandler implements Listener, CommandExecutor {
|
||||
public static Main plugin;
|
||||
|
||||
public BannerHandler(Main main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (p.hasPermission("builders.util.banner")) {
|
||||
BannerGUI g = new BannerGUI();
|
||||
p.openInventory(g.generateStartInv());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.buildersrefuge.utilities.cmd;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.util.ColorGUI;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class ColorHandler implements Listener, CommandExecutor {
|
||||
public static Main plugin;
|
||||
|
||||
public ColorHandler(Main main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (p.hasPermission("builders.util.color")) {
|
||||
ColorGUI g = new ColorGUI();
|
||||
p.openInventory(g.generateInv());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
package com.buildersrefuge.utilities.cmd;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.object.NoClipManager;
|
||||
import com.buildersrefuge.utilities.util.ToggleGUI;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class CommandHandler implements Listener, CommandExecutor {
|
||||
public static Main plugin;
|
||||
public static String prefix = "§3buildersUtil> §b";
|
||||
|
||||
public CommandHandler(Main main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
StringBuilder s;
|
||||
switch (cmd.getName().toLowerCase()) {
|
||||
case "nc":
|
||||
if (p.hasPermission("builders.util.noclip")) {
|
||||
if (NoClipManager.noClipPlayerNames.contains(p.getName())) {
|
||||
NoClipManager.noClipPlayerNames.remove(p.getName());
|
||||
p.sendMessage(prefix + " NoClip §cDisabled");
|
||||
if (p.getGameMode() == GameMode.SPECTATOR) {
|
||||
p.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
} else {
|
||||
NoClipManager.noClipPlayerNames.add(p.getName());
|
||||
p.sendMessage(prefix + " NoClip §aEnabled");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case "n":
|
||||
if (p.hasPermission("builders.util.nightvision")) {
|
||||
if (p.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
|
||||
p.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||
|
||||
p.sendMessage(prefix + " NightVision §cDisabled");
|
||||
} else {
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
|
||||
p.sendMessage(prefix + " NightVision §aEnabled");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case "butil":
|
||||
|
||||
ToggleGUI gui = new ToggleGUI();
|
||||
p.openInventory(gui.generateInv(p));
|
||||
return true;
|
||||
case "af":
|
||||
if (p.hasPermission("builders.util.advancedfly")) {
|
||||
if (com.buildersrefuge.utilities.listeners.PlayerMoveListener.togglePlayer(p)) {
|
||||
p.sendMessage(prefix + " Advanced Fly §aEnabled");
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(prefix + " Advanced Fly §cDisabled");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "/1":
|
||||
plugin.getServer().dispatchCommand(p, "/pos1");
|
||||
return true;
|
||||
case "/2":
|
||||
plugin.getServer().dispatchCommand(p, "/pos2");
|
||||
return true;
|
||||
case "/cuboid":
|
||||
plugin.getServer().dispatchCommand(p, "/sel cuboid");
|
||||
return true;
|
||||
case "/convex":
|
||||
plugin.getServer().dispatchCommand(p, "/sel convex");
|
||||
return true;
|
||||
case "/s":
|
||||
s = new StringBuilder();
|
||||
if (args.length != 0) {
|
||||
for (String arg : args) {
|
||||
s.append(arg).append(" ");
|
||||
}
|
||||
}
|
||||
plugin.getServer().dispatchCommand(p, "/set " + s);
|
||||
return true;
|
||||
case "/r":
|
||||
s = new StringBuilder();
|
||||
if (args.length != 0) {
|
||||
for (String arg : args) {
|
||||
s.append(arg).append(" ");
|
||||
}
|
||||
}
|
||||
plugin.getServer().dispatchCommand(p, "/replace " + s);
|
||||
return true;
|
||||
case "/pa":
|
||||
s = new StringBuilder();
|
||||
if (args.length != 0) {
|
||||
for (String arg : args) {
|
||||
s.append(arg).append(" ");
|
||||
}
|
||||
}
|
||||
plugin.getServer().dispatchCommand(p, "/paste " + s);
|
||||
return true;
|
||||
case "/f":
|
||||
s = new StringBuilder();
|
||||
if (args.length != 0) {
|
||||
for (String arg : args) {
|
||||
s.append(arg).append(" ");
|
||||
}
|
||||
}
|
||||
plugin.getServer().dispatchCommand(p, "/flip " + s);
|
||||
return true;
|
||||
case "/c":
|
||||
s = new StringBuilder();
|
||||
if (args.length != 0) {
|
||||
for (String arg : args) {
|
||||
s.append(arg).append(" ");
|
||||
}
|
||||
}
|
||||
plugin.getServer().dispatchCommand(p, "/copy " + s);
|
||||
return true;
|
||||
case "/derot":
|
||||
if (args.length == 2) {
|
||||
int degrees;
|
||||
try {
|
||||
degrees = Integer.parseInt(args[1]);
|
||||
} catch (Exception e) {
|
||||
p.sendMessage(prefix + "§c //derot [axis] [degrees]");
|
||||
return true;
|
||||
}
|
||||
float radian = (float) (((float) degrees / (float) 360) * 2 * Math.PI);
|
||||
if (args[0].equalsIgnoreCase("x")) {
|
||||
plugin.getServer().dispatchCommand(p, "/deform rotate(y,z," + radian + ")");
|
||||
} else if (args[0].equalsIgnoreCase("y")) {
|
||||
plugin.getServer().dispatchCommand(p, "/deform rotate(x,z," + radian + ")");
|
||||
} else if (args[0].equalsIgnoreCase("z")) {
|
||||
plugin.getServer().dispatchCommand(p, "/deform rotate(x,y," + radian + ")");
|
||||
} else {
|
||||
p.sendMessage(prefix + "§c //derot [axis] [degrees]");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(prefix + "§c //derot [axis] [degrees]");
|
||||
return true;
|
||||
}
|
||||
case "/twist":
|
||||
if (args.length == 2) {
|
||||
int degrees;
|
||||
try {
|
||||
degrees = Integer.parseInt(args[1]);
|
||||
} catch (Exception e) {
|
||||
p.sendMessage(prefix + "§c //twist [axis] [degrees]");
|
||||
return true;
|
||||
}
|
||||
float radian = (float) (((float) degrees / (float) 360) * 2 * Math.PI);
|
||||
if (args[0].equalsIgnoreCase("x")) {
|
||||
plugin.getServer().dispatchCommand(p, "/deform rotate(y,z," + radian / 2 + "*(x+1))");
|
||||
} else if (args[0].equalsIgnoreCase("y")) {
|
||||
plugin.getServer().dispatchCommand(p, "/deform rotate(x,z," + radian / 2 + "*(y+1))");
|
||||
} else if (args[0].equalsIgnoreCase("z")) {
|
||||
plugin.getServer().dispatchCommand(p, "/deform rotate(x,y," + radian / 2 + "*(z+1))");
|
||||
} else {
|
||||
p.sendMessage(prefix + "§c //twist [axis] [degrees]");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(prefix + "§c //twist [axis] [degrees]");
|
||||
return true;
|
||||
}
|
||||
case "/scale":
|
||||
if (args.length == 1) {
|
||||
double size;
|
||||
try {
|
||||
size = Double.parseDouble(args[0]);
|
||||
} catch (Exception e) {
|
||||
p.sendMessage(prefix + "§c //scale [size]");
|
||||
return true;
|
||||
}
|
||||
plugin.getServer().dispatchCommand(p, "/deform x/=" + size + ";y/=" + size + ";z/=" + size);
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(prefix + "§c //scale [size]");
|
||||
return true;
|
||||
}
|
||||
case "/ws":
|
||||
s = new StringBuilder();
|
||||
if (args.length != 0) {
|
||||
for (String arg : args) {
|
||||
s.append(arg).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getServer().dispatchCommand(p, "speed walk " + s);
|
||||
return true;
|
||||
case "fa":
|
||||
s = new StringBuilder();
|
||||
if (args.length != 0) {
|
||||
for (String arg : args) {
|
||||
s.append(arg).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getServer().dispatchCommand(p, "speed fly " + s);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.buildersrefuge.utilities.cmd;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.util.SecretBlockGUI;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class SecretBlockHandler implements Listener, CommandExecutor {
|
||||
public static Main plugin;
|
||||
|
||||
public SecretBlockHandler(Main main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (p.hasPermission("builders.util.secretblocks")) {
|
||||
SecretBlockGUI g = new SecretBlockGUI();
|
||||
p.openInventory(g.generateStartInv());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.buildersrefuge.utilities.enums;
|
||||
|
||||
public enum InventoryTypeEnum {
|
||||
BANNER_BASE, BANNER_COLOR, BANNER_PATTERN, COLOR, SECRET, TOGGLE, INVALID;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.buildersrefuge.utilities.inventory;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.enums.InventoryTypeEnum;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public class UtilitiesInventoryHolder implements InventoryHolder {
|
||||
|
||||
private InventoryTypeEnum type;
|
||||
private Inventory inv;
|
||||
|
||||
public UtilitiesInventoryHolder(InventoryTypeEnum type){
|
||||
this.type = type;
|
||||
inv = Main.main.getServer().createInventory(this, 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inv;
|
||||
}
|
||||
|
||||
public InventoryTypeEnum getType(){
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
package com.buildersrefuge.utilities.listeners;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.enums.InventoryTypeEnum;
|
||||
import com.buildersrefuge.utilities.inventory.UtilitiesInventoryHolder;
|
||||
import com.buildersrefuge.utilities.util.BannerGUI;
|
||||
import com.buildersrefuge.utilities.util.BannerUtil;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BannerInventoryListener implements Listener {
|
||||
public Main plugin;
|
||||
|
||||
public BannerInventoryListener(Main main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
int slot;
|
||||
Random r = new Random();
|
||||
try {
|
||||
e.getClickedInventory().getHolder();
|
||||
} catch (Exception exc) {
|
||||
return;
|
||||
}
|
||||
if (e.getClickedInventory().getHolder() instanceof UtilitiesInventoryHolder){
|
||||
UtilitiesInventoryHolder inventoryHolder = (UtilitiesInventoryHolder)e.getClickedInventory().getHolder();
|
||||
InventoryTypeEnum typeEnum = inventoryHolder.getType();
|
||||
try {
|
||||
slot = e.getRawSlot();
|
||||
} catch (Exception exc) {
|
||||
return;
|
||||
}
|
||||
BannerGUI gui = new BannerGUI();
|
||||
switch (typeEnum) {
|
||||
case BANNER_BASE:
|
||||
e.setCancelled(true);
|
||||
if (slot == 1) {
|
||||
int ran = r.nextInt(16);
|
||||
if (ran > 7) {
|
||||
ran++;
|
||||
}
|
||||
p.openInventory(gui.generateColorInv(e.getClickedInventory(), e.getClickedInventory().getItem(ran + 20), true));
|
||||
}
|
||||
if (slot == 7) {
|
||||
p.closeInventory();
|
||||
}
|
||||
if (slot > 18 && slot < 36 && (slot % 9) > 0) {
|
||||
p.openInventory(gui.generateColorInv(e.getClickedInventory(), e.getCurrentItem(), true));
|
||||
}
|
||||
break;
|
||||
case BANNER_COLOR:
|
||||
e.setCancelled(true);
|
||||
if (slot == 1) {
|
||||
int ran = r.nextInt(16);
|
||||
if (ran > 7) {
|
||||
ran++;
|
||||
}
|
||||
p.openInventory(gui.generatePatternInv(e.getClickedInventory(), e.getClickedInventory().getItem(ran + 20)));
|
||||
}
|
||||
if (slot == 7) {
|
||||
p.closeInventory();
|
||||
} else if (slot == 4) {
|
||||
ItemStack item = e.getCurrentItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("");
|
||||
item.setItemMeta(meta);
|
||||
p.getInventory().addItem(item);
|
||||
p.closeInventory();
|
||||
} else if (slot > 18 && slot < 36 && (slot % 9) > 0) {
|
||||
p.openInventory(gui.generatePatternInv(e.getClickedInventory(), e.getCurrentItem()));
|
||||
}
|
||||
break;
|
||||
case BANNER_PATTERN:
|
||||
e.setCancelled(true);
|
||||
if (slot == 1) {
|
||||
if (((BannerMeta) e.getClickedInventory().getItem(4).getItemMeta()).numberOfPatterns() > 9) {
|
||||
BannerUtil bU = new BannerUtil();
|
||||
int ran = r.nextInt(38) + 9;
|
||||
ItemStack item = bU.addPattern(e.getClickedInventory().getItem(4), new Pattern(bU.getColorFromBanner(e.getClickedInventory().getItem(ran)), bU.getPatternType(e.getClickedInventory().getItem(ran))));
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("");
|
||||
item.setItemMeta(meta);
|
||||
p.getInventory().addItem(item);
|
||||
p.closeInventory();
|
||||
} else {
|
||||
p.openInventory(gui.generateColorInv(e.getClickedInventory(), e.getClickedInventory().getItem(r.nextInt(38) + 9), false));
|
||||
}
|
||||
}
|
||||
if (slot == 7) {
|
||||
p.closeInventory();
|
||||
} else if (slot == 4) {
|
||||
ItemStack item = e.getCurrentItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("");
|
||||
item.setItemMeta(meta);
|
||||
p.getInventory().addItem(item);
|
||||
p.closeInventory();
|
||||
} else if (slot > 8 && slot < 47) {
|
||||
if (((BannerMeta) e.getClickedInventory().getItem(4).getItemMeta()).numberOfPatterns() > 9) {
|
||||
BannerUtil bU = new BannerUtil();
|
||||
ItemStack item = bU.addPattern(e.getClickedInventory().getItem(4), new Pattern(bU.getColorFromBanner(e.getCurrentItem()), bU.getPatternType(e.getCurrentItem())));
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("");
|
||||
item.setItemMeta(meta);
|
||||
p.getInventory().addItem(item);
|
||||
p.closeInventory();
|
||||
} else {
|
||||
p.openInventory(gui.generateColorInv(e.getClickedInventory(), e.getCurrentItem(), false));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
package com.buildersrefuge.utilities.listeners;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.enums.InventoryTypeEnum;
|
||||
import com.buildersrefuge.utilities.inventory.UtilitiesInventoryHolder;
|
||||
import com.buildersrefuge.utilities.util.ColorGUI;
|
||||
import com.buildersrefuge.utilities.util.Items;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ColorInventoryListener implements Listener {
|
||||
public Main plugin;
|
||||
|
||||
public ColorInventoryListener(Main main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
int slot;
|
||||
try {
|
||||
e.getClickedInventory().getHolder();
|
||||
} catch (Exception exc) {
|
||||
return;
|
||||
}
|
||||
if (e.getClickedInventory().getHolder() instanceof UtilitiesInventoryHolder){
|
||||
UtilitiesInventoryHolder inventoryHolder = (UtilitiesInventoryHolder)e.getClickedInventory().getHolder();
|
||||
InventoryTypeEnum typeEnum = inventoryHolder.getType();
|
||||
try {
|
||||
slot = e.getRawSlot();
|
||||
} catch (Exception exc) {
|
||||
return;
|
||||
}
|
||||
if (typeEnum.equals(InventoryTypeEnum.COLOR)) {
|
||||
Items i = new Items();
|
||||
ColorGUI gui = new ColorGUI();
|
||||
Random ra = new Random();
|
||||
String lore = "&7__&7Left click to increase__&7Right click to decrease__&7Shift click to change by 5";
|
||||
e.setCancelled(true);
|
||||
if (slot == 10 || slot == 19 || slot == 28 || slot == 37) {
|
||||
float multiplier = 255f / 20f;
|
||||
int r = (int) ((float) e.getClickedInventory().getItem(31).getAmount() * multiplier);
|
||||
int g = (int) ((float) e.getClickedInventory().getItem(32).getAmount() * multiplier);
|
||||
int b = (int) ((float) e.getClickedInventory().getItem(33).getAmount() * multiplier);
|
||||
p.getInventory().addItem(i.color(i.create(e.getCurrentItem().getType(), (short) 0, 1, "", ""), r, g, b));
|
||||
} else if (slot == 31) { //RED
|
||||
if (e.getClick().equals(ClickType.LEFT) && e.getClickedInventory().getItem(31).getAmount() < 20) {
|
||||
e.getClickedInventory().setItem(31, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y0NmMzMWQ2ZWU2ZWE2MTlmNzJlNzg1MjMyY2IwNDhhYjI3MDQ2MmRiMGNiMTQ1NDUxNDQzNjI1MWMxYSJ9fX0=",
|
||||
e.getClickedInventory().getItem(31).getAmount() + 1, "&cRed", lore));
|
||||
}
|
||||
if (e.getClick().equals(ClickType.RIGHT) && e.getClickedInventory().getItem(31).getAmount() > 1) {
|
||||
e.getClickedInventory().setItem(31, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y0NmMzMWQ2ZWU2ZWE2MTlmNzJlNzg1MjMyY2IwNDhhYjI3MDQ2MmRiMGNiMTQ1NDUxNDQzNjI1MWMxYSJ9fX0=",
|
||||
e.getClickedInventory().getItem(31).getAmount() - 1, "&cRed", lore));
|
||||
}
|
||||
if (e.getClick().equals(ClickType.SHIFT_LEFT) && e.getClickedInventory().getItem(31).getAmount() < 16) {
|
||||
e.getClickedInventory().setItem(31, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y0NmMzMWQ2ZWU2ZWE2MTlmNzJlNzg1MjMyY2IwNDhhYjI3MDQ2MmRiMGNiMTQ1NDUxNDQzNjI1MWMxYSJ9fX0=",
|
||||
e.getClickedInventory().getItem(31).getAmount() + 5, "&cRed", lore));
|
||||
} else if (e.getClick().equals(ClickType.SHIFT_LEFT)) {
|
||||
e.getClickedInventory().setItem(31, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y0NmMzMWQ2ZWU2ZWE2MTlmNzJlNzg1MjMyY2IwNDhhYjI3MDQ2MmRiMGNiMTQ1NDUxNDQzNjI1MWMxYSJ9fX0=",
|
||||
20, "&cRed", lore));
|
||||
}
|
||||
if (e.getClick().equals(ClickType.SHIFT_RIGHT) && e.getClickedInventory().getItem(31).getAmount() > 5) {
|
||||
e.getClickedInventory().setItem(31, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y0NmMzMWQ2ZWU2ZWE2MTlmNzJlNzg1MjMyY2IwNDhhYjI3MDQ2MmRiMGNiMTQ1NDUxNDQzNjI1MWMxYSJ9fX0=",
|
||||
e.getClickedInventory().getItem(31).getAmount() - 5, "&cRed", lore));
|
||||
} else if (e.getClick().equals(ClickType.SHIFT_RIGHT)) {
|
||||
e.getClickedInventory().setItem(31, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y0NmMzMWQ2ZWU2ZWE2MTlmNzJlNzg1MjMyY2IwNDhhYjI3MDQ2MmRiMGNiMTQ1NDUxNDQzNjI1MWMxYSJ9fX0=",
|
||||
1, "&cRed", lore));
|
||||
}
|
||||
gui.updateInv(e.getClickedInventory());
|
||||
} else if (slot == 32) { //GREEN
|
||||
if (e.getClick().equals(ClickType.LEFT) && e.getClickedInventory().getItem(32).getAmount() < 20) {
|
||||
e.getClickedInventory().setItem(32, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzZmNjlmN2I3NTM4YjQxZGMzNDM5ZjM2NThhYmJkNTlmYWNjYTM2NmYxOTBiY2YxZDZkMGEwMjZjOGY5NiJ9fX0=",
|
||||
e.getClickedInventory().getItem(32).getAmount() + 1, "&aGreen", lore));
|
||||
}
|
||||
if (e.getClick().equals(ClickType.RIGHT) && e.getClickedInventory().getItem(32).getAmount() > 1) {
|
||||
e.getClickedInventory().setItem(32, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzZmNjlmN2I3NTM4YjQxZGMzNDM5ZjM2NThhYmJkNTlmYWNjYTM2NmYxOTBiY2YxZDZkMGEwMjZjOGY5NiJ9fX0=",
|
||||
e.getClickedInventory().getItem(32).getAmount() - 1, "&aGreen", lore));
|
||||
}
|
||||
if (e.getClick().equals(ClickType.SHIFT_LEFT) && e.getClickedInventory().getItem(32).getAmount() < 16) {
|
||||
e.getClickedInventory().setItem(32, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzZmNjlmN2I3NTM4YjQxZGMzNDM5ZjM2NThhYmJkNTlmYWNjYTM2NmYxOTBiY2YxZDZkMGEwMjZjOGY5NiJ9fX0=",
|
||||
e.getClickedInventory().getItem(32).getAmount() + 5, "&aGreen", lore));
|
||||
} else if (e.getClick().equals(ClickType.SHIFT_LEFT)) {
|
||||
e.getClickedInventory().setItem(32, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzZmNjlmN2I3NTM4YjQxZGMzNDM5ZjM2NThhYmJkNTlmYWNjYTM2NmYxOTBiY2YxZDZkMGEwMjZjOGY5NiJ9fX0=",
|
||||
20, "&aGreen", lore));
|
||||
}
|
||||
if (e.getClick().equals(ClickType.SHIFT_RIGHT) && e.getClickedInventory().getItem(32).getAmount() > 5) {
|
||||
e.getClickedInventory().setItem(32, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzZmNjlmN2I3NTM4YjQxZGMzNDM5ZjM2NThhYmJkNTlmYWNjYTM2NmYxOTBiY2YxZDZkMGEwMjZjOGY5NiJ9fX0=",
|
||||
e.getClickedInventory().getItem(32).getAmount() - 5, "&aGreen", lore));
|
||||
} else if (e.getClick().equals(ClickType.SHIFT_RIGHT)) {
|
||||
e.getClickedInventory().setItem(32, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzZmNjlmN2I3NTM4YjQxZGMzNDM5ZjM2NThhYmJkNTlmYWNjYTM2NmYxOTBiY2YxZDZkMGEwMjZjOGY5NiJ9fX0=",
|
||||
1, "&aGreen", lore));
|
||||
}
|
||||
gui.updateInv(e.getClickedInventory());
|
||||
} else if (slot == 33) { //BLUE
|
||||
if (e.getClick().equals(ClickType.LEFT) && e.getClickedInventory().getItem(33).getAmount() < 20) {
|
||||
e.getClickedInventory().setItem(33, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjgzOWUzODFkOWZlZGFiNmY4YjU5Mzk2YTI3NjQyMzhkY2ViMmY3ZWVhODU2ZGM2ZmM0NDc2N2RhMzgyZjEifX19",
|
||||
e.getClickedInventory().getItem(33).getAmount() + 1, "&bBlue", lore));
|
||||
}
|
||||
if (e.getClick().equals(ClickType.RIGHT) && e.getClickedInventory().getItem(33).getAmount() > 1) {
|
||||
e.getClickedInventory().setItem(33, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjgzOWUzODFkOWZlZGFiNmY4YjU5Mzk2YTI3NjQyMzhkY2ViMmY3ZWVhODU2ZGM2ZmM0NDc2N2RhMzgyZjEifX19",
|
||||
e.getClickedInventory().getItem(33).getAmount() - 1, "&bBlue", lore));
|
||||
}
|
||||
if (e.getClick().equals(ClickType.SHIFT_LEFT) && e.getClickedInventory().getItem(33).getAmount() < 16) {
|
||||
e.getClickedInventory().setItem(33, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjgzOWUzODFkOWZlZGFiNmY4YjU5Mzk2YTI3NjQyMzhkY2ViMmY3ZWVhODU2ZGM2ZmM0NDc2N2RhMzgyZjEifX19",
|
||||
e.getClickedInventory().getItem(33).getAmount() + 5, "&bBlue", lore));
|
||||
} else if (e.getClick().equals(ClickType.SHIFT_LEFT)) {
|
||||
e.getClickedInventory().setItem(33, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjgzOWUzODFkOWZlZGFiNmY4YjU5Mzk2YTI3NjQyMzhkY2ViMmY3ZWVhODU2ZGM2ZmM0NDc2N2RhMzgyZjEifX19",
|
||||
20, "&bBlue", lore));
|
||||
}
|
||||
if (e.getClick().equals(ClickType.SHIFT_RIGHT) && e.getClickedInventory().getItem(33).getAmount() > 5) {
|
||||
e.getClickedInventory().setItem(33, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjgzOWUzODFkOWZlZGFiNmY4YjU5Mzk2YTI3NjQyMzhkY2ViMmY3ZWVhODU2ZGM2ZmM0NDc2N2RhMzgyZjEifX19",
|
||||
e.getClickedInventory().getItem(33).getAmount() - 5, "&bBlue", lore));
|
||||
} else if (e.getClick().equals(ClickType.SHIFT_RIGHT)) {
|
||||
e.getClickedInventory().setItem(33, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjgzOWUzODFkOWZlZGFiNmY4YjU5Mzk2YTI3NjQyMzhkY2ViMmY3ZWVhODU2ZGM2ZmM0NDc2N2RhMzgyZjEifX19",
|
||||
1, "&bBlue", lore));
|
||||
}
|
||||
gui.updateInv(e.getClickedInventory());
|
||||
} else if (slot == 22) { //RANDOM RED
|
||||
e.getClickedInventory().setItem(31, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y0NmMzMWQ2ZWU2ZWE2MTlmNzJlNzg1MjMyY2IwNDhhYjI3MDQ2MmRiMGNiMTQ1NDUxNDQzNjI1MWMxYSJ9fX0=",
|
||||
ra.nextInt(20) + 1, "&cRed", lore));
|
||||
gui.updateInv(e.getClickedInventory());
|
||||
} else if (slot == 23) { //RANDOM GREEN
|
||||
e.getClickedInventory().setItem(32, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzZmNjlmN2I3NTM4YjQxZGMzNDM5ZjM2NThhYmJkNTlmYWNjYTM2NmYxOTBiY2YxZDZkMGEwMjZjOGY5NiJ9fX0=",
|
||||
ra.nextInt(20) + 1, "&aGreen", lore));
|
||||
gui.updateInv(e.getClickedInventory());
|
||||
} else if (slot == 24) { //RANDOM BLUE
|
||||
e.getClickedInventory().setItem(33, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjgzOWUzODFkOWZlZGFiNmY4YjU5Mzk2YTI3NjQyMzhkY2ViMmY3ZWVhODU2ZGM2ZmM0NDc2N2RhMzgyZjEifX19",
|
||||
ra.nextInt(20) + 1, "&bBlue", lore));
|
||||
gui.updateInv(e.getClickedInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
package com.buildersrefuge.utilities.listeners;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerMoveListener implements Listener {
|
||||
private HashMap<String, Double> lastVelocity = new HashMap<>();
|
||||
private static List<String> slower = new ArrayList<>();
|
||||
private static List<String> slower2 = new ArrayList<>();
|
||||
public static List<String> enabledPlayers = new ArrayList<>();
|
||||
|
||||
public Main plugin;
|
||||
|
||||
public PlayerMoveListener(Main main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
public static boolean togglePlayer(Player p) {
|
||||
if (enabledPlayers.contains(p.getName())) {
|
||||
enabledPlayers.remove(p.getName());
|
||||
return false;
|
||||
} else {
|
||||
enabledPlayers.add(p.getName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onMove(final PlayerMoveEvent e) {
|
||||
if (e.getPlayer().isFlying()) {
|
||||
if (!enabledPlayers.contains(e.getPlayer().getName())) {
|
||||
return;
|
||||
}
|
||||
Double speed = e.getFrom().clone().add(0, -e.getFrom().getY(), 0).distance(e.getTo().clone().add(0, -e.getTo().getY(), 0));
|
||||
|
||||
if (Math.abs(e.getFrom().getYaw() - e.getTo().getYaw()) > 5) {
|
||||
return;
|
||||
}
|
||||
if (Math.abs(e.getFrom().getPitch() - e.getTo().getPitch()) > 5) {
|
||||
return;
|
||||
}
|
||||
if (lastVelocity.containsKey(e.getPlayer().getName())) {
|
||||
Double lastSpeed = lastVelocity.get(e.getPlayer().getName());
|
||||
if (speed * 1.3 < lastSpeed) {
|
||||
if (slower.contains(e.getPlayer().getName())) {
|
||||
if (slower2.contains(e.getPlayer().getName())) {
|
||||
Vector v = e.getPlayer().getVelocity().clone();
|
||||
v.setX(0);
|
||||
v.setZ(0);
|
||||
e.getPlayer().setVelocity(v);
|
||||
lastVelocity.put(e.getPlayer().getName(), 0.0);
|
||||
//No more if slower.contains** as if e.getPlayer().getName() isn't thhere, it won't get removed (:
|
||||
slower.remove(e.getPlayer().getName());
|
||||
slower2.remove(e.getPlayer().getName());
|
||||
} else {
|
||||
slower2.add(e.getPlayer().getName());
|
||||
}
|
||||
} else {
|
||||
slower.add(e.getPlayer().getName());
|
||||
}
|
||||
} else if (speed > lastSpeed) {
|
||||
lastVelocity.put(e.getPlayer().getName(), speed);
|
||||
slower.remove(e.getPlayer().getName());
|
||||
slower2.remove(e.getPlayer().getName());
|
||||
}
|
||||
} else {
|
||||
lastVelocity.put(e.getPlayer().getName(), speed);
|
||||
slower.remove(e.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.buildersrefuge.utilities.listeners;
|
||||
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.enums.InventoryTypeEnum;
|
||||
import com.buildersrefuge.utilities.inventory.UtilitiesInventoryHolder;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class SecretBlocksInventoryListener implements Listener {
|
||||
public Main plugin;
|
||||
|
||||
public SecretBlocksInventoryListener(Main main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
try {
|
||||
e.getClickedInventory().getHolder();
|
||||
} catch (Exception exc) {
|
||||
return;
|
||||
}
|
||||
if (e.getClickedInventory().getHolder() instanceof UtilitiesInventoryHolder){
|
||||
UtilitiesInventoryHolder inventoryHolder = (UtilitiesInventoryHolder)e.getClickedInventory().getHolder();
|
||||
InventoryTypeEnum typeEnum = inventoryHolder.getType();
|
||||
if (typeEnum.equals(InventoryTypeEnum.SECRET)) {
|
||||
e.getWhoClicked().getInventory().addItem(e.getCurrentItem());
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
package com.buildersrefuge.utilities.listeners;
|
||||
|
||||
import com.buildersrefuge.utilities.enums.InventoryTypeEnum;
|
||||
import com.buildersrefuge.utilities.inventory.UtilitiesInventoryHolder;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.object.NoClipManager;
|
||||
import com.buildersrefuge.utilities.util.ToggleGUI;
|
||||
|
||||
public class ToggleInventoryListener implements Listener{
|
||||
public Main plugin;
|
||||
|
||||
public ToggleInventoryListener(Main main){
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onInventoryClick(InventoryClickEvent e){
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
int slot;
|
||||
try {
|
||||
e.getClickedInventory().getHolder();
|
||||
} catch (Exception exc) {
|
||||
return;
|
||||
}
|
||||
if (e.getClickedInventory().getHolder() instanceof UtilitiesInventoryHolder){
|
||||
UtilitiesInventoryHolder inventoryHolder = (UtilitiesInventoryHolder)e.getClickedInventory().getHolder();
|
||||
InventoryTypeEnum typeEnum = inventoryHolder.getType();
|
||||
try{
|
||||
slot = e.getRawSlot();
|
||||
}
|
||||
catch(Exception exc){
|
||||
return;
|
||||
}
|
||||
if (typeEnum.equals(InventoryTypeEnum.TOGGLE)) {
|
||||
ToggleGUI gui = new ToggleGUI();
|
||||
e.setCancelled(true);
|
||||
if (slot==1||slot==10||slot==19){
|
||||
if (Main.ironTrapdoorNames.contains(p.getName())){
|
||||
Main.ironTrapdoorNames.remove(p.getName());
|
||||
}
|
||||
else{
|
||||
Main.ironTrapdoorNames.add(p.getName());
|
||||
}
|
||||
}
|
||||
if (slot==2||slot==11||slot==20){
|
||||
if (Main.slabNames.contains(p.getName())){
|
||||
Main.slabNames.remove(p.getName());
|
||||
}
|
||||
else{
|
||||
Main.slabNames.add(p.getName());
|
||||
}
|
||||
}
|
||||
if (slot==3||slot==12||slot==21){
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 12 ,0)){
|
||||
if (Main.terracottaNames.contains(p.getName())){
|
||||
Main.terracottaNames.remove(p.getName());
|
||||
}
|
||||
else{
|
||||
Main.terracottaNames.add(p.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (slot==5||slot==14||slot==23){
|
||||
if (p.hasPermission("builders.util.nightvision")){
|
||||
if (p.hasPotionEffect(PotionEffectType.NIGHT_VISION)){
|
||||
p.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||
}
|
||||
else {
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (slot==6||slot==15||slot==24){
|
||||
if (p.hasPermission("builders.util.noclip")){
|
||||
if(NoClipManager.noClipPlayerNames.contains(p.getName())){
|
||||
NoClipManager.noClipPlayerNames.remove(p.getName());
|
||||
if (p.getGameMode()==GameMode.SPECTATOR){
|
||||
p.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
NoClipManager.noClipPlayerNames.add(p.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (slot==7||slot==16||slot==25){
|
||||
if (p.hasPermission("builders.util.advancedfly")){
|
||||
com.buildersrefuge.utilities.listeners.PlayerMoveListener.togglePlayer(p);
|
||||
}
|
||||
}
|
||||
gui.updateInv(e.getClickedInventory(), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,718 +0,0 @@
|
||||
package com.buildersrefuge.utilities.object;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* bStats collects some data for plugin authors.
|
||||
* <p>
|
||||
* Check out https://bStats.org/ to learn more about bStats!
|
||||
*/
|
||||
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||
public class Metrics {
|
||||
|
||||
static {
|
||||
// You can use the property to disable the check in your test environment
|
||||
if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) {
|
||||
// Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D
|
||||
final String defaultPackage = new String(
|
||||
new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'});
|
||||
final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
|
||||
// We want to make sure nobody just copy & pastes the example and use the wrong package names
|
||||
if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
|
||||
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The version of this bStats class
|
||||
public static final int B_STATS_VERSION = 1;
|
||||
|
||||
// The url to which the data is sent
|
||||
private static final String URL = "https://bStats.org/submitData/bukkit";
|
||||
|
||||
// Is bStats enabled on this server?
|
||||
private boolean enabled;
|
||||
|
||||
// Should failed requests be logged?
|
||||
private static boolean logFailedRequests;
|
||||
|
||||
// Should the sent data be logged?
|
||||
private static boolean logSentData;
|
||||
|
||||
// Should the response text be logged?
|
||||
private static boolean logResponseStatusText;
|
||||
|
||||
// The uuid of the server
|
||||
private static String serverUUID;
|
||||
|
||||
// The plugin
|
||||
private final Plugin plugin;
|
||||
|
||||
// A list with all custom charts
|
||||
private final List<CustomChart> charts = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param plugin The plugin which stats should be submitted.
|
||||
*/
|
||||
public Metrics(Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null!");
|
||||
}
|
||||
this.plugin = plugin;
|
||||
|
||||
// Get the config file
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
File configFile = new File(bStatsFolder, "config.yml");
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
// Check if the config file exists
|
||||
if (!config.isSet("serverUuid")) {
|
||||
|
||||
// Add default values
|
||||
config.addDefault("enabled", true);
|
||||
// Every server gets it's unique random id.
|
||||
config.addDefault("serverUuid", UUID.randomUUID().toString());
|
||||
// Should failed request be logged?
|
||||
config.addDefault("logFailedRequests", false);
|
||||
// Should the sent data be logged?
|
||||
config.addDefault("logSentData", false);
|
||||
// Should the response text be logged?
|
||||
config.addDefault("logResponseStatusText", false);
|
||||
|
||||
// Inform the server owners about bStats
|
||||
config.options().header(
|
||||
"bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
|
||||
"To honor their work, you should not disable it.\n" +
|
||||
"This has nearly no effect on the server performance!\n" +
|
||||
"Check out https://bStats.org/ to learn more :)"
|
||||
).copyDefaults(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException ignored) { }
|
||||
}
|
||||
|
||||
// Load the data
|
||||
enabled = config.getBoolean("enabled", true);
|
||||
serverUUID = config.getString("serverUuid");
|
||||
logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
logSentData = config.getBoolean("logSentData", false);
|
||||
logResponseStatusText = config.getBoolean("logResponseStatusText", false);
|
||||
|
||||
if (enabled) {
|
||||
boolean found = false;
|
||||
// Search for all other bStats Metrics classes to see if we are the first one
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
found = true; // We aren't the first
|
||||
break;
|
||||
} catch (NoSuchFieldException ignored) { }
|
||||
}
|
||||
// Register our service
|
||||
Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
|
||||
if (!found) {
|
||||
// We are the first!
|
||||
startSubmitting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if bStats is enabled.
|
||||
*
|
||||
* @return Whether bStats is enabled or not.
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Chart cannot be null!");
|
||||
}
|
||||
charts.add(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Scheduler which submits our data every 30 minutes.
|
||||
*/
|
||||
private void startSubmitting() {
|
||||
final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!plugin.isEnabled()) { // Plugin was disabled
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
|
||||
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
|
||||
Bukkit.getScheduler().runTask(plugin, () -> submitData());
|
||||
}
|
||||
}, 1000 * 60 * 5, 1000 * 60 * 30);
|
||||
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
|
||||
// WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
|
||||
// WARNING: Just don't do it!
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin specific data.
|
||||
* This method is called using Reflection.
|
||||
*
|
||||
* @return The plugin specific data.
|
||||
*/
|
||||
public JsonObject getPluginData() {
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
String pluginName = plugin.getDescription().getName();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
|
||||
data.addProperty("pluginName", pluginName); // Append the name of the plugin
|
||||
data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin
|
||||
JsonArray customCharts = new JsonArray();
|
||||
for (CustomChart customChart : charts) {
|
||||
// Add the data of the custom charts
|
||||
JsonObject chart = customChart.getRequestJsonObject();
|
||||
if (chart == null) { // If the chart is null, we skip it
|
||||
continue;
|
||||
}
|
||||
customCharts.add(chart);
|
||||
}
|
||||
data.add("customCharts", customCharts);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server specific data.
|
||||
*
|
||||
* @return The server specific data.
|
||||
*/
|
||||
private JsonObject getServerData() {
|
||||
// Minecraft specific data
|
||||
int playerAmount;
|
||||
try {
|
||||
// Around MC 1.8 the return type was changed to a collection from an array,
|
||||
// This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
|
||||
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
||||
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
|
||||
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
|
||||
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||
} catch (Exception e) {
|
||||
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
|
||||
}
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
String bukkitVersion = Bukkit.getVersion();
|
||||
String bukkitName = Bukkit.getName();
|
||||
|
||||
// OS/Java specific data
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
String osName = System.getProperty("os.name");
|
||||
String osArch = System.getProperty("os.arch");
|
||||
String osVersion = System.getProperty("os.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
data.addProperty("serverUUID", serverUUID);
|
||||
|
||||
data.addProperty("playerAmount", playerAmount);
|
||||
data.addProperty("onlineMode", onlineMode);
|
||||
data.addProperty("bukkitVersion", bukkitVersion);
|
||||
data.addProperty("bukkitName", bukkitName);
|
||||
|
||||
data.addProperty("javaVersion", javaVersion);
|
||||
data.addProperty("osName", osName);
|
||||
data.addProperty("osArch", osArch);
|
||||
data.addProperty("osVersion", osVersion);
|
||||
data.addProperty("coreCount", coreCount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the data and sends it afterwards.
|
||||
*/
|
||||
private void submitData() {
|
||||
final JsonObject data = getServerData();
|
||||
|
||||
JsonArray pluginData = new JsonArray();
|
||||
// Search for all other bStats Metrics classes to get their plugin data
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
|
||||
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
|
||||
try {
|
||||
Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider());
|
||||
if (plugin instanceof JsonObject) {
|
||||
pluginData.add((JsonObject) plugin);
|
||||
} else { // old bstats version compatibility
|
||||
try {
|
||||
Class<?> jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject");
|
||||
if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) {
|
||||
Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString");
|
||||
jsonStringGetter.setAccessible(true);
|
||||
String jsonString = (String) jsonStringGetter.invoke(plugin);
|
||||
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
|
||||
pluginData.add(object);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// minecraft version 1.14+
|
||||
if (logFailedRequests) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e);
|
||||
}
|
||||
continue; // continue looping since we cannot do any other thing.
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
|
||||
}
|
||||
} catch (NoSuchFieldException ignored) { }
|
||||
}
|
||||
|
||||
data.add("plugins", pluginData);
|
||||
|
||||
// Create a new thread for the connection to the bStats server
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(plugin, data);
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the data to the bStats server.
|
||||
*
|
||||
* @param plugin Any plugin. It's just used to get a logger instance.
|
||||
* @param data The data to send.
|
||||
* @throws Exception If the request failed.
|
||||
*/
|
||||
private static void sendData(Plugin plugin, JsonObject data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data cannot be null!");
|
||||
}
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
throw new IllegalAccessException("This method must not be called from the main thread!");
|
||||
}
|
||||
if (logSentData) {
|
||||
plugin.getLogger().info("Sending data to bStats: " + data.toString());
|
||||
}
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
|
||||
// Compress the data to save bandwidth
|
||||
byte[] compressedData = compress(data.toString());
|
||||
|
||||
// Add headers
|
||||
connection.setRequestMethod("POST");
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
|
||||
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||
connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
|
||||
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||
|
||||
// Send data
|
||||
connection.setDoOutput(true);
|
||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.write(compressedData);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
bufferedReader.close();
|
||||
if (logResponseStatusText) {
|
||||
plugin.getLogger().info("Sent data to bStats and received response: " + builder.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gzips the given String.
|
||||
*
|
||||
* @param str The string to gzip.
|
||||
* @return The gzipped String.
|
||||
* @throws IOException If the compression failed.
|
||||
*/
|
||||
private static byte[] compress(final String str) throws IOException {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
gzip.close();
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom chart.
|
||||
*/
|
||||
public static abstract class CustomChart {
|
||||
|
||||
// The id of the chart
|
||||
final String chartId;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
*/
|
||||
CustomChart(String chartId) {
|
||||
if (chartId == null || chartId.isEmpty()) {
|
||||
throw new IllegalArgumentException("ChartId cannot be null or empty!");
|
||||
}
|
||||
this.chartId = chartId;
|
||||
}
|
||||
|
||||
private JsonObject getRequestJsonObject() {
|
||||
JsonObject chart = new JsonObject();
|
||||
chart.addProperty("chartId", chartId);
|
||||
try {
|
||||
JsonObject data = getChartData();
|
||||
if (data == null) {
|
||||
// If the data is null we don't send the chart.
|
||||
return null;
|
||||
}
|
||||
chart.add("data", data);
|
||||
} catch (Throwable t) {
|
||||
if (logFailedRequests) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return chart;
|
||||
}
|
||||
|
||||
protected abstract JsonObject getChartData() throws Exception;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom simple pie.
|
||||
*/
|
||||
public static class SimplePie extends CustomChart {
|
||||
|
||||
private final Callable<String> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimplePie(String chartId, Callable<String> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
String value = callable.call();
|
||||
if (value == null || value.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.addProperty("value", value);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom advanced pie.
|
||||
*/
|
||||
public static class AdvancedPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom drilldown pie.
|
||||
*/
|
||||
public static class DrilldownPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Map<String, Integer>>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Map<String, Integer>> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean reallyAllSkipped = true;
|
||||
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
|
||||
JsonObject value = new JsonObject();
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
|
||||
value.addProperty(valueEntry.getKey(), valueEntry.getValue());
|
||||
allSkipped = false;
|
||||
}
|
||||
if (!allSkipped) {
|
||||
reallyAllSkipped = false;
|
||||
values.add(entryValues.getKey(), value);
|
||||
}
|
||||
}
|
||||
if (reallyAllSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom single line chart.
|
||||
*/
|
||||
public static class SingleLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Integer> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SingleLineChart(String chartId, Callable<Integer> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
int value = callable.call();
|
||||
if (value == 0) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.addProperty("value", value);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom multi line chart.
|
||||
*/
|
||||
public static class MultiLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom simple bar chart.
|
||||
*/
|
||||
public static class SimpleBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
JsonArray categoryValues = new JsonArray();
|
||||
categoryValues.add(entry.getValue());
|
||||
values.add(entry.getKey(), categoryValues);
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom advanced bar chart.
|
||||
*/
|
||||
public static class AdvancedBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, int[]>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, int[]> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, int[]> entry : map.entrySet()) {
|
||||
if (entry.getValue().length == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
JsonArray categoryValues = new JsonArray();
|
||||
for (int categoryValue : entry.getValue()) {
|
||||
categoryValues.add(categoryValue);
|
||||
}
|
||||
values.add(entry.getKey(), categoryValues);
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.buildersrefuge.utilities.object;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NoClipManager {
|
||||
public static List<String> noClipPlayerNames;
|
||||
private Main main;
|
||||
|
||||
public NoClipManager(Main main) {
|
||||
noClipPlayerNames = new ArrayList<>();
|
||||
this.main = main;
|
||||
everyTick();
|
||||
}
|
||||
|
||||
private void everyTick() {
|
||||
Bukkit.getScheduler().runTaskTimer(this.main, this::checkForBlocks, 1L, 1L);
|
||||
}
|
||||
|
||||
private void checkForBlocks() {
|
||||
for (String name : noClipPlayerNames) {
|
||||
Player p = Bukkit.getPlayer(name);
|
||||
if (p.isOnline()) {
|
||||
if (p.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
boolean noClip;
|
||||
if (p.getLocation().add(0, -0.1, 0).getBlock().getType() != Material.AIR && p.isSneaking()) {
|
||||
noClip = true;
|
||||
} else {
|
||||
noClip = isNoClip(p);
|
||||
}
|
||||
if (noClip) {
|
||||
p.setGameMode(GameMode.SPECTATOR);
|
||||
}
|
||||
} else if (p.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
boolean noClip;
|
||||
if (p.getLocation().add(0, -0.1, 0).getBlock().getType() != Material.AIR) {
|
||||
noClip = true;
|
||||
} else noClip = isNoClip(p);
|
||||
if (!noClip) {
|
||||
p.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNoClip(Player p) {
|
||||
boolean noClip = false;
|
||||
if (p.getLocation().add(+0.4, 0, 0).getBlock().getType() != Material.AIR) {
|
||||
noClip = true;
|
||||
} else if (p.getLocation().add(-0.4, 0, 0).getBlock().getType() != Material.AIR) {
|
||||
noClip = true;
|
||||
} else if (p.getLocation().add(0, 0, +0.4).getBlock().getType() != Material.AIR) {
|
||||
noClip = true;
|
||||
} else if (p.getLocation().add(0, 0, -0.4).getBlock().getType() != Material.AIR) {
|
||||
noClip = true;
|
||||
} else if (p.getLocation().add(+0.4, 1, 0).getBlock().getType() != Material.AIR) {
|
||||
noClip = true;
|
||||
} else if (p.getLocation().add(-0.4, 1, 0).getBlock().getType() != Material.AIR) {
|
||||
noClip = true;
|
||||
} else if (p.getLocation().add(0, 1, +0.4).getBlock().getType() != Material.AIR) {
|
||||
noClip = true;
|
||||
} else if (p.getLocation().add(0, 1, -0.4).getBlock().getType() != Material.AIR) {
|
||||
noClip = true;
|
||||
} else if (p.getLocation().add(0, +1.9, 0).getBlock().getType() != Material.AIR) {
|
||||
noClip = true;
|
||||
}
|
||||
return noClip;
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.buildersrefuge.utilities.util;
|
||||
|
||||
import com.buildersrefuge.utilities.enums.InventoryTypeEnum;
|
||||
import com.buildersrefuge.utilities.inventory.UtilitiesInventoryHolder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class BannerGUI {
|
||||
|
||||
public BannerGUI() {
|
||||
}
|
||||
|
||||
public Inventory generateStartInv() {
|
||||
Items i = new Items();
|
||||
BannerUtil bU = new BannerUtil();
|
||||
Inventory inv = Bukkit.createInventory(new UtilitiesInventoryHolder(InventoryTypeEnum.BANNER_BASE), 54, "§1Select a base color");
|
||||
for (int x = 0; x < 54; x++) {
|
||||
inv.setItem(x, i.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", ""));
|
||||
}
|
||||
inv.setItem(1, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19", 1, "&7Click to randomise", ""));
|
||||
inv.setItem(4, bU.createBanner("&a", 1, DyeColor.WHITE, ""));
|
||||
inv.setItem(7, i.create(Material.BARRIER, (short) 0, 1, "&cClick to close", ""));
|
||||
for (int x = 19; x < 27; x++) {
|
||||
inv.setItem(x, bU.createBanner("&3" + bU.getAllColors().get(x - 19).toString().toLowerCase().replace("_", " "), 1, bU.getAllColors().get(x - 19), "&7__&7click to select"));
|
||||
}
|
||||
for (int x = 28; x < 36; x++) {
|
||||
inv.setItem(x, bU.createBanner("&3" + bU.getAllColors().get(x - 28 + 8).toString().toLowerCase().replace("_", " "), 1, bU.getAllColors().get(x - 28 + 8), "&7__&7click to select"));
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
|
||||
public Inventory generateColorInv(Inventory inv, ItemStack clicked, boolean first) {
|
||||
Items i = new Items();
|
||||
BannerUtil bU = new BannerUtil();
|
||||
Inventory inv1 = Bukkit.createInventory(new UtilitiesInventoryHolder(InventoryTypeEnum.BANNER_COLOR), 54, "§1Select a color");
|
||||
for (int x = 0; x < 54; x++) {
|
||||
inv1.setItem(x, i.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", ""));
|
||||
}
|
||||
inv1.setItem(1, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19", 1, "&7Click to randomise", ""));
|
||||
if (first) {
|
||||
inv1.setItem(4, bU.createBanner("&aClick to get the banner", 1, DyeColor.valueOf(clicked.getType().toString().replace("_BANNER","")), ""));
|
||||
} else {
|
||||
inv1.setItem(4, bU.addPattern(inv.getItem(4), new Pattern(bU.getColorFromBanner(clicked), bU.getPatternType(clicked))));
|
||||
}
|
||||
inv1.setItem(7, i.create(Material.BARRIER, (short) 0, 1, "&cClick to close", ""));
|
||||
for (int x = 19; x < 27; x++) {
|
||||
inv1.setItem(x, i.create(Material.LEGACY_INK_SACK, (short) (x - 19), 1, "&3" + bU.getAllColors().get(x - 19).toString().toLowerCase().replace("_", " "), "&7__&7click to select"));
|
||||
}
|
||||
for (int x = 28; x < 36; x++) {
|
||||
inv1.setItem(x, i.create(Material.LEGACY_INK_SACK, (short) (x - 20), 1, "&3" + bU.getAllColors().get(x - 20).toString().toLowerCase().replace("_", " "), "&7__&7click to select"));
|
||||
}
|
||||
return inv1;
|
||||
}
|
||||
|
||||
public Inventory generatePatternInv(Inventory inv, ItemStack clicked) {
|
||||
try{
|
||||
Items i = new Items();
|
||||
BannerUtil bU = new BannerUtil();
|
||||
Inventory inv1 = Bukkit.createInventory(new UtilitiesInventoryHolder(InventoryTypeEnum.BANNER_PATTERN), 54, "§1Select a pattern");
|
||||
for (int x = 0; x < 54; x++) {
|
||||
inv1.setItem(x, i.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", ""));
|
||||
}
|
||||
inv1.setItem(1, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19", 1, "&7Click to randomise", ""));
|
||||
inv1.setItem(4, inv.getItem(4));
|
||||
inv1.setItem(7, i.create(Material.BARRIER, (short) 0, 1, "&cClick to close", ""));
|
||||
DyeColor base = DyeColor.WHITE;
|
||||
DyeColor click = bU.getDyeColor(clicked);
|
||||
if (click.equals(DyeColor.WHITE) || click.equals(DyeColor.LIGHT_GRAY) || click.equals(DyeColor.LIME) || click.equals(DyeColor.LIGHT_BLUE) || click.equals(DyeColor.YELLOW)) {
|
||||
base = DyeColor.BLACK;
|
||||
}
|
||||
for (int x = 9; x < 47; x++) {
|
||||
inv1.setItem(x, bU.createBanner("&3" + bU.getAllPatternTypes().get(x - 9).toString().toLowerCase().replace("_", " "), 1, base, "&7__&7click to select", new Pattern(click, bU.getAllPatternTypes().get(x - 9))));
|
||||
}
|
||||
return inv1;
|
||||
}
|
||||
catch (Exception e){
|
||||
return inv;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
package com.buildersrefuge.utilities.util;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BannerUtil {
|
||||
|
||||
private List<DyeColor> allColors;
|
||||
private List<PatternType> allPatterns;
|
||||
|
||||
public BannerUtil() {
|
||||
allColors = new ArrayList<>();
|
||||
allPatterns = new ArrayList<>();
|
||||
addColors();
|
||||
addPatterns();
|
||||
}
|
||||
|
||||
private void addPatterns() {
|
||||
for (PatternType pt : PatternType.values()) {
|
||||
if (!pt.equals(PatternType.BASE)) {
|
||||
allPatterns.add(pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addColors() {
|
||||
allColors.add(DyeColor.BLACK);
|
||||
allColors.add(DyeColor.RED);
|
||||
allColors.add(DyeColor.GREEN);
|
||||
allColors.add(DyeColor.BROWN);
|
||||
allColors.add(DyeColor.BLUE);
|
||||
allColors.add(DyeColor.PURPLE);
|
||||
allColors.add(DyeColor.CYAN);
|
||||
allColors.add(DyeColor.LIGHT_GRAY);
|
||||
allColors.add(DyeColor.GRAY);
|
||||
allColors.add(DyeColor.PINK);
|
||||
allColors.add(DyeColor.LIME);
|
||||
allColors.add(DyeColor.YELLOW);
|
||||
allColors.add(DyeColor.LIGHT_BLUE);
|
||||
allColors.add(DyeColor.MAGENTA);
|
||||
allColors.add(DyeColor.ORANGE);
|
||||
allColors.add(DyeColor.WHITE);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack createBanner(String name, DyeColor base, String lore, List<Pattern> patterns) {
|
||||
Items i = new Items();
|
||||
ItemStack item = i.create(XMaterial.fromString(base.toString() + "_BANNER").parseMaterial(), (short)0, 1, name, "");
|
||||
BannerMeta meta = (BannerMeta) item.getItemMeta();
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 11 ,0)){
|
||||
item.setDurability((short) allColors.indexOf(base));
|
||||
} else {
|
||||
meta.setBaseColor(base);
|
||||
}
|
||||
|
||||
meta.setPatterns(patterns);
|
||||
if (!lore.equals("")) {
|
||||
String[] loreListArray = lore.split("__");
|
||||
List<String> loreList = new ArrayList<>();
|
||||
for (String s : loreListArray) {
|
||||
loreList.add(s.replace("&", "§"));
|
||||
}
|
||||
meta.setLore(loreList);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
ItemStack createBanner(String name, int amount, DyeColor base, String lore) {
|
||||
Items i = new Items();
|
||||
ItemStack item = i.create(XMaterial.fromString(base.toString() + "_BANNER").parseMaterial(), (short)0, 1, name, "");
|
||||
BannerMeta meta = (BannerMeta) item.getItemMeta();
|
||||
if (!lore.equals("")) {
|
||||
String[] loreListArray = lore.split("__");
|
||||
List<String> loreList = new ArrayList<>();
|
||||
for (String s : loreListArray) {
|
||||
loreList.add(s.replace("&", "§"));
|
||||
}
|
||||
meta.setLore(loreList);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
ItemStack createBanner(String name, int amount, DyeColor base, String lore, Pattern pat) {
|
||||
Items i = new Items();
|
||||
ItemStack item = i.create(XMaterial.fromString(base.toString() + "_BANNER").parseMaterial(), (short)0, 1, name, "");
|
||||
BannerMeta meta = (BannerMeta) item.getItemMeta();
|
||||
meta.addPattern(pat);
|
||||
if (!lore.equals("")) {
|
||||
String[] loreListArray = lore.split("__");
|
||||
List<String> loreList = new ArrayList<>();
|
||||
for (String s : loreListArray) {
|
||||
loreList.add(s.replace("&", "§"));
|
||||
}
|
||||
meta.setLore(loreList);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
List<PatternType> getAllPatternTypes() {
|
||||
return allPatterns;
|
||||
}
|
||||
|
||||
List<DyeColor> getAllColors() {
|
||||
return allColors;
|
||||
}
|
||||
|
||||
public ItemStack addPattern(ItemStack i, Pattern pat) {
|
||||
if (i.getType().toString().contains("BANNER")) {
|
||||
BannerMeta meta = (BannerMeta) i.getItemMeta();
|
||||
List<Pattern> patterns = meta.getPatterns();
|
||||
patterns.add(pat);
|
||||
meta.setPatterns(patterns);
|
||||
i.setItemMeta(meta);
|
||||
return i;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
DyeColor getBaseColor(ItemStack i) {
|
||||
if (i.getType().toString().contains("BANNER")) {
|
||||
BannerMeta meta = (BannerMeta) i.getItemMeta();
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 11 ,0)){
|
||||
return allColors.get(i.getDurability());
|
||||
} else {
|
||||
return meta.getBaseColor();
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PatternType getPatternType(ItemStack i) {
|
||||
if (i.getType().toString().contains("BANNER")) {
|
||||
BannerMeta meta = (BannerMeta) i.getItemMeta();
|
||||
return meta.getPattern(0).getPattern();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public DyeColor getColorFromBanner(ItemStack i) {
|
||||
if (i.getType().toString().contains("BANNER")) {
|
||||
BannerMeta meta = (BannerMeta) i.getItemMeta();
|
||||
return meta.getPattern(0).getColor();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public DyeColor getRandomDye() {
|
||||
Random r = new Random();
|
||||
return allColors.get(r.nextInt(allColors.size()));
|
||||
}
|
||||
|
||||
public PatternType getRandomPattern() {
|
||||
Random r = new Random();
|
||||
return allPatterns.get(r.nextInt(allPatterns.size()));
|
||||
}
|
||||
|
||||
DyeColor getDyeColor(ItemStack i) {
|
||||
switch (i.getType()){
|
||||
case INK_SAC: return DyeColor.BLACK;
|
||||
case ROSE_RED: return DyeColor.RED;
|
||||
case CACTUS_GREEN: return DyeColor.GREEN;
|
||||
case COCOA_BEANS: return DyeColor.BROWN;
|
||||
case LAPIS_LAZULI: return DyeColor.BLUE;
|
||||
case PURPLE_DYE: return DyeColor.PURPLE;
|
||||
case CYAN_DYE: return DyeColor.CYAN;
|
||||
case LIGHT_GRAY_DYE: return DyeColor.LIGHT_GRAY;
|
||||
case GRAY_DYE: return DyeColor.GRAY;
|
||||
case PINK_DYE: return DyeColor.PINK;
|
||||
case LIME_DYE: return DyeColor.LIME;
|
||||
case DANDELION_YELLOW: return DyeColor.YELLOW;
|
||||
case LIGHT_BLUE_DYE: return DyeColor.LIGHT_BLUE;
|
||||
case MAGENTA_DYE: return DyeColor.MAGENTA;
|
||||
case ORANGE_DYE: return DyeColor.ORANGE;
|
||||
case BONE_MEAL: return DyeColor.WHITE;
|
||||
default: return DyeColor.BLACK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.buildersrefuge.utilities.util;
|
||||
|
||||
import com.buildersrefuge.utilities.enums.InventoryTypeEnum;
|
||||
import com.buildersrefuge.utilities.inventory.UtilitiesInventoryHolder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class ColorGUI {
|
||||
|
||||
public ColorGUI() {
|
||||
}
|
||||
|
||||
public Inventory generateInv() {
|
||||
Items i = new Items();
|
||||
String lore = "&7__&7Left click to increase__&7Right click to decrease__&7Shift click to change by 5";
|
||||
Inventory inv = Bukkit.createInventory(new UtilitiesInventoryHolder(InventoryTypeEnum.COLOR), 54, "§1Armor Color Creator");
|
||||
for (int x = 0; x < 54; x++) {
|
||||
inv.setItem(x, i.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", ""));
|
||||
}
|
||||
inv.setItem(10, i.create(Material.LEATHER_HELMET, (short) 0, 1, "&aClick to get helmet", ""));
|
||||
inv.setItem(19, i.create(Material.LEATHER_CHESTPLATE, (short) 0, 1, "&aClick to get chestplate", ""));
|
||||
inv.setItem(28, i.create(Material.LEATHER_LEGGINGS, (short) 0, 1, "&aClick to get leggings", ""));
|
||||
inv.setItem(37, i.create(Material.LEATHER_BOOTS, (short) 0, 1, "&aClick to get boots", ""));
|
||||
inv.setItem(22, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTEzMWRlOGU5NTFmZGQ3YjlhM2QyMzlkN2NjM2FhM2U4NjU1YTMzNmI5OTliOWVkYmI0ZmIzMjljYmQ4NyJ9fX0=",
|
||||
1, "&cClick to randomize", ""));
|
||||
inv.setItem(23, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWMzY2VjNjg3NjlmZTljOTcxMjkxZWRiN2VmOTZhNGUzYjYwNDYyY2ZkNWZiNWJhYTFjYmIzYTcxNTEzZTdiIn19fQ==",
|
||||
1, "&aClick to randomize", ""));
|
||||
inv.setItem(24, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjMyOGYzNzhmMjhhOTg3MjIyNmY1Y2UwNGQ2ZTFkZmExMTE2MTg1ODdmNDhkZmExZmU4MmQwNDMyMTZhNWNmIn19fQ==",
|
||||
1, "&bClick to randomize", ""));
|
||||
inv.setItem(31, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y0NmMzMWQ2ZWU2ZWE2MTlmNzJlNzg1MjMyY2IwNDhhYjI3MDQ2MmRiMGNiMTQ1NDUxNDQzNjI1MWMxYSJ9fX0=",
|
||||
10, "&cRed", lore));
|
||||
inv.setItem(32, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzZmNjlmN2I3NTM4YjQxZGMzNDM5ZjM2NThhYmJkNTlmYWNjYTM2NmYxOTBiY2YxZDZkMGEwMjZjOGY5NiJ9fX0=",
|
||||
10, "&aGreen", lore));
|
||||
inv.setItem(33, i.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjgzOWUzODFkOWZlZGFiNmY4YjU5Mzk2YTI3NjQyMzhkY2ViMmY3ZWVhODU2ZGM2ZmM0NDc2N2RhMzgyZjEifX19",
|
||||
10, "&bBlue", lore));
|
||||
updateInv(inv);
|
||||
return inv;
|
||||
}
|
||||
|
||||
public void updateInv(Inventory inv) {
|
||||
Items i = new Items();
|
||||
float multiplier = 255f / 20f;
|
||||
int r = (int) (((float) inv.getItem(31).getAmount()) * multiplier);
|
||||
int g = (int) (((float) inv.getItem(32).getAmount()) * multiplier);
|
||||
int b = (int) (((float) inv.getItem(33).getAmount()) * multiplier);
|
||||
inv.setItem(10, i.color(inv.getItem(10), r, g, b));
|
||||
inv.setItem(19, i.color(inv.getItem(19), r, g, b));
|
||||
inv.setItem(28, i.color(inv.getItem(28), r, g, b));
|
||||
inv.setItem(37, i.color(inv.getItem(37), r, g, b));
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.buildersrefuge.utilities.util;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Items {
|
||||
public Items() {
|
||||
}
|
||||
|
||||
public ItemStack create(Material mat, short data, int amount, String name, String lore) {
|
||||
ItemStack is = new ItemStack(mat);
|
||||
is.setAmount(amount);
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
if (!lore.equals("")) {
|
||||
String[] loreListArray = lore.split("__");
|
||||
List<String> loreList = new ArrayList<>();
|
||||
for (String s : loreListArray) {
|
||||
loreList.add(s.replace("&", "§"));
|
||||
}
|
||||
meta.setLore(loreList);
|
||||
}
|
||||
if (!name.equals("")) {
|
||||
meta.setDisplayName(name.replace("&", "§"));
|
||||
}
|
||||
is.setItemMeta(meta);
|
||||
is.setDurability(data);
|
||||
return is;
|
||||
}
|
||||
|
||||
public ItemStack color(ItemStack is, int r, int g, int b) {
|
||||
LeatherArmorMeta lam = (LeatherArmorMeta) is.getItemMeta();
|
||||
Color c = Color.fromRGB(r, g, b);
|
||||
lam.setColor(c);
|
||||
is.setItemMeta(lam);
|
||||
return is;
|
||||
}
|
||||
|
||||
public ItemStack createHead(String data, int amount, String name, String lore) {
|
||||
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
|
||||
item.setAmount(amount);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (!lore.equals("")) {
|
||||
String[] loreListArray = lore.split("__");
|
||||
List<String> loreList = new ArrayList<>();
|
||||
for (String s : loreListArray) {
|
||||
loreList.add(s.replace("&", "§"));
|
||||
}
|
||||
meta.setLore(loreList);
|
||||
}
|
||||
if (!name.equals("")) {
|
||||
meta.setDisplayName(name.replace("&", "§"));
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
SkullMeta headMeta = (SkullMeta) item.getItemMeta();
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", data));
|
||||
Field profileField;
|
||||
try {
|
||||
profileField = headMeta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(headMeta, profile);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
item.setItemMeta(headMeta);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
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) {
|
||||
return version.equalsIgnoreCase(v);
|
||||
}
|
||||
|
||||
public boolean isVersion(int gameV, int releaseV, int subReleaseV) {
|
||||
return version.equalsIgnoreCase("v" + gameV + "_" + releaseV + "_R" + subReleaseV);
|
||||
}
|
||||
|
||||
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 {
|
||||
return subRelease >= subReleaseV;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.buildersrefuge.utilities.util;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.enums.InventoryTypeEnum;
|
||||
import com.buildersrefuge.utilities.inventory.UtilitiesInventoryHolder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class SecretBlockGUI {
|
||||
|
||||
public SecretBlockGUI() {
|
||||
}
|
||||
|
||||
public Inventory generateStartInv() {
|
||||
Items i = new Items();
|
||||
Inventory inv = Bukkit.createInventory(new UtilitiesInventoryHolder(InventoryTypeEnum.SECRET), 9, "§1Secret Blocks");
|
||||
inv.setItem(0, i.create(Material.SPAWNER, (short) 0, 1, "§3Spawner Cage", ""));
|
||||
inv.setItem(1, i.create(Material.BARRIER, (short) 0, 1, "§3Barrier", ""));
|
||||
inv.setItem(2, i.create(Material.DRAGON_EGG, (short) 0, 1, "§3Dragon Egg", ""));
|
||||
if (Main.nmsManager.isAtLeastVersion(1, 9 ,0)){
|
||||
inv.setItem(3, i.create(Material.GRASS_PATH, (short) 0, 1, "§3Grass Path", ""));
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
package com.buildersrefuge.utilities.util;
|
||||
|
||||
import com.buildersrefuge.utilities.Main;
|
||||
import com.buildersrefuge.utilities.enums.InventoryTypeEnum;
|
||||
import com.buildersrefuge.utilities.inventory.UtilitiesInventoryHolder;
|
||||
import com.buildersrefuge.utilities.object.NoClipManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class ToggleGUI {
|
||||
|
||||
public Inventory generateInv(Player p) {
|
||||
Items i = new Items();
|
||||
Inventory inv = Bukkit.createInventory(new UtilitiesInventoryHolder(InventoryTypeEnum.TOGGLE), 27, "§1Builders Utilities");
|
||||
ItemStack GRAY_GLASS_PANE = i.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
|
||||
for (int x = 0; x < 27; x++) {
|
||||
inv.setItem(x, GRAY_GLASS_PANE);
|
||||
}
|
||||
updateInv(inv, p);
|
||||
return inv;
|
||||
}
|
||||
|
||||
public void updateInv(Inventory inv, Player p) {
|
||||
Items i = new Items();
|
||||
ItemStack GREEN_GLASS_PANE = i.create(Material.LIME_STAINED_GLASS_PANE, (short)0, 1, "&7", "");
|
||||
ItemStack ORANGE_GLASS_PANE = i.create(Material.ORANGE_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
|
||||
ItemStack RED_GLASS_PANE = i.create(Material.RED_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
|
||||
if (!Main.ironTrapdoorNames.contains(p.getName())) {
|
||||
inv.setItem(1, GREEN_GLASS_PANE);
|
||||
inv.setItem(10, i.create(Material.IRON_TRAPDOOR, (short) 0, 1, "&6Iron Trapdoor Interaction", "&a&lEnabled__&7__&7Click to toggle"));
|
||||
inv.setItem(19, GREEN_GLASS_PANE);
|
||||
} else {
|
||||
inv.setItem(1, RED_GLASS_PANE);
|
||||
inv.setItem(10, i.create(Material.IRON_TRAPDOOR, (short) 0, 1, "&6Iron Trapdoor Interaction", "&c&lDisabled__&7__&7Click to toggle"));
|
||||
inv.setItem(19, RED_GLASS_PANE);
|
||||
}
|
||||
if (!Main.slabNames.contains(p.getName())) {
|
||||
inv.setItem(2, GREEN_GLASS_PANE);
|
||||
inv.setItem(11, i.create(Material.STONE_SLAB, (short) 0, 1, "&6Custom Slab Breaking", "&a&lEnabled__&7__&7Click to toggle"));
|
||||
inv.setItem(20, GREEN_GLASS_PANE);
|
||||
} else {
|
||||
inv.setItem(2, RED_GLASS_PANE);
|
||||
inv.setItem(11, i.create(Material.STONE_SLAB, (short) 0, 1, "&6Custom Slab Breaking", "&c&lDisabled__&7__&7Click to toggle"));
|
||||
inv.setItem(20, RED_GLASS_PANE);
|
||||
}
|
||||
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"));
|
||||
inv.setItem(21, GREEN_GLASS_PANE);
|
||||
} else {
|
||||
inv.setItem(3, RED_GLASS_PANE);
|
||||
inv.setItem(12, i.create(Material.ORANGE_GLAZED_TERRACOTTA, (short) 0, 1, "&6Glazed Terracotta Rotating", "&c&lDisabled__&7__&7Click to toggle"));
|
||||
inv.setItem(21, RED_GLASS_PANE);
|
||||
}
|
||||
} else {
|
||||
inv.setItem(3, ORANGE_GLASS_PANE);
|
||||
inv.setItem(12, i.create(Material.ORANGE_GLAZED_TERRACOTTA, (short) 0, 1, "&6Glazed Terracotta Rotating", "&c&l1.12+ only"));
|
||||
inv.setItem(21, ORANGE_GLASS_PANE);
|
||||
}
|
||||
|
||||
if (p.hasPermission("builders.util.nightvision")) {
|
||||
if (p.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
|
||||
inv.setItem(5, GREEN_GLASS_PANE);
|
||||
inv.setItem(14, i.create(Material.ENDER_EYE, (short) 0, 1, "&6Nightvision", "&a&lEnabled__&7__&7Click to toggle"));
|
||||
inv.setItem(23, GREEN_GLASS_PANE);
|
||||
} else {
|
||||
inv.setItem(5, RED_GLASS_PANE);
|
||||
inv.setItem(14, i.create(Material.ENDER_EYE, (short) 0, 1, "&6Nightvision", "&c&lDisabled__&7__&7Click to toggle"));
|
||||
inv.setItem(23, RED_GLASS_PANE);
|
||||
}
|
||||
} else {
|
||||
inv.setItem(5, ORANGE_GLASS_PANE);
|
||||
inv.setItem(14, i.create(Material.ENDER_EYE, (short) 0, 1, "&6Nightvision", "&c&lNo permission"));
|
||||
inv.setItem(23, ORANGE_GLASS_PANE);
|
||||
}
|
||||
|
||||
if (p.hasPermission("builders.util.noclip")) {
|
||||
if (NoClipManager.noClipPlayerNames.contains(p.getName())) {
|
||||
inv.setItem(6, GREEN_GLASS_PANE);
|
||||
inv.setItem(15, i.create(Material.COMPASS, (short) 0, 1, "&6NoClip", "&a&lEnabled__&7__&7Click to toggle"));
|
||||
inv.setItem(24, GREEN_GLASS_PANE);
|
||||
} else {
|
||||
inv.setItem(6, RED_GLASS_PANE);
|
||||
inv.setItem(15, i.create(Material.COMPASS, (short) 0, 1, "&6NoClip", "&c&lDisabled__&7__&7Click to toggle"));
|
||||
inv.setItem(24, RED_GLASS_PANE);
|
||||
}
|
||||
} else {
|
||||
inv.setItem(6, ORANGE_GLASS_PANE);
|
||||
inv.setItem(15, i.create(Material.COMPASS, (short) 0, 1, "&6NoClip", "&c&lNo permission"));
|
||||
inv.setItem(24, ORANGE_GLASS_PANE);
|
||||
}
|
||||
|
||||
if (p.hasPermission("builders.util.advancedfly")) {
|
||||
if (com.buildersrefuge.utilities.listeners.PlayerMoveListener.enabledPlayers.contains(p.getName())) {
|
||||
inv.setItem(7, GREEN_GLASS_PANE);
|
||||
inv.setItem(16, i.create(Material.FEATHER, (short) 0, 1, "&6Advanced Fly", "&a&lEnabled__&7__&7Click to toggle"));
|
||||
inv.setItem(25, GREEN_GLASS_PANE);
|
||||
} else {
|
||||
inv.setItem(7, RED_GLASS_PANE);
|
||||
inv.setItem(16, i.create(Material.FEATHER, (short) 0, 1, "&6Advanced Fly", "&c&lDisabled__&7__&7Click to toggle"));
|
||||
inv.setItem(25, RED_GLASS_PANE);
|
||||
}
|
||||
} else {
|
||||
inv.setItem(7, ORANGE_GLASS_PANE);
|
||||
inv.setItem(16, i.create(Material.FEATHER, (short) 0, 1, "&6Advanced Fly", "&c&lNo permission"));
|
||||
inv.setItem(25, ORANGE_GLASS_PANE);
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
-1
@@ -1,17 +1,39 @@
|
||||
# This disables weather changing from what it currently is
|
||||
# If it is currently raining, it will continue raining
|
||||
# If it is currently sunny, it will continue being sunny
|
||||
# True if you want this feature, false if you do not.
|
||||
disable-weather-changes: true
|
||||
|
||||
# This completely disables all redstone functions
|
||||
# True if you want this feature, false if you do not
|
||||
disable-redstone: false
|
||||
|
||||
# This completely disables all physics for blocks
|
||||
disable-physics: true
|
||||
|
||||
disable-gravity-physics: false
|
||||
|
||||
# Disables all types of explosions
|
||||
# EX: creepers, tnt, end crystals, etc.
|
||||
disable-explosions: true
|
||||
|
||||
# Prevents pesky peers pulverizing produce
|
||||
# Prevent people from trampling your crops and ruining
|
||||
# your soil
|
||||
disable-soil-trample: true
|
||||
|
||||
# Disables leaves from vanishing when they are not
|
||||
# nearby any logs
|
||||
disable-leaves-decay: true
|
||||
|
||||
|
||||
fix-attackspeed: false
|
||||
|
||||
prevent-dragon-egg-teleport: true
|
||||
# Prevent the dragon egg from teleporting away
|
||||
prevent-dragon-egg-teleport: true
|
||||
|
||||
# Determines if players will be sent messages such as
|
||||
# "You do not have permission for this command"
|
||||
# This is useful for when you do not want to give away what
|
||||
# plugins exist on your server.
|
||||
send-error-messages: true
|
||||
+60
-56
@@ -1,58 +1,62 @@
|
||||
name: BuildersUtilities
|
||||
main: com.buildersrefuge.utilities.Main
|
||||
version: 1.3.2
|
||||
author: Arcaniax
|
||||
name: Builders-Utilities
|
||||
version: 1.4.0
|
||||
api-version: 1.13
|
||||
|
||||
main: com.arcaniax.buildersutilities.Main
|
||||
authors: [Ktar5, Arcaniax]
|
||||
commands:
|
||||
banner:
|
||||
description: opens banner creator
|
||||
aliases: bm
|
||||
armorcolor:
|
||||
description: opens armor color creator
|
||||
aliases: color
|
||||
nc:
|
||||
aliases: noclip
|
||||
description: Toggles NoClip.
|
||||
af:
|
||||
aliases: advfly
|
||||
description: Toggles Advanced fly.
|
||||
n:
|
||||
aliases: nv
|
||||
description: Toggles Nightvision.
|
||||
/1:
|
||||
description: alias
|
||||
/2:
|
||||
description: alias
|
||||
/r:
|
||||
description: alias
|
||||
/s:
|
||||
description: alias
|
||||
/c:
|
||||
description: alias
|
||||
/f:
|
||||
description: alias
|
||||
/pa:
|
||||
description: alias
|
||||
/derot:
|
||||
description: alias
|
||||
/twist:
|
||||
description: alias
|
||||
/scale:
|
||||
description: alias
|
||||
butil:
|
||||
description: alias
|
||||
aliases: bu
|
||||
/cuboid:
|
||||
description: alias
|
||||
aliases: /cub
|
||||
/convex:
|
||||
description: alias
|
||||
aliases: /con
|
||||
blocks:
|
||||
description: opens secret blocks menu
|
||||
aliases: secretblocks
|
||||
ws:
|
||||
description: alias
|
||||
fs:
|
||||
description: alias
|
||||
bu:
|
||||
buildersutils:
|
||||
builders:
|
||||
utils:
|
||||
util:
|
||||
banner:
|
||||
description: opens banner creator
|
||||
aliases: bm
|
||||
armorcolor:
|
||||
description: opens armor color creator
|
||||
aliases: color
|
||||
nc:
|
||||
aliases: noclip
|
||||
description: Toggles NoClip.
|
||||
af:
|
||||
aliases: advfly
|
||||
description: Toggles Advanced fly.
|
||||
n:
|
||||
aliases: nv
|
||||
description: Toggles Nightvision.
|
||||
/1:
|
||||
description: alias
|
||||
/2:
|
||||
description: alias
|
||||
/r:
|
||||
description: alias
|
||||
/s:
|
||||
description: alias
|
||||
/c:
|
||||
description: alias
|
||||
/f:
|
||||
description: alias
|
||||
/pa:
|
||||
description: alias
|
||||
/derot:
|
||||
description: alias
|
||||
/twist:
|
||||
description: alias
|
||||
/scale:
|
||||
description: alias
|
||||
butil:
|
||||
description: alias
|
||||
aliases: bu
|
||||
/cuboid:
|
||||
description: alias
|
||||
aliases: /cub
|
||||
/convex:
|
||||
description: alias
|
||||
aliases: /con
|
||||
blocks:
|
||||
description: opens secret blocks menu
|
||||
aliases: secretblocks
|
||||
ws:
|
||||
description: alias
|
||||
fs:
|
||||
description: alias
|
||||
Reference in new issue
Block a user