mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-06 07:46:08 +00:00
Cleanup
This commit is contained in:
@@ -69,7 +69,7 @@ public interface DecreeParameterHandler<T> {
|
||||
/**
|
||||
* Should parse a String into the designated type. You can force it to not throw a whichexception
|
||||
*
|
||||
* @param in The string to parse
|
||||
* @param in The string to parse
|
||||
* @param force force an option instead of throwing decreewhich
|
||||
* @return The value extracted from the string, of the designated type
|
||||
* @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
|
||||
|
||||
@@ -59,11 +59,9 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
KList<String> v = getRoot().tabComplete(enhanced, enhanced.toString(" "));
|
||||
v.removeDuplicates();
|
||||
|
||||
if(sender instanceof Player)
|
||||
{
|
||||
if(IrisSettings.get().getGeneral().isCommandSounds())
|
||||
{
|
||||
((Player)sender).playSound(((Player)sender).getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 0.25f, RNG.r.f(0.125f, 1.95f));
|
||||
if (sender instanceof Player) {
|
||||
if (IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 0.25f, RNG.r.f(0.125f, 1.95f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,26 +77,19 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
J.aBukkit(() -> {
|
||||
if (!call(new VolmitSender(sender), args)) {
|
||||
|
||||
if(IrisSettings.get().getGeneral().isCommandSounds())
|
||||
{
|
||||
if(sender instanceof Player)
|
||||
{
|
||||
((Player)sender).playSound(((Player)sender).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 0.25f);
|
||||
((Player)sender).playSound(((Player)sender).getLocation(), Sound.BLOCK_BEACON_DEACTIVATE, 0.2f, 0.45f);
|
||||
if (IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 0.25f);
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_BEACON_DEACTIVATE, 0.2f, 0.45f);
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(C.RED + "Unknown Iris Command");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if(IrisSettings.get().getGeneral().isCommandSounds())
|
||||
{
|
||||
if(sender instanceof Player)
|
||||
{
|
||||
((Player)sender).playSound(((Player)sender).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 1.65f);
|
||||
((Player)sender).playSound(((Player)sender).getLocation(), Sound.BLOCK_RESPAWN_ANCHOR_CHARGE, 0.125f, 2.99f);
|
||||
} else {
|
||||
if (IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 1.65f);
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_RESPAWN_ANCHOR_CHARGE, 0.125f, 2.99f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,21 +65,13 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Biome \"" + in + "\"");
|
||||
} else if (options.size() > 1) {
|
||||
if(force)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (force) {
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,21 +62,13 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Dimension \"" + in + "\"");
|
||||
} else if (options.size() > 1) {
|
||||
if(force)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (force) {
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,21 +82,13 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Entity \"" + in + "\"");
|
||||
} else if (options.size() > 1) {
|
||||
if(force)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (force) {
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,21 +62,13 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Generator \"" + in + "\"");
|
||||
} else if (options.size() > 1) {
|
||||
if(force)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (force) {
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,21 +46,13 @@ public class PlayerHandler implements DecreeParameterHandler<Player> {
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Player \"" + in + "\"");
|
||||
} else if (options.size() > 1) {
|
||||
if(force)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (force) {
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,21 +65,13 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Region \"" + in + "\"");
|
||||
} else if (options.size() > 1) {
|
||||
if(force)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (force) {
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,21 +62,13 @@ public class ScriptHandler implements DecreeParameterHandler<IrisScript> {
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Script \"" + in + "\"");
|
||||
} else if (options.size() > 1) {
|
||||
if(force)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (force) {
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,21 +51,13 @@ public class WorldHandler implements DecreeParameterHandler<World> {
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find World \"" + in + "\"");
|
||||
} else if (options.size() > 1) {
|
||||
if(force)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (force) {
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,21 +56,13 @@ public class ObjectHandler implements DecreeParameterHandler<String> {
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Object \"" + in + "\"");
|
||||
} else if (options.size() > 1) {
|
||||
if(force)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (force) {
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,18 +34,18 @@ import com.volmit.iris.util.plugin.CommandDummy;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.stream.utility.SemaphoreStream;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@Data
|
||||
public class VirtualDecreeCommand {
|
||||
@@ -105,17 +105,14 @@ public class VirtualDecreeCommand {
|
||||
|
||||
private ChronoLatch cl = new ChronoLatch(1000);
|
||||
|
||||
public void cacheAll()
|
||||
{
|
||||
public void cacheAll() {
|
||||
VolmitSender sender = new VolmitSender(new CommandDummy());
|
||||
|
||||
if(isNode())
|
||||
{
|
||||
if (isNode()) {
|
||||
J.a(() -> sender.sendDecreeHelpNode(this));
|
||||
}
|
||||
|
||||
for(VirtualDecreeCommand j : nodes)
|
||||
{
|
||||
for (VirtualDecreeCommand j : nodes) {
|
||||
j.cacheAll();
|
||||
}
|
||||
}
|
||||
@@ -286,8 +283,7 @@ public class VirtualDecreeCommand {
|
||||
for (int ix = 0; ix < in.size(); ix++) {
|
||||
String i = in.get(ix);
|
||||
|
||||
if(i == null)
|
||||
{
|
||||
if (i == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -337,8 +333,7 @@ public class VirtualDecreeCommand {
|
||||
Iris.debug("Found multiple results for " + key + "=" + value + " in " + getPath() + " using the handler " + param.getHandler().getClass().getSimpleName() + " with potential matches [" + validOptions.toString(",") + "]. Asking client to define one");
|
||||
String update = pickValidOption(sender, validOptions, param.getHandler(), param.getName(), param.getType().getSimpleName());
|
||||
|
||||
if(update == null)
|
||||
{
|
||||
if (update == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -360,8 +355,7 @@ public class VirtualDecreeCommand {
|
||||
KList<?> validOptions = par.getHandler().getPossibilities(i);
|
||||
String update = pickValidOption(sender, validOptions, par.getHandler(), par.getName(), par.getType().getSimpleName());
|
||||
|
||||
if(update == null)
|
||||
{
|
||||
if (update == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -403,15 +397,10 @@ public class VirtualDecreeCommand {
|
||||
sender.sendDecreeHelp(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
else if(args.size() == 1)
|
||||
{
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.startsWith("help="))
|
||||
{
|
||||
sender.sendDecreeHelp(this, Integer.parseInt(i.split("\\Q=\\E")[1])-1);
|
||||
} else if (args.size() == 1) {
|
||||
for (String i : args) {
|
||||
if (i.startsWith("help=")) {
|
||||
sender.sendDecreeHelp(this, Integer.parseInt(i.split("\\Q=\\E")[1]) - 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -452,8 +441,7 @@ public class VirtualDecreeCommand {
|
||||
KList<?> validOptions = i.getHandler().getPossibilities(i.getParam().defaultValue());
|
||||
String update = pickValidOption(sender, validOptions, i.getHandler(), i.getName(), i.getType().getSimpleName());
|
||||
|
||||
if(update == null)
|
||||
{
|
||||
if (update == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -530,17 +518,15 @@ public class VirtualDecreeCommand {
|
||||
String password = UUID.randomUUID().toString().replaceAll("\\Q-\\E", "");
|
||||
int m = 0;
|
||||
|
||||
for(String i : validOptions.convert(handler::toStringForce))
|
||||
{
|
||||
sender.sendMessage( "<hover:show_text:'" + gradients[m%gradients.length] + i+"</gradient>'><click:run_command:/irisdecree "+ password + " " + i+">"+"- " + gradients[m%gradients.length] + i + "</gradient></click></hover>");
|
||||
for (String i : validOptions.convert(handler::toStringForce)) {
|
||||
sender.sendMessage("<hover:show_text:'" + gradients[m % gradients.length] + i + "</gradient>'><click:run_command:/irisdecree " + password + " " + i + ">" + "- " + gradients[m % gradients.length] + i + "</gradient></click></hover>");
|
||||
m++;
|
||||
}
|
||||
|
||||
CompletableFuture<String> future = new CompletableFuture<>();
|
||||
Iris.service(CommandSVC.class).post(password, future);
|
||||
|
||||
if(IrisSettings.get().getGeneral().isCommandSounds() && sender.isPlayer())
|
||||
{
|
||||
if (IrisSettings.get().getGeneral().isCommandSounds() && sender.isPlayer()) {
|
||||
(sender.player()).playSound((sender.player()).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 0.65f);
|
||||
(sender.player()).playSound((sender.player()).getLocation(), Sound.BLOCK_BEACON_DEACTIVATE, 0.125f, 1.99f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user