Moved "util" package contents into correct "utils" package
This commit is contained in:
@@ -1,5 +1,16 @@
|
|||||||
package com.redstoner.modules.blockplacemods;
|
package com.redstoner.modules.blockplacemods;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import com.nemez.cmdmgr.Command;
|
import com.nemez.cmdmgr.Command;
|
||||||
import com.redstoner.annotations.AutoRegisterListener;
|
import com.redstoner.annotations.AutoRegisterListener;
|
||||||
import com.redstoner.annotations.Version;
|
import com.redstoner.annotations.Version;
|
||||||
@@ -9,17 +20,11 @@ import com.redstoner.modules.Module;
|
|||||||
import com.redstoner.modules.blockplacemods.mods.Mod;
|
import com.redstoner.modules.blockplacemods.mods.Mod;
|
||||||
import com.redstoner.modules.blockplacemods.mods.ModAbstract;
|
import com.redstoner.modules.blockplacemods.mods.ModAbstract;
|
||||||
import com.redstoner.modules.blockplacemods.mods.ModToggledAbstract;
|
import com.redstoner.modules.blockplacemods.mods.ModToggledAbstract;
|
||||||
import com.redstoner.modules.blockplacemods.util.CommandException;
|
import com.redstoner.utils.CommandException;
|
||||||
import com.redstoner.modules.blockplacemods.util.CommandMap;
|
import com.redstoner.utils.CommandMap;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@AutoRegisterListener
|
@AutoRegisterListener
|
||||||
@Version(major = 3, minor = 2, revision = 3, compatible = 3)
|
@Version(major = 3, minor = 2, revision = 4, compatible = 3)
|
||||||
public final class BlockPlaceMods implements Module, Listener
|
public final class BlockPlaceMods implements Module, Listener
|
||||||
{
|
{
|
||||||
public static String PREFIX = ChatColor.GRAY + "[" + ChatColor.DARK_GREEN + "BPM" + ChatColor.GRAY + "]"
|
public static String PREFIX = ChatColor.GRAY + "[" + ChatColor.DARK_GREEN + "BPM" + ChatColor.GRAY + "]"
|
||||||
@@ -90,7 +95,6 @@ public final class BlockPlaceMods implements Module, Listener
|
|||||||
* "}\n" +
|
* "}\n" +
|
||||||
* "}\n";
|
* "}\n";
|
||||||
* } */
|
* } */
|
||||||
|
|
||||||
@Command(hook = "mod_empty")
|
@Command(hook = "mod_empty")
|
||||||
public void onModEmptyCommand(CommandSender sender)
|
public void onModEmptyCommand(CommandSender sender)
|
||||||
{
|
{
|
||||||
@@ -104,34 +108,46 @@ public final class BlockPlaceMods implements Module, Listener
|
|||||||
.filter(x -> x != null && !x.trim().isEmpty()).toArray(String[]::new);
|
.filter(x -> x != null && !x.trim().isEmpty()).toArray(String[]::new);
|
||||||
String prefix = PREFIX;
|
String prefix = PREFIX;
|
||||||
String message;
|
String message;
|
||||||
|
try
|
||||||
try {
|
{
|
||||||
|
if (args.length > 0)
|
||||||
if (args.length > 0) {
|
{
|
||||||
Mod target = ModAbstract.getMod(args[0].toLowerCase());
|
Mod target = ModAbstract.getMod(args[0].toLowerCase());
|
||||||
if (target != null) {
|
if (target != null)
|
||||||
|
{
|
||||||
prefix += "&7[&2" + capitalize(target.getName()) + "&7]&a";
|
prefix += "&7[&2" + capitalize(target.getName()) + "&7]&a";
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player))
|
||||||
|
{
|
||||||
message = "&cYou must be a player to use any block place mod";
|
message = "&cYou must be a player to use any block place mod";
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
message = target.runCommand((Player) sender, Arrays.copyOfRange(args, 1, args.length));
|
message = target.runCommand((Player) sender, Arrays.copyOfRange(args, 1, args.length));
|
||||||
}
|
}
|
||||||
} else if (args[0].equalsIgnoreCase("help")) {
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("help"))
|
||||||
|
{
|
||||||
message = commandHelp(sender, args);
|
message = commandHelp(sender, args);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
message = "&cThat argument could not be recognized";
|
message = "&cThat argument could not be recognized";
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
message = commandHelp(sender, args);
|
message = commandHelp(sender, args);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (CommandException ex) {
|
catch (CommandException ex)
|
||||||
|
{
|
||||||
message = " &c" + ex.getMessage();
|
message = " &c" + ex.getMessage();
|
||||||
} catch (Throwable t) {
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
message = " &cAn unexpected error occurred while executing this command.";
|
message = " &cAn unexpected error occurred while executing this command.";
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.sendMessage(sender, prefix, message, '&');
|
Utils.sendMessage(sender, prefix, message, '&');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,36 +155,35 @@ public final class BlockPlaceMods implements Module, Listener
|
|||||||
{
|
{
|
||||||
StringBuilder result = new StringBuilder("§7BlockPlaceMods adds some redstone-centric utilities");
|
StringBuilder result = new StringBuilder("§7BlockPlaceMods adds some redstone-centric utilities");
|
||||||
result.append("\n").append(ChatColor.GRAY.toString()).append("Available mods:");
|
result.append("\n").append(ChatColor.GRAY.toString()).append("Available mods:");
|
||||||
|
|
||||||
List<Mod> mods = new ArrayList<>(ModAbstract.getMods().values());
|
List<Mod> mods = new ArrayList<>(ModAbstract.getMods().values());
|
||||||
mods.sort(Comparator.<Mod>comparingInt(m -> ModToggledAbstract.class.isInstance(m) ? 1 : -1).thenComparing(Mod::getName));
|
mods.sort(Comparator.<Mod> comparingInt(m -> ModToggledAbstract.class.isInstance(m) ? 1 : -1)
|
||||||
|
.thenComparing(Mod::getName));
|
||||||
for (Mod mod : mods)
|
for (Mod mod : mods)
|
||||||
{
|
{
|
||||||
result.append("\n").append(ChatColor.AQUA.toString()).append("/mod ").append(ChatColor.ITALIC.toString())
|
result.append("\n").append(ChatColor.AQUA.toString()).append("/mod ").append(ChatColor.ITALIC.toString())
|
||||||
.append(mod.getName());
|
.append(mod.getName());
|
||||||
|
for (String alias : mod.getAliases())
|
||||||
for (String alias : mod.getAliases()) {
|
{
|
||||||
result.append('|').append(alias);
|
result.append('|').append(alias);
|
||||||
}
|
}
|
||||||
|
result.append(ChatColor.GRAY.toString()).append(" - ").append(mod.getDescription());
|
||||||
result.append(ChatColor.GRAY.toString()).append(" - ")
|
|
||||||
.append(mod.getDescription());
|
|
||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String capitalize(String modName) {
|
private static String capitalize(String modName)
|
||||||
if (modName.isEmpty()) {
|
{
|
||||||
|
if (modName.isEmpty())
|
||||||
|
{
|
||||||
return modName;
|
return modName;
|
||||||
}
|
}
|
||||||
char first = modName.charAt(0);
|
char first = modName.charAt(0);
|
||||||
if (first != (first = Character.toUpperCase(first))) {
|
if (first != (first = Character.toUpperCase(first)))
|
||||||
|
{
|
||||||
char[] result = modName.toCharArray();
|
char[] result = modName.toCharArray();
|
||||||
result[0] = first;
|
result[0] = first;
|
||||||
return String.valueOf(result);
|
return String.valueOf(result);
|
||||||
}
|
}
|
||||||
return modName;
|
return modName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package com.redstoner.modules.blockplacemods.mods;
|
package com.redstoner.modules.blockplacemods.mods;
|
||||||
|
|
||||||
import com.redstoner.modules.blockplacemods.util.CommandException;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.redstoner.utils.CommandException;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface Mod
|
public interface Mod
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package com.redstoner.modules.blockplacemods.mods;
|
package com.redstoner.modules.blockplacemods.mods;
|
||||||
|
|
||||||
import com.redstoner.modules.blockplacemods.util.CommandException;
|
|
||||||
import com.redstoner.modules.blockplacemods.util.ItemProperties;
|
|
||||||
import com.redstoner.modules.datamanager.DataManager;
|
import com.redstoner.modules.datamanager.DataManager;
|
||||||
|
import com.redstoner.utils.CommandException;
|
||||||
|
import com.redstoner.utils.ItemProperties;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.redstoner.modules.blockplacemods.mods;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.redstoner.modules.blockplacemods.util.CommandException;
|
|
||||||
import com.redstoner.modules.datamanager.DataManager;
|
import com.redstoner.modules.datamanager.DataManager;
|
||||||
|
import com.redstoner.utils.CommandException;
|
||||||
|
|
||||||
public abstract class ModToggledAbstract extends ModAbstract
|
public abstract class ModToggledAbstract extends ModAbstract
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.redstoner.modules.blockplacemods.util;
|
package com.redstoner.utils;
|
||||||
|
|
||||||
public class CommandException extends Exception {
|
public class CommandException extends Exception {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.redstoner.modules.blockplacemods.util;
|
package com.redstoner.utils;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.redstoner.modules.blockplacemods.util;
|
package com.redstoner.utils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.redstoner.modules.blockplacemods.util;
|
package com.redstoner.utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A supplier with a throws declaration.
|
* A supplier with a throws declaration.
|
||||||
Reference in New Issue
Block a user