Little cleanup & setup (#4)

* Setup project

* Update namespace

- Relocate bstats

* Some reformatting and documentation

* Setup issue templates

* chmod+x gradlew

* Create pull request template

* Apply license

* Exclude XMaterial from licensing
This commit is contained in:
NotMyFault authored and GitHub committed 2020-09-08 20:59:30 +02:00
1 parent f763d4c472
commit 9806a083bc
129 files changed
+5068 -1506

No files matched your search

@@ -1,26 +0,0 @@
package com.arcaniax.buildersutilities.commands;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import com.arcaniax.buildersutilities.listeners.PlayerMoveListener;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class AdvancedFlyCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.advancedfly")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
if (PlayerMoveListener.togglePlayer(player)) {
player.sendMessage(Main.MSG_PREFIX + "Advanced Fly " + ChatColor.GREEN + ChatColor.ITALIC + "Enabled");
} else {
player.sendMessage(Main.MSG_PREFIX + "Advanced Fly " + ChatColor.RED + ChatColor.ITALIC + "Disabled");
}
}
}
@@ -1,23 +0,0 @@
package com.arcaniax.buildersutilities.commands;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import com.arcaniax.buildersutilities.menus.Menus;
import org.bukkit.entity.Player;
public class BannerCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.banner")) {
if(Settings.sendErrorMessages){
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Menus.BANNER_MENU.open(player);
}
}
@@ -1,21 +0,0 @@
package com.arcaniax.buildersutilities.commands;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import com.arcaniax.buildersutilities.menus.Menus;
import org.bukkit.entity.Player;
public class ColorCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.color")) {
if(Settings.sendErrorMessages){
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Menus.COLOR_MENU.open(player);
}
}
@@ -1,21 +0,0 @@
package com.arcaniax.buildersutilities.commands;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.CommandForwarder;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class HelpCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.help")) {
if(Settings.sendErrorMessages){
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
}
}
@@ -1,30 +0,0 @@
package com.arcaniax.buildersutilities.commands;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class NightVisionCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.nightvision")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
player.sendMessage(Main.MSG_PREFIX + "Night Vision " + ChatColor.RED + ChatColor.ITALIC + "Disabled");
} else {
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
player.sendMessage(Main.MSG_PREFIX + "Night Vision " + ChatColor.GREEN + ChatColor.ITALIC + "Enabled");
}
}
}
@@ -1,32 +0,0 @@
package com.arcaniax.buildersutilities.commands;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.NoClipManager;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
public class NoClipCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.noclip")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
if (NoClipManager.noClipPlayerIds.contains(player.getUniqueId())) {
NoClipManager.noClipPlayerIds.remove(player.getUniqueId());
player.sendMessage(Main.MSG_PREFIX + "NoClip " + ChatColor.RED + ChatColor.ITALIC + "Disabled");
if (player.getGameMode() == GameMode.SPECTATOR) {
player.setGameMode(GameMode.CREATIVE);
}
} else {
NoClipManager.noClipPlayerIds.add(player.getUniqueId());
player.sendMessage(Main.MSG_PREFIX + "NoClip " + ChatColor.GREEN + ChatColor.ITALIC + "Enabled");
}
}
}
@@ -1,21 +0,0 @@
package com.arcaniax.buildersutilities.commands;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import com.arcaniax.buildersutilities.menus.Menus;
import org.bukkit.entity.Player;
public class SecretBlockCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.secretblocks")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Menus.SECRET_BLOCK_MENU.open(player);
}
}
@@ -1,24 +0,0 @@
package com.arcaniax.buildersutilities.commands;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import com.arcaniax.buildersutilities.menus.Menus;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class UtilsCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.gui")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Menus.TOGGLE_MENU.open(player);
}
}
@@ -1,21 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class ConvexSelectionAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Main.getInstance().getServer().dispatchCommand(player, "/sel convex");
}
}
@@ -1,27 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class CopyAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "/copy " + builder.toString());
}
}
@@ -1,21 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class CuboidSelectionAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Main.getInstance().getServer().dispatchCommand(player, "/sel cuboid");
}
}
@@ -1,27 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class FlipAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "/flip " + builder.toString());
}
}
@@ -1,27 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class FlySpeedAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "speed fly " + builder.toString());
}
}
@@ -1,27 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class PasteAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "/paste " + builder.toString());
}
}
@@ -1,22 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class PosOneAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Main.getInstance().getServer().dispatchCommand(player, "/pos1");
}
}
@@ -1,21 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class PosTwoAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Main.getInstance().getServer().dispatchCommand(player, "/pos2");
}
}
@@ -1,27 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class ReplaceAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "/replace " + builder.toString());
}
}
@@ -1,35 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class ScaleAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
if (args.length != 1) {
player.sendMessage(Main.MSG_PREFIX + ChatColor.RED + "//scale [size]");
return;
}
double size;
try {
size = Double.parseDouble(args[0]);
} catch (Exception e) {
player.sendMessage(Main.MSG_PREFIX + ChatColor.RED + "//scale [size]");
return;
}
Main.getInstance().getServer().dispatchCommand(player, "/deform x/=" + size + ";y/=" + size + ";z/=" + size);
}
}
@@ -1,27 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class SetAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "/set " + builder.toString());
}
}
@@ -1,46 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class TwistAliasCommand implements ICommand {
private final float radiansPerDegree = 0.0174533f;
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
if (args.length != 2) {
player.sendMessage(Main.MSG_PREFIX + ChatColor.RED + "//twist [axis] [degrees]");
return;
}
int degrees;
try {
degrees = Integer.parseInt(args[1]);
} catch (Exception e) {
player.sendMessage(Main.MSG_PREFIX + ChatColor.RED + "//twist [axis] [degrees]");
return;
}
float radian = degrees * radiansPerDegree;
if (args[0].equalsIgnoreCase("x")) {
Main.getInstance().getServer().dispatchCommand(player, "/deform rotate(y,z," + radian / 2 + "*(x+1))");
} else if (args[0].equalsIgnoreCase("y")) {
Main.getInstance().getServer().dispatchCommand(player, "/deform rotate(x,z," + radian / 2 + "*(y+1))");
} else if (args[0].equalsIgnoreCase("z")) {
Main.getInstance().getServer().dispatchCommand(player, "/deform rotate(x,y," + radian / 2 + "*(z+1))");
} else {
player.sendMessage(Main.MSG_PREFIX + ChatColor.RED + "//twist [axis] [degrees]");
}
}
}
@@ -1,28 +0,0 @@
package com.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class WalkSpeedAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "speed walk " + builder.toString());
}
}
@@ -1,72 +0,0 @@
package com.arcaniax.buildersutilities.commands.system;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.commands.*;
import com.arcaniax.buildersutilities.commands.aliases.*;
import org.bukkit.ChatColor;
import org.bukkit.block.Banner;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class CommandForwarder implements CommandExecutor {
private final Map<String, ICommand> commands;
public CommandForwarder() {
commands = new HashMap<>();
registerCommand(new HelpCommand(), "help", "h", "?");
registerCommand(new AdvancedFlyCommand(), "af", "advancedfly");
registerCommand(new BannerCommand(), "banner");
registerCommand(new ColorCommand(), "color", "ac", "armorcolor");
registerCommand(new SecretBlockCommand(), "secretblock", "secretblocks", "blocks");
registerCommand(new NoClipCommand(), "noclip", "nc");
registerCommand(new NightVisionCommand(), "nv", "nightvision", "n");
registerCommand(new UtilsCommand(), "utils", "u", "util", "gui", "inventory");
registerCommand(new PosOneAliasCommand(), "p1", "1", "one", "pos1");
registerCommand(new PosTwoAliasCommand(), "p2", "2", "two", "pos2");
registerCommand(new CuboidSelectionAliasCommand(), "cuboid", "cube");
registerCommand(new ConvexSelectionAliasCommand(), "convex", "conv");
registerCommand(new SetAliasCommand(), "set", "s");
registerCommand(new ReplaceAliasCommand(), "replace", "r", "repl", "rep");
registerCommand(new PasteAliasCommand(), "paste", "pa");
registerCommand(new FlipAliasCommand(), "flip", "f");
registerCommand(new CopyAliasCommand(), "copy", "c", "clone");
registerCommand(new DeformRotateAliasCommand(), "deformrotate", "defrot", "dr");
registerCommand(new TwistAliasCommand(), "twist", "tw", "t");
registerCommand(new ScaleAliasCommand(), "scale", "sc");
registerCommand(new WalkSpeedAliasCommand(), "walkspeed", "ws");
registerCommand(new FlySpeedAliasCommand(), "flyspeed", "fs");
}
private void registerCommand(ICommand iCommand, String... aliases) {
for (String alias : aliases) {
commands.put(alias.toLowerCase(), iCommand);
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
//Make it player-only
Player player = sender instanceof Player ? ((Player) sender) : null;
if (player == null) {
sender.sendMessage(Main.MSG_ERROR + "Sorry this command can only be used by a player.");
return false;
}
if (args.length == 0) {
new HelpCommand().execute(player, args);
return true;
}
ICommand iCommand = commands.get(args[0].toLowerCase());
if (iCommand != null) {
iCommand.execute(player, Arrays.copyOfRange(args, 1, args.length));
}
return true;
}
}
@@ -1,9 +0,0 @@
package com.arcaniax.buildersutilities.commands.system;
import org.bukkit.entity.Player;
public interface ICommand {
public void execute(Player player, String[] args);
}
@@ -1,17 +0,0 @@
package com.arcaniax.buildersutilities.listeners;
import com.arcaniax.buildersutilities.Settings;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
public class ExplosionListener implements Listener {
@EventHandler
public void onExplode(EntityExplodeEvent event) {
if (Settings.disableExplosions) {
event.setCancelled(true);
}
}
}
@@ -1,16 +0,0 @@
package com.arcaniax.buildersutilities.listeners;
import com.arcaniax.buildersutilities.Settings;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.LeavesDecayEvent;
public class LeafDecayListener implements Listener {
@EventHandler
public void onLeafDecay(LeavesDecayEvent event) {
if (Settings.disableLeavesDecay) {
event.setCancelled(true);
}
}
}
@@ -1,42 +0,0 @@
package com.arcaniax.buildersutilities.listeners;
import com.arcaniax.buildersutilities.Settings;
import org.bukkit.Material;
import org.bukkit.block.Block;
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.player.PlayerInteractEvent;
public class PlayerInteractListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onDragonEggTP(PlayerInteractEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
&& event.getClickedBlock().getType().equals(Material.DRAGON_EGG)
&& (!event.getPlayer().isSneaking())
&& Settings.preventDragonEggTeleport) {
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.isCancelled()) {
return;
}
if (Settings.disableSoilTrample) {
if (event.getAction() == Action.PHYSICAL) {
Block block = event.getClickedBlock();
if (block != null && block.getType() == Material.FARMLAND) {
event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
event.setCancelled(true);
}
}
}
}
}
@@ -1,39 +0,0 @@
package com.arcaniax.buildersutilities.listeners;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.NoClipManager;
import com.arcaniax.buildersutilities.Settings;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerQuitAndJoinListener implements Listener {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
NoClipManager.noClipPlayerIds.remove(player.getUniqueId());
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (Main.getInstance().getNmsManager().isAtLeastVersion(1, 9, 0)) {
AttributeInstance attribute = event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED);
if (attribute == null) {
return;
}
if (Settings.fixAttackSpeed) {
attribute.setBaseValue(1024.0D);
} else if (attribute.getBaseValue() == 1024.0D) {
attribute.setBaseValue(attribute.getDefaultValue());
}
event.getPlayer().saveData();
}
}
}
@@ -1,21 +0,0 @@
package com.arcaniax.buildersutilities.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
public class TeleportListener implements Listener {
@EventHandler
public void onTeleport(PlayerTeleportEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.SPECTATE)) {
//TODO what is this tpgm3 lol
if (!event.getPlayer().hasPermission("builders.util.tpgm3")) {
event.setCancelled(true);
}
}
}
}
@@ -1,15 +0,0 @@
package com.arcaniax.buildersutilities.listeners;
import com.arcaniax.buildersutilities.Settings;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.weather.WeatherChangeEvent;
public class WeatherChangeListener implements Listener {
@EventHandler
public void onWeather(WeatherChangeEvent e) {
if (Settings.disableWeatherChanges) {
e.setCancelled(true);
}
}
}
@@ -1,12 +0,0 @@
package com.arcaniax.buildersutilities.menus;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import org.bukkit.entity.Player;
public class BannerMenuProvider implements InventoryProvider {
@Override
public void init(Player player, InventoryContents contents) {
}
}
@@ -1,30 +0,0 @@
package com.arcaniax.buildersutilities.menus;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.menus.inv.ClickableItem;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import com.arcaniax.buildersutilities.utils.Items;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SecretBlockMenuProvider implements InventoryProvider {
private static ItemStack SPAWNER = Items.create(Material.SPAWNER, (short) 0, 1, ChatColor.DARK_AQUA + "Spawner Cage", "");
private static ItemStack BARRIER = Items.create(Material.BARRIER, (short) 0, 1, ChatColor.DARK_AQUA + "Barrier", "");
private static ItemStack DRAGON_EGG = Items.create(Material.DRAGON_EGG, (short) 0, 1, ChatColor.DARK_AQUA + "Dragon Egg", "");
private static ItemStack GRASS_PATH = Items.create(Material.GRASS_PATH, (short) 0, 1, ChatColor.DARK_AQUA + "Grass Path", "");
@Override
public void init(Player player, InventoryContents contents) {
contents.set(0, 0, ClickableItem.of(SPAWNER, inventoryClickEvent -> player.getInventory().addItem(new ItemStack(Material.SPAWNER))));
contents.set(0, 1, ClickableItem.of(BARRIER, inventoryClickEvent -> player.getInventory().addItem(new ItemStack(Material.BARRIER))));
contents.set(0, 2, ClickableItem.of(DRAGON_EGG, inventoryClickEvent -> player.getInventory().addItem(new ItemStack(Material.DRAGON_EGG))));
if (Main.getInstance().getNmsManager().isAtLeastVersion(1, 9, 0)) {
contents.set(0, 3, ClickableItem.of(GRASS_PATH, inventoryClickEvent -> player.getInventory().addItem(new ItemStack(Material.GRASS_PATH))));
}
}
}
@@ -1,35 +0,0 @@
package com.arcaniax.buildersutilities.menus.bannermenus;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import com.arcaniax.buildersutilities.utils.Items;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.banner.Pattern;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class BannerColorMenuProvider implements InventoryProvider {
private static final ItemStack grayPane = Items.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
private static final ItemStack head = Items.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19", 1, "&7Click to randomise", "");
@Override
public void init(Player player, InventoryContents contents) {
// for (int x = 0; x < 54; x++) {
// contents.set(x / 9, x % 9, grayPane);
// }
// inv1.setItem(1, );
// 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"));
// }
}
}
@@ -1,36 +0,0 @@
package com.arcaniax.buildersutilities.menus.bannermenus;
import com.arcaniax.buildersutilities.menus.inv.ClickableItem;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
//import com.arcaniax.buildersutilities.utils.BannerUtil;
import com.arcaniax.buildersutilities.utils.Items;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class BannerMenuProvider implements InventoryProvider {
private static final ItemStack grayPane = Items.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
private static final ItemStack randomizeHead = Items.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19", 1, "&7Click to randomise", "");
// private static final ItemStack currentColor = BannerUtil.createBanner("&a", 1, DyeColor.WHITE, "");
private static final ItemStack closeButton = Items.create(Material.BARRIER, (short) 0, 1, "&cClick to close", "");
@Override
public void init(Player player, InventoryContents contents) {
// for (int x = 0; x < 54; x++) {
// contents.set(x / 9, x % 9, ClickableItem.empty(grayPane));
// }
// contents.set(0, 1, ClickableItem.of(randomizeHead, NULL));
// contents.set(0, 4, ClickableItem.empty(currentColor));
// contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
// for (int x = 19; x < 27; x++) {
// ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 19).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 19), "&7__&7click to select");
// contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
// }
// for (int x = 28; x < 36; x++) {
// ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 28 + 8).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 28 + 8), "&7__&7click to select");
// contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
// }
}
}
@@ -1,36 +0,0 @@
package com.arcaniax.buildersutilities.menus.bannermenus;
import com.arcaniax.buildersutilities.menus.inv.ClickableItem;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
//import com.arcaniax.buildersutilities.utils.BannerUtil;
import com.arcaniax.buildersutilities.utils.Items;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class BannerPatternMenuProvider implements InventoryProvider {
private static final ItemStack grayPane = Items.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
private static final ItemStack randomizeHead = Items.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19", 1, "&7Click to randomise", "");
// private static final ItemStack currentColor = BannerUtil.createBanner("&a", 1, DyeColor.WHITE, "");
private static final ItemStack closeButton = Items.create(Material.BARRIER, (short) 0, 1, "&cClick to close", "");
@Override
public void init(Player player, InventoryContents contents) {
// for (int x = 0; x < 54; x++) {
// contents.set(x / 9, x % 9, ClickableItem.empty(grayPane));
// }
// contents.set(0, 1, ClickableItem.of(randomizeHead, NULL));
// contents.set(0, 4, ClickableItem.empty(currentColor));
// contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
// for (int x = 19; x < 27; x++) {
// ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 19).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 19), "&7__&7click to select");
// contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
// }
// for (int x = 28; x < 36; x++) {
// ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 28 + 8).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 28 + 8), "&7__&7click to select");
// contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
// }
}
}
@@ -1,35 +0,0 @@
package com.arcaniax.buildersutilities.menus.inv;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import java.util.function.Consumer;
public class ClickableItem {
private ItemStack item;
private Consumer<InventoryClickEvent> consumer;
private ClickableItem(ItemStack item, Consumer<InventoryClickEvent> consumer) {
this.item = item;
this.consumer = consumer;
}
public static ClickableItem empty(ItemStack item) {
return of(item, e -> {
});
}
public static ClickableItem of(ItemStack item, Consumer<InventoryClickEvent> consumer) {
return new ClickableItem(item, consumer);
}
public void run(InventoryClickEvent e) {
consumer.accept(e);
}
public ItemStack getItem() {
return item;
}
}
@@ -1,23 +0,0 @@
package com.arcaniax.buildersutilities.menus.inv;
import java.util.function.Consumer;
public class InventoryListener<T> {
private Class<T> type;
private Consumer<T> consumer;
public InventoryListener(Class<T> type, Consumer<T> consumer) {
this.type = type;
this.consumer = consumer;
}
public void accept(T t) {
consumer.accept(t);
}
public Class<T> getType() {
return type;
}
}
@@ -1,12 +0,0 @@
package com.arcaniax.buildersutilities.menus.inv.content;
import org.bukkit.entity.Player;
public interface InventoryProvider {
void init(Player player, InventoryContents contents);
default void update(Player player, InventoryContents contents) {
}
}
@@ -1,45 +0,0 @@
package com.arcaniax.buildersutilities.menus.inv.content;
public class SlotPos {
private final int row;
private final int column;
public SlotPos(int row, int column) {
this.row = row;
this.column = column;
}
public static SlotPos of(int row, int column) {
return new SlotPos(row, column);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || getClass() != obj.getClass())
return false;
SlotPos slotPos = (SlotPos) obj;
return row == slotPos.row && column == slotPos.column;
}
@Override
public int hashCode() {
int result = row;
result = 31 * result + column;
return result;
}
public int getRow() {
return row;
}
public int getColumn() {
return column;
}
}
@@ -1,34 +0,0 @@
package com.arcaniax.buildersutilities.menus.inv.opener;
import com.arcaniax.buildersutilities.menus.inv.InventoryManager;
import com.arcaniax.buildersutilities.menus.inv.SmartInventory;
import com.google.common.base.Preconditions;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
public class ChestInventoryOpener implements InventoryOpener {
@Override
public Inventory open(SmartInventory inv, Player player) {
Preconditions.checkArgument(inv.getColumns() == 9,
"The column count for the chest inventory must be 9, found: %s.", inv.getColumns());
Preconditions.checkArgument(inv.getRows() >= 1 && inv.getRows() <= 6,
"The row count for the chest inventory must be between 1 and 6, found: %s", inv.getRows());
InventoryManager manager = inv.getManager();
Inventory handle = Bukkit.createInventory(player, inv.getRows() * inv.getColumns(), inv.getTitle());
fill(handle, manager.getContents(player).get());
player.openInventory(handle);
return handle;
}
@Override
public boolean supports(InventoryType type) {
return type == InventoryType.CHEST || type == InventoryType.ENDER_CHEST;
}
}
@@ -1,27 +0,0 @@
package com.arcaniax.buildersutilities.menus.inv.opener;
import com.arcaniax.buildersutilities.menus.inv.ClickableItem;
import com.arcaniax.buildersutilities.menus.inv.SmartInventory;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
public interface InventoryOpener {
Inventory open(SmartInventory inv, Player player);
boolean supports(InventoryType type);
default void fill(Inventory handle, InventoryContents contents) {
ClickableItem[][] items = contents.all();
for (int row = 0; row < items.length; row++) {
for (int column = 0; column < items[row].length; column++) {
if (items[row][column] != null)
handle.setItem(9 * row + column, items[row][column].getItem());
}
}
}
}
@@ -1,43 +0,0 @@
package com.arcaniax.buildersutilities.menus.inv.opener;
import com.arcaniax.buildersutilities.menus.inv.InventoryManager;
import com.arcaniax.buildersutilities.menus.inv.SmartInventory;
import com.google.common.collect.ImmutableList;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import java.util.List;
public class SpecialInventoryOpener implements InventoryOpener {
private static final List<InventoryType> SUPPORTED = ImmutableList.of(
InventoryType.FURNACE,
InventoryType.WORKBENCH,
InventoryType.DISPENSER,
InventoryType.DROPPER,
InventoryType.ENCHANTING,
InventoryType.BREWING,
InventoryType.ANVIL,
InventoryType.BEACON,
InventoryType.HOPPER
);
@Override
public Inventory open(SmartInventory inv, Player player) {
InventoryManager manager = inv.getManager();
Inventory handle = Bukkit.createInventory(player, inv.getType(), inv.getTitle());
fill(handle, manager.getContents(player).get());
player.openInventory(handle);
return handle;
}
@Override
public boolean supports(InventoryType type) {
return SUPPORTED.contains(type);
}
}
@@ -1,41 +0,0 @@
package com.arcaniax.buildersutilities.utils;
import com.arcaniax.buildersutilities.Main;
public class NmsManager {
private String version;
public NmsManager() {
String packageString = Main.getInstance().getServer().getClass().getPackage().getName();
version = packageString.substring(packageString.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.arcaniax.buildersutilities.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class Utility {
public static String readFileAsString(File file) {
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append(System.lineSeparator());
line = br.readLine();
}
return sb.toString();
} catch (IOException e) {
e.printStackTrace();
return e.getMessage();
}
}
}
@@ -1,11 +1,35 @@
package com.arcaniax.buildersutilities;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities;
import com.arcaniax.buildersutilities.commands.system.CommandForwarder;
import com.arcaniax.buildersutilities.listeners.*;
import com.arcaniax.buildersutilities.menus.inv.InventoryManager;
import com.arcaniax.buildersutilities.utils.CustomConfig;
import com.arcaniax.buildersutilities.utils.Metrics;
import com.arcaniax.buildersutilities.utils.NmsManager;
import net.arcaniax.buildersutilities.commands.system.CommandForwarder;
import net.arcaniax.buildersutilities.listeners.*;
import net.arcaniax.buildersutilities.menus.inv.InventoryManager;
import net.arcaniax.buildersutilities.utils.CustomConfig;
import net.arcaniax.buildersutilities.utils.NmsManager;
import net.arcaniax.buildersutilities.utils.Metrics;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -13,19 +37,21 @@ import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public final class Main extends JavaPlugin {
public static final String MSG_PREFIX = ChatColor.DARK_AQUA + "BuildersUtils> " + ChatColor.AQUA;
public static final String MSG_ERROR = ChatColor.DARK_RED + "Error: " + ChatColor.RED;
private static Main instance;
private Metrics metrics;
private static Main instance;
private Settings settings;
private NoClipManager noClipManager;
private InventoryManager inventoryManager;
private NmsManager nmsManager;
public static Main getInstance() {
return instance;
}
@Override
public void onEnable() {
instance = this;
@@ -36,7 +62,7 @@ public final class Main extends JavaPlugin {
this.inventoryManager = new InventoryManager(this);
this.inventoryManager.init();
this.metrics = new Metrics(this, /*plugin id*/ 5168);
this.metrics = new Metrics(this, 5168);
this.getServer().getPluginManager().registerEvents(new BlockBreakListener(), this);
this.getServer().getPluginManager().registerEvents(new BlockPhysicsListener(), this);
@@ -50,7 +76,6 @@ public final class Main extends JavaPlugin {
this.getServer().getPluginManager().registerEvents(new TerracottaInteractListener(), this);
this.getServer().getPluginManager().registerEvents(new WeatherChangeListener(), this);
CommandForwarder executor = new CommandForwarder();
this.getCommand("bu").setExecutor(executor);
this.getCommand("buildersutils").setExecutor(executor);
@@ -60,12 +85,11 @@ public final class Main extends JavaPlugin {
CommandExecutor commandExecutor = new CommandExecutor() {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
public boolean onCommand(CommandSender commandSender, Command command, String s,
String[] strings) {
String[] commandArgs = new String[strings.length + 1];
commandArgs[0] = s;
for (int i = 0; i < strings.length; i++) {
commandArgs[i + 1] = strings[i];
}
System.arraycopy(strings, 0, commandArgs, 1, strings.length);
executor.onCommand(commandSender, command, s, commandArgs);
return true;
}
@@ -95,6 +119,9 @@ public final class Main extends JavaPlugin {
getCommand("butil").setExecutor(commandExecutor);
}
private void startMetrics() {
}
@Override
public void onDisable() {
// Plugin shutdown logic
@@ -115,8 +142,4 @@ public final class Main extends JavaPlugin {
public NmsManager getNmsManager() {
return nmsManager;
}
public static Main getInstance() {
return instance;
}
}
@@ -1,13 +1,40 @@
package com.arcaniax.buildersutilities;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class NoClipManager {
public static Set<UUID> noClipPlayerIds;
public NoClipManager() {
@@ -21,7 +48,8 @@ public class NoClipManager {
if (player != null && player.isOnline()) {
if (player.getGameMode().equals(GameMode.CREATIVE)) {
boolean noClip;
if (player.getLocation().add(0, -0.1, 0).getBlock().getType() != Material.AIR && player.isSneaking()) {
if (player.getLocation().add(0, -0.1, 0).getBlock().getType() != Material.AIR && player
.isSneaking()) {
noClip = true;
} else {
noClip = isNoClip(player);
@@ -33,7 +61,9 @@ public class NoClipManager {
boolean noClip;
if (player.getLocation().add(0, -0.1, 0).getBlock().getType() != Material.AIR) {
noClip = true;
} else noClip = isNoClip(player);
} else {
noClip = isNoClip(player);
}
if (!noClip) {
player.setGameMode(GameMode.CREATIVE);
}
@@ -1,8 +1,33 @@
package com.arcaniax.buildersutilities;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities;
import com.arcaniax.buildersutilities.utils.CustomConfig;
import net.arcaniax.buildersutilities.utils.CustomConfig;
public class Settings {
public static boolean disableWeatherChanges;
public static boolean disableRedstone;
public static boolean disablePhysics;
@@ -21,7 +46,7 @@ public class Settings {
reloadSettings();
}
public void reloadSettings(){
public void reloadSettings() {
disableWeatherChanges = customConfig.get("disable-weather-changes", Boolean.class, true);
disableRedstone = customConfig.get("disable-redstone", Boolean.class, false);
disablePhysics = customConfig.get("disable-physics", Boolean.class, true);
@@ -0,0 +1,50 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import net.arcaniax.buildersutilities.listeners.PlayerMoveListener;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class AdvancedFlyCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.advancedfly")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
if (PlayerMoveListener.togglePlayer(player)) {
player.sendMessage(Main.MSG_PREFIX + "Advanced Fly " + ChatColor.GREEN + ChatColor.ITALIC + "Enabled");
} else {
player.sendMessage(Main.MSG_PREFIX + "Advanced Fly " + ChatColor.RED + ChatColor.ITALIC + "Disabled");
}
}
}
@@ -0,0 +1,47 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import net.arcaniax.buildersutilities.menus.Menus;
import org.bukkit.entity.Player;
public class BannerCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.banner")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Menus.BANNER_MENU.open(player);
}
}
@@ -0,0 +1,45 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import net.arcaniax.buildersutilities.menus.Menus;
import org.bukkit.entity.Player;
public class ColorCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.color")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Menus.COLOR_MENU.open(player);
}
}
@@ -0,0 +1,43 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class HelpCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.help")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
}
}
}
@@ -0,0 +1,53 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class NightVisionCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.nightvision")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
player.sendMessage(Main.MSG_PREFIX + "Night Vision " + ChatColor.RED + ChatColor.ITALIC + "Disabled");
} else {
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
player.sendMessage(Main.MSG_PREFIX + "Night Vision " + ChatColor.GREEN + ChatColor.ITALIC + "Enabled");
}
}
}
@@ -0,0 +1,56 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.NoClipManager;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
public class NoClipCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.noclip")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
if (NoClipManager.noClipPlayerIds.contains(player.getUniqueId())) {
NoClipManager.noClipPlayerIds.remove(player.getUniqueId());
player.sendMessage(Main.MSG_PREFIX + "NoClip " + ChatColor.RED + ChatColor.ITALIC + "Disabled");
if (player.getGameMode() == GameMode.SPECTATOR) {
player.setGameMode(GameMode.CREATIVE);
}
} else {
NoClipManager.noClipPlayerIds.add(player.getUniqueId());
player.sendMessage(Main.MSG_PREFIX + "NoClip " + ChatColor.GREEN + ChatColor.ITALIC + "Enabled");
}
}
}
@@ -0,0 +1,45 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import net.arcaniax.buildersutilities.menus.Menus;
import org.bukkit.entity.Player;
public class SecretBlockCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.secretblocks")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Menus.SECRET_BLOCK_MENU.open(player);
}
}
@@ -0,0 +1,45 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import net.arcaniax.buildersutilities.menus.Menus;
import org.bukkit.entity.Player;
public class UtilsCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.gui")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Menus.TOGGLE_MENU.open(player);
}
}
@@ -0,0 +1,45 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class ConvexSelectionAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Main.getInstance().getServer().dispatchCommand(player, "/sel convex");
}
}
@@ -0,0 +1,51 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class CopyAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "/copy " + builder.toString());
}
}
@@ -0,0 +1,45 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class CuboidSelectionAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Main.getInstance().getServer().dispatchCommand(player, "/sel cuboid");
}
}
@@ -1,13 +1,36 @@
package com.arcaniax.buildersutilities.commands.aliases;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.Settings;
import com.arcaniax.buildersutilities.commands.system.ICommand;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class DeformRotateAliasCommand implements ICommand {
private final float radiansPerDegree = 0.0174533f;
@Override
public void execute(Player player, String[] args) {
@@ -34,6 +57,7 @@ public class DeformRotateAliasCommand implements ICommand {
// float radian = (float) (((float) degrees / (float) 360) * 2 * Math.PI);
//Use the degree to radian conversion number: "0.0174533" radians per degree
float radiansPerDegree = 0.0174533f;
float radian = degrees * radiansPerDegree;
if (args[0].equalsIgnoreCase("x")) {
@@ -0,0 +1,51 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class FlipAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "/flip " + builder.toString());
}
}
@@ -0,0 +1,51 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class FlySpeedAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "speed fly " + builder.toString());
}
}
@@ -0,0 +1,51 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class PasteAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "/paste " + builder.toString());
}
}
@@ -0,0 +1,45 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class PosOneAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Main.getInstance().getServer().dispatchCommand(player, "/pos1");
}
}
@@ -0,0 +1,45 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class PosTwoAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
Main.getInstance().getServer().dispatchCommand(player, "/pos2");
}
}
@@ -0,0 +1,51 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class ReplaceAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "/replace " + builder.toString());
}
}
@@ -0,0 +1,58 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class ScaleAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
if (args.length != 1) {
player.sendMessage(Main.MSG_PREFIX + ChatColor.RED + "//scale [size]");
return;
}
double size;
try {
size = Double.parseDouble(args[0]);
} catch (Exception e) {
player.sendMessage(Main.MSG_PREFIX + ChatColor.RED + "//scale [size]");
return;
}
Main.getInstance().getServer().dispatchCommand(player, "/deform x/=" + size + ";y/=" + size + ";z/=" + size);
}
}
@@ -0,0 +1,51 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class SetAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "/set " + builder.toString());
}
}
@@ -0,0 +1,70 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class TwistAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
if (args.length != 2) {
player.sendMessage(Main.MSG_PREFIX + ChatColor.RED + "//twist [axis] [degrees]");
return;
}
int degrees;
try {
degrees = Integer.parseInt(args[1]);
} catch (Exception e) {
player.sendMessage(Main.MSG_PREFIX + ChatColor.RED + "//twist [axis] [degrees]");
return;
}
float radiansPerDegree = 0.0174533f;
float radian = degrees * radiansPerDegree;
if (args[0].equalsIgnoreCase("x")) {
Main.getInstance().getServer().dispatchCommand(player, "/deform rotate(y,z," + radian / 2 + "*(x+1))");
} else if (args[0].equalsIgnoreCase("y")) {
Main.getInstance().getServer().dispatchCommand(player, "/deform rotate(x,z," + radian / 2 + "*(y+1))");
} else if (args[0].equalsIgnoreCase("z")) {
Main.getInstance().getServer().dispatchCommand(player, "/deform rotate(x,y," + radian / 2 + "*(z+1))");
} else {
player.sendMessage(Main.MSG_PREFIX + ChatColor.RED + "//twist [axis] [degrees]");
}
}
}
@@ -0,0 +1,51 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.aliases;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.entity.Player;
public class WalkSpeedAliasCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.aliases")) {
if (Settings.sendErrorMessages) {
player.sendMessage(Main.MSG_ERROR + "You do not have access to this command.");
}
return;
}
StringBuilder builder = new StringBuilder();
if (args.length != 0) {
for (String arg : args) {
builder.append(arg).append(" ");
}
}
Main.getInstance().getServer().dispatchCommand(player, "speed walk " + builder.toString());
}
}
@@ -0,0 +1,114 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.system;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.commands.AdvancedFlyCommand;
import net.arcaniax.buildersutilities.commands.BannerCommand;
import net.arcaniax.buildersutilities.commands.ColorCommand;
import net.arcaniax.buildersutilities.commands.HelpCommand;
import net.arcaniax.buildersutilities.commands.SecretBlockCommand;
import net.arcaniax.buildersutilities.commands.NoClipCommand;
import net.arcaniax.buildersutilities.commands.NightVisionCommand;
import net.arcaniax.buildersutilities.commands.UtilsCommand;
import net.arcaniax.buildersutilities.commands.aliases.ConvexSelectionAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.CuboidSelectionAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.PosOneAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.PosTwoAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.SetAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.ReplaceAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.PasteAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.FlipAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.CopyAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.DeformRotateAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.TwistAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.ScaleAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.WalkSpeedAliasCommand;
import net.arcaniax.buildersutilities.commands.aliases.FlySpeedAliasCommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class CommandForwarder implements CommandExecutor {
private final Map<String, ICommand> commands;
public CommandForwarder() {
commands = new HashMap<>();
registerCommand(new HelpCommand(), "help", "h", "?");
registerCommand(new AdvancedFlyCommand(), "af", "advancedfly");
registerCommand(new BannerCommand(), "banner");
registerCommand(new ColorCommand(), "color", "ac", "armorcolor");
registerCommand(new SecretBlockCommand(), "secretblock", "secretblocks", "blocks");
registerCommand(new NoClipCommand(), "noclip", "nc");
registerCommand(new NightVisionCommand(), "nv", "nightvision", "n");
registerCommand(new UtilsCommand(), "utils", "u", "util", "gui", "inventory");
registerCommand(new PosOneAliasCommand(), "p1", "1", "one", "pos1");
registerCommand(new PosTwoAliasCommand(), "p2", "2", "two", "pos2");
registerCommand(new CuboidSelectionAliasCommand(), "cuboid", "cube");
registerCommand(new ConvexSelectionAliasCommand(), "convex", "conv");
registerCommand(new SetAliasCommand(), "set", "s");
registerCommand(new ReplaceAliasCommand(), "replace", "r", "repl", "rep");
registerCommand(new PasteAliasCommand(), "paste", "pa");
registerCommand(new FlipAliasCommand(), "flip", "f");
registerCommand(new CopyAliasCommand(), "copy", "c", "clone");
registerCommand(new DeformRotateAliasCommand(), "deformrotate", "defrot", "dr");
registerCommand(new TwistAliasCommand(), "twist", "tw", "t");
registerCommand(new ScaleAliasCommand(), "scale", "sc");
registerCommand(new WalkSpeedAliasCommand(), "walkspeed", "ws");
registerCommand(new FlySpeedAliasCommand(), "flyspeed", "fs");
}
private void registerCommand(ICommand iCommand, String... aliases) {
for (String alias : aliases) {
commands.put(alias.toLowerCase(), iCommand);
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
//Make it player-only
Player player = sender instanceof Player ? ((Player) sender) : null;
if (player == null) {
sender.sendMessage(Main.MSG_ERROR + "Sorry this command can only be used by a player.");
return false;
}
if (args.length == 0) {
new HelpCommand().execute(player, args);
return true;
}
ICommand iCommand = commands.get(args[0].toLowerCase());
if (iCommand != null) {
iCommand.execute(player, Arrays.copyOfRange(args, 1, args.length));
}
return true;
}
}
@@ -0,0 +1,33 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands.system;
import org.bukkit.entity.Player;
public interface ICommand {
void execute(Player player, String[] args);
}
@@ -1,4 +1,28 @@
package com.arcaniax.buildersutilities.listeners;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import org.bukkit.GameMode;
import org.bukkit.Location;
@@ -11,12 +35,14 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import java.util.*;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class BlockBreakListener implements Listener {
public static Set<UUID> slabIds;
public BlockBreakListener(){
public BlockBreakListener() {
slabIds = new HashSet<>();
}
@@ -1,6 +1,30 @@
package com.arcaniax.buildersutilities.listeners;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import com.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.Settings;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -0,0 +1,41 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import net.arcaniax.buildersutilities.Settings;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
public class ExplosionListener implements Listener {
@EventHandler
public void onExplode(EntityExplodeEvent event) {
if (Settings.disableExplosions) {
event.setCancelled(true);
}
}
}
@@ -1,6 +1,30 @@
package com.arcaniax.buildersutilities.listeners;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import com.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Main;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
@@ -13,7 +37,9 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import java.util.*;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class IronTrapdoorListener implements Listener {
public static Set<UUID> ironTrapdoorIds;
@@ -0,0 +1,40 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import net.arcaniax.buildersutilities.Settings;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.LeavesDecayEvent;
public class LeafDecayListener implements Listener {
@EventHandler
public void onLeafDecay(LeavesDecayEvent event) {
if (Settings.disableLeavesDecay) {
event.setCancelled(true);
}
}
}
@@ -0,0 +1,66 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import net.arcaniax.buildersutilities.Settings;
import org.bukkit.Material;
import org.bukkit.block.Block;
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.player.PlayerInteractEvent;
public class PlayerInteractListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onDragonEggTP(PlayerInteractEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
&& event.getClickedBlock().getType().equals(Material.DRAGON_EGG)
&& (!event.getPlayer().isSneaking())
&& Settings.preventDragonEggTeleport) {
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.isCancelled()) {
return;
}
if (Settings.disableSoilTrample) {
if (event.getAction() == Action.PHYSICAL) {
Block block = event.getClickedBlock();
if (block != null && block.getType() == Material.FARMLAND) {
event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
event.setCancelled(true);
}
}
}
}
}
@@ -1,4 +1,28 @@
package com.arcaniax.buildersutilities.listeners;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -10,10 +34,10 @@ import org.bukkit.util.Vector;
import java.util.*;
public class PlayerMoveListener implements Listener {
private final HashMap<String, Double> lastVelocity = new HashMap<>();
private static final List<String> slower = new ArrayList<>();
private static final List<String> slower2 = new ArrayList<>();
public static Set<UUID> enabledPlayers = new HashSet<>();
private final HashMap<String, Double> lastVelocity = new HashMap<>();
public static boolean togglePlayer(Player p) {
if (enabledPlayers.contains(p.getUniqueId())) {
@@ -49,7 +73,7 @@ public class PlayerMoveListener implements Listener {
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 (:
//No more if slower.contains** as if e.getPlayer().getName() isn't there, it won't get removed (:
slower.remove(e.getPlayer().getName());
slower2.remove(e.getPlayer().getName());
} else {
@@ -0,0 +1,63 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.NoClipManager;
import net.arcaniax.buildersutilities.Settings;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerQuitAndJoinListener implements Listener {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
NoClipManager.noClipPlayerIds.remove(player.getUniqueId());
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (Main.getInstance().getNmsManager().isAtLeastVersion(1, 9, 0)) {
AttributeInstance attribute = event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED);
if (attribute == null) {
return;
}
if (Settings.fixAttackSpeed) {
attribute.setBaseValue(1024.0D);
} else if (attribute.getBaseValue() == 1024.0D) {
attribute.setBaseValue(attribute.getDefaultValue());
}
event.getPlayer().saveData();
}
}
}
@@ -0,0 +1,45 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
public class TeleportListener implements Listener {
@EventHandler
public void onTeleport(PlayerTeleportEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.SPECTATE)) {
//TODO what is this tpgm3 lol
if (!event.getPlayer().hasPermission("builders.util.tpgm3")) {
event.setCancelled(true);
}
}
}
}
@@ -1,6 +1,30 @@
package com.arcaniax.buildersutilities.listeners;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import com.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.Main;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -13,7 +37,9 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import java.util.*;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class TerracottaInteractListener implements Listener {
public static Set<UUID> terracottaIds;
@@ -0,0 +1,39 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.listeners;
import net.arcaniax.buildersutilities.Settings;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.weather.WeatherChangeEvent;
public class WeatherChangeListener implements Listener {
@EventHandler
public void onWeather(WeatherChangeEvent e) {
if (Settings.disableWeatherChanges) {
e.setCancelled(true);
}
}
}
@@ -0,0 +1,36 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import org.bukkit.entity.Player;
public class BannerMenuProvider implements InventoryProvider {
@Override
public void init(Player player, InventoryContents contents) {
}
}
@@ -1,9 +1,33 @@
package com.arcaniax.buildersutilities.menus;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus;
import com.arcaniax.buildersutilities.menus.inv.ClickableItem;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import com.arcaniax.buildersutilities.utils.Items;
import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import net.arcaniax.buildersutilities.utils.Items;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -28,23 +52,23 @@ public class ColorMenuProvider implements InventoryProvider {
private void setLeatherItems(Player player, InventoryContents contents) {
int r;
if(contents.get(3, 4).get().getItem().getType().equals(Material.RED_STAINED_GLASS)){
if (contents.get(3, 4).get().getItem().getType().equals(Material.RED_STAINED_GLASS)) {
r = 0;
}else{
} else {
r = (int) (contents.get(3, 4).get().getItem().getAmount() * MULTIPLIER);
}
int g;
if(contents.get(3, 5).get().getItem().getType().equals(Material.GREEN_STAINED_GLASS)){
if (contents.get(3, 5).get().getItem().getType().equals(Material.GREEN_STAINED_GLASS)) {
g = 0;
}else{
} else {
g = (int) (contents.get(3, 5).get().getItem().getAmount() * MULTIPLIER);
}
int b;
if(contents.get(3, 6).get().getItem().getType().equals(Material.BLUE_STAINED_GLASS)){
if (contents.get(3, 6).get().getItem().getType().equals(Material.BLUE_STAINED_GLASS)) {
b = 0;
}else{
} else {
b = (int) (contents.get(3, 6).get().getItem().getAmount() * MULTIPLIER);
}
@@ -61,17 +85,17 @@ public class ColorMenuProvider implements InventoryProvider {
private void setRedItem(Player player, InventoryContents contents, int amount) {
contents.set(3, 4, ClickableItem.of(
amount == 0 ? Items.create(Material.RED_STAINED_GLASS, "&cRed", LORE) :
Items.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y0NmMzMWQ2ZWU2ZWE2MTlmNzJlNzg1MjMyY2IwNDhhYjI3MDQ2MmRiMGNiMTQ1NDUxNDQzNjI1MWMxYSJ9fX0=",
amount, "&cRed", LORE), inventoryClickEvent -> {
if (inventoryClickEvent.isShiftClick()) {
setRedItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 5, 20) : Math.max(amount - 5, 0));
} else {
setRedItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 1, 20) : Math.max(amount - 1, 0));
}
setLeatherItems(player, contents);
}));
Items.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y0NmMzMWQ2ZWU2ZWE2MTlmNzJlNzg1MjMyY2IwNDhhYjI3MDQ2MmRiMGNiMTQ1NDUxNDQzNjI1MWMxYSJ9fX0=",
amount, "&cRed", LORE), inventoryClickEvent -> {
if (inventoryClickEvent.isShiftClick()) {
setRedItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 5, 20) : Math.max(amount - 5, 0));
} else {
setRedItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 1, 20) : Math.max(amount - 1, 0));
}
setLeatherItems(player, contents);
}));
}
private void setRedRandomItem(Player player, InventoryContents contents) {
@@ -85,17 +109,17 @@ public class ColorMenuProvider implements InventoryProvider {
private void setGreenItem(Player player, InventoryContents contents, int amount) {
contents.set(3, 5, ClickableItem.of(
amount == 0 ? Items.create(Material.GREEN_STAINED_GLASS, "&aGreen", LORE) :
Items.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzZmNjlmN2I3NTM4YjQxZGMzNDM5ZjM2NThhYmJkNTlmYWNjYTM2NmYxOTBiY2YxZDZkMGEwMjZjOGY5NiJ9fX0=",
amount, "&aGreen", LORE), inventoryClickEvent -> {
if (inventoryClickEvent.isShiftClick()) {
setGreenItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 5, 20) : Math.max(amount - 5, 0));
} else {
setGreenItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 1, 20) : Math.max(amount - 1, 0));
}
setLeatherItems(player, contents);
}));
Items.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzZmNjlmN2I3NTM4YjQxZGMzNDM5ZjM2NThhYmJkNTlmYWNjYTM2NmYxOTBiY2YxZDZkMGEwMjZjOGY5NiJ9fX0=",
amount, "&aGreen", LORE), inventoryClickEvent -> {
if (inventoryClickEvent.isShiftClick()) {
setGreenItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 5, 20) : Math.max(amount - 5, 0));
} else {
setGreenItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 1, 20) : Math.max(amount - 1, 0));
}
setLeatherItems(player, contents);
}));
}
private void setGreenRandomItem(Player player, InventoryContents contents) {
@@ -109,17 +133,17 @@ public class ColorMenuProvider implements InventoryProvider {
private void setBlueItem(Player player, InventoryContents contents, int amount) {
contents.set(3, 6, ClickableItem.of(
amount == 0 ? Items.create(Material.BLUE_STAINED_GLASS, "&bBlue", LORE) :
Items.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjgzOWUzODFkOWZlZGFiNmY4YjU5Mzk2YTI3NjQyMzhkY2ViMmY3ZWVhODU2ZGM2ZmM0NDc2N2RhMzgyZjEifX19",
amount, "&bBlue", LORE), inventoryClickEvent -> {
if (inventoryClickEvent.isShiftClick()) {
setBlueItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 5, 20) : Math.max(amount - 5, 0));
} else {
setBlueItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 1, 20) : Math.max(amount - 1, 0));
}
setLeatherItems(player, contents);
}));
Items.createHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjgzOWUzODFkOWZlZGFiNmY4YjU5Mzk2YTI3NjQyMzhkY2ViMmY3ZWVhODU2ZGM2ZmM0NDc2N2RhMzgyZjEifX19",
amount, "&bBlue", LORE), inventoryClickEvent -> {
if (inventoryClickEvent.isShiftClick()) {
setBlueItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 5, 20) : Math.max(amount - 5, 0));
} else {
setBlueItem(player, contents,
inventoryClickEvent.isLeftClick() ? Math.min(amount + 1, 20) : Math.max(amount - 1, 0));
}
setLeatherItems(player, contents);
}));
}
private void setBlueRandomItem(Player player, InventoryContents contents) {
@@ -1,9 +1,33 @@
package com.arcaniax.buildersutilities.menus;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus;
import com.arcaniax.buildersutilities.Main;
import com.arcaniax.buildersutilities.menus.bannermenus.BannerMenuProvider;
import com.arcaniax.buildersutilities.menus.inv.InventoryListener;
import com.arcaniax.buildersutilities.menus.inv.SmartInventory;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.menus.bannermenus.BannerMenuProvider;
import net.arcaniax.buildersutilities.menus.inv.InventoryListener;
import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@@ -0,0 +1,54 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus;
import net.arcaniax.buildersutilities.Main;
import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import net.arcaniax.buildersutilities.utils.Items;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SecretBlockMenuProvider implements InventoryProvider {
private static final ItemStack SPAWNER = Items.create(Material.SPAWNER, (short) 0, 1, ChatColor.DARK_AQUA + "Spawner Cage", "");
private static final ItemStack BARRIER = Items.create(Material.BARRIER, (short) 0, 1, ChatColor.DARK_AQUA + "Barrier", "");
private static final ItemStack DRAGON_EGG = Items.create(Material.DRAGON_EGG, (short) 0, 1, ChatColor.DARK_AQUA + "Dragon Egg", "");
private static final ItemStack GRASS_PATH = Items.create(Material.GRASS_PATH, (short) 0, 1, ChatColor.DARK_AQUA + "Grass Path", "");
@Override
public void init(Player player, InventoryContents contents) {
contents.set(0, 0, ClickableItem.of(SPAWNER, inventoryClickEvent -> player.getInventory().addItem(new ItemStack(Material.SPAWNER))));
contents.set(0, 1, ClickableItem.of(BARRIER, inventoryClickEvent -> player.getInventory().addItem(new ItemStack(Material.BARRIER))));
contents.set(0, 2, ClickableItem.of(DRAGON_EGG, inventoryClickEvent -> player.getInventory().addItem(new ItemStack(Material.DRAGON_EGG))));
if (Main.getInstance().getNmsManager().isAtLeastVersion(1, 9, 0)) {
contents.set(0, 3, ClickableItem.of(GRASS_PATH, inventoryClickEvent -> player.getInventory().addItem(new ItemStack(Material.GRASS_PATH))));
}
}
}
@@ -1,14 +1,38 @@
package com.arcaniax.buildersutilities.menus;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus;
import com.arcaniax.buildersutilities.NoClipManager;
import com.arcaniax.buildersutilities.listeners.BlockBreakListener;
import com.arcaniax.buildersutilities.listeners.IronTrapdoorListener;
import com.arcaniax.buildersutilities.listeners.PlayerMoveListener;
import com.arcaniax.buildersutilities.listeners.TerracottaInteractListener;
import com.arcaniax.buildersutilities.menus.inv.ClickableItem;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import com.arcaniax.buildersutilities.utils.Items;
import net.arcaniax.buildersutilities.NoClipManager;
import net.arcaniax.buildersutilities.listeners.BlockBreakListener;
import net.arcaniax.buildersutilities.listeners.IronTrapdoorListener;
import net.arcaniax.buildersutilities.listeners.PlayerMoveListener;
import net.arcaniax.buildersutilities.listeners.TerracottaInteractListener;
import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import net.arcaniax.buildersutilities.utils.Items;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -0,0 +1,61 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.bannermenus;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import net.arcaniax.buildersutilities.utils.Items;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class BannerColorMenuProvider implements InventoryProvider {
private static final ItemStack grayPane = Items
.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
private static final ItemStack head = Items.createHead(
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19",
1, "&7Click to randomise", "");
@Override
public void init(Player player, InventoryContents contents) {
// for (int x = 0; x < 54; x++) {
// contents.set(x / 9, x % 9, grayPane);
// }
// inv1.setItem(1, );
// 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"));
// }
}
}
@@ -0,0 +1,62 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.bannermenus;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import net.arcaniax.buildersutilities.utils.Items;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class BannerMenuProvider implements InventoryProvider {
private static final ItemStack grayPane = Items
.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
private static final ItemStack randomizeHead = Items.createHead(
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19",
1, "&7Click to randomise", "");
// private static final ItemStack currentColor = BannerUtil.createBanner("&a", 1, DyeColor.WHITE, "");
private static final ItemStack closeButton = Items
.create(Material.BARRIER, (short) 0, 1, "&cClick to close", "");
@Override
public void init(Player player, InventoryContents contents) {
// for (int x = 0; x < 54; x++) {
// contents.set(x / 9, x % 9, ClickableItem.empty(grayPane));
// }
// contents.set(0, 1, ClickableItem.of(randomizeHead, NULL));
// contents.set(0, 4, ClickableItem.empty(currentColor));
// contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
// for (int x = 19; x < 27; x++) {
// ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 19).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 19), "&7__&7click to select");
// contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
// }
// for (int x = 28; x < 36; x++) {
// ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 28 + 8).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 28 + 8), "&7__&7click to select");
// contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
// }
}
}
@@ -0,0 +1,62 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.bannermenus;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import net.arcaniax.buildersutilities.utils.Items;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class BannerPatternMenuProvider implements InventoryProvider {
private static final ItemStack grayPane = Items
.create(Material.LIGHT_GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
private static final ItemStack randomizeHead = Items.createHead(
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19",
1, "&7Click to randomise", "");
// private static final ItemStack currentColor = BannerUtil.createBanner("&a", 1, DyeColor.WHITE, "");
private static final ItemStack closeButton = Items
.create(Material.BARRIER, (short) 0, 1, "&cClick to close", "");
@Override
public void init(Player player, InventoryContents contents) {
// for (int x = 0; x < 54; x++) {
// contents.set(x / 9, x % 9, ClickableItem.empty(grayPane));
// }
// contents.set(0, 1, ClickableItem.of(randomizeHead, NULL));
// contents.set(0, 4, ClickableItem.empty(currentColor));
// contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
// for (int x = 19; x < 27; x++) {
// ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 19).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 19), "&7__&7click to select");
// contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
// }
// for (int x = 28; x < 36; x++) {
// ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 28 + 8).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 28 + 8), "&7__&7click to select");
// contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
// }
}
}
@@ -0,0 +1,59 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import java.util.function.Consumer;
public class ClickableItem {
private final ItemStack item;
private final Consumer<InventoryClickEvent> consumer;
private ClickableItem(ItemStack item, Consumer<InventoryClickEvent> consumer) {
this.item = item;
this.consumer = consumer;
}
public static ClickableItem empty(ItemStack item) {
return of(item, e -> {
});
}
public static ClickableItem of(ItemStack item, Consumer<InventoryClickEvent> consumer) {
return new ClickableItem(item, consumer);
}
public void run(InventoryClickEvent e) {
consumer.accept(e);
}
public ItemStack getItem() {
return item;
}
}
@@ -0,0 +1,47 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv;
import java.util.function.Consumer;
public class InventoryListener<T> {
private final Class<T> type;
private final Consumer<T> consumer;
public InventoryListener(Class<T> type, Consumer<T> consumer) {
this.type = type;
this.consumer = consumer;
}
public void accept(T t) {
consumer.accept(t);
}
public Class<T> getType() {
return type;
}
}
@@ -1,9 +1,33 @@
package com.arcaniax.buildersutilities.menus.inv;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import com.arcaniax.buildersutilities.menus.inv.opener.ChestInventoryOpener;
import com.arcaniax.buildersutilities.menus.inv.opener.InventoryOpener;
import com.arcaniax.buildersutilities.menus.inv.opener.SpecialInventoryOpener;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import net.arcaniax.buildersutilities.menus.inv.opener.ChestInventoryOpener;
import net.arcaniax.buildersutilities.menus.inv.opener.InventoryOpener;
import net.arcaniax.buildersutilities.menus.inv.opener.SpecialInventoryOpener;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -20,14 +44,14 @@ import java.util.*;
public class InventoryManager {
private JavaPlugin plugin;
private PluginManager pluginManager;
private final JavaPlugin plugin;
private final PluginManager pluginManager;
private Map<Player, SmartInventory> inventories;
private Map<Player, InventoryContents> contents;
private final Map<Player, SmartInventory> inventories;
private final Map<Player, InventoryContents> contents;
private List<InventoryOpener> defaultOpeners;
private List<InventoryOpener> openers;
private final List<InventoryOpener> defaultOpeners;
private final List<InventoryOpener> openers;
public InventoryManager(JavaPlugin plugin) {
this.plugin = plugin;
@@ -72,8 +96,9 @@ public class InventoryManager {
List<Player> list = new ArrayList<>();
this.inventories.forEach((player, playerInv) -> {
if (inv.equals(playerInv))
if (inv.equals(playerInv)) {
list.add(player);
}
});
return list;
@@ -84,10 +109,11 @@ public class InventoryManager {
}
protected void setInventory(Player p, SmartInventory inv) {
if (inv == null)
if (inv == null) {
this.inventories.remove(p);
else
} else {
this.inventories.put(p, inv);
}
}
public Optional<InventoryContents> getContents(Player p) {
@@ -95,10 +121,11 @@ public class InventoryManager {
}
protected void setContents(Player p, InventoryContents contents) {
if (contents == null)
if (contents == null) {
this.contents.remove(p);
else
} else {
this.contents.put(p, contents);
}
}
@SuppressWarnings("unchecked")
@@ -108,8 +135,9 @@ public class InventoryManager {
public void onInventoryClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (!inventories.containsKey(p))
if (!inventories.containsKey(p)) {
return;
}
if (e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
e.setCancelled(true);
@@ -130,13 +158,15 @@ public class InventoryManager {
int row = e.getSlot() / 9;
int column = e.getSlot() % 9;
if (row < 0 || column < 0)
if (row < 0 || column < 0) {
return;
}
SmartInventory inv = inventories.get(p);
if (row >= inv.getRows() || column >= inv.getColumns())
if (row >= inv.getRows() || column >= inv.getColumns()) {
return;
}
inv.getListeners().stream()
.filter(listener -> listener.getType() == InventoryClickEvent.class)
@@ -152,14 +182,16 @@ public class InventoryManager {
public void onInventoryDrag(InventoryDragEvent e) {
Player p = (Player) e.getWhoClicked();
if (!inventories.containsKey(p))
if (!inventories.containsKey(p)) {
return;
}
SmartInventory inv = inventories.get(p);
for (int slot : e.getRawSlots()) {
if (slot >= p.getOpenInventory().getTopInventory().getSize())
if (slot >= p.getOpenInventory().getTopInventory().getSize()) {
continue;
}
e.setCancelled(true);
break;
@@ -174,8 +206,9 @@ public class InventoryManager {
public void onInventoryOpen(InventoryOpenEvent e) {
Player p = (Player) e.getPlayer();
if (!inventories.containsKey(p))
if (!inventories.containsKey(p)) {
return;
}
SmartInventory inv = inventories.get(p);
@@ -188,8 +221,9 @@ public class InventoryManager {
public void onInventoryClose(InventoryCloseEvent e) {
Player p = (Player) e.getPlayer();
if (!inventories.containsKey(p))
if (!inventories.containsKey(p)) {
return;
}
SmartInventory inv = inventories.get(p);
@@ -202,16 +236,18 @@ public class InventoryManager {
inventories.remove(p);
contents.remove(p);
} else
} else {
Bukkit.getScheduler().runTask(plugin, () -> p.openInventory(e.getInventory()));
}
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerQuit(PlayerQuitEvent e) {
Player p = e.getPlayer();
if (!inventories.containsKey(p))
if (!inventories.containsKey(p)) {
return;
}
SmartInventory inv = inventories.get(p);
@@ -243,7 +279,8 @@ public class InventoryManager {
@Override
public void run() {
new HashMap<>(inventories).forEach((player, inv) -> inv.getProvider().update(player, contents.get(player)));
new HashMap<>(inventories)
.forEach((player, inv) -> inv.getProvider().update(player, contents.get(player)));
}
}
@@ -1,8 +1,32 @@
package com.arcaniax.buildersutilities.menus.inv;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import com.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import com.arcaniax.buildersutilities.menus.inv.opener.InventoryOpener;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
import net.arcaniax.buildersutilities.menus.inv.opener.InventoryOpener;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.inventory.InventoryCloseEvent;
@@ -16,17 +40,15 @@ import java.util.Optional;
@SuppressWarnings("unchecked")
public class SmartInventory {
private final InventoryManager manager;
private String id;
private String title;
private InventoryType type;
private int rows, columns;
private boolean closeable;
private InventoryProvider provider;
private SmartInventory parent;
private List<InventoryListener<? extends Event>> listeners;
private InventoryManager manager;
private SmartInventory(InventoryManager manager) {
this.manager = manager;
@@ -59,7 +81,8 @@ public class SmartInventory {
this.provider.init(player, contents);
InventoryOpener opener = this.manager.findOpener(type)
.orElseThrow(() -> new IllegalStateException("No opener found for the inventory type " + type.name()));
.orElseThrow(() -> new IllegalStateException(
"No opener found for the inventory type " + type.name()));
Inventory handle = opener.open(this, player);
this.manager.setInventory(player, this);
@@ -126,18 +149,16 @@ public class SmartInventory {
public static final class Builder {
private final List<InventoryListener<? extends Event>> listeners = new ArrayList<>();
private String id = "unknown";
private String title = "";
private InventoryType type = InventoryType.CHEST;
private int rows = 6, columns = 9;
private boolean closeable = true;
private InventoryManager manager;
private InventoryProvider provider;
private SmartInventory parent;
private List<InventoryListener<? extends Event>> listeners = new ArrayList<>();
private Builder() {
}
@@ -188,14 +209,18 @@ public class SmartInventory {
}
public SmartInventory build() {
if (this.provider == null)
throw new IllegalStateException("The provider of the SmartInventory.Builder must be set.");
if (this.provider == null) {
throw new IllegalStateException(
"The provider of the SmartInventory.Builder must be set.");
}
InventoryManager manager = this.manager;
if (manager == null)
throw new IllegalStateException("The manager of the SmartInventory.Builder must be set, "
+ "or the SmartInvs should be loaded as a plugin.");
if (manager == null) {
throw new IllegalStateException(
"The manager of the SmartInventory.Builder must be set, "
+ "or the SmartInvs should be loaded as a plugin.");
}
SmartInventory inv = new SmartInventory(manager);
inv.id = this.id;
@@ -1,7 +1,31 @@
package com.arcaniax.buildersutilities.menus.inv.content;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv.content;
import com.arcaniax.buildersutilities.menus.inv.ClickableItem;
import com.arcaniax.buildersutilities.menus.inv.SmartInventory;
import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@@ -61,14 +85,14 @@ public interface InventoryContents {
class Impl implements InventoryContents {
private SmartInventory inv;
private Player player;
private final SmartInventory inv;
private final Player player;
private ClickableItem[][] contents;
private final ClickableItem[][] contents;
private Pagination pagination = new Pagination.Impl();
private Map<String, SlotIterator> iterators = new HashMap<>();
private Map<String, Object> properties = new HashMap<>();
private final Pagination pagination = new Pagination.Impl();
private final Map<String, SlotIterator> iterators = new HashMap<>();
private final Map<String, Object> properties = new HashMap<>();
public Impl(SmartInventory inv, Player player) {
this.inv = inv;
@@ -92,7 +116,8 @@ public interface InventoryContents {
}
@Override
public SlotIterator newIterator(String id, SlotIterator.Type type, int startRow, int startColumn) {
public SlotIterator newIterator(String id, SlotIterator.Type type, int startRow,
int startColumn) {
SlotIterator iterator = new SlotIterator.Impl(this, inv,
type, startRow, startColumn);
@@ -124,8 +149,9 @@ public interface InventoryContents {
public Optional<SlotPos> firstEmpty() {
for (int row = 0; row < contents.length; row++) {
for (int column = 0; column < contents[0].length; column++) {
if (!this.get(row, column).isPresent())
if (!this.get(row, column).isPresent()) {
return Optional.of(new SlotPos(row, column));
}
}
}
@@ -134,10 +160,12 @@ public interface InventoryContents {
@Override
public Optional<ClickableItem> get(int row, int column) {
if (row >= contents.length)
if (row >= contents.length) {
return Optional.empty();
if (column >= contents[row].length)
}
if (column >= contents[row].length) {
return Optional.empty();
}
return Optional.ofNullable(contents[row][column]);
}
@@ -149,10 +177,12 @@ public interface InventoryContents {
@Override
public InventoryContents set(int row, int column, ClickableItem item) {
if (row >= contents.length)
if (row >= contents.length) {
return this;
if (column >= contents[row].length)
}
if (column >= contents[row].length) {
return this;
}
contents[row][column] = item;
update(row, column, item != null ? item.getItem() : null);
@@ -180,28 +210,33 @@ public interface InventoryContents {
@Override
public InventoryContents fill(ClickableItem item) {
for (int row = 0; row < contents.length; row++)
for (int column = 0; column < contents[row].length; column++)
for (int row = 0; row < contents.length; row++) {
for (int column = 0; column < contents[row].length; column++) {
set(row, column, item);
}
}
return this;
}
@Override
public InventoryContents fillRow(int row, ClickableItem item) {
if (row >= contents.length)
if (row >= contents.length) {
return this;
}
for (int column = 0; column < contents[row].length; column++)
for (int column = 0; column < contents[row].length; column++) {
set(row, column, item);
}
return this;
}
@Override
public InventoryContents fillColumn(int column, ClickableItem item) {
for (int row = 0; row < contents.length; row++)
for (int row = 0; row < contents.length; row++) {
set(row, column, item);
}
return this;
}
@@ -213,11 +248,13 @@ public interface InventoryContents {
}
@Override
public InventoryContents fillRect(int fromRow, int fromColumn, int toRow, int toColumn, ClickableItem item) {
public InventoryContents fillRect(int fromRow, int fromColumn, int toRow, int toColumn,
ClickableItem item) {
for (int row = fromRow; row <= toRow; row++) {
for (int column = fromColumn; column <= toColumn; column++) {
if (row != fromRow && row != toRow && column != fromColumn && column != toColumn)
if (row != fromRow && row != toRow && column != fromColumn && column != toColumn) {
continue;
}
set(row, column, item);
}
@@ -228,7 +265,8 @@ public interface InventoryContents {
@Override
public InventoryContents fillRect(SlotPos fromPos, SlotPos toPos, ClickableItem item) {
return fillRect(fromPos.getRow(), fromPos.getColumn(), toPos.getRow(), toPos.getColumn(), item);
return fillRect(fromPos.getRow(), fromPos.getColumn(), toPos.getRow(), toPos.getColumn(),
item);
}
@SuppressWarnings("unchecked")
@@ -250,8 +288,9 @@ public interface InventoryContents {
}
private void update(int row, int column, ItemStack item) {
if (!inv.getManager().getOpenedPlayers(inv).contains(player))
if (!inv.getManager().getOpenedPlayers(inv).contains(player)) {
return;
}
Inventory topInventory = player.getOpenInventory().getTopInventory();
topInventory.setItem(inv.getColumns() * row + column, item);
@@ -0,0 +1,36 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv.content;
import org.bukkit.entity.Player;
public interface InventoryProvider {
void init(Player player, InventoryContents contents);
default void update(Player player, InventoryContents contents) {
}
}
@@ -1,6 +1,30 @@
package com.arcaniax.buildersutilities.menus.inv.content;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv.content;
import com.arcaniax.buildersutilities.menus.inv.ClickableItem;
import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
import java.util.Arrays;
@@ -75,16 +99,18 @@ public interface Pagination {
@Override
public Pagination previous() {
if (!isFirst())
if (!isFirst()) {
this.currentPage--;
}
return this;
}
@Override
public Pagination next() {
if (!isLast())
if (!isLast()) {
this.currentPage++;
}
return this;
}
@@ -100,8 +126,9 @@ public interface Pagination {
for (ClickableItem item : getPageItems()) {
iterator.next().set(item);
if (iterator.ended())
if (iterator.ended()) {
break;
}
}
return this;
@@ -1,7 +1,31 @@
package com.arcaniax.buildersutilities.menus.inv.content;
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv.content;
import com.arcaniax.buildersutilities.menus.inv.ClickableItem;
import com.arcaniax.buildersutilities.menus.inv.SmartInventory;
import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
import java.util.HashSet;
import java.util.Optional;
@@ -44,16 +68,15 @@ public interface SlotIterator {
class Impl implements SlotIterator {
private InventoryContents contents;
private SmartInventory inv;
private final InventoryContents contents;
private final SmartInventory inv;
private Type type;
private final Type type;
private final Set<SlotPos> blacklisted = new HashSet<>();
private boolean started = false;
private boolean allowOverride = true;
private int row, column;
private Set<SlotPos> blacklisted = new HashSet<>();
public Impl(InventoryContents contents, SmartInventory inv,
Type type, int startRow, int startColumn) {
@@ -79,8 +102,9 @@ public interface SlotIterator {
@Override
public SlotIterator set(ClickableItem item) {
if (canPlace())
if (canPlace()) {
contents.set(row, column, item);
}
return this;
}
@@ -136,14 +160,16 @@ public interface SlotIterator {
case HORIZONTAL:
column = ++column % inv.getColumns();
if (column == 0)
if (column == 0) {
row++;
}
break;
case VERTICAL:
row = ++row % inv.getRows();
if (row == 0)
if (row == 0) {
column++;
}
break;
}
}
@@ -209,7 +235,8 @@ public interface SlotIterator {
}
private boolean canPlace() {
return !blacklisted.contains(SlotPos.of(row, column)) && (allowOverride || !this.get().isPresent());
return !blacklisted.contains(SlotPos.of(row, column)) && (allowOverride || !this.get()
.isPresent());
}
}
@@ -0,0 +1,71 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv.content;
public class SlotPos {
private final int row;
private final int column;
public SlotPos(int row, int column) {
this.row = row;
this.column = column;
}
public static SlotPos of(int row, int column) {
return new SlotPos(row, column);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
SlotPos slotPos = (SlotPos) obj;
return row == slotPos.row && column == slotPos.column;
}
@Override
public int hashCode() {
int result = row;
result = 31 * result + column;
return result;
}
public int getRow() {
return row;
}
public int getColumn() {
return column;
}
}
@@ -0,0 +1,59 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv.opener;
import com.google.common.base.Preconditions;
import net.arcaniax.buildersutilities.menus.inv.InventoryManager;
import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
public class ChestInventoryOpener implements InventoryOpener {
@Override
public Inventory open(SmartInventory inv, Player player) {
Preconditions.checkArgument(inv.getColumns() == 9,
"The column count for the chest inventory must be 9, found: %s.", inv.getColumns());
Preconditions.checkArgument(inv.getRows() >= 1 && inv.getRows() <= 6,
"The row count for the chest inventory must be between 1 and 6, found: %s", inv.getRows());
InventoryManager manager = inv.getManager();
Inventory handle = Bukkit
.createInventory(player, inv.getRows() * inv.getColumns(), inv.getTitle());
fill(handle, manager.getContents(player).get());
player.openInventory(handle);
return handle;
}
@Override
public boolean supports(InventoryType type) {
return type == InventoryType.CHEST || type == InventoryType.ENDER_CHEST;
}
}
@@ -0,0 +1,52 @@
/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2020 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.menus.inv.opener;
import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
public interface InventoryOpener {
Inventory open(SmartInventory inv, Player player);
boolean supports(InventoryType type);
default void fill(Inventory handle, InventoryContents contents) {
ClickableItem[][] items = contents.all();
for (int row = 0; row < items.length; row++) {
for (int column = 0; column < items[row].length; column++) {
if (items[row][column] != null) {
handle.setItem(9 * row + column, items[row][column].getItem());
}
}
}
}
}
Loaded 100 of 129 files, more files were not shown because too many files have changed in this diff. Show more