Skip to content

Commit

Permalink
Version 3.5.0 - Overall improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsLewizzz committed Feb 20, 2022
1 parent 36f4534 commit 8b5c79b
Show file tree
Hide file tree
Showing 42 changed files with 1,416 additions and 995 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fun.lewisdev</groupId>
<artifactId>DeluxeHub</artifactId>
<version>3.3.10</version>
<version>3.5.0</version>
<packaging>jar</packaging>

<name>DeluxeHub</name>
Expand Down Expand Up @@ -103,7 +103,7 @@
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>mojang</id>
Expand All @@ -115,7 +115,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -160,7 +160,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.8.0-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.shynixn.headdatabase</groupId>
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cl.bgmp.minecraft.util.commands.exceptions.CommandUsageException;
import cl.bgmp.minecraft.util.commands.exceptions.MissingNestedCommandException;
import cl.bgmp.minecraft.util.commands.exceptions.WrappedCommandException;
import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion;
import fun.lewisdev.deluxehub.action.ActionManager;
import fun.lewisdev.deluxehub.command.CommandManager;
import fun.lewisdev.deluxehub.config.ConfigManager;
Expand All @@ -30,7 +31,6 @@
public class DeluxeHubPlugin extends JavaPlugin {

private static final int BSTATS_ID = 3151;
public static int SERVER_VERSION;

private ConfigManager configManager;
private ActionManager actionManager;
Expand Down Expand Up @@ -64,8 +64,7 @@ public void onEnable() {
return;
}

SERVER_VERSION = Integer.parseInt(Bukkit.getBukkitVersion().split("-")[0].replace(".", "#").split("#")[1]);
if (SERVER_VERSION > 15) TextUtil.HEX_USE = true;
MinecraftVersion.disableUpdateCheck();

// Enable bStats metrics
new MetricsLite(this, BSTATS_ID);
Expand Down Expand Up @@ -136,7 +135,7 @@ public boolean onCommand(CommandSender sender, org.bukkit.command.Command cmd, S
try {
getCommandManager().execute(cmd.getName(), args, sender);
} catch (CommandPermissionsException e) {
sender.sendMessage(Messages.NO_PERMISSION.toString());
Messages.NO_PERMISSION.send(sender);
} catch (MissingNestedCommandException e) {
sender.sendMessage(ChatColor.RED + e.getUsage());
} catch (CommandUsageException e) {
Expand Down Expand Up @@ -179,10 +178,6 @@ public InventoryManager getInventoryManager() {
return inventoryManager;
}

public int getServerVersionNumber() {
return SERVER_VERSION;
}

public ConfigManager getConfigManager() {
return configManager;
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/fun/lewisdev/deluxehub/action/ActionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

public class ActionManager {

private DeluxeHubPlugin plugin;
private Map<String, Action> actions;
private final DeluxeHubPlugin plugin;
private final Map<String, Action> actions;

public ActionManager(DeluxeHubPlugin plugin) {
this.plugin = plugin;
Expand Down Expand Up @@ -45,15 +45,16 @@ public void registerAction(Action... actions) {

public void executeActions(Player player, List<String> items) {
items.forEach(item -> {

String actionName = StringUtils.substringBetween(item, "[", "]").toUpperCase();
Action action = actionName.isEmpty() ? null : actions.get(actionName);
String actionName = StringUtils.substringBetween(item, "[", "]");
Action action = actionName == null ? null : actions.get(actionName.toUpperCase());

if (action != null) {
item = item.contains(" ") ? item.split(" ", 2)[1] : "";
item = PlaceholderUtil.setPlaceholders(item, player);

action.execute(plugin, player, item);
}else{
plugin.getLogger().warning("There was a problem attempting to process action: '" + item + "'");
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import fun.lewisdev.deluxehub.action.Action;
import fun.lewisdev.deluxehub.utility.TextUtil;
import fun.lewisdev.deluxehub.utility.reflection.Titles;
import fun.lewisdev.deluxehub.utility.universal.XMaterial;
import org.bukkit.entity.Player;

public class TitleAction implements Action {
Expand Down Expand Up @@ -33,7 +34,7 @@ public void execute(DeluxeHubPlugin plugin, Player player, String data) {
fadeOut = 1;
}

if (plugin.getServerVersionNumber() > 10) {
if (XMaterial.supports(10)) {
player.sendTitle(mainTitle, subTitle, fadeIn * 20, stay * 20, fadeOut * 20);
} else {
Titles.sendTitle(player, fadeIn * 20, stay * 20, fadeOut * 20, mainTitle, subTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ClearchatCommand(DeluxeHubPlugin plugin) {
public void clearchat(final CommandContext args, final CommandSender sender) throws CommandException {

if (!(sender.hasPermission(Permissions.COMMAND_CLEARCHAT.getPermission()))) {
sender.sendMessage(Messages.NO_PERMISSION.toString());
Messages.NO_PERMISSION.send(sender);
return;
}

Expand All @@ -33,20 +33,20 @@ public void clearchat(final CommandContext args, final CommandSender sender) thr
for (int i = 0; i < 100; i++) {
player.sendMessage("");
}
player.sendMessage(Messages.CLEARCHAT.toString().replace("%player%", sender.getName()));
Messages.CLEARCHAT.send(player, "%player%", sender.getName());
}
} else if (args.argsLength() == 1) {

Player player = Bukkit.getPlayer(args.getString(0));
if (player == null) {
sender.sendMessage(Messages.INVALID_PLAYER.toString().replace("%player%", args.getString(0)));
Messages.INVALID_PLAYER.send(sender, "%player%", args.getString(0));
return;
}

for (int i = 0; i < 100; i++) {
player.sendMessage("");
}
sender.sendMessage(Messages.CLEARCHAT_PLAYER.toString().replace("%player%", sender.getName()));
Messages.CLEARCHAT_PLAYER.send(sender, "%player%", sender.getName());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ public void main(final CommandContext args, final CommandSender sender) throws C
else if (args.getString(0).equalsIgnoreCase("reload")) {

if (!sender.hasPermission(Permissions.COMMAND_DELUXEHUB_RELOAD.getPermission())) {
sender.sendMessage(Messages.NO_PERMISSION.toString());
Messages.NO_PERMISSION.send(sender);
return;
}

long start = System.currentTimeMillis();
plugin.reload();
sender.sendMessage(Messages.CONFIG_RELOAD.toString().replace("%time%", String.valueOf(System.currentTimeMillis() - start)));
Messages.CONFIG_RELOAD.send(sender,"%time%", String.valueOf(System.currentTimeMillis() - start));
int inventories = plugin.getInventoryManager().getInventories().size();
if (inventories > 0) {
sender.sendMessage(TextUtil.color("&8- &7Loaded &a" + inventories + "&7 custom menus."));
Expand All @@ -106,7 +106,7 @@ else if (args.getString(0).equalsIgnoreCase("scoreboard")) {
if (!(sender instanceof Player)) throw new CommandException("Console cannot toggle the scoreboard");

if (!sender.hasPermission(Permissions.COMMAND_SCOREBOARD_TOGGLE.getPermission())) {
sender.sendMessage(Messages.NO_PERMISSION.toString());
Messages.NO_PERMISSION.send(sender);
return;
}

Expand All @@ -120,10 +120,10 @@ else if (args.getString(0).equalsIgnoreCase("scoreboard")) {

if (scoreboardManager.hasScore(player.getUniqueId())) {
scoreboardManager.removeScoreboard(player);
player.sendMessage(Messages.SCOREBOARD_TOGGLE.toString().replace("%value%", "disabled"));
Messages.SCOREBOARD_TOGGLE.send(player, "%value%", "disabled");
} else {
scoreboardManager.createScoreboard(player);
player.sendMessage(Messages.SCOREBOARD_TOGGLE.toString().replace("%value%", "enabled"));
Messages.SCOREBOARD_TOGGLE.send(player, "%value%", "enabled");
}
}

Expand All @@ -134,7 +134,7 @@ else if (args.getString(0).equalsIgnoreCase("scoreboard")) {
else if (args.getString(0).equalsIgnoreCase("info")) {

if (!sender.hasPermission(Permissions.COMMAND_DELUXEHUB_HELP.getPermission())) {
sender.sendMessage(Messages.NO_PERMISSION.toString());
Messages.NO_PERMISSION.send(sender);
return;
}

Expand Down Expand Up @@ -175,7 +175,7 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
if (!(sender instanceof Player)) throw new CommandException("Console cannot open menus");

if (!sender.hasPermission(Permissions.COMMAND_OPEN_MENUS.getPermission())) {
sender.sendMessage(Messages.NO_PERMISSION.toString());
Messages.NO_PERMISSION.send(sender);
return;
}

Expand Down Expand Up @@ -203,7 +203,7 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
}

if (!sender.hasPermission(Permissions.COMMAND_HOLOGRAMS.getPermission())) {
sender.sendMessage(Messages.NO_PERMISSION.toString());
Messages.NO_PERMISSION.send(sender);
return;
}

Expand Down Expand Up @@ -236,7 +236,7 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
if (args.getString(1).equalsIgnoreCase("list")) {

if (plugin.getHologramManager().getHolograms().isEmpty()) {
sender.sendMessage(Messages.HOLOGRAMS_EMPTY.toString());
Messages.HOLOGRAMS_EMPTY.send(player);
return;
}

Expand All @@ -256,7 +256,7 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
}

if (plugin.getHologramManager().hasHologram(args.getString(2))) {
sender.sendMessage(Messages.HOLOGRAMS_ALREADY_EXISTS.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_ALREADY_EXISTS.send(player, "%name%", args.getString(2));
return;
}

Expand All @@ -265,7 +265,7 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
defaultMsg.add("&7Created new Hologram called &b" + args.getString(2));
defaultMsg.add("&7Use &b/deluxehub holo &7to customise");
holo.setLines(defaultMsg);
sender.sendMessage(Messages.HOLOGRAMS_SPAWNED.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_SPAWNED.send(player, "%name%", args.getString(2));
return;
}

Expand All @@ -277,12 +277,12 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
}

if (!plugin.getHologramManager().hasHologram(args.getString(2))) {
sender.sendMessage(Messages.HOLOGRAMS_INVALID_HOLOGRAM.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_INVALID_HOLOGRAM.send(player, "%name%", args.getString(2));
return;
}

plugin.getHologramManager().deleteHologram(args.getString(2));
sender.sendMessage(Messages.HOLOGRAMS_DESPAWNED.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_DESPAWNED.send(player, "%name%", args.getString(2));
return;
}

Expand All @@ -293,7 +293,7 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
}

if (!plugin.getHologramManager().hasHologram(args.getString(2))) {
sender.sendMessage(Messages.HOLOGRAMS_INVALID_HOLOGRAM.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_INVALID_HOLOGRAM.send(player, "%name%", args.getString(2));
return;
}

Expand All @@ -302,11 +302,11 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
String text = TextUtil.joinString(5, args.getOriginalArgs());

if (!holo.hasLine(line)) {
sender.sendMessage(Messages.HOLOGRAMS_INVALID_LINE.toString().replace("%line%", String.valueOf(line)));
Messages.HOLOGRAMS_INVALID_LINE.send(player, "%line%", String.valueOf(line));
return;
}
holo.setLine(line, text);
sender.sendMessage(Messages.HOLOGRAMS_LINE_SET.toString().replace("%line%", String.valueOf(line)));
Messages.HOLOGRAMS_LINE_SET.send(player, "%line%", String.valueOf(line));
return;
}

Expand All @@ -317,15 +317,15 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
}

if (!plugin.getHologramManager().hasHologram(args.getString(2))) {
sender.sendMessage(Messages.HOLOGRAMS_INVALID_HOLOGRAM.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_INVALID_HOLOGRAM.send(player, "%name%", args.getString(2));
return;
}

Hologram holo = plugin.getHologramManager().getHologram(args.getString(2));
String text = TextUtil.joinString(4, args.getOriginalArgs());

holo.addLine(text);
sender.sendMessage(Messages.HOLOGRAMS_ADDED_LINE.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_ADDED_LINE.send(player, "%name%", args.getString(2));
}

if (args.getString(1).equalsIgnoreCase("removeline")) {
Expand All @@ -335,21 +335,21 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
}

if (!plugin.getHologramManager().hasHologram(args.getString(2))) {
sender.sendMessage(Messages.HOLOGRAMS_INVALID_HOLOGRAM.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_INVALID_HOLOGRAM.send(player, "%name%", args.getString(2));
return;
}

Hologram holo = plugin.getHologramManager().getHologram(args.getString(2));
int line = Integer.parseInt(args.getString(3));

if (!holo.hasLine(line)) {
sender.sendMessage(Messages.HOLOGRAMS_INVALID_LINE.toString().replace("%line%", String.valueOf(line)));
Messages.HOLOGRAMS_INVALID_LINE.send(player, "%line%", String.valueOf(line));
return;
}

if (holo.removeLine(line) == null) {
plugin.getHologramManager().deleteHologram(args.getString(2));
sender.sendMessage(Messages.HOLOGRAMS_REMOVED_LINE.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_REMOVED_LINE.send(player, "%name%", args.getString(2));
}

return;
Expand All @@ -362,14 +362,14 @@ else if (args.getString(0).equalsIgnoreCase("open")) {
}

if (!plugin.getHologramManager().hasHologram(args.getString(2))) {
sender.sendMessage(Messages.HOLOGRAMS_INVALID_HOLOGRAM.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_INVALID_HOLOGRAM.send(player, "%name%", args.getString(2));
return;
}

Hologram holo = plugin.getHologramManager().getHologram(args.getString(2));

holo.setLocation(player.getLocation());
sender.sendMessage(Messages.HOLOGRAMS_MOVED.toString().replace("%name%", args.getString(2)));
Messages.HOLOGRAMS_MOVED.send(player, "%name%", args.getString(2));
}
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,37 @@ public void flight(final CommandContext args, final CommandSender sender) throws
if (!(sender instanceof Player)) throw new CommandException("Console cannot clear inventory");

if (!(sender.hasPermission(Permissions.COMMAND_FLIGHT.getPermission()))) {
sender.sendMessage(Messages.NO_PERMISSION.toString());
Messages.NO_PERMISSION.send(sender);
return;
}

Player player = (Player) sender;

if (player.getAllowFlight()) {
player.sendMessage(Messages.FLIGHT_DISABLE.toString());
Messages.FLIGHT_DISABLE.send(player);
toggleFlight(player, false);
} else {
player.sendMessage(Messages.FLIGHT_ENABLE.toString());
Messages.FLIGHT_ENABLE.send(player);
toggleFlight(player, true);
}
} else if (args.argsLength() == 1) {
if (!(sender.hasPermission(Permissions.COMMAND_FLIGHT_OTHERS.getPermission()))) {
sender.sendMessage(Messages.NO_PERMISSION.toString());
Messages.NO_PERMISSION.send(sender);
return;
}

Player player = Bukkit.getPlayer(args.getString(0));
if (player == null) {
sender.sendMessage(Messages.INVALID_PLAYER.toString().replace("%player%", args.getString(0)));
Messages.INVALID_PLAYER.send(sender, "%player%", args.getString(0));
return;
}
if (player.getAllowFlight()) {
player.sendMessage(Messages.FLIGHT_DISABLE.toString());
sender.sendMessage(Messages.FLIGHT_DISABLE_OTHER.toString().replace("%player%", player.getName()));
Messages.FLIGHT_DISABLE.send(player);
Messages.FLIGHT_DISABLE_OTHER.send(sender, "%player%", player.getName());
toggleFlight(player, false);
} else {
player.sendMessage(Messages.FLIGHT_ENABLE.toString());
sender.sendMessage(Messages.FLIGHT_ENABLE_OTHER.toString().replace("%player%", player.getName()));
Messages.FLIGHT_ENABLE.send(player);
Messages.FLIGHT_ENABLE_OTHER.send(sender, "%player%", player.getName());
toggleFlight(player, true);
}
}
Expand Down
Loading

0 comments on commit 8b5c79b

Please sign in to comment.