mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 19:19:07 +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);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.volmit.iris.util.io;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.function.Consumer3;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -48,8 +47,7 @@ public class ReactiveFolder {
|
||||
if (checkCycle % 3 == 0 ? fw.checkModified() : fw.checkModifiedFast()) {
|
||||
for (File i : fw.getCreated()) {
|
||||
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) {
|
||||
if(i.getPath().contains(".iris"))
|
||||
{
|
||||
if (i.getPath().contains(".iris")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -60,8 +58,7 @@ public class ReactiveFolder {
|
||||
|
||||
if (!modified) {
|
||||
for (File i : fw.getChanged()) {
|
||||
if(i.getPath().contains(".iris"))
|
||||
{
|
||||
if (i.getPath().contains(".iris")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -74,8 +71,7 @@ public class ReactiveFolder {
|
||||
|
||||
if (!modified) {
|
||||
for (File i : fw.getDeleted()) {
|
||||
if(i.getPath().contains(".iris"))
|
||||
{
|
||||
if (i.getPath().contains(".iris")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package com.volmit.iris.util.matter;
|
||||
|
||||
import com.volmit.iris.util.matter.slices.MarkerMatter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@@ -23,31 +23,26 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Chunks {
|
||||
public static boolean isSafe(World w, int x, int z)
|
||||
{
|
||||
public static boolean isSafe(World w, int x, int z) {
|
||||
return w.isChunkLoaded(x, z)
|
||||
&& w.isChunkLoaded(x+1, z)
|
||||
&& w.isChunkLoaded(x, z+1)
|
||||
&& w.isChunkLoaded(x-1, z)
|
||||
&& w.isChunkLoaded(x, z-1)
|
||||
&& w.isChunkLoaded(x-1, z-1)
|
||||
&& w.isChunkLoaded(x+1, z+1)
|
||||
&& w.isChunkLoaded(x+1, z-1)
|
||||
&& w.isChunkLoaded(x-1, z+1);
|
||||
&& w.isChunkLoaded(x + 1, z)
|
||||
&& w.isChunkLoaded(x, z + 1)
|
||||
&& w.isChunkLoaded(x - 1, z)
|
||||
&& w.isChunkLoaded(x, z - 1)
|
||||
&& w.isChunkLoaded(x - 1, z - 1)
|
||||
&& w.isChunkLoaded(x + 1, z + 1)
|
||||
&& w.isChunkLoaded(x + 1, z - 1)
|
||||
&& w.isChunkLoaded(x - 1, z + 1);
|
||||
}
|
||||
|
||||
public static boolean isSafe(Location l)
|
||||
{
|
||||
public static boolean isSafe(Location l) {
|
||||
return isSafe(l.getWorld(), l.getBlockX() >> 4, l.getBlockZ() >> 4);
|
||||
}
|
||||
|
||||
public static boolean hasPlayersNearby(Location at) {
|
||||
try{
|
||||
try {
|
||||
return !at.getWorld().getNearbyEntities(at, 32, 32, 32, (i) -> i instanceof Player).isEmpty();
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
} catch (Throwable ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.ChatPaginator;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Set;
|
||||
@@ -251,8 +250,7 @@ public class VolmitSender implements CommandSender {
|
||||
}
|
||||
|
||||
private Component createNoPrefixComponent(String message) {
|
||||
if(!IrisSettings.get().getGeneral().canUseCustomColors(this))
|
||||
{
|
||||
if (!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
|
||||
String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(message));
|
||||
return MiniMessage.get().parse(t);
|
||||
}
|
||||
@@ -267,8 +265,7 @@ public class VolmitSender implements CommandSender {
|
||||
}
|
||||
|
||||
private Component createComponent(String message) {
|
||||
if(!IrisSettings.get().getGeneral().canUseCustomColors(this))
|
||||
{
|
||||
if (!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
|
||||
String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(getTag() + message));
|
||||
return MiniMessage.get().parse(t);
|
||||
}
|
||||
@@ -279,8 +276,7 @@ public class VolmitSender implements CommandSender {
|
||||
}
|
||||
|
||||
private Component createComponentRaw(String message) {
|
||||
if(!IrisSettings.get().getGeneral().canUseCustomColors(this))
|
||||
{
|
||||
if (!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
|
||||
String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(getTag() + message));
|
||||
return MiniMessage.get().parse(t);
|
||||
}
|
||||
@@ -315,8 +311,7 @@ public class VolmitSender implements CommandSender {
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if(s instanceof CommandDummy)
|
||||
{
|
||||
if (s instanceof CommandDummy) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -341,8 +336,7 @@ public class VolmitSender implements CommandSender {
|
||||
}
|
||||
|
||||
public void sendMessageRaw(String message) {
|
||||
if(s instanceof CommandDummy)
|
||||
{
|
||||
if (s instanceof CommandDummy) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -445,15 +439,13 @@ public class VolmitSender implements CommandSender {
|
||||
}
|
||||
|
||||
|
||||
public static <T> KList<T> paginate(KList<T> all, int linesPerPage, int page, AtomicBoolean hasNext)
|
||||
{
|
||||
int totalPages = (int) Math.ceil((double)all.size() / linesPerPage);
|
||||
public static <T> KList<T> paginate(KList<T> all, int linesPerPage, int page, AtomicBoolean hasNext) {
|
||||
int totalPages = (int) Math.ceil((double) all.size() / linesPerPage);
|
||||
page = page < 0 ? 0 : page >= totalPages ? totalPages - 1 : page;
|
||||
hasNext.set(page < totalPages-1);
|
||||
hasNext.set(page < totalPages - 1);
|
||||
KList<T> d = new KList<>();
|
||||
|
||||
for(int i = linesPerPage * page; i < Math.min(all.size(), linesPerPage * (page + 1)); i++)
|
||||
{
|
||||
for (int i = linesPerPage * page; i < Math.min(all.size(), linesPerPage * (page + 1)); i++) {
|
||||
d.add(all.get(i));
|
||||
}
|
||||
|
||||
@@ -461,8 +453,7 @@ public class VolmitSender implements CommandSender {
|
||||
}
|
||||
|
||||
public void sendDecreeHelp(VirtualDecreeCommand v, int page) {
|
||||
if(!isPlayer())
|
||||
{
|
||||
if (!isPlayer()) {
|
||||
for (VirtualDecreeCommand i : v.getNodes()) {
|
||||
sendDecreeHelpNode(i);
|
||||
}
|
||||
@@ -475,7 +466,7 @@ public class VolmitSender implements CommandSender {
|
||||
sendMessageRaw("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||
|
||||
if (v.getNodes().isNotEmpty()) {
|
||||
sendHeader(v.getPath() + (page > 0 ? (" {" + (page+1) + "}") : ""));
|
||||
sendHeader(v.getPath() + (page > 0 ? (" {" + (page + 1) + "}") : ""));
|
||||
if (isPlayer() && v.getParent() != null) {
|
||||
sendMessageRaw("<hover:show_text:'" + "<#b54b38>Click to go back to <#3299bf>" + Form.capitalize(v.getParent().getName()) + " Help" + "'><click:run_command:" + v.getParent().getPath() + "><font:minecraft:uniform><#f58571>〈 Back</click></hover>");
|
||||
}
|
||||
@@ -488,16 +479,14 @@ public class VolmitSender implements CommandSender {
|
||||
String s = "";
|
||||
int l = 75 - (page > 0 ? 10 : 0) - (next.get() ? 10 : 0);
|
||||
|
||||
if(page > 0)
|
||||
{
|
||||
if (page > 0) {
|
||||
s += "<hover:show_text:'<green>Click to go back to page " + page + "'><click:run_command:" + v.getPath() + " help=" + page + "><gradient:#27b84d:#2770b8>〈 Page " + page + "</click></hover><reset> ";
|
||||
}
|
||||
|
||||
s += "<reset><font:minecraft:uniform><strikethrough><gradient:#32bfad:#34eb6b>" + Form.repeat(" ", l) + "<reset>";
|
||||
|
||||
if(next.get())
|
||||
{
|
||||
s += " <hover:show_text:'<green>Click to go to back to page " + (page+2) + "'><click:run_command:" + v.getPath() + " help=" + (page+2) + "><gradient:#2770b8:#27b84d>Page " + (page+2) + " ❭</click></hover>";
|
||||
if (next.get()) {
|
||||
s += " <hover:show_text:'<green>Click to go to back to page " + (page + 2) + "'><click:run_command:" + v.getPath() + " help=" + (page + 2) + "><gradient:#2770b8:#27b84d>Page " + (page + 2) + " ❭</click></hover>";
|
||||
}
|
||||
|
||||
sendMessageRaw(s);
|
||||
@@ -512,8 +501,7 @@ public class VolmitSender implements CommandSender {
|
||||
public void sendDecreeHelpNode(VirtualDecreeCommand i) {
|
||||
if (isPlayer() || s instanceof CommandDummy) {
|
||||
sendMessageRaw(helpCache.compute(i.getPath(), (k, v) -> {
|
||||
if(v != null)
|
||||
{
|
||||
if (v != null) {
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user