9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 11:39:07 +00:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
cyberpwn
2021-09-04 14:05:52 -04:00
79 changed files with 623 additions and 740 deletions

View File

@@ -48,7 +48,7 @@ public class BoardManager {
this.plugin = plugin;
this.boardSettings = boardSettings;
this.scoreboards = new ConcurrentHashMap<>();
this.updateTask = new BoardUpdateTask(this).runTaskTimer(plugin, 2L, 2L);
this.updateTask = new BoardUpdateTask(this).runTaskTimer(plugin, 2L, 20L);
plugin.getServer().getOnlinePlayers().forEach(this::setup);
}

View File

@@ -22,9 +22,8 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.scheduling.ChronoLatch;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.ints.IntSets;
import it.unimi.dsi.fastutil.ints.*;
import net.minecraft.world.level.levelgen.OreVeinifier;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
@@ -43,6 +42,9 @@ public class B {
private static final Material AIR_MATERIAL = Material.AIR;
private static final BlockData AIR = AIR_MATERIAL.createBlockData();
private static final IntSet foliageCache = buildFoliageCache();
private static final IntSet deepslateCache = buildDeepslateCache();
private static final Int2IntMap normal2DeepslateCache = buildNormal2DeepslateCache();
private static final Int2IntMap deepslate2NormalCache = buildNormal2DeepslateCache();
private static final IntSet decorantCache = buildDecorantCache();
private static final IntSet storageCache = buildStorageCache();
private static final IntSet storageChestCache = buildStorageChestCache();
@@ -84,6 +86,54 @@ public class B {
return IntSets.unmodifiable(b);
}
private static IntSet buildDeepslateCache() {
IntSet b = new IntOpenHashSet();
Arrays.stream(new Material[]{
DEEPSLATE,
DEEPSLATE_BRICKS,
DEEPSLATE_BRICK_SLAB,
DEEPSLATE_BRICK_STAIRS,
DEEPSLATE_BRICK_WALL,
DEEPSLATE_TILE_SLAB,
DEEPSLATE_TILES,
DEEPSLATE_TILE_STAIRS,
DEEPSLATE_TILE_WALL,
CRACKED_DEEPSLATE_TILES
}).forEach((i) -> b.add(i.ordinal()));
return IntSets.unmodifiable(b);
}
private static Int2IntMap buildNormal2DeepslateCache() {
Int2IntMap b = new Int2IntOpenHashMap();
b.put(COAL_ORE.ordinal(), DEEPSLATE_COAL_ORE.ordinal());
b.put(EMERALD_ORE.ordinal(), DEEPSLATE_EMERALD_ORE.ordinal());
b.put(DIAMOND_ORE.ordinal(), DEEPSLATE_DIAMOND_ORE.ordinal());
b.put(COPPER_ORE.ordinal(), DEEPSLATE_COPPER_ORE.ordinal());
b.put(GOLD_ORE.ordinal(), DEEPSLATE_GOLD_ORE.ordinal());
b.put(IRON_ORE.ordinal(), DEEPSLATE_IRON_ORE.ordinal());
b.put(LAPIS_ORE.ordinal(), DEEPSLATE_LAPIS_ORE.ordinal());
b.put(REDSTONE_ORE.ordinal(), DEEPSLATE_REDSTONE_ORE.ordinal());
return b;
}
private static Int2IntMap buildDeepslate2NormalCache() {
Int2IntMap b = new Int2IntOpenHashMap();
b.put(DEEPSLATE_COAL_ORE.ordinal(), COAL_ORE.ordinal());
b.put(DEEPSLATE_EMERALD_ORE.ordinal(), EMERALD_ORE.ordinal());
b.put(DEEPSLATE_DIAMOND_ORE.ordinal(), DIAMOND_ORE.ordinal());
b.put(DEEPSLATE_COPPER_ORE.ordinal(), COPPER_ORE.ordinal());
b.put(DEEPSLATE_GOLD_ORE.ordinal(), GOLD_ORE.ordinal());
b.put(DEEPSLATE_IRON_ORE.ordinal(), IRON_ORE.ordinal());
b.put(DEEPSLATE_LAPIS_ORE.ordinal(), LAPIS_ORE.ordinal());
b.put(DEEPSLATE_REDSTONE_ORE.ordinal(), REDSTONE_ORE.ordinal());
return b;
}
private static IntSet buildDecorantCache() {
IntSet b = new IntOpenHashSet();
Arrays.stream(new Material[]{
@@ -216,6 +266,32 @@ public class B {
return IntSets.unmodifiable(b);
}
public static BlockData toDeepSlateOre(BlockData block, BlockData ore) {
int key = ore.getMaterial().ordinal();
if(isDeepSlate(block))
{
if(normal2DeepslateCache.containsKey(key))
{
return Material.values()[normal2DeepslateCache.get(key)].createBlockData();
}
}
else
{
if(deepslate2NormalCache.containsKey(key))
{
return Material.values()[deepslate2NormalCache.get(key)].createBlockData();
}
}
return ore;
}
public static boolean isDeepSlate(BlockData blockData) {
return deepslateCache.contains(blockData.getMaterial().ordinal());
}
public static boolean isOre(BlockData blockData) {
return blockData.getMaterial().name().endsWith("_ORE");
}

View File

@@ -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)

View File

@@ -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);
}
}
}

View File

@@ -32,7 +32,7 @@ public class BiomeContextHandler implements DecreeContextHandler<IrisBiome> {
if (sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getBiome(sender.player().getLocation());
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getBiomeOrMantle(sender.player().getLocation());
}
return null;

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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())
{
J.a(() -> sender.sendDecreeHelpNode(this));
if (isNode()) {
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);
}

View File

@@ -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;
}

View File

@@ -502,4 +502,8 @@ public class Mantle {
public void deleteChunkSlice(int x, int z, Class<?> c) {
getChunk(x, z).deleteSlices(c);
}
public int getLoadedRegionCount() {
return loadedRegions.size();
}
}

View File

@@ -26,5 +26,20 @@ import lombok.Data;
public class MatterCavern {
private final boolean cavern;
private final String customBiome;
private final boolean water;
private final byte liquid; // 0 none 1 water 2 lava
public boolean isAir()
{
return liquid == 0;
}
public boolean isWater()
{
return liquid == 1;
}
public boolean isLava()
{
return liquid == 2;
}
}

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.matter;
import com.volmit.iris.util.matter.slices.MarkerMatter;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@@ -27,8 +27,8 @@ import java.io.IOException;
@Sliced
public class CavernMatter extends RawMatter<MatterCavern> {
public static MatterCavern get(String customBiome, boolean underwater) {
return new MatterCavern(true, customBiome, underwater);
public static MatterCavern get(String customBiome, int liquid) {
return new MatterCavern(true, customBiome, (byte) liquid);
}
public CavernMatter() {
@@ -42,16 +42,16 @@ public class CavernMatter extends RawMatter<MatterCavern> {
@Override
public void writeNode(MatterCavern b, DataOutputStream dos) throws IOException {
dos.writeBoolean(b.isCavern());
dos.writeBoolean(b.isWater());
dos.writeUTF(b.getCustomBiome());
dos.writeByte(b.getLiquid());
}
@Override
public MatterCavern readNode(DataInputStream din) throws IOException {
boolean b = din.readBoolean();
boolean w = din.readBoolean();
String v = din.readUTF();
byte l = din.readByte();
return new MatterCavern(b, v, w);
return new MatterCavern(b, v, l);
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}