Merge remote-tracking branch 'upstream/master' into DecreeCommands

This commit is contained in:
CocoTheOwner 2021-08-17 16:16:49 +02:00
commit 104f1232f3
125 changed files with 1843 additions and 1955 deletions

View File

@ -32,7 +32,7 @@ plugins {
}
group 'com.volmit.iris'
version '1.7.1'
version '1.7.2'
def apiVersion = '1.17'
def name = getRootProject().getName() // See settings.gradle
def main = 'com.volmit.iris.Iris'

View File

@ -0,0 +1,23 @@
name: ${name}
version: ${version}
main: ${main}
load: STARTUP
authors: [ cyberpwn, NextdoorPsycho ]
website: volmit.com
description: More than a Dimension!
libraries:
- org.zeroturnaround:zt-zip:1.14
- com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2
- org.ow2.asm:asm:9.2
- com.google.code.gson:gson:2.8.7
- it.unimi.dsi:fastutil:8.5.4
- com.google.guava:guava:30.1.1-jre
- bsf:bsf:2.4.0
- rhino:js:1.7R2
commands:
iris:
aliases: [ ir, irs ]
irisd:
aliases: [ ird, irsd ]
api-version: ${apiversion}
hotload-dependencies: false

View File

@ -18,18 +18,17 @@
package com.volmit.iris;
import com.volmit.iris.core.*;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.command.CommandIris;
import com.volmit.iris.core.command.PermissionIris;
import com.volmit.iris.core.command.studio.CommandIrisStudio;
import com.volmit.iris.core.command.world.CommandLocate;
import com.volmit.iris.core.link.IrisPapiExpansion;
import com.volmit.iris.core.link.MultiverseCoreLink;
import com.volmit.iris.core.link.MythicMobsLink;
import com.volmit.iris.core.link.OraxenLink;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.biome.IrisBiomeCustom;
import com.volmit.iris.engine.object.common.IrisWorld;
@ -37,6 +36,7 @@ import com.volmit.iris.engine.object.compat.IrisCompat;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
@ -48,20 +48,13 @@ import com.volmit.iris.util.io.JarScanner;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.plugin.Metrics;
import com.volmit.iris.util.plugin.Permission;
import com.volmit.iris.util.plugin.VolmitPlugin;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.plugin.*;
import com.volmit.iris.util.reflect.ShadeFix;
import com.volmit.iris.util.scheduling.GroupedExecutor;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Queue;
import com.volmit.iris.util.scheduling.ShurikenQueue;
import com.volmit.iris.util.scheduling.*;
import io.papermc.lib.PaperLib;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.serializer.ComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -75,22 +68,17 @@ import java.io.*;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.util.Date;
import java.util.Map;
@SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener {
private KMap<Class<? extends IrisService>, IrisService> services;
public static KList<GroupedExecutor> executors = new KList<>();
public static Iris instance;
public static BukkitAudiences audiences;
public static ProjectManager proj;
public static ConversionManager convert;
public static WandManager wand;
public static EditManager edit;
public static CoreBoardManager board;
public static MultiverseCoreLink linkMultiverseCore;
public static OraxenLink linkOraxen;
public static MythicMobsLink linkMythicMobs;
public static CommandManager commandManager;
public static TreeManager saplingManager;
private static final Queue<Runnable> syncJobs = new ShurikenQueue<>();
public static IrisCompat compat;
public static FileWatcher configWatcher;
@ -105,68 +93,76 @@ public class Iris extends VolmitPlugin implements Listener {
@com.volmit.iris.util.plugin.Command
public CommandIrisStudio commandStudio;
public Iris() {
private void preEnable() {
instance = this;
INMS.get();
IO.delete(new File("iris"));
installDataPacks();
fixShading();
}
public void onEnable() {
@SuppressWarnings("unchecked")
private void enable() {
services = new KMap<>();
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
audiences = BukkitAudiences.create(this);
fixShading();
sender = new VolmitSender(Bukkit.getConsoleSender());
sender.setTag(getTag());
instance = this;
compat = IrisCompat.configured(getDataFile("compat.json"));
proj = new ProjectManager();
convert = new ConversionManager();
wand = new WandManager();
board = new CoreBoardManager();
linkMultiverseCore = new MultiverseCoreLink();
linkOraxen = new OraxenLink();
linkMythicMobs = new MythicMobsLink();
saplingManager = new TreeManager();
edit = new EditManager();
configWatcher = new FileWatcher(getDataFile("settings.json"));
commandManager = new CommandManager();
getServer().getPluginManager().registerEvents(new CommandLocate(), this);
getServer().getPluginManager().registerEvents(new WandManager(), this);
getServer().getPluginManager().registerEvents(new DolphinManager(), this);
getServer().getPluginManager().registerEvents(new VillagerManager(), this);
super.onEnable();
Bukkit.getPluginManager().registerEvents(this, this);
J.s(this::lateBind);
services.values().forEach(IrisService::onEnable);
services.values().forEach(this::registerListener);
}
private void postEnable() {
J.a(() -> PaperLib.suggestPaper(this));
J.a(() -> IO.delete(getTemp()));
J.a(this::bstats);
J.ar(this::checkConfigHotload, 60);
J.sr(this::tickQueue, 0);
J.s(this::setupPapi);
J.a(this::verifyDataPacksPost, 20);
splash();
}
@SuppressWarnings("unchecked")
public static <T> T service(Class<T> c) {
return (T) instance.services.get(c);
}
public Iris() {
preEnable();
}
@SuppressWarnings("unchecked")
public void onEnable() {
enable();
super.onEnable();
Bukkit.getPluginManager().registerEvents(this, this);
J.s(this::postEnable);
}
public void onDisable() {
if (IrisSettings.get().isStudio()) {
Iris.debug("Studio Mode Active: Closing Projects");
proj.close();
for (World i : Bukkit.getWorlds()) {
if (IrisToolbelt.isIrisWorld(i)) {
Iris.debug("Closing Platform Generator " + i.getName());
IrisToolbelt.access(i).close();
}
}
for (GroupedExecutor i : executors) {
Iris.debug("Closing Executor " + i.toString());
i.closeNow();
}
}
executors.clear();
board.disable();
Iris.debug("Cancelled all tasks");
Bukkit.getScheduler().cancelTasks(this);
Iris.debug("Unregistered all events");
HandlerList.unregisterAll((Plugin) this);
Iris.debug("Multiburst Shutting down");
MultiBurst.burst.shutdown();
Iris.debug("Iris Shutdown");
services.values().forEach(IrisService::onDisable);
services.clear();
super.onDisable();
}
@ -203,15 +199,6 @@ public class Iris extends VolmitPlugin implements Listener {
ShadeFix.fix(ComponentSerializer.class);
}
private void lateBind() {
J.a(() -> PaperLib.suggestPaper(this));
J.a(() -> IO.delete(getTemp()));
J.a(this::bstats);
J.ar(this::checkConfigHotload, 60);
J.sr(this::tickQueue, 0);
J.s(this::setupPapi);
}
private void setupPapi() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new IrisPapiExpansion().register();
@ -330,13 +317,7 @@ public class Iris extends VolmitPlugin implements Listener {
private void bstats() {
if (IrisSettings.get().getGeneral().isPluginMetrics()) {
J.s(() -> {
Metrics m = new Metrics(Iris.instance, 8757);
m.addCustomChart(new Metrics.SingleLineChart("custom_dimensions", ProjectManager::countUniqueDimensions));
m.addCustomChart(new Metrics.SimplePie("using_custom_dimensions", () -> ProjectManager.countUniqueDimensions() > 0 ? "Active Projects" : "No Projects"));
});
J.s(() -> new Metrics(Iris.instance, 8757));
}
}
@ -449,7 +430,7 @@ public class Iris extends VolmitPlugin implements Listener {
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
IrisDimension dim;
if (id == null || id.isEmpty()){
if (id == null || id.isEmpty()) {
dim = IrisData.loadAnyDimension(IrisSettings.get().getGenerator().getDefaultWorldType());
} else {
dim = IrisData.loadAnyDimension(id);
@ -459,7 +440,7 @@ public class Iris extends VolmitPlugin implements Listener {
if (dim == null) {
Iris.warn("Unable to find dimension type " + id + " Looking for online packs...");
Iris.proj.downloadSearch(new VolmitSender(Bukkit.getConsoleSender()), id, true);
service(StudioSVC.class).downloadSearch(new VolmitSender(Bukkit.getConsoleSender()), id, true);
dim = IrisData.loadAnyDimension(id);
if (dim == null) {
@ -611,12 +592,7 @@ public class Iris extends VolmitPlugin implements Listener {
msg(C.WHITE + string);
}
public void hit(long hits2) {
board.hits.put(hits2);
}
public void splash() {
J.a(this::verifyDataPacksPost, 20);
if (!IrisSettings.get().getGeneral().isSplashLogoStartup()) {
return;
}
@ -729,4 +705,37 @@ public class Iris extends VolmitPlugin implements Listener {
}
}
public static void dump()
{
try
{
File fi = Iris.instance.getDataFile("dump", "td-" + new java.sql.Date(M.ms()) + ".txt");
FileOutputStream fos = new FileOutputStream(fi );
Map<Thread, StackTraceElement[]> f = Thread.getAllStackTraces();
PrintWriter pw = new PrintWriter(fos);
for(Thread i : f.keySet())
{
pw.println("========================================");
pw.println("Thread: '" + i.getName() + "' ID: " + i.getId() + " STATUS: " + i.getState().name());
for(StackTraceElement j : f.get(i))
{
pw.println(" @ " + j.toString());
}
pw.println("========================================");
pw.println();
pw.println();
}
pw.close();
System.out.println("DUMPED! See " + fi.getAbsolutePath());
}
catch(Throwable e)
{
e.printStackTrace();
}
}
}

View File

@ -1,27 +0,0 @@
package com.volmit.iris.core;
import com.volmit.iris.core.tools.IrisToolbelt;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEntityEvent;
public class DolphinManager implements Listener {
/**
* Prevents dolphins from being fed, to locate a treasure map.
* Note: This results in odd dolphin behaviour, but it's the best we can do.
*/
@EventHandler
public void on(PlayerInteractEntityEvent event) {
if (!IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) {
return;
}
Material hand = event.getPlayer().getInventory().getItem(event.getHand()).getType();
if (event.getRightClicked().getType().equals(EntityType.DOLPHIN) && (hand.equals(Material.TROPICAL_FISH) || hand.equals(Material.PUFFERFISH) || hand.equals(Material.COD) || hand.equals(Material.SALMON))) {
event.setCancelled(true);
}
}
}

View File

@ -19,6 +19,7 @@
package com.volmit.iris.core.command;
import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.MortarCommand;
@ -75,7 +76,7 @@ public class CommandIrisDownload extends MortarCommand {
final String finalPack = pack + "/" + branch;
J.a(() -> Iris.proj.downloadSearch(sender, finalPack, btrim));
J.a(() -> Iris.service(StudioSVC.class).downloadSearch(sender, finalPack, btrim));
return true;
}

View File

@ -19,6 +19,7 @@
package com.volmit.iris.core.command;
import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.MortarCommand;
@ -45,7 +46,7 @@ public class CommandIrisUpdateProject extends MortarCommand {
return true;
}
J.a(() -> Iris.proj.downloadSearch(sender, args[0], false, true));
J.a(() -> Iris.service(StudioSVC.class).downloadSearch(sender, args[0], false, true));
return true;
}

View File

@ -1,9 +1,27 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ProjectManager;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.objects.IrisObject;
import com.volmit.iris.util.collection.KList;
@ -71,7 +89,7 @@ public class CommandIrisObjectAnalyze extends MortarCommand {
IrisObject obj = IrisData.loadAnyObject(args[0]);
if (obj == null || obj.getLoadFile() == null) {
sender.sendMessage("Can't find " + args[0] + " in the " + ProjectManager.WORKSPACE_NAME + " folder");
sender.sendMessage("Can't find " + args[0] + " in the " + StudioSVC.WORKSPACE_NAME + " folder");
return;
}

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.math.Direction;
@ -58,13 +58,13 @@ public class CommandIrisObjectContract extends MortarCommand {
Player p = sender.player();
if (!WandManager.isHoldingWand(p)) {
if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand.");
return true;
}
int amt = args.length == 1 ? Integer.parseInt(args[0]) : 1;
Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(p.getInventory().getItemInMainHand());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Cuboid cursor = new Cuboid(a1, a2);
@ -72,7 +72,7 @@ public class CommandIrisObjectContract extends MortarCommand {
cursor = cursor.expand(d, -amt);
b[0] = cursor.getLowerNE();
b[1] = cursor.getUpperSW();
p.getInventory().setItemInMainHand(WandManager.createWand(b[0], b[1]));
p.getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1]));
p.updateInventory();
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
@ -51,7 +51,7 @@ public class CommandIrisObjectDust extends MortarCommand {
return true;
}
sender.player().getInventory().addItem(WandManager.createDust());
sender.player().getInventory().addItem(WandSVC.createDust());
sender.player().playSound(sender.player().getLocation(), Sound.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS, 1f, 1.5f);
return true;

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.math.Direction;
@ -58,13 +58,13 @@ public class CommandIrisObjectExpand extends MortarCommand {
Player p = sender.player();
if (!WandManager.isHoldingWand(p)) {
if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand.");
return true;
}
int amt = args.length == 1 ? Integer.parseInt(args[0]) : 1;
Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(p.getInventory().getItemInMainHand());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Cuboid cursor = new Cuboid(a1, a2);
@ -72,7 +72,7 @@ public class CommandIrisObjectExpand extends MortarCommand {
cursor = cursor.expand(d, amt);
b[0] = cursor.getLowerNE();
b[1] = cursor.getUpperSW();
p.getInventory().setItemInMainHand(WandManager.createWand(b[0], b[1]));
p.getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1]));
p.updateInventory();
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
@ -57,15 +57,15 @@ public class CommandIrisObjectP1 extends MortarCommand {
Player p = sender.player();
if (!WandManager.isHoldingWand(p)) {
if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand.");
return true;
}
ItemStack wand = p.getInventory().getItemInMainHand();
if (WandManager.isWand(wand)) {
Location[] g = WandManager.getCuboid(wand);
if (WandSVC.isWand(wand)) {
Location[] g = WandSVC.getCuboid(wand);
g[0] = p.getLocation().getBlock().getLocation().clone().add(0, -1, 0);
if (args.length == 1 && args[0].equals("-l")) {
@ -73,7 +73,7 @@ public class CommandIrisObjectP1 extends MortarCommand {
g[0] = p.getTargetBlock(null, 256).getLocation().clone();
}
p.setItemInHand(WandManager.createWand(g[0], g[1]));
p.setItemInHand(WandSVC.createWand(g[0], g[1]));
}
return true;

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
@ -57,15 +57,15 @@ public class CommandIrisObjectP2 extends MortarCommand {
Player p = sender.player();
if (!WandManager.isHoldingWand(p)) {
if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand.");
return true;
}
ItemStack wand = p.getInventory().getItemInMainHand();
if (WandManager.isWand(wand)) {
Location[] g = WandManager.getCuboid(wand);
if (WandSVC.isWand(wand)) {
Location[] g = WandSVC.getCuboid(wand);
g[1] = p.getLocation().getBlock().getLocation().clone().add(0, -1, 0);
if (args.length == 1 && args[0].equals("-l")) {
@ -73,7 +73,7 @@ public class CommandIrisObjectP2 extends MortarCommand {
g[1] = p.getTargetBlock(null, 256).getLocation().clone();
}
p.setItemInHand(WandManager.createWand(g[0], g[1]));
p.setItemInHand(WandSVC.createWand(g[0], g[1]));
}
return true;

View File

@ -20,9 +20,9 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ProjectManager;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.common.IObjectPlacer;
import com.volmit.iris.engine.object.objects.IrisObject;
@ -91,7 +91,7 @@ public class CommandIrisObjectPaste extends MortarCommand {
if (obj == null || obj.getLoadFile() == null) {
sender.sendMessage("Can't find " + args[0] + " in the " + ProjectManager.WORKSPACE_NAME + " folder");
sender.sendMessage("Can't find " + args[0] + " in the " + StudioSVC.WORKSPACE_NAME + " folder");
return true;
}
@ -188,14 +188,14 @@ public class CommandIrisObjectPaste extends MortarCommand {
CommandIrisObjectUndo.addChanges(sender.player(), futureChanges);
if (intoWand) {
ItemStack newWand = WandManager.createWand(block.clone().subtract(obj.getCenter()).add(obj.getW() - 1,
ItemStack newWand = WandSVC.createWand(block.clone().subtract(obj.getCenter()).add(obj.getW() - 1,
obj.getH() + obj.getCenter().clone().getY() - 1, obj.getD() - 1), block.clone().subtract(obj.getCenter().clone().setY(0)));
if (WandManager.isWand(wand)) {
if (WandSVC.isWand(wand)) {
wand = newWand;
p.getInventory().setItemInMainHand(wand);
sender.sendMessage("Updated wand for " + "objects/" + args[0] + ".iob");
} else {
int slot = WandManager.findWand(sender.player().getInventory());
int slot = WandSVC.findWand(sender.player().getInventory());
if (slot == -1) {
p.getInventory().addItem(newWand);
sender.sendMessage("Given new wand for " + "objects/" + args[0] + ".iob");

View File

@ -20,7 +20,8 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.engine.object.objects.IrisObject;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
@ -75,8 +76,8 @@ public class CommandIrisObjectSave extends MortarCommand {
Player p = sender.player();
ItemStack wand = p.getInventory().getItemInMainHand();
IrisObject o = WandManager.createSchematic(wand);
File file = Iris.proj.getWorkspaceFile(args[0], "objects", args[1] + ".iob");
IrisObject o = WandSVC.createSchematic(wand);
File file = Iris.service(StudioSVC.class).getWorkspaceFile(args[0], "objects", args[1] + ".iob");
if (file.exists()) {
if (!overwrite) {

View File

@ -20,7 +20,8 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.plugin.MortarCommand;
@ -75,8 +76,8 @@ public class CommandIrisObjectSaveMatter extends MortarCommand {
Player p = sender.player();
ItemStack wand = p.getInventory().getItemInMainHand();
Matter o = WandManager.createMatterSchem(p, wand);
File file = Iris.proj.getWorkspaceFile(args[0], "objects", args[1] + ".iob");
Matter o = WandSVC.createMatterSchem(p, wand);
File file = Iris.service(StudioSVC.class).getWorkspaceFile(args[0], "objects", args[1] + ".iob");
if (file.exists()) {
if (!overwrite) {

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.math.Direction;
@ -58,13 +58,13 @@ public class CommandIrisObjectShift extends MortarCommand {
Player p = sender.player();
if (!WandManager.isHoldingWand(p)) {
if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand.");
return true;
}
int amt = args.length == 1 ? Integer.parseInt(args[0]) : 1;
Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(p.getInventory().getItemInMainHand());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Direction d = Direction.closest(p.getLocation().getDirection()).reverse();
@ -73,7 +73,7 @@ public class CommandIrisObjectShift extends MortarCommand {
Cuboid cursor = new Cuboid(a1, a2);
b[0] = cursor.getLowerNE();
b[1] = cursor.getUpperSW();
p.getInventory().setItemInMainHand(WandManager.createWand(b[0], b[1]));
p.getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1]));
p.updateInventory();
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
@ -52,7 +52,7 @@ public class CommandIrisObjectWand extends MortarCommand {
return true;
}
sender.player().getInventory().addItem(WandManager.createWand());
sender.player().getInventory().addItem(WandSVC.createWand());
sender.player().playSound(sender.player().getLocation(), Sound.ITEM_ARMOR_EQUIP_NETHERITE, 1f, 1.5f);
return true;

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.data.Cuboid.CuboidDirection;
@ -60,12 +60,12 @@ public class CommandIrisObjectXAY extends MortarCommand {
Player p = sender.player();
if (!WandManager.isHoldingWand(p)) {
if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand.");
return true;
}
Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(p.getInventory().getItemInMainHand());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Location a1x = b[0].clone();
@ -99,7 +99,7 @@ public class CommandIrisObjectXAY extends MortarCommand {
cursor = cursor.contract(CuboidDirection.West);
b[0] = cursor.getLowerNE();
b[1] = cursor.getUpperSW();
p.getInventory().setItemInMainHand(WandManager.createWand(b[0], b[1]));
p.getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1]));
p.updateInventory();
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.data.Cuboid.CuboidDirection;
@ -59,11 +59,11 @@ public class CommandIrisObjectXPY extends MortarCommand {
Player p = sender.player();
if (!WandManager.isHoldingWand(p)) {
if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand.");
return true;
}
Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(p.getInventory().getItemInMainHand());
b[0].add(new Vector(0, 1, 0));
b[1].add(new Vector(0, 1, 0));
Location a1 = b[0].clone();
@ -87,7 +87,7 @@ public class CommandIrisObjectXPY extends MortarCommand {
cursor = cursor.contract(CuboidDirection.West);
b[0] = cursor.getLowerNE();
b[1] = cursor.getUpperSW();
p.getInventory().setItemInMainHand(WandManager.createWand(b[0], b[1]));
p.getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1]));
p.updateInventory();
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.command.pregen;
import com.volmit.iris.Iris;

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.command.pregen;
import com.volmit.iris.Iris;

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.command.pregen;
import com.volmit.iris.Iris;

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.IO;
@ -54,12 +55,12 @@ public class CommandIrisStudioBeautify extends MortarCommand {
File clean = null;
if (args.length == 0) {
if (!Iris.proj.isProjectOpen()) {
if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender.sendMessage("No open project. Either use /iris std beautify <project> or have a project open.");
return true;
}
clean = Iris.proj.getActiveProject().getPath();
clean = Iris.service(StudioSVC.class).getActiveProject().getPath();
} else {
clean = Iris.instance.getDataFolder("packs", args[0]);
@ -73,6 +74,7 @@ public class CommandIrisStudioBeautify extends MortarCommand {
return true;
}
private int clean(VolmitSender s, File clean) {
int c = 0;
if (clean.isDirectory()) {
@ -130,7 +132,6 @@ public class CommandIrisStudioBeautify extends MortarCommand {
}
@Override
protected String getArgsUsage() {
return "[project]";

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
@ -47,7 +48,7 @@ public class CommandIrisStudioClose extends MortarCommand {
return true;
}
if (!Iris.proj.isProjectOpen()) {
if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender.sendMessage("No open projects.");
return true;
}
@ -56,7 +57,7 @@ public class CommandIrisStudioClose extends MortarCommand {
World f = null;
for (World i : Bukkit.getWorlds()) {
if (i.getWorldFolder().getAbsolutePath().equals(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().worldFolder().getAbsolutePath())) {
if (i.getWorldFolder().getAbsolutePath().equals(Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getTarget().getWorld().worldFolder().getAbsolutePath())) {
continue;
}
@ -65,17 +66,17 @@ public class CommandIrisStudioClose extends MortarCommand {
}
if (f == null) {
for (Player i : Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getPlayers()) {
for (Player i : Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getTarget().getWorld().getPlayers()) {
i.kickPlayer("Project Closing, No other world to put you in. Rejoin Please!");
}
} else {
for (Player i : Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getPlayers()) {
for (Player i : Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getTarget().getWorld().getPlayers()) {
i.teleport(f.getSpawnLocation());
}
}
}
Iris.proj.close();
Iris.service(StudioSVC.class).close();
sender.sendMessage("Projects Closed & Caches Cleared!");
return true;
}

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.ConversionSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
@ -44,7 +45,7 @@ public class CommandIrisStudioConvert extends MortarCommand {
return true;
}
Iris.convert.check(sender);
Iris.service(ConversionSVC.class).check(sender);
return true;
}

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.MortarCommand;
@ -60,9 +61,9 @@ public class CommandIrisStudioCreate extends MortarCommand {
}
if (template != null) {
Iris.proj.create(sender, args[0], template);
Iris.service(StudioSVC.class).create(sender, args[0], template);
} else {
Iris.proj.create(sender, args[0]);
Iris.service(StudioSVC.class).create(sender, args[0]);
}
return true;

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
@ -48,7 +49,7 @@ public class CommandIrisStudioEditBiome extends MortarCommand {
return true;
}
if (!Iris.proj.isProjectOpen()) {
if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender.sendMessage("There is not a studio currently loaded.");
return true;
}
@ -57,7 +58,7 @@ public class CommandIrisStudioEditBiome extends MortarCommand {
Player p = sender.player();
try {
File f = Iris.proj.getActiveProject().getActiveProvider().getEngine().getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ()).getLoadFile();
File f = Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getEngine().getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ()).getLoadFile();
Desktop.getDesktop().open(f);
} catch (Throwable e) {
Iris.reportError(e);

View File

@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.gui.NoiseExplorerGUI;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.noise.IrisGenerator;
import com.volmit.iris.util.collection.KList;
@ -75,9 +76,9 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand {
Supplier<Function2<Double, Double, Double>> l = () -> {
long seed = 12345;
IrisGenerator generator;
if (Iris.proj.isProjectOpen()) {
generator = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]);
seed = Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().seed();
if (Iris.service(StudioSVC.class).isProjectOpen()) {
generator = Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]);
seed = Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getTarget().getWorld().seed();
} else {
generator = IrisData.loadAnyGenerator(args[0]);
}

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.loot.IrisLootTable;
@ -58,7 +59,7 @@ public class CommandIrisStudioLoot extends MortarCommand {
Player p = sender.player();
Engine prov = IrisToolbelt.access(sender.player().getWorld()).getEngine();
if (!Iris.proj.isProjectOpen()) {
if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender.sendMessage("You can only use /iris studio loot in a studio world of iris.");
return true;
}
@ -67,7 +68,7 @@ public class CommandIrisStudioLoot extends MortarCommand {
Inventory inv = Bukkit.createInventory(null, 27 * 2);
try {
Iris.proj.getActiveProject().getActiveProvider().getEngine().addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(), 1);
Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getEngine().addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(), 1);
} catch (Throwable e) {
Iris.reportError(e);
sender.sendMessage("You can only use /iris loot in a studio world of iris.");
@ -109,7 +110,7 @@ public class CommandIrisStudioLoot extends MortarCommand {
inv.clear();
}
Iris.proj.getActiveProject().getActiveProvider().getEngine().addItems(true, inv, new RNG(RNG.r.imax()), tables, InventorySlotType.STORAGE, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(), 1);
Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getEngine().addItems(true, inv, new RNG(RNG.r.imax()), tables, InventorySlotType.STORAGE, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(), 1);
}, 0, fast ? 5 : 35));
return true;

View File

@ -21,6 +21,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.gui.VisionGUI;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList;
@ -55,7 +56,7 @@ public class CommandIrisStudioMap extends MortarCommand {
Engine fe;
try {
Engine g = Iris.proj.getActiveProject().getActiveProvider().getEngine();
Engine g = Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getEngine();
VisionGUI.launch(g, 0);
sender.sendMessage("Opening Map!");
} catch (Throwable e) {

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
@ -50,7 +51,7 @@ public class CommandIrisStudioOpen extends MortarCommand {
}
sender.sendMessage("Opening studio world...");
Iris.proj.open(sender, args[0]);
Iris.service(StudioSVC.class).open(sender, args[0]);
return true;
}

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
@ -63,7 +64,7 @@ public class CommandIrisStudioPackage extends MortarCommand {
}
String dim = args[0];
Iris.proj.compilePackage(sender, dim, o, m);
Iris.service(StudioSVC.class).compilePackage(sender, dim, o, m);
});
return true;

View File

@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.biome.IrisBiomePaletteLayer;
import com.volmit.iris.engine.object.noise.IrisGenerator;
@ -70,12 +71,12 @@ public class CommandIrisStudioProfile extends MortarCommand {
File report = Iris.instance.getDataFile("profile.txt");
KList<String> v = new KList<>();
if (args.length == 0) {
if (!Iris.proj.isProjectOpen()) {
if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender.sendMessage("No open project. Either use /iris std beautify <project> or have a project open.");
return;
}
f = Iris.proj.getActiveProject().getPath();
f = Iris.service(StudioSVC.class).getActiveProject().getPath();
} else {
f = Iris.instance.getDataFolder("packs", args[0]);

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
@ -50,14 +51,14 @@ public class CommandIrisStudioTPStudio extends MortarCommand {
return true;
}
if (!Iris.proj.isProjectOpen()) {
if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender.sendMessage("There is not a studio currently loaded.");
return true;
}
try {
sender.sendMessage("Teleporting you to the active studio world.");
sender.player().teleport(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().spawnLocation());
sender.player().teleport(Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getTarget().getWorld().spawnLocation());
sender.player().setGameMode(GameMode.SPECTATOR);
} catch (Throwable e) {
Iris.reportError(e);

View File

@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.object.objects.IrisObject;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
@ -62,7 +63,7 @@ public class CommandIrisStudioUpdate extends MortarCommand {
for (String i : args) {
if (i.equals("--rewrite-objects")) {
IrisData data = new IrisData(Iris.proj.getWorkspaceFolder(args[0]));
IrisData data = new IrisData(Iris.service(StudioSVC.class).getWorkspaceFolder(args[0]));
int t = data.getObjectLoader().getPossibleKeys().length;
ChronoLatch cl = new ChronoLatch(250, false);
MultiBurst bx = new MultiBurst("Object Rewriter", Thread.MIN_PRIORITY, Runtime.getRuntime().availableProcessors());
@ -107,7 +108,7 @@ public class CommandIrisStudioUpdate extends MortarCommand {
}
}
if (new IrisProject(Iris.proj.getWorkspaceFolder(args[0])).updateWorkspace()) {
if (new IrisProject(Iris.service(StudioSVC.class).getWorkspaceFolder(args[0])).updateWorkspace()) {
sender.sendMessage("Updated Code Workspace for " + args[0]);
} else {
sender.sendMessage("Invalid project: " + args[0] + ". Try deleting the code-workspace file and try again.");

View File

@ -21,7 +21,6 @@ package com.volmit.iris.core.command.what;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.json.JSONObject;

View File

@ -20,25 +20,16 @@ package com.volmit.iris.core.command.world;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.core.tools.IrisWorldCreator;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.exceptions.IrisException;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.O;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import java.io.File;
import java.util.Random;
import java.util.concurrent.atomic.AtomicReference;
public class CommandIrisCreate extends MortarCommand {
public CommandIrisCreate() {
@ -128,7 +119,6 @@ public class CommandIrisCreate extends MortarCommand {
String finalDimensionName = dimensionName;
long finalSeed = seed;
J.a(() -> {
try {

View File

@ -19,6 +19,7 @@
package com.volmit.iris.core.command.world;
import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.MortarCommand;
@ -64,10 +65,10 @@ public class CommandIrisUpdateWorld extends MortarCommand {
folder.mkdirs();
if (bfre) {
Iris.proj.downloadSearch(sender, args[1], false, true);
Iris.service(StudioSVC.class).downloadSearch(sender, args[1], false, true);
}
Iris.proj.installIntoWorld(sender, args[1], folder);
Iris.service(StudioSVC.class).installIntoWorld(sender, args[1], folder);
});
return true;

View File

@ -51,6 +51,7 @@ public class CommandLocate extends MortarCommand implements Listener {
public CommandLocate() {
super("locate");
requiresPermission(Iris.perm);
Iris.instance.registerListener(this);
}
@Override

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.decrees;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.util.decree.DecreeExecutor;
@ -27,12 +28,16 @@ import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.M;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.sql.Date;
import java.util.Map;
@Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command")
public class DecIris implements DecreeExecutor
{
public class DecIris implements DecreeExecutor {
private DecStudio studio;
private DecPregen pregen;
@ -45,14 +50,14 @@ public class DecIris implements DecreeExecutor
IrisDimension type,
@Param(description = "The seed to generate the world with", defaultValue = "1337")
long seed
){
) {
if (name.equals("iris")) {
sender().sendMessage(C.RED + "You cannot use the world name \"iris\" for creating worlds as Iris uses this directory for studio worlds.");
sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?");
return;
}
if (new File(name).exists()){
if (new File(name).exists()) {
sender().sendMessage(C.RED + "That folder already exists!");
return;
}
@ -65,7 +70,7 @@ public class DecIris implements DecreeExecutor
.sender(sender())
.studio(false)
.create();
} catch (Throwable e){
} catch (Throwable e) {
sender().sendMessage(C.RED + "Exception raised during creation. See the console for more details.");
Iris.error("Exception raised during world creation: " + e.getMessage());
Iris.reportError(e);
@ -76,7 +81,7 @@ public class DecIris implements DecreeExecutor
}
@Decree(description = "Print version information")
public void version(){
public void version() {
sender().sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
}
@ -106,7 +111,7 @@ public class DecIris implements DecreeExecutor
int value2
) {
Integer v = null;
switch(operator) {
switch (operator) {
case "|" -> v = value1 | value2;
case "&" -> v = value1 & value2;
case "^" -> v = value1 ^ value2;
@ -141,12 +146,12 @@ public class DecIris implements DecreeExecutor
boolean overwrite
) {
sender().sendMessage(C.GREEN + "Downloading pack: " + pack + "/" + branch + (trim ? " trimmed" : ""));
Iris.proj.downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim, overwrite);
Iris.service(StudioSVC.class).downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim, overwrite);
}
@Decree(description = "Get metrics for your world", aliases = "measure", origin = DecreeOrigin.PLAYER)
public void metrics() {
if (!IrisToolbelt.isIrisWorld(world())){
if (!IrisToolbelt.isIrisWorld(world())) {
sender().sendMessage(C.RED + "You must be in an Iris world");
return;
}

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.decrees;
import com.volmit.iris.Iris;
@ -9,7 +27,6 @@ import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.Position2;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.util.Vector;
@ -40,7 +57,7 @@ public class DecPregen implements DecreeExecutor {
}
@Decree(description = "Stop the active pregeneration task", aliases = "x")
public void stop(){
public void stop() {
if (PregeneratorJob.shutdownInstance()) {
sender().sendMessage(C.GREEN + "Stopped pregeneration task");
} else {

View File

@ -20,7 +20,6 @@ package com.volmit.iris.core.decrees;
import com.volmit.iris.util.decree.DecreeExecutor;
public class DecSettings implements DecreeExecutor
{
public class DecSettings implements DecreeExecutor {
}

View File

@ -24,6 +24,8 @@ import com.volmit.iris.core.gui.NoiseExplorerGUI;
import com.volmit.iris.core.gui.VisionGUI;
import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.service.ConversionSVC;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.engine.object.biome.IrisBiome;
@ -89,17 +91,17 @@ public class DecStudio implements DecreeExecutor {
@Param(defaultValue = "1337", description = "The seed to generate the studio with", aliases = "s")
long seed) {
sender().sendMessage(C.GREEN + "Opening studio for the \"" + dimension.getName() + "\" pack (seed: " + seed + ")");
Iris.proj.open(sender(), seed, dimension.getLoadKey());
Iris.service(StudioSVC.class).open(sender(), seed, dimension.getLoadKey());
}
@Decree(description = "Close an open studio project", aliases = "x", sync = true)
public void close() {
if (!Iris.proj.isProjectOpen()) {
if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender().sendMessage(C.RED + "No open studio projects.");
return;
}
Iris.proj.close();
Iris.service(StudioSVC.class).close();
sender().sendMessage(C.GREEN + "Project Closed.");
}
@ -108,12 +110,11 @@ public class DecStudio implements DecreeExecutor {
@Param(description = "The name of this new Iris Project.")
String name,
@Param(description = "Copy the contents of an existing project in your packs folder and use it as a template in this new project.", contextual = true)
IrisDimension template)
{
IrisDimension template) {
if (template != null) {
Iris.proj.create(sender(), name, template.getLoadKey());
Iris.service(StudioSVC.class).create(sender(), name, template.getLoadKey());
} else {
Iris.proj.create(sender(), name);
Iris.service(StudioSVC.class).create(sender(), name);
}
}
@ -137,7 +138,7 @@ public class DecStudio implements DecreeExecutor {
MultiBurst burst = new MultiBurst("Cleaner", Thread.MIN_PRIORITY, Runtime.getRuntime().availableProcessors() * 2);
jobs.add(new SingleJob("Updating Workspace", () -> {
if (!new IrisProject(Iris.proj.getWorkspaceFolder(project.getLoadKey())).updateWorkspace()) {
if (!new IrisProject(Iris.service(StudioSVC.class).getWorkspaceFolder(project.getLoadKey())).updateWorkspace()) {
sender().sendMessage(C.GOLD + "Invalid project: " + project.getLoadKey() + ". Try deleting the code-workspace file and try again.");
}
J.sleep(250);
@ -145,8 +146,7 @@ public class DecStudio implements DecreeExecutor {
sender().sendMessage("Files: " + files.size());
if(fixIds)
{
if (fixIds) {
QueueJob<File> r = new QueueJob<>() {
@Override
public void execute(File f) {
@ -171,8 +171,7 @@ public class DecStudio implements DecreeExecutor {
jobs.add(r);
}
if(beautify)
{
if (beautify) {
QueueJob<File> r = new QueueJob<>() {
@Override
public void execute(File f) {
@ -195,8 +194,7 @@ public class DecStudio implements DecreeExecutor {
jobs.add(r);
}
if(rewriteObjects)
{
if (rewriteObjects) {
QueueJob<Runnable> q = new QueueJob<>() {
@Override
public void execute(Runnable runnable) {
@ -210,9 +208,9 @@ public class DecStudio implements DecreeExecutor {
}
};
IrisData data = new IrisData(Iris.proj.getWorkspaceFolder(project.getLoadKey()));
IrisData data = new IrisData(Iris.service(StudioSVC.class).getWorkspaceFolder(project.getLoadKey()));
for (String f : data.getObjectLoader().getPossibleKeys()) {
CompletableFuture<?> gg = burst.complete(() ->{
CompletableFuture<?> gg = burst.complete(() -> {
File ff = data.getObjectLoader().findFile(f);
IrisObject oo = new IrisObject(0, 0, 0);
try {
@ -256,7 +254,7 @@ public class DecStudio implements DecreeExecutor {
@Decree(description = "Convert objects in the \"convert\" folder")
public void convert() {
Iris.convert.check(sender());
Iris.service(ConversionSVC.class).check(sender());
}
@ -301,7 +299,7 @@ public class DecStudio implements DecreeExecutor {
IrisGenerator generator,
@Param(description = "The seed to generate with", defaultValue = "12345")
long seed
){
) {
if (noGUI()) return;
sender().sendMessage(C.GREEN + "Opening Noise Explorer!");
@ -322,13 +320,13 @@ public class DecStudio implements DecreeExecutor {
IrisBiome biome,
@Param(description = "The region to find", contextual = true)
IrisRegion region
){
if (!IrisToolbelt.isIrisWorld(world())){
) {
if (!IrisToolbelt.isIrisWorld(world())) {
sender().sendMessage(C.RED + "You must be in an Iris world to use this command!");
return;
}
if (biome == null && region == null){
if (biome == null && region == null) {
sender().sendMessage(C.RED + "You must specify a biome or region!");
return;
}
@ -382,7 +380,7 @@ public class DecStudio implements DecreeExecutor {
try {
engine().addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ(), 1);
} catch (Throwable e){
} catch (Throwable e) {
Iris.reportError(e);
sender().sendMessage(C.RED + "Cannot add items to virtual inventory because of: " + e.getMessage());
return;
@ -412,8 +410,7 @@ public class DecStudio implements DecreeExecutor {
}
@Decree(description = "Render a world map (External GUI)", aliases = "render")
public void map()
{
public void map() {
if (noStudio()) return;
if (noGUI()) return;
@ -430,15 +427,15 @@ public class DecStudio implements DecreeExecutor {
boolean obfuscate,
@Param(name = "minify", description = "Whether or not to minify the pack", defaultValue = "true")
boolean minify
){
Iris.proj.compilePackage(sender(), dimension.getLoadKey(), obfuscate, minify);
) {
Iris.service(StudioSVC.class).compilePackage(sender(), dimension.getLoadKey(), obfuscate, minify);
}
@Decree(description = "Profiles the performance of a dimension", origin = DecreeOrigin.PLAYER)
public void profile(
@Param(description = "The dimension to profile", contextual = true, defaultValue = "overworld")
IrisDimension dimension
){
) {
File pack = dimension.getLoadFile().getParentFile().getParentFile();
File report = Iris.instance.getDataFile("profile.txt");
IrisProject project = new IrisProject(pack);
@ -627,11 +624,11 @@ public class DecStudio implements DecreeExecutor {
@Param(description = "The Iris Entity to spawn")
IrisEntity entity
) {
if (!sender().isPlayer()){
if (!sender().isPlayer()) {
sender().sendMessage(C.RED + "Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER to the command you tried to run)");
return;
}
if (IrisToolbelt.isIrisWorld(world())){
if (IrisToolbelt.isIrisWorld(world())) {
sender().sendMessage(C.RED + "You can only spawn entities in Iris worlds!");
return;
}
@ -640,19 +637,19 @@ public class DecStudio implements DecreeExecutor {
}
@Decree(description = "Teleport to the active studio world", aliases = "stp", origin = DecreeOrigin.PLAYER, sync = true)
public void tpstudio(){
if (!Iris.proj.isProjectOpen()){
public void tpstudio() {
if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender().sendMessage(C.RED + "No studio world is open!");
return;
}
if (IrisToolbelt.isIrisWorld(world()) && engine().isStudio()){
if (IrisToolbelt.isIrisWorld(world()) && engine().isStudio()) {
sender().sendMessage(C.RED + "You are already in a studio world!");
return;
}
sender().sendMessage(C.GREEN + "Sending you to the studio world!");
player().teleport(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().spawnLocation());
player().teleport(Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getTarget().getWorld().spawnLocation());
player().setGameMode(GameMode.SPECTATOR);
}
@ -660,7 +657,7 @@ public class DecStudio implements DecreeExecutor {
public void update(
@Param(description = "The dimension to update the workspace of", contextual = true, defaultValue = "overworld")
IrisDimension dimension
){
) {
if (new IrisProject(dimension.getLoadFile().getParentFile().getParentFile()).updateWorkspace()) {
sender().sendMessage(C.GREEN + "Updated Code Workspace for " + dimension.getName());
} else {
@ -680,7 +677,7 @@ public class DecStudio implements DecreeExecutor {
boolean look,
@Param(description = "Whether or not to show information about the block you are holding", defaultValue = "true")
boolean hand
){
) {
// Data
BlockData handHeld = player().getInventory().getItemInMainHand().getType().createBlockData();
Block targetBlock = player().getTargetBlockExact(128, FluidCollisionMode.NEVER);
@ -706,7 +703,7 @@ public class DecStudio implements DecreeExecutor {
}
// Target
if (targetBlockData == null){
if (targetBlockData == null) {
sender().sendMessage(C.RED + "Not looking at any block");
} else if (look) {
sender().sendMessage(C.GREEN + "" + C.BOLD + "Looked-at block information");
@ -758,7 +755,7 @@ public class DecStudio implements DecreeExecutor {
* @return true if server GUIs are not enabled
*/
private boolean noGUI() {
if (!IrisSettings.get().isUseServerLaunchedGuis()){
if (!IrisSettings.get().isUseServerLaunchedGuis()) {
sender().sendMessage(C.RED + "You must have server launched GUIs enabled in the settings!");
return true;
}
@ -768,16 +765,16 @@ public class DecStudio implements DecreeExecutor {
/**
* @return true if no studio is open or the player is not in one
*/
private boolean noStudio(){
if (!sender().isPlayer()){
private boolean noStudio() {
if (!sender().isPlayer()) {
sender().sendMessage(C.RED + "Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER to the command you tried to run)");
return true;
}
if (!Iris.proj.isProjectOpen()){
if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender().sendMessage(C.RED + "No studio world is open!");
return true;
}
if (!engine().isStudio()){
if (!engine().isStudio()) {
sender().sendMessage(C.RED + "You must be in a studio world!");
return true;
}
@ -785,9 +782,7 @@ public class DecStudio implements DecreeExecutor {
}
public void files(File clean, KList<File> files)
{
public void files(File clean, KList<File> files) {
if (clean.isDirectory()) {
for (File i : clean.listFiles()) {
files(i, files);

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.edit;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.engine.object.jigsaw.IrisJigsawPiece;
import com.volmit.iris.engine.object.jigsaw.IrisJigsawPieceConnector;
@ -168,7 +169,7 @@ public class JigsawEditor implements Listener {
public void onTick() {
if (cl.flip()) {
Iris.wand.draw(cuboid, player);
Iris.service(WandSVC.class).draw(cuboid, player);
f:
for (IrisPosition i : falling.k()) {

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.link;
import org.bukkit.Bukkit;

View File

@ -228,7 +228,7 @@ public class NMSBinding17_1 implements INMSBinding {
@Override
public Object getCustomBiomeBaseFor(String mckey) {
try {
return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.aO, new MinecraftKey(mckey)));
return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.aO, new MinecraftKey(mckey.toLowerCase())));
} catch (Throwable e) {
Iris.reportError(e);
}

View File

@ -18,11 +18,15 @@
package com.volmit.iris.core.project;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.data.IrisPackRepository;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.plugin.VolmitSender;
import lombok.Data;
import java.io.File;
import java.net.MalformedURLException;
@Data
public class IrisPack {
@ -33,8 +37,21 @@ public class IrisPack {
this.folder = folder;
}
public String getName()
public void delete()
{
return getFolder().getName();
IO.delete(folder);
folder.delete();
}
public static IrisPack from(VolmitSender sender, String url) throws MalformedURLException {
return from(sender, IrisPackRepository.from(url));
}
public static IrisPack from(VolmitSender sender, IrisPackRepository repo) throws MalformedURLException {
String name = repo.getRepo();
String url = repo.toURL();
repo.install(sender);
return new IrisPack(Iris.instance.getDataFolder(StudioSVC.WORKSPACE_NAME, repo.getRepo()));
}
}

View File

@ -21,11 +21,9 @@ package com.volmit.iris.core.project;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.project.loader.ResourceLoader;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.core.tools.IrisWorldCreator;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.block.IrisBlockData;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
@ -40,7 +38,6 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.exceptions.IrisException;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.json.JSONArray;
@ -52,9 +49,8 @@ import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.O;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Data;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.zeroturnaround.zip.ZipUtil;
import java.awt.*;
@ -448,7 +444,6 @@ public class IrisProject {
}
public static int clean(VolmitSender s, File clean) {
int c = 0;
if (clean.isDirectory()) {

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core;
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisToolbelt;
@ -29,6 +29,7 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.RollingSequence;
import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.Bukkit;
@ -38,30 +39,31 @@ import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import java.util.List;
public class CoreBoardManager implements BoardProvider, Listener {
private final BossBar energyBar;
private final com.volmit.iris.util.board.BoardManager manager;
public class BoardSVC implements IrisService, BoardProvider {
private BossBar energyBar;
private com.volmit.iris.util.board.BoardManager manager;
private String mem = "...";
public final RollingSequence hits = new RollingSequence(20);
public final RollingSequence tp = new RollingSequence(100);
private final ChronoLatch cl = new ChronoLatch(1000);
private final ChronoLatch ecl = new ChronoLatch(50);
public CoreBoardManager() {
Iris.instance.registerListener(this);
//@builder
@Override
public void onEnable() {
manager = new com.volmit.iris.util.board.BoardManager(Iris.instance, BoardSettings.builder()
.boardProvider(this)
.scoreDirection(ScoreDirection.DOWN)
.build());
energyBar = Bukkit.createBossBar("Spawner Energy " + 0, BarColor.BLUE, BarStyle.SOLID);
//@done
}
@Override
public void onDisable() {
manager.onDisable();
energyBar.removeAll();
}
@EventHandler
@ -69,7 +71,6 @@ public class CoreBoardManager implements BoardProvider, Listener {
J.s(() -> updatePlayer(e.getPlayer()));
}
private boolean isIrisWorld(World w) {
return IrisToolbelt.isIrisWorld(w) && IrisToolbelt.access(w).isStudio();
}
@ -154,10 +155,4 @@ public class CoreBoardManager implements BoardProvider, Listener {
return v;
}
public void disable() {
manager.onDisable();
energyBar.removeAll();
}
}

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core;
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.decrees.DecIris;
@ -24,15 +24,22 @@ import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.decree.DecreeSystem;
import com.volmit.iris.util.decree.virtual.VirtualDecreeCommand;
import com.volmit.iris.util.plugin.IrisService;
public class CommandManager implements DecreeSystem {
private final transient AtomicCache<VirtualDecreeCommand> commandCache = new AtomicCache<>();
private final transient AtomicCache<KList<String>> startsCache = new AtomicCache<>();
public CommandManager(){
public class CommandSVC implements IrisService, DecreeSystem {
@Override
public void onEnable() {
Iris.instance.getCommand("irisd").setExecutor(this);
}
@Override
public void onDisable() {
}
private final transient AtomicCache<VirtualDecreeCommand> commandCache = new AtomicCache<>();
private final transient AtomicCache<KList<String>> startsCache = new AtomicCache<>();
@Override
public VirtualDecreeCommand getRoot() {
return commandCache.aquire(() -> {

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core;
package com.volmit.iris.core.service;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
@ -39,6 +39,7 @@ import com.volmit.iris.util.nbt.mca.NBTWorld;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.IntTag;
import com.volmit.iris.util.nbt.tag.ListTag;
import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.Material;
@ -49,11 +50,9 @@ import java.io.File;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
public class ConversionManager {
private final KList<Converter> converters;
private final File folder;
public ConversionManager() {
public class ConversionSVC implements IrisService {
@Override
public void onEnable() {
folder = Iris.instance.getDataFolder("convert");
converters = new KList<>();
@ -64,6 +63,14 @@ public class ConversionManager {
}), 5);
}
@Override
public void onDisable() {
}
private KList<Converter> converters;
private File folder;
private String toPoolName(String poolReference) {
return poolReference.split("\\Q:\\E")[1];
}

View File

@ -0,0 +1,54 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.service;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.util.plugin.IrisService;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
public class DolphinSVC implements IrisService {
@Override
public void onEnable() {
}
@Override
public void onDisable() {
}
/**
* Prevents dolphins from being fed, to locate a treasure map.
* Note: This results in odd dolphin behaviour, but it's the best we can do.
*/
@EventHandler
public void on(PlayerInteractEntityEvent event) {
if (!IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) {
return;
}
Material hand = event.getPlayer().getInventory().getItem(event.getHand()).getType();
if (event.getRightClicked().getType().equals(EntityType.DOLPHIN) && (hand.equals(Material.TROPICAL_FISH) || hand.equals(Material.PUFFERFISH) || hand.equals(Material.COD) || hand.equals(Material.SALMON))) {
event.setCancelled(true);
}
}
}

View File

@ -16,28 +16,34 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core;
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.edit.BlockEditor;
import com.volmit.iris.core.edit.BukkitBlockEditor;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.plugin.IrisService;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldUnloadEvent;
public class EditManager implements Listener {
private final KMap<World, BlockEditor> editors;
public class EditSVC implements IrisService {
private KMap<World, BlockEditor> editors;
public EditManager() {
@Override
public void onEnable() {
this.editors = new KMap<>();
Iris.instance.registerListener(this);
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::update, 0, 0);
Iris.info("EDIT SVC ENABLED!");
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::update, 1000, 1000);
}
@Override
public void onDisable() {
flushNow();
}
public BlockData get(World world, int x, int y, int z) {
@ -90,11 +96,10 @@ public class EditManager implements Listener {
return editors.get(world);
}
BlockEditor e = null;
e = new BukkitBlockEditor(world);
BlockEditor e = new BukkitBlockEditor(world);
editors.put(world, e);
return e;
}
}

View File

@ -16,13 +16,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core;
package com.volmit.iris.core.service;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.util.collection.KMap;
@ -31,9 +33,11 @@ import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.json.JSONException;
import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
import lombok.Data;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils;
@ -41,16 +45,15 @@ import java.io.File;
import java.io.IOException;
import java.util.UUID;
@Data
public class ProjectManager {
public class StudioSVC implements IrisService {
public static final String LISTING = "https://raw.githubusercontent.com/IrisDimensions/_listing/main/listing-v2.json";
public static final String WORKSPACE_NAME = "packs";
private KMap<String, String> cacheListing = null;
private final KMap<String, String> cacheListing = null;
private IrisProject activeProject;
private static final AtomicCache<Integer> counter = new AtomicCache<>();
public ProjectManager() {
if (IrisSettings.get().isStudio()) {
@Override
public void onEnable() {
J.a(() ->
{
File ignore = getWorkspaceFile(".gitignore");
@ -67,29 +70,19 @@ public class ProjectManager {
}
});
}
}
public static int countUniqueDimensions() {
@Override
public void onDisable() {
if (IrisSettings.get().isStudio()) {
Iris.debug("Studio Mode Active: Closing Projects");
return counter.aquire(() -> {
int v = 0;
try {
for (File i : Iris.instance.getDataFolder(WORKSPACE_NAME).listFiles()) {
try {
if (i.isDirectory() && i.list().length > 0 && !Iris.proj.getListing(true).containsKey(i.getName())) {
v++;
}
} catch (Throwable e) {
Iris.reportError(e);
for (World i : Bukkit.getWorlds()) {
if (IrisToolbelt.isIrisWorld(i)) {
Iris.debug("Closing Platform Generator " + i.getName());
IrisToolbelt.access(i).close();
}
}
} catch (Throwable e) {
Iris.reportError(e);
}
return v;
});
}
public IrisDimension installIntoWorld(VolmitSender sender, String type, File folder) {
@ -99,15 +92,15 @@ public class ProjectManager {
IrisDimension dim = IrisData.loadAnyDimension(type);
if (dim == null) {
for (File i : Iris.proj.getWorkspaceFolder().listFiles()) {
for (File i : getWorkspaceFolder().listFiles()) {
if (i.isFile() && i.getName().equals(type + ".iris")) {
sender.sendMessage("Found " + type + ".iris in " + ProjectManager.WORKSPACE_NAME + " folder");
sender.sendMessage("Found " + type + ".iris in " + WORKSPACE_NAME + " folder");
ZipUtil.unpack(i, irispack);
break;
}
}
} else {
sender.sendMessage("Found " + type + " dimension in " + ProjectManager.WORKSPACE_NAME + " folder. Repackaging");
sender.sendMessage("Found " + type + " dimension in " + WORKSPACE_NAME + " folder. Repackaging");
File f = new IrisProject(new File(getWorkspaceFolder(), type)).getPath();
try {
@ -120,8 +113,8 @@ public class ProjectManager {
File dimf = new File(irispack, "dimensions/" + type + ".json");
if (!dimf.exists() || !dimf.isFile()) {
Iris.proj.downloadSearch(sender, type, false);
File downloaded = Iris.proj.getWorkspaceFolder(type);
downloadSearch(sender, type, false);
File downloaded = getWorkspaceFolder(type);
for (File i : downloaded.listFiles()) {
if (i.isFile()) {
@ -170,6 +163,12 @@ public class ProjectManager {
try {
url = getListing(false).get(key);
if(url == null)
{
Iris.warn("ITS ULL for " + key);
}
url = url == null ? key : url;
Iris.info("Assuming URL " + url);
String branch = "master";
@ -190,7 +189,7 @@ public class ProjectManager {
public void download(VolmitSender sender, String repo, String branch, boolean trim, boolean forceOverwrite) throws JsonSyntaxException, IOException {
String url = "https://codeload.github.com/" + repo + "/zip/refs/heads/" + branch;
sender.sendMessage("Downloading " + url);
sender.sendMessage("Downloading " + url + " "); //The extra space stops a bug in adventure API from repeating the last letter of the URL
File zip = Iris.getNonCachedFile("pack-" + trim + "-" + repo, url);
File temp = Iris.getTemp();
File work = new File(temp, "dl-" + UUID.randomUUID());
@ -296,10 +295,6 @@ public class ProjectManager {
}
public KMap<String, String> getListing(boolean cached) {
if (cached && cacheListing != null) {
return cacheListing;
}
JSONObject a;
if (cached) {
@ -315,6 +310,9 @@ public class ProjectManager {
l.put(i, a.getString(i));
}
// TEMP FIX
l.put("IrisDimensions/overworld/master", "IrisDimensions/overworld/stable");
l.put("overworld", "IrisDimensions/overworld/stable");
return l;
}
@ -329,7 +327,8 @@ public class ProjectManager {
public void open(VolmitSender sender, long seed, String dimm) {
try {
open(sender,seed, dimm, () -> {});
open(sender, seed, dimm, () -> {
});
} catch (Exception e) {
Iris.reportError(e);
sender.sendMessage("Error when creating studio world:");
@ -454,6 +453,10 @@ public class ProjectManager {
create(sender, s, "example");
}
public IrisProject getActiveProject() {
return activeProject;
}
public void updateWorkspace() {
if (isProjectOpen()) {
activeProject.updateWorkspace();

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core;
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.project.loader.IrisData;
@ -35,6 +35,7 @@ import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.*;
import org.bukkit.block.Block;
@ -44,19 +45,23 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Sapling;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.StructureGrowEvent;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
public class TreeManager implements Listener {
public class TreeSVC implements IrisService {
private boolean block = false;
public TreeManager() {
Iris.instance.registerListener(this);
@Override
public void onEnable() {
}
@Override
public void onDisable() {
}
/**

View File

@ -1,15 +1,43 @@
package com.volmit.iris.core;
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.villager.IrisVillagerOverride;
import com.volmit.iris.engine.object.villager.IrisVillagerTrade;
import com.volmit.iris.util.plugin.IrisService;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.VillagerAcquireTradeEvent;
public class VillagerManager implements Listener {
public class VillageSVC implements IrisService {
@Override
public void onEnable() {
}
@Override
public void onDisable() {
}
/**
* Replace or disable villager trade add event to prevent explorer map
*/

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core;
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.edit.DustRevealer;
@ -28,6 +28,7 @@ import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.matter.WorldMatter;
import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.*;
@ -35,7 +36,6 @@ import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
@ -49,12 +49,12 @@ import java.awt.Color;
import java.util.ArrayList;
import java.util.Objects;
public class WandManager implements Listener {
public class WandSVC implements IrisService {
private static ItemStack wand;
private static ItemStack dust;
public WandManager() {
@Override
public void onEnable() {
wand = createWand();
dust = createDust();
@ -65,6 +65,11 @@ public class WandManager implements Listener {
}, 0);
}
@Override
public void onDisable() {
}
public void tick(Player p) {
try {
try {

View File

@ -22,13 +22,10 @@ import com.google.common.util.concurrent.AtomicDouble;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.common.HeadlessWorld;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.engine.platform.HeadlessGenerator;
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.exceptions.IrisException;
import com.volmit.iris.util.exceptions.MissingDimensionException;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.RNG;
@ -37,15 +34,12 @@ import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.O;
import lombok.Data;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.*;
import java.io.File;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
/**
* Makes it a lot easier to setup an engine, world, studio or whatever
@ -93,21 +87,18 @@ public class IrisCreator {
* @throws IrisException shit happens
*/
public World create() throws IrisException {
if(Bukkit.isPrimaryThread())
{
if (Bukkit.isPrimaryThread()) {
throw new IrisException("You cannot invoke create() on the main thread.");
}
IrisDimension d = IrisToolbelt.getDimension(dimension());
if(d == null)
{
if (d == null) {
throw new IrisException("Dimension cannot be found null for id " + dimension());
}
if(!studio())
{
Iris.proj.installIntoWorld(sender, d.getLoadKey(), new File(name()));
if (!studio()) {
Iris.service(StudioSVC.class).installIntoWorld(sender, d.getLoadKey(), new File(name()));
}
PlatformChunkGenerator access = null;
@ -157,15 +148,13 @@ public class IrisCreator {
done.set(true);
if(sender.isPlayer())
{
if (sender.isPlayer()) {
J.s(() -> {
sender.player().teleport(new Location(world.get(), 0, world.get().getHighestBlockYAt(0, 0), 0));
});
}
if(studio)
{
if (studio) {
J.s(() -> {
Iris.linkMultiverseCore.removeFromConfig(world.get());
@ -188,8 +177,7 @@ public class IrisCreator {
AtomicBoolean dx = new AtomicBoolean(false);
J.a(() -> {
while(!dx.get())
{
while (!dx.get()) {
if (sender.isPlayer()) {
sender.sendProgress(pp.get(), "Pregenerating");
J.sleep(16);

View File

@ -20,36 +20,22 @@ package com.volmit.iris.core.tools;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ProjectManager;
import com.volmit.iris.core.gui.PregeneratorJob;
import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.pregenerator.PregeneratorMethod;
import com.volmit.iris.core.pregenerator.methods.HeadlessPregenMethod;
import com.volmit.iris.core.pregenerator.methods.HybridPregenMethod;
import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.engine.platform.HeadlessGenerator;
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.IrisProjectRepo;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.jobs.DownloadJob;
import com.volmit.iris.util.scheduling.jobs.Job;
import com.volmit.iris.util.scheduling.jobs.JobCollection;
import com.volmit.iris.util.scheduling.jobs.SingleJob;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
/**
* Something you really want to wear if working on Iris. Shit gets pretty hectic down there.
@ -71,7 +57,7 @@ public class IrisToolbelt {
File pack = Iris.instance.getDataFolder("packs", dimension);
if (!pack.exists()) {
Iris.proj.downloadSearch(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag()), dimension, false, false);
Iris.service(StudioSVC.class).downloadSearch(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag()), dimension, false, false);
}
if (!pack.exists()) {
@ -182,42 +168,9 @@ public class IrisToolbelt {
return false;
}
/**
* Attempts to ensure that the pack is installed
* @param sender the sender
* @param url the dimension
* @throws Throwable shit happens
*/
public static void install(VolmitSender sender, String url) throws Throwable {
IrisProjectRepo r = IrisProjectRepo.from(url);
if(r != null)
{
url = r.getRepo();
}
File f = Iris.instance.getDataFolder("packs", url);
IO.delete(f);
KList<Job> j = new KList<>();
File pack = new File(Iris.getTemp(), UUID.nameUUIDFromBytes(r.toURL().getBytes(StandardCharsets.UTF_8)) + ".zip");
j.add(new DownloadJob(r.toURL(), pack));
j.add(new SingleJob("Extracting", () -> {
File work = new File(Iris.getTemp(), "dltk-" + UUID.randomUUID());
ZipUtil.unpack(pack, work);
File raw = work.listFiles()[0];
try {
FileUtils.copyDirectory(raw, f);
} catch (IOException e) {
e.printStackTrace();
}
}));
JobCollection c = new JobCollection("Pack", j);
c.execute(sender);
}
/**
* Evacuate all players from the world
*
* @param world the world to leave
* @param m the message
* @return true if it was evacuated.

View File

@ -65,6 +65,8 @@ import org.bukkit.generator.BlockPopulator;
import java.io.File;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
@ -287,12 +289,11 @@ public class IrisEngine extends BlockPopulator implements Engine {
@Override
public void close() {
J.car(art);
closed = true;
J.car(art);
getWorldManager().close();
getTarget().close();
saveEngineData();
getMantle().close();
getTerrainActuator().close();
getDecorantActuator().close();
getBiomeActuator().close();
@ -300,6 +301,8 @@ public class IrisEngine extends BlockPopulator implements Engine {
getRavineModifier().close();
getCaveModifier().close();
getPostModifier().close();
getMantle().close();
Iris.debug("Engine Fully Shutdown!");
}
@Override
@ -355,7 +358,12 @@ public class IrisEngine extends BlockPopulator implements Engine {
@BlockCoordinates
@Override
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes, boolean multicore) {
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes, boolean multicore) throws WrongEngineBroException {
if(closed)
{
throw new WrongEngineBroException();
}
context.touch();
getEngineData().getStatistics().generatedChunk();
try {
@ -415,10 +423,18 @@ public class IrisEngine extends BlockPopulator implements Engine {
@ChunkCoordinates
@Override
public void populate(World world, Random random, Chunk c) {
try
{
updateChunk(c);
placeTiles(c);
}
catch(Throwable e)
{
e.printStackTrace();
}
}
@Override
public void fail(String error, Throwable e) {
failing = true;

View File

@ -139,7 +139,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
double modifyZ(double z);
@BlockCoordinates
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore);
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore) throws WrongEngineBroException;
EngineMetrics getMetrics();

View File

@ -78,6 +78,13 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
Position2 pr = null;
double d = Double.MAX_VALUE;
Iris.debug("Ps: " + p.size());
for(Position2 i : p)
{
Iris.debug("- " + i.getX() + " " + i.getZ());
}
for (Position2 i : p) {
double dx = i.distance(px);
if (dx < d) {
@ -88,7 +95,9 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
if (pr != null) {
e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.ITEM_TRIDENT_THROW, 1f, 1.6f);
((EnderSignal) e.getEntity()).setTargetLocation(new Location(e.getEntity().getWorld(), pr.getX(), 40, pr.getZ()));
Location ll = new Location(e.getEntity().getWorld(), pr.getX(), 40, pr.getZ());
Iris.debug("ESignal: " + ll.getBlockX() + " " + ll.getBlockZ());
((EnderSignal) e.getEntity()).setTargetLocation(ll);
}
}
}

View File

@ -0,0 +1,22 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.framework;
public class WrongEngineBroException extends Exception {
}

View File

@ -167,4 +167,8 @@ public class IrisBiomeCustom {
return 0;
}
public String getId() {
return id.toLowerCase();
}
}

View File

@ -20,6 +20,7 @@ package com.volmit.iris.engine.object.common;
import com.volmit.iris.Iris;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
@ -60,7 +61,7 @@ public class HeadlessWorld {
new File(world.worldFolder(), "region").mkdirs();
if (!studio && !new File(world.worldFolder(), "iris/pack").exists()) {
Iris.proj.installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag("Headless")), dimension.getLoadKey(), world.worldFolder());
Iris.service(StudioSVC.class).installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag("Headless")), dimension.getLoadKey(), world.worldFolder());
}
}

View File

@ -472,14 +472,14 @@ public class IrisDimension extends IrisRegistrant {
boolean write = false;
boolean changed = false;
IO.delete(new File(datapacks, "iris/data/" + getLoadKey()));
IO.delete(new File(datapacks, "iris/data/" + getLoadKey().toLowerCase()));
for (IrisBiome i : getAllBiomes(data)) {
if (i.isCustom()) {
write = true;
for (IrisBiomeCustom j : i.getCustomDerivitives()) {
File output = new File(datapacks, "iris/data/" + getLoadKey() + "/worldgen/biome/" + j.getId() + ".json");
File output = new File(datapacks, "iris/data/" + getLoadKey().toLowerCase() + "/worldgen/biome/" + j.getId() + ".json");
if (!output.exists()) {
changed = true;

View File

@ -21,7 +21,6 @@ package com.volmit.iris.engine.object.spawners;
import com.volmit.iris.engine.object.annotations.Desc;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.Waterlogged;
@Desc("The type of surface entities should spawn on")

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object.villager;
import com.volmit.iris.engine.object.annotations.ArrayType;

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object.villager;

View File

@ -21,11 +21,13 @@ package com.volmit.iris.engine.platform;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.data.chunk.TerrainChunk;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.WrongEngineBroException;
import com.volmit.iris.engine.object.common.IrisWorld;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.io.ReactiveFolder;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Looper;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import org.bukkit.Bukkit;
@ -40,8 +42,10 @@ import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Semaphore;
public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChunkGenerator {
private static final int HOTLOAD_LOCKS = 1000000;
private final EngineProvider provider;
private final IrisWorld world;
private final File dataLocation;
@ -50,11 +54,13 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
private final KList<BlockPopulator> populators;
private final ChronoLatch hotloadChecker;
private final Looper hotloader;
private final Semaphore hotloadLock;
private final boolean studio;
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
populators = new KList<>();
this.world = world;
this.hotloadLock = new Semaphore(HOTLOAD_LOCKS);
this.hotloadChecker = new ChronoLatch(1000, false);
this.studio = studio;
this.dataLocation = dataLocation;
@ -78,9 +84,12 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
hotloader.setName(getTarget().getWorld().name() + " Hotloader");
}
public Engine getEngine() {
public synchronized Engine getEngine() {
synchronized (provider)
{
return provider.getEngine();
}
}
@Override
public boolean isHeadless() {
@ -89,9 +98,12 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
@Override
public void close() {
synchronized (provider)
{
hotloader.interrupt();
provider.close();
}
}
@Override
public boolean isStudio() {
@ -100,19 +112,38 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
@Override
public void hotload() {
J.aBukkit(this::hotloadBLOCKING);
}
public void hotloadBLOCKING() {
try {
hotloadLock.acquire(HOTLOAD_LOCKS);
initialize();
hotloadLock.release(HOTLOAD_LOCKS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
private void initialize() {
synchronized (provider)
{
provider.provideEngine(world, dimensionKey, dataLocation, isStudio(), (e) -> {
populators.clear();
populators.add((BlockPopulator) e);
folder.checkIgnore();
});
}
}
@Override
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
try {
hotloadLock.acquire();
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
Iris.debug("Generated " + x + " " + z);
PrecisionStopwatch ps = PrecisionStopwatch.start();
@ -121,8 +152,18 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
this.world.bind(world);
getEngine().generate(x * 16, z * 16, blocks, biomes, true);
hotloadLock.release();
return tc.getRaw();
} catch (Throwable e) {
}
catch(WrongEngineBroException e)
{
hotloadLock.release();
hotloadBLOCKING();
return generateChunkData(world, ignored, x, z, biome);
}
catch (Throwable e) {
Iris.error("======================================");
e.printStackTrace();
Iris.reportErrorChunk(x, z, e, "CHUNK");
@ -136,8 +177,10 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
}
}
hotloadLock.release();
return d;
}
}
@NotNull

View File

@ -43,8 +43,7 @@ public class EngineProvider {
IrisData data = new IrisData(dataLocation);
IrisDimension realDimension = data.getDimensionLoader().load(dimension);
if(realDimension == null)
{
if (realDimension == null) {
throw new RuntimeException("Cannot find dimension in " + data.getDataFolder().getAbsolutePath() + " with key " + dimension);
}

View File

@ -19,7 +19,6 @@
package com.volmit.iris.engine.scripting;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.common.IrisScript;
import org.apache.bsf.BSFManager;
public interface EngineExecutionEnvironment {

View File

@ -159,10 +159,7 @@ public class B {
if (bx instanceof Leaves && IrisSettings.get().getGenerator().preventLeafDecay) {
((Leaves) bx).setPersistent(true);
}
else if(bx instanceof Leaves)
{
} else if (bx instanceof Leaves) {
((Leaves) bx).setPersistent(false);
}

View File

@ -18,12 +18,28 @@
package com.volmit.iris.util.data;
import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.jobs.DownloadJob;
import com.volmit.iris.util.scheduling.jobs.Job;
import com.volmit.iris.util.scheduling.jobs.JobCollection;
import com.volmit.iris.util.scheduling.jobs.SingleJob;
import lombok.Builder;
import lombok.Data;
import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.UUID;
@Data
@Builder
public class IrisProjectRepo {
public class IrisPackRepository {
@Builder.Default
private String user = "IrisDimensions";
@ -36,65 +52,45 @@ public class IrisProjectRepo {
@Builder.Default
private String tag = "";
public static IrisProjectRepo from(String g)
{
public static IrisPackRepository from(String g) {
// https://github.com/IrisDimensions/overworld
if(g.startsWith("https://github.com/"))
{
if (g.startsWith("https://github.com/")) {
String sub = g.split("\\Qgithub.com/\\E")[1];
IrisProjectRepo r = IrisProjectRepo.builder()
IrisPackRepository r = IrisPackRepository.builder()
.user(sub.split("\\Q/\\E")[0])
.repo(sub.split("\\Q/\\E")[1]).build();
if(g.contains("/tree/"))
{
if (g.contains("/tree/")) {
r.setBranch(g.split("/tree/")[1]);
}
return r;
}
else if(g.contains("/"))
{
} else if (g.contains("/")) {
String[] f = g.split("\\Q/\\E");
if(f.length == 1)
{
if (f.length == 1) {
return from(g);
}
else if(f.length == 2)
{
return IrisProjectRepo.builder()
} else if (f.length == 2) {
return IrisPackRepository.builder()
.user(f[0])
.repo(f[1])
.build();
}
else if(f.length >= 3)
{
IrisProjectRepo r = IrisProjectRepo.builder()
} else if (f.length >= 3) {
IrisPackRepository r = IrisPackRepository.builder()
.user(f[0])
.repo(f[1])
.build();
if(f[2].startsWith("#"))
{
if (f[2].startsWith("#")) {
r.setTag(f[2].substring(1));
}
else
{
} else {
r.setBranch(f[2]);
}
return r;
}
}
else
{
return IrisProjectRepo.builder()
} else {
return IrisPackRepository.builder()
.user("IrisDimensions")
.repo(g)
.branch(g.equals("overworld") ? "stable" : "master")
@ -104,13 +100,31 @@ public class IrisProjectRepo {
return null;
}
public String toURL()
{
if(!tag.trim().isEmpty())
{
public String toURL() {
if (!tag.trim().isEmpty()) {
return "https://codeload.github.com/" + user + "/" + repo + "/zip/refs/tags/" + tag;
}
return "https://codeload.github.com/" + user + "/" + repo + "/zip/refs/heads/" + branch;
}
public void install(VolmitSender sender) throws MalformedURLException {
File pack = Iris.instance.getDataFolder(StudioSVC.WORKSPACE_NAME, getRepo());
if(!pack.exists())
{
File dl = new File(Iris.getTemp(), "dltk-" + UUID.randomUUID() + ".zip");
File work = new File(Iris.getTemp(), "extk-" + UUID.randomUUID());
new JobCollection(Form.capitalize(getRepo()),
new DownloadJob(toURL(), pack),
new SingleJob("Extracting", () -> ZipUtil.unpack(dl, work)),
new SingleJob("Installing", () -> {
try {
FileUtils.copyDirectory(work.listFiles()[0], pack);
} catch (IOException e) {
e.printStackTrace();
}
})).execute(sender);
}
}
}

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree;
import com.volmit.iris.Iris;
@ -5,19 +23,15 @@ import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.plugin.VolmitSender;
public interface DecreeContextHandler<T> {
static KMap<Class<?>, DecreeContextHandler<?>> contextHandlers = buildContextHandlers();
KMap<Class<?>, DecreeContextHandler<?>> contextHandlers = buildContextHandlers();
static KMap<Class<?>, DecreeContextHandler<?>> buildContextHandlers() {
KMap<Class<?>, DecreeContextHandler<?>> contextHandlers = new KMap<>();
try
{
try {
Iris.initialize("com.volmit.iris.util.decree.context").forEach((i)
-> contextHandlers.put(((DecreeContextHandler<?>)i).getType(), (DecreeContextHandler<?>)i));
}
catch(Throwable e)
{
-> contextHandlers.put(((DecreeContextHandler<?>) i).getType(), (DecreeContextHandler<?>) i));
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}

View File

@ -21,28 +21,23 @@ package com.volmit.iris.util.decree;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.World;
import org.bukkit.entity.Player;
public interface DecreeExecutor {
default VolmitSender sender()
{
default VolmitSender sender() {
return DecreeContext.get();
}
default Player player()
{
default Player player() {
return sender().player();
}
default Engine engine()
{
if(sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null)
{
default Engine engine() {
if (sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null) {
PlatformChunkGenerator gen = IrisToolbelt.access(sender().player().getWorld());
if (gen != null){
if (gen != null) {
return gen.getEngine();
}
}
@ -50,24 +45,21 @@ public interface DecreeExecutor {
return null;
}
default PlatformChunkGenerator access()
{
if(sender().isPlayer()) {
default PlatformChunkGenerator access() {
if (sender().isPlayer()) {
return IrisToolbelt.access(world());
}
return null;
}
default World world()
{
if (sender().isPlayer()){
default World world() {
if (sender().isPlayer()) {
return sender().player().getWorld();
}
return null;
}
default <T> T get(T v, T ifUndefined)
{
default <T> T get(T v, T ifUndefined) {
return v == null ? ifUndefined : v;
}
}

View File

@ -25,7 +25,6 @@ import lombok.Data;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Arrays;
@Data
public class DecreeNode {
@ -37,20 +36,20 @@ public class DecreeNode {
this.instance = instance;
this.method = method;
this.decree = method.getDeclaredAnnotation(Decree.class);
if (decree == null){
if (decree == null) {
throw new RuntimeException("Cannot instantiate DecreeNode on method " + method.getName() + " in " + method.getDeclaringClass().getCanonicalName() + " not annotated by @Decree");
}
}
/**
* Get the parameters of this decree node
*
* @return The list of parameters if ALL are annotated by @{@link Param}, else null
*/
public KList<DecreeParameter> getParameters() {
KList<DecreeParameter> p = new KList<>();
for(Parameter i : method.getParameters())
{
for (Parameter i : method.getParameters()) {
p.add(new DecreeParameter(i));
}
@ -72,10 +71,8 @@ public class DecreeNode {
public KList<String> getNames() {
KList<String> d = new KList<>();
for(String i : decree.aliases())
{
if(i.isEmpty())
{
for (String i : decree.aliases()) {
if (i.isEmpty()) {
continue;
}

View File

@ -30,11 +30,12 @@ public enum DecreeOrigin {
/**
* Check if the origin is valid for a sender
*
* @param sender The sender to check
* @return True if valid for origin
*/
public boolean validFor(VolmitSender sender){
if (sender.isPlayer()){
public boolean validFor(VolmitSender sender) {
if (sender.isPlayer()) {
return this.equals(PLAYER) || this.equals(BOTH);
} else {
return this.equals(CONSOLE) || this.equals(BOTH);

View File

@ -34,7 +34,7 @@ public class DecreeParameter {
public DecreeParameter(Parameter parameter) {
this.parameter = parameter;
this.param = parameter.getDeclaredAnnotation(Param.class);
if (param == null){
if (param == null) {
throw new RuntimeException("Cannot instantiate DecreeParameter on " + parameter.getName() + " in method " + parameter.getDeclaringExecutable().getName() + "(...) in class " + parameter.getDeclaringExecutable().getDeclaringClass().getCanonicalName() + " not annotated by @Param");
}
}
@ -62,10 +62,8 @@ public class DecreeParameter {
public KList<String> getNames() {
KList<String> d = new KList<>();
for(String i : param.aliases())
{
if(i.isEmpty())
{
for (String i : param.aliases()) {
if (i.isEmpty()) {
continue;
}
@ -90,8 +88,7 @@ public class DecreeParameter {
KList<?> ff = getHandler().getPossibilities();
ff = ff != null ? ff : new KList<>();
KList<String> f = ff.convert((i) -> getHandler().toStringForce(i));
if(f.isEmpty())
{
if (f.isEmpty()) {
f = new KList<>();
f.add(getHandler().getRandomDefault());
}

View File

@ -21,19 +21,20 @@ package com.volmit.iris.util.decree;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.atomic.AtomicReference;
public interface DecreeParameterHandler<T> {
/**
* Should return the possible values for this type
*
* @return Possibilities for this type.
*/
KList<T> getPossibilities();
/**
* Converting the type back to a string (inverse of the {@link #parse(String) parse} method)
*
* @param t The input of the designated type to convert to a String
* @return The resulting string
*/
@ -41,16 +42,17 @@ public interface DecreeParameterHandler<T> {
/**
* Forces conversion to the designated type before converting to a string using {@link #toString(T t)}
*
* @param t The object to convert to string (that should be of this type)
* @return The resulting string.
*/
default String toStringForce(Object t)
{
return toString((T)t);
default String toStringForce(Object t) {
return toString((T) t);
}
/**
* Should parse a String into the designated type
*
* @param in The string to parse
* @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)
@ -60,6 +62,7 @@ public interface DecreeParameterHandler<T> {
/**
* Returns whether a certain type is supported by this handler<br>
*
* @param type The type to check
* @return True if supported, false if not
*/
@ -67,13 +70,12 @@ public interface DecreeParameterHandler<T> {
/**
* The possible entries for the inputted string (support for autocomplete on partial entries)
*
* @param input The inputted string to check against
* @return A {@link KList} of possibilities
*/
default KList<T> getPossibilities(String input)
{
if(input.trim().isEmpty())
{
default KList<T> getPossibilities(String input) {
if (input.trim().isEmpty()) {
KList<T> f = getPossibilities();
return f == null ? new KList<>() : f;
}
@ -82,26 +84,23 @@ public interface DecreeParameterHandler<T> {
KList<T> possible = getPossibilities();
KList<T> matches = new KList<>();
if (possible == null || possible.isEmpty()){
if (possible == null || possible.isEmpty()) {
return matches;
}
if (input.isEmpty())
{
if (input.isEmpty()) {
return getPossibilities();
}
KList<String> converted = possible.convert(v -> toString(v).trim());
for(int i = 0; i < converted.size(); i++)
{
for (int i = 0; i < converted.size(); i++) {
String g = converted.get(i);
// if
// G == I or
// I in G or
// G in I
if(g.equalsIgnoreCase(input) || g.toLowerCase().contains(input.toLowerCase()) || input.toLowerCase().contains(g.toLowerCase()))
{
if (g.equalsIgnoreCase(input) || g.toLowerCase().contains(input.toLowerCase()) || input.toLowerCase().contains(g.toLowerCase())) {
matches.add(possible.get(i));
}
}
@ -109,54 +108,36 @@ public interface DecreeParameterHandler<T> {
return matches;
}
default String getRandomDefault()
{
default String getRandomDefault() {
return "NOEXAMPLE";
}
default double getMultiplier(AtomicReference<String> g)
{
default double getMultiplier(AtomicReference<String> g) {
double multiplier = 1;
String in = g.get();
boolean valid = true;
while(valid) {
while (valid) {
boolean trim = false;
if (in.toLowerCase().endsWith("k"))
{
if (in.toLowerCase().endsWith("k")) {
multiplier *= 1000;
trim = true;
}
else if(in.toLowerCase().endsWith("m"))
{
} else if (in.toLowerCase().endsWith("m")) {
multiplier *= 1000000;
trim = true;
}
else if(in.toLowerCase().endsWith("h"))
{
} else if (in.toLowerCase().endsWith("h")) {
multiplier *= 100;
trim = true;
}
else if(in.toLowerCase().endsWith("c"))
{
} else if (in.toLowerCase().endsWith("c")) {
multiplier *= 16;
trim = true;
}
else if(in.toLowerCase().endsWith("r"))
{
} else if (in.toLowerCase().endsWith("r")) {
multiplier *= (16 * 32);
trim = true;
}
else {
} else {
valid = false;
}
if(trim)
{
if (trim) {
in = in.substring(0, in.length() - 1);
}
}

View File

@ -38,12 +38,12 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
/**
* The root class to start command searching from
*
* @return
*/
VirtualDecreeCommand getRoot();
default boolean call(VolmitSender sender, String[] args)
{
default boolean call(VolmitSender sender, String[] args) {
DecreeContext.touch(sender);
return getRoot().invoke(sender, enhanceArgs(args));
}
@ -61,108 +61,77 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
@Override
default boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
J.aBukkit(() -> {
if(!call(new VolmitSender(sender), args))
{
if (!call(new VolmitSender(sender), args)) {
sender.sendMessage(C.RED + "Unknown Iris Command");
}
});
return true;
}
static KList<String> enhanceArgs(String[] args)
{
static KList<String> enhanceArgs(String[] args) {
return enhanceArgs(args, true);
}
static KList<String> enhanceArgs(String[] args, boolean trim)
{
static KList<String> enhanceArgs(String[] args, boolean trim) {
KList<String> a = new KList<>();
if(args.length == 0)
{
if (args.length == 0) {
return a;
}
StringBuilder flat = new StringBuilder();
for(String i : args)
{
if(trim)
{
if(i.trim().isEmpty())
{
for (String i : args) {
if (trim) {
if (i.trim().isEmpty()) {
continue;
}
flat.append(" ").append(i.trim());
}
else
{
if(i.endsWith(" "))
{
} else {
if (i.endsWith(" ")) {
flat.append(" ").append(i.trim()).append(" ");
}
}
}
flat = new StringBuilder(flat.length() > 0 ? trim ? flat.toString().trim().length() > 0 ?flat.substring(1).trim() : flat.toString().trim() : flat.substring(1) : flat);
flat = new StringBuilder(flat.length() > 0 ? trim ? flat.toString().trim().length() > 0 ? flat.substring(1).trim() : flat.toString().trim() : flat.substring(1) : flat);
StringBuilder arg = new StringBuilder();
boolean quoting = false;
for(int x = 0; x < flat.length(); x++)
{
for (int x = 0; x < flat.length(); x++) {
char i = flat.charAt(x);
char j = x < flat.length() - 1 ? flat.charAt(x + 1) : i;
boolean hasNext = x < flat.length();
if(i == ' ' && !quoting)
{
if(!arg.toString().trim().isEmpty() && trim)
{
if (i == ' ' && !quoting) {
if (!arg.toString().trim().isEmpty() && trim) {
a.add(arg.toString().trim());
arg = new StringBuilder();
}
}
else if(i == '"')
{
if(!quoting && (arg.length() == 0))
{
} else if (i == '"') {
if (!quoting && (arg.length() == 0)) {
quoting = true;
}
else if(quoting)
{
} else if (quoting) {
quoting = false;
if(hasNext && j == ' ')
{
if(!arg.toString().trim().isEmpty() && trim)
{
if (hasNext && j == ' ') {
if (!arg.toString().trim().isEmpty() && trim) {
a.add(arg.toString().trim());
arg = new StringBuilder();
}
}
else if(!hasNext)
{
if(!arg.toString().trim().isEmpty() && trim)
{
} else if (!hasNext) {
if (!arg.toString().trim().isEmpty() && trim) {
a.add(arg.toString().trim());
arg = new StringBuilder();
}
}
}
}
else
{
} else {
arg.append(i);
}
}
if(!arg.toString().trim().isEmpty() && trim)
{
if (!arg.toString().trim().isEmpty() && trim) {
a.add(arg.toString().trim());
}
@ -171,14 +140,13 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
/**
* Get the handler for the specified type
*
* @param type The type to handle
* @return The corresponding {@link DecreeParameterHandler}, or null
*/
static DecreeParameterHandler<?> getHandler(Class<?> type) {
for(DecreeParameterHandler<?> i : handlers)
{
if(i.supports(type))
{
for (DecreeParameterHandler<?> i : handlers) {
if (i.supports(type)) {
return i;
}
}

View File

@ -38,6 +38,7 @@ public @interface Decree {
/**
* Only allow if studio mode is enabled
*
* @return defaults to false
*/
boolean studio() default false;

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt;
@ -6,14 +24,14 @@ import com.volmit.iris.util.decree.DecreeContextHandler;
import com.volmit.iris.util.plugin.VolmitSender;
public class BiomeContextHandler implements DecreeContextHandler<IrisBiome> {
public Class<IrisBiome> getType(){return IrisBiome.class;}
public Class<IrisBiome> getType() {
return IrisBiome.class;
}
public IrisBiome handle(VolmitSender sender)
{
if(sender.isPlayer()
public IrisBiome handle(VolmitSender sender) {
if (sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null)
{
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getBiome(sender.player().getLocation());
}

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt;
@ -6,14 +24,14 @@ import com.volmit.iris.util.decree.DecreeContextHandler;
import com.volmit.iris.util.plugin.VolmitSender;
public class DimensionContextHandler implements DecreeContextHandler<IrisDimension> {
public Class<IrisDimension> getType(){return IrisDimension.class;}
public Class<IrisDimension> getType() {
return IrisDimension.class;
}
public IrisDimension handle(VolmitSender sender)
{
if(sender.isPlayer()
public IrisDimension handle(VolmitSender sender) {
if (sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null)
{
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getDimension();
}

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt;
@ -14,10 +32,9 @@ public class GeneratorContextHandler implements DecreeContextHandler<IrisGenerat
@Override
public IrisGenerator handle(VolmitSender sender) {
if(sender.isPlayer()
if (sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null)
{
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
Engine engine = IrisToolbelt.access(sender.player().getWorld()).getEngine();
return engine.getData().getGeneratorLoader().load(engine.getBiome(sender.player().getLocation()).getGenerators().getRandom().getGenerator());
}

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt;
@ -6,14 +24,14 @@ import com.volmit.iris.util.decree.DecreeContextHandler;
import com.volmit.iris.util.plugin.VolmitSender;
public class RegionContextHandler implements DecreeContextHandler<IrisRegion> {
public Class<IrisRegion> getType(){return IrisRegion.class;}
public Class<IrisRegion> getType() {
return IrisRegion.class;
}
public IrisRegion handle(VolmitSender sender)
{
if(sender.isPlayer()
public IrisRegion handle(VolmitSender sender) {
if (sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null)
{
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getRegion(sender.player().getLocation());
}

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.context;
import com.volmit.iris.util.decree.DecreeContextHandler;
@ -5,10 +23,11 @@ import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.World;
public class WorldContextHandler implements DecreeContextHandler<World> {
public Class<World> getType(){return World.class;}
public Class<World> getType() {
return World.class;
}
public World handle(VolmitSender sender)
{
public World handle(VolmitSender sender) {
return sender.isPlayer() ? sender.player().getWorld() : null;
}
}

View File

@ -21,7 +21,7 @@ package com.volmit.iris.util.decree.exceptions;
/**
* Thrown when a decree parameter is parsed, but parsing fails
*/
public class DecreeParsingException extends Exception{
public class DecreeParsingException extends Exception {
public DecreeParsingException(String message) {
super(message);
}

View File

@ -18,13 +18,11 @@
package com.volmit.iris.util.decree.exceptions;
import com.volmit.iris.util.collection.KList;
/**
* Thrown when more than one option is available for a singular mapping<br>
* Like having a hashmap where one input maps to two outputs.
*/
public class DecreeWhichException extends Exception{
public class DecreeWhichException extends Exception {
public DecreeWhichException() {
super();
}

View File

@ -21,13 +21,11 @@ package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.decree.DecreeParameterHandler;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
import com.volmit.iris.util.math.RNG;
import java.io.File;
@ -37,12 +35,10 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
KMap<String, IrisBiome> p = new KMap<>();
//noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles())
{
if(i.isDirectory()) {
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
if (i.isDirectory()) {
IrisData data = new IrisData(i, true);
for (IrisBiome j : data.getBiomeLoader().loadAll(data.getBiomeLoader().getPossibleKeys()))
{
for (IrisBiome j : data.getBiomeLoader().loadAll(data.getBiomeLoader().getPossibleKeys())) {
p.putIfAbsent(j.getLoadKey(), j);
}
@ -60,27 +56,19 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
@Override
public IrisBiome parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<IrisBiome> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Biome \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Biome \"" + in + "\" because of an uncaught exception: " + e);
}
}
@ -91,8 +79,7 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "biome";
}
}

View File

@ -30,7 +30,6 @@ import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.FluidCollisionMode;
import org.bukkit.entity.Player;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
@Override
@ -38,8 +37,7 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
KList<BlockVector> vx = new KList<>();
VolmitSender s = DecreeContext.get();
if(s.isPlayer())
{
if (s.isPlayer()) {
vx.add(s.player().getLocation().toVector().toBlockVector());
}
@ -48,9 +46,8 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
@Override
public String toString(BlockVector v) {
if(v.getY() == 0)
{
return Form.f(v.getBlockX(), 2)+ "," + Form.f(v.getBlockZ(), 2);
if (v.getY() == 0) {
return Form.f(v.getBlockX(), 2) + "," + Form.f(v.getBlockZ(), 2);
}
return Form.f(v.getBlockX(), 2) + "," + Form.f(v.getBlockY(), 2) + "," + Form.f(v.getBlockZ(), 2);
@ -59,69 +56,43 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
@Override
public BlockVector parse(String in) throws DecreeParsingException, DecreeWhichException {
try {
if (in.contains(","))
{
if (in.contains(",")) {
String[] comp = in.split("\\Q,\\E");
if(comp.length == 2)
{
if (comp.length == 2) {
return new BlockVector(Integer.parseInt(comp[0].trim()), 0, Integer.parseInt(comp[1].trim()));
}
else if(comp.length == 3)
{
} else if (comp.length == 3) {
return new BlockVector(Integer.parseInt(comp[0].trim()),
Integer.parseInt(comp[1].trim()),
Integer.parseInt(comp[2].trim()));
}
else
{
} else {
throw new DecreeParsingException("Could not parse components for vector. You have " + comp.length + " components. Expected 2 or 3.");
}
}
else if(in.equalsIgnoreCase("here") ||in.equalsIgnoreCase("me") ||in.equalsIgnoreCase("self"))
{
if(!DecreeContext.get().isPlayer())
{
} else if (in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) {
if (!DecreeContext.get().isPlayer()) {
throw new DecreeParsingException("You cannot specify me,self,here as a console.");
}
return DecreeContext.get().player().getLocation().toVector().toBlockVector();
}
else if(in.equalsIgnoreCase("look") ||in.equalsIgnoreCase("cursor") ||in.equalsIgnoreCase("crosshair"))
{
if(!DecreeContext.get().isPlayer())
{
} else if (in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) {
if (!DecreeContext.get().isPlayer()) {
throw new DecreeParsingException("You cannot specify look,cursor,crosshair as a console.");
}
return DecreeContext.get().player().getTargetBlockExact(256, FluidCollisionMode.NEVER).getLocation().toVector().toBlockVector();
}
else if(in.trim().toLowerCase().startsWith("player:"))
{
} else if (in.trim().toLowerCase().startsWith("player:")) {
String v = in.trim().split("\\Q:\\E")[1];
KList<?> px = DecreeSystem.getHandler(Player.class).getPossibilities(v);
if(px != null && px.isNotEmpty())
{
return ((Player)px.get(0)).getLocation().toVector().toBlockVector();
}
else if(px == null || px.isEmpty())
{
if (px != null && px.isNotEmpty()) {
return ((Player) px.get(0)).getLocation().toVector().toBlockVector();
} else if (px == null || px.isEmpty()) {
throw new DecreeParsingException("Cannot find player: " + v);
}
}
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to get Vector for \"" + in + "\" because of an uncaught exception: " + e);
}
@ -134,8 +105,7 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return M.r(0.5) ? "0,0" : "0,0,0";
}
}

View File

@ -22,7 +22,6 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.decree.DecreeParameterHandler;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
public class BooleanHandler implements DecreeParameterHandler<Boolean> {
@Override
@ -37,13 +36,9 @@ public class BooleanHandler implements DecreeParameterHandler<Boolean> {
@Override
public Boolean parse(String in) throws DecreeParsingException {
try
{
try {
return Boolean.parseBoolean(in);
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse boolean \"" + in + "\"");
}
}
@ -54,8 +49,7 @@ public class BooleanHandler implements DecreeParameterHandler<Boolean> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return M.r(0.5) + "";
}
}

View File

@ -36,13 +36,9 @@ public class ByteHandler implements DecreeParameterHandler<Byte> {
@Override
public Byte parse(String in) throws DecreeParsingException {
try
{
try {
return Byte.parseByte(in);
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse byte \"" + in + "\"");
}
}
@ -53,8 +49,7 @@ public class ByteHandler implements DecreeParameterHandler<Byte> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return RNG.r.i(0, Byte.MAX_VALUE) + "";
}
}

View File

@ -26,8 +26,6 @@ import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.decree.DecreeParameterHandler;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.io.File;
@ -37,12 +35,10 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
KMap<String, IrisDimension> p = new KMap<>();
//noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles())
{
if(i.isDirectory()) {
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
if (i.isDirectory()) {
IrisData data = new IrisData(i, true);
for (IrisDimension j : data.getDimensionLoader().loadAll(data.getDimensionLoader().getPossibleKeys()))
{
for (IrisDimension j : data.getDimensionLoader().loadAll(data.getDimensionLoader().getPossibleKeys())) {
p.putIfAbsent(j.getLoadKey(), j);
}
@ -60,27 +56,19 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
@Override
public IrisDimension parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<IrisDimension> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Dimension \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Dimension \"" + in + "\" because of an uncaught exception: " + e);
}
}
@ -91,8 +79,7 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "dimension";
}
}

View File

@ -34,15 +34,11 @@ public class DoubleHandler implements DecreeParameterHandler<Double> {
@Override
public Double parse(String in) throws DecreeParsingException {
try
{
try {
AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r);
return Double.parseDouble(r.get()) * m;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse double \"" + in + "\"");
}
}
@ -58,8 +54,7 @@ public class DoubleHandler implements DecreeParameterHandler<Double> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return Form.f(RNG.r.d(0, 99.99), 1) + "";
}
}

View File

@ -1,8 +1,25 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.engine.object.entity.IrisEntity;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
@ -24,12 +41,10 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
KMap<String, IrisEntity> p = new KMap<>();
//noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles())
{
if(i.isDirectory()) {
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
if (i.isDirectory()) {
IrisData data = new IrisData(i, true);
for (IrisEntity j : data.getEntityLoader().loadAll(data.getEntityLoader().getPossibleKeys()))
{
for (IrisEntity j : data.getEntityLoader().loadAll(data.getEntityLoader().getPossibleKeys())) {
p.putIfAbsent(j.getLoadKey(), j);
}
@ -61,27 +76,19 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
*/
@Override
public IrisEntity parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<IrisEntity> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Entity \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Entity \"" + in + "\" because of an uncaught exception: " + e);
}
}
@ -98,8 +105,7 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "entity";
}
}

View File

@ -34,15 +34,11 @@ public class FloatHandler implements DecreeParameterHandler<Float> {
@Override
public Float parse(String in) throws DecreeParsingException {
try
{
try {
AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r);
return (float)(Float.parseFloat(r.get()) * m);
}
catch(Throwable e)
{
return (float) (Float.parseFloat(r.get()) * m);
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse float \"" + in + "\"");
}
}
@ -58,8 +54,7 @@ public class FloatHandler implements DecreeParameterHandler<Float> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return Form.f(RNG.r.d(0, 99.99), 1) + "";
}
}

View File

@ -1,3 +1,21 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris;
@ -17,12 +35,10 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
KMap<String, IrisGenerator> p = new KMap<>();
//noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles())
{
if(i.isDirectory()) {
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
if (i.isDirectory()) {
IrisData data = new IrisData(i, true);
for (IrisGenerator j : data.getGeneratorLoader().loadAll(data.getGeneratorLoader().getPossibleKeys()))
{
for (IrisGenerator j : data.getGeneratorLoader().loadAll(data.getGeneratorLoader().getPossibleKeys())) {
p.putIfAbsent(j.getLoadKey(), j);
}
@ -40,27 +56,19 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
@Override
public IrisGenerator parse(String in) throws DecreeParsingException, DecreeWhichException {
try
{
try {
KList<IrisGenerator> options = getPossibilities(in);
if(options.isEmpty())
{
if (options.isEmpty()) {
throw new DecreeParsingException("Unable to find Generator \"" + in + "\"");
}
else if(options.size() > 1)
{
} else if (options.size() > 1) {
throw new DecreeWhichException();
}
return options.get(0);
}
catch(DecreeParsingException e){
} catch (DecreeParsingException e) {
throw e;
}
catch(Throwable e)
{
} catch (Throwable e) {
throw new DecreeParsingException("Unable to find Generator \"" + in + "\" because of an uncaught exception: " + e);
}
}
@ -71,8 +79,7 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return "generator";
}
}

View File

@ -21,10 +21,8 @@ package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.decree.DecreeParameterHandler;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.RNG;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicReference;
public class IntegerHandler implements DecreeParameterHandler<Integer> {
@ -35,15 +33,11 @@ public class IntegerHandler implements DecreeParameterHandler<Integer> {
@Override
public Integer parse(String in) throws DecreeParsingException {
try
{
try {
AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r);
return (int)(Integer.valueOf(r.get()).doubleValue() * m);
}
catch(Throwable e)
{
return (int) (Integer.valueOf(r.get()).doubleValue() * m);
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse integer \"" + in + "\"");
}
}
@ -59,8 +53,7 @@ public class IntegerHandler implements DecreeParameterHandler<Integer> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return RNG.r.i(0, 99) + "";
}
}

View File

@ -33,15 +33,11 @@ public class LongHandler implements DecreeParameterHandler<Long> {
@Override
public Long parse(String in) throws DecreeParsingException {
try
{
try {
AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r);
return (long)(Long.valueOf(r.get()).doubleValue() * m);
}
catch(Throwable e)
{
return (long) (Long.valueOf(r.get()).doubleValue() * m);
} catch (Throwable e) {
throw new DecreeParsingException("Unable to parse long \"" + in + "\"");
}
}
@ -57,8 +53,7 @@ public class LongHandler implements DecreeParameterHandler<Long> {
}
@Override
public String getRandomDefault()
{
public String getRandomDefault() {
return RNG.r.i(0, 99) + "";
}
}

Some files were not shown because too many files have changed in this diff Show More