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' group 'com.volmit.iris'
version '1.7.1' version '1.7.2'
def apiVersion = '1.17' def apiVersion = '1.17'
def name = getRootProject().getName() // See settings.gradle def name = getRootProject().getName() // See settings.gradle
def main = 'com.volmit.iris.Iris' 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; 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.CommandIris;
import com.volmit.iris.core.command.PermissionIris; import com.volmit.iris.core.command.PermissionIris;
import com.volmit.iris.core.command.studio.CommandIrisStudio; 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.IrisPapiExpansion;
import com.volmit.iris.core.link.MultiverseCoreLink; import com.volmit.iris.core.link.MultiverseCoreLink;
import com.volmit.iris.core.link.MythicMobsLink; import com.volmit.iris.core.link.MythicMobsLink;
import com.volmit.iris.core.link.OraxenLink; import com.volmit.iris.core.link.OraxenLink;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.project.loader.IrisData; 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.IrisBiome;
import com.volmit.iris.engine.object.biome.IrisBiomeCustom; import com.volmit.iris.engine.object.biome.IrisBiomeCustom;
import com.volmit.iris.engine.object.common.IrisWorld; 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.object.dimensional.IrisDimension;
import com.volmit.iris.engine.platform.BukkitChunkGenerator; import com.volmit.iris.engine.platform.BukkitChunkGenerator;
import com.volmit.iris.util.collection.KList; 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.collection.KSet;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; 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.M;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.parallel.MultiBurst; import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.plugin.Metrics; import com.volmit.iris.util.plugin.*;
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.reflect.ShadeFix; import com.volmit.iris.util.reflect.ShadeFix;
import com.volmit.iris.util.scheduling.GroupedExecutor; import com.volmit.iris.util.scheduling.*;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Queue;
import com.volmit.iris.util.scheduling.ShurikenQueue;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.serializer.ComponentSerializer; import net.kyori.adventure.text.serializer.ComponentSerializer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -75,22 +68,17 @@ import java.io.*;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.net.URL; import java.net.URL;
import java.util.Date; import java.util.Date;
import java.util.Map;
@SuppressWarnings("CanBeFinal") @SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener { public class Iris extends VolmitPlugin implements Listener {
private KMap<Class<? extends IrisService>, IrisService> services;
public static KList<GroupedExecutor> executors = new KList<>(); public static KList<GroupedExecutor> executors = new KList<>();
public static Iris instance; public static Iris instance;
public static BukkitAudiences audiences; 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 MultiverseCoreLink linkMultiverseCore;
public static OraxenLink linkOraxen; public static OraxenLink linkOraxen;
public static MythicMobsLink linkMythicMobs; public static MythicMobsLink linkMythicMobs;
public static CommandManager commandManager;
public static TreeManager saplingManager;
private static final Queue<Runnable> syncJobs = new ShurikenQueue<>(); private static final Queue<Runnable> syncJobs = new ShurikenQueue<>();
public static IrisCompat compat; public static IrisCompat compat;
public static FileWatcher configWatcher; public static FileWatcher configWatcher;
@ -105,68 +93,76 @@ public class Iris extends VolmitPlugin implements Listener {
@com.volmit.iris.util.plugin.Command @com.volmit.iris.util.plugin.Command
public CommandIrisStudio commandStudio; public CommandIrisStudio commandStudio;
public Iris() { private void preEnable() {
instance = this; instance = this;
INMS.get(); INMS.get();
IO.delete(new File("iris")); IO.delete(new File("iris"));
installDataPacks(); 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); audiences = BukkitAudiences.create(this);
fixShading();
sender = new VolmitSender(Bukkit.getConsoleSender()); sender = new VolmitSender(Bukkit.getConsoleSender());
sender.setTag(getTag()); sender.setTag(getTag());
instance = this; instance = this;
compat = IrisCompat.configured(getDataFile("compat.json")); compat = IrisCompat.configured(getDataFile("compat.json"));
proj = new ProjectManager();
convert = new ConversionManager();
wand = new WandManager();
board = new CoreBoardManager();
linkMultiverseCore = new MultiverseCoreLink(); linkMultiverseCore = new MultiverseCoreLink();
linkOraxen = new OraxenLink(); linkOraxen = new OraxenLink();
linkMythicMobs = new MythicMobsLink(); linkMythicMobs = new MythicMobsLink();
saplingManager = new TreeManager();
edit = new EditManager();
configWatcher = new FileWatcher(getDataFile("settings.json")); configWatcher = new FileWatcher(getDataFile("settings.json"));
commandManager = new CommandManager();
getServer().getPluginManager().registerEvents(new CommandLocate(), this); services.values().forEach(IrisService::onEnable);
getServer().getPluginManager().registerEvents(new WandManager(), this); services.values().forEach(this::registerListener);
getServer().getPluginManager().registerEvents(new DolphinManager(), this); }
getServer().getPluginManager().registerEvents(new VillagerManager(), this);
super.onEnable(); private void postEnable() {
Bukkit.getPluginManager().registerEvents(this, this); J.a(() -> PaperLib.suggestPaper(this));
J.s(this::lateBind); 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(); 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() { public void onDisable() {
if (IrisSettings.get().isStudio()) { for (GroupedExecutor i : executors) {
Iris.debug("Studio Mode Active: Closing Projects"); Iris.debug("Closing Executor " + i.toString());
proj.close(); i.closeNow();
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(); executors.clear();
board.disable();
Iris.debug("Cancelled all tasks");
Bukkit.getScheduler().cancelTasks(this); Bukkit.getScheduler().cancelTasks(this);
Iris.debug("Unregistered all events");
HandlerList.unregisterAll((Plugin) this); HandlerList.unregisterAll((Plugin) this);
Iris.debug("Multiburst Shutting down");
MultiBurst.burst.shutdown(); MultiBurst.burst.shutdown();
Iris.debug("Iris Shutdown");
services.values().forEach(IrisService::onDisable);
services.clear();
super.onDisable(); super.onDisable();
} }
@ -203,15 +199,6 @@ public class Iris extends VolmitPlugin implements Listener {
ShadeFix.fix(ComponentSerializer.class); 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() { private void setupPapi() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new IrisPapiExpansion().register(); new IrisPapiExpansion().register();
@ -330,13 +317,7 @@ public class Iris extends VolmitPlugin implements Listener {
private void bstats() { private void bstats() {
if (IrisSettings.get().getGeneral().isPluginMetrics()) { if (IrisSettings.get().getGeneral().isPluginMetrics()) {
J.s(() -> { J.s(() -> new Metrics(Iris.instance, 8757));
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"));
});
} }
} }
@ -449,7 +430,7 @@ public class Iris extends VolmitPlugin implements Listener {
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
IrisDimension dim; IrisDimension dim;
if (id == null || id.isEmpty()){ if (id == null || id.isEmpty()) {
dim = IrisData.loadAnyDimension(IrisSettings.get().getGenerator().getDefaultWorldType()); dim = IrisData.loadAnyDimension(IrisSettings.get().getGenerator().getDefaultWorldType());
} else { } else {
dim = IrisData.loadAnyDimension(id); dim = IrisData.loadAnyDimension(id);
@ -459,7 +440,7 @@ public class Iris extends VolmitPlugin implements Listener {
if (dim == null) { if (dim == null) {
Iris.warn("Unable to find dimension type " + id + " Looking for online packs..."); 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); dim = IrisData.loadAnyDimension(id);
if (dim == null) { if (dim == null) {
@ -611,12 +592,7 @@ public class Iris extends VolmitPlugin implements Listener {
msg(C.WHITE + string); msg(C.WHITE + string);
} }
public void hit(long hits2) {
board.hits.put(hits2);
}
public void splash() { public void splash() {
J.a(this::verifyDataPacksPost, 20);
if (!IrisSettings.get().getGeneral().isSplashLogoStartup()) { if (!IrisSettings.get().getGeneral().isSplashLogoStartup()) {
return; 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; package com.volmit.iris.core.command;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.MortarCommand;
@ -75,7 +76,7 @@ public class CommandIrisDownload extends MortarCommand {
final String finalPack = pack + "/" + branch; 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; return true;
} }

View File

@ -19,6 +19,7 @@
package com.volmit.iris.core.command; package com.volmit.iris.core.command;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.MortarCommand;
@ -45,7 +46,7 @@ public class CommandIrisUpdateProject extends MortarCommand {
return true; 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; 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; package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; 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.project.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.objects.IrisObject; import com.volmit.iris.engine.object.objects.IrisObject;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
@ -71,7 +89,7 @@ public class CommandIrisObjectAnalyze extends MortarCommand {
IrisObject obj = IrisData.loadAnyObject(args[0]); IrisObject obj = IrisData.loadAnyObject(args[0]);
if (obj == null || obj.getLoadFile() == null) { 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; return;
} }

View File

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

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; 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.collection.KList;
import com.volmit.iris.util.data.Cuboid; import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.math.Direction; import com.volmit.iris.util.math.Direction;
@ -58,13 +58,13 @@ public class CommandIrisObjectExpand extends MortarCommand {
Player p = sender.player(); Player p = sender.player();
if (!WandManager.isHoldingWand(p)) { if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; return true;
} }
int amt = args.length == 1 ? Integer.parseInt(args[0]) : 1; 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 a1 = b[0].clone();
Location a2 = b[1].clone(); Location a2 = b[1].clone();
Cuboid cursor = new Cuboid(a1, a2); Cuboid cursor = new Cuboid(a1, a2);
@ -72,7 +72,7 @@ public class CommandIrisObjectExpand extends MortarCommand {
cursor = cursor.expand(d, amt); cursor = cursor.expand(d, amt);
b[0] = cursor.getLowerNE(); b[0] = cursor.getLowerNE();
b[1] = cursor.getUpperSW(); 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.updateInventory();
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f); 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.Iris;
import com.volmit.iris.core.IrisSettings; 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.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
@ -57,15 +57,15 @@ public class CommandIrisObjectP1 extends MortarCommand {
Player p = sender.player(); Player p = sender.player();
if (!WandManager.isHoldingWand(p)) { if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; return true;
} }
ItemStack wand = p.getInventory().getItemInMainHand(); ItemStack wand = p.getInventory().getItemInMainHand();
if (WandManager.isWand(wand)) { if (WandSVC.isWand(wand)) {
Location[] g = WandManager.getCuboid(wand); Location[] g = WandSVC.getCuboid(wand);
g[0] = p.getLocation().getBlock().getLocation().clone().add(0, -1, 0); g[0] = p.getLocation().getBlock().getLocation().clone().add(0, -1, 0);
if (args.length == 1 && args[0].equals("-l")) { 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(); 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; return true;

View File

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

View File

@ -20,9 +20,9 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; 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.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.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.common.IObjectPlacer; import com.volmit.iris.engine.object.common.IObjectPlacer;
import com.volmit.iris.engine.object.objects.IrisObject; import com.volmit.iris.engine.object.objects.IrisObject;
@ -91,7 +91,7 @@ public class CommandIrisObjectPaste extends MortarCommand {
if (obj == null || obj.getLoadFile() == null) { 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; return true;
} }
@ -188,14 +188,14 @@ public class CommandIrisObjectPaste extends MortarCommand {
CommandIrisObjectUndo.addChanges(sender.player(), futureChanges); CommandIrisObjectUndo.addChanges(sender.player(), futureChanges);
if (intoWand) { 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))); 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; wand = newWand;
p.getInventory().setItemInMainHand(wand); p.getInventory().setItemInMainHand(wand);
sender.sendMessage("Updated wand for " + "objects/" + args[0] + ".iob"); sender.sendMessage("Updated wand for " + "objects/" + args[0] + ".iob");
} else { } else {
int slot = WandManager.findWand(sender.player().getInventory()); int slot = WandSVC.findWand(sender.player().getInventory());
if (slot == -1) { if (slot == -1) {
p.getInventory().addItem(newWand); p.getInventory().addItem(newWand);
sender.sendMessage("Given new wand for " + "objects/" + args[0] + ".iob"); 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.Iris;
import com.volmit.iris.core.IrisSettings; 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.engine.object.objects.IrisObject;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.MortarCommand;
@ -75,8 +76,8 @@ public class CommandIrisObjectSave extends MortarCommand {
Player p = sender.player(); Player p = sender.player();
ItemStack wand = p.getInventory().getItemInMainHand(); ItemStack wand = p.getInventory().getItemInMainHand();
IrisObject o = WandManager.createSchematic(wand); IrisObject o = WandSVC.createSchematic(wand);
File file = Iris.proj.getWorkspaceFile(args[0], "objects", args[1] + ".iob"); File file = Iris.service(StudioSVC.class).getWorkspaceFile(args[0], "objects", args[1] + ".iob");
if (file.exists()) { if (file.exists()) {
if (!overwrite) { if (!overwrite) {

View File

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

View File

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

View File

@ -20,7 +20,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; 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.collection.KList;
import com.volmit.iris.util.data.Cuboid; import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.data.Cuboid.CuboidDirection; import com.volmit.iris.util.data.Cuboid.CuboidDirection;
@ -60,12 +60,12 @@ public class CommandIrisObjectXAY extends MortarCommand {
Player p = sender.player(); Player p = sender.player();
if (!WandManager.isHoldingWand(p)) { if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; return true;
} }
Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand()); Location[] b = WandSVC.getCuboid(p.getInventory().getItemInMainHand());
Location a1 = b[0].clone(); Location a1 = b[0].clone();
Location a2 = b[1].clone(); Location a2 = b[1].clone();
Location a1x = b[0].clone(); Location a1x = b[0].clone();
@ -99,7 +99,7 @@ public class CommandIrisObjectXAY extends MortarCommand {
cursor = cursor.contract(CuboidDirection.West); cursor = cursor.contract(CuboidDirection.West);
b[0] = cursor.getLowerNE(); b[0] = cursor.getLowerNE();
b[1] = cursor.getUpperSW(); 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.updateInventory();
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f); 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.Iris;
import com.volmit.iris.core.IrisSettings; 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.collection.KList;
import com.volmit.iris.util.data.Cuboid; import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.data.Cuboid.CuboidDirection; import com.volmit.iris.util.data.Cuboid.CuboidDirection;
@ -59,11 +59,11 @@ public class CommandIrisObjectXPY extends MortarCommand {
Player p = sender.player(); Player p = sender.player();
if (!WandManager.isHoldingWand(p)) { if (!WandSVC.isHoldingWand(p)) {
sender.sendMessage("Ready your Wand."); sender.sendMessage("Ready your Wand.");
return true; 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[0].add(new Vector(0, 1, 0));
b[1].add(new Vector(0, 1, 0)); b[1].add(new Vector(0, 1, 0));
Location a1 = b[0].clone(); Location a1 = b[0].clone();
@ -87,7 +87,7 @@ public class CommandIrisObjectXPY extends MortarCommand {
cursor = cursor.contract(CuboidDirection.West); cursor = cursor.contract(CuboidDirection.West);
b[0] = cursor.getLowerNE(); b[0] = cursor.getLowerNE();
b[1] = cursor.getUpperSW(); 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.updateInventory();
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f); 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; package com.volmit.iris.core.command.pregen;
import com.volmit.iris.Iris; 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; package com.volmit.iris.core.command.pregen;
import com.volmit.iris.Iris; 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; package com.volmit.iris.core.command.pregen;
import com.volmit.iris.Iris; 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.Iris;
import com.volmit.iris.core.IrisSettings; 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.collection.KList;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.io.IO; import com.volmit.iris.util.io.IO;
@ -54,12 +55,12 @@ public class CommandIrisStudioBeautify extends MortarCommand {
File clean = null; File clean = null;
if (args.length == 0) { 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."); sender.sendMessage("No open project. Either use /iris std beautify <project> or have a project open.");
return true; return true;
} }
clean = Iris.proj.getActiveProject().getPath(); clean = Iris.service(StudioSVC.class).getActiveProject().getPath();
} else { } else {
clean = Iris.instance.getDataFolder("packs", args[0]); clean = Iris.instance.getDataFolder("packs", args[0]);
@ -73,6 +74,7 @@ public class CommandIrisStudioBeautify extends MortarCommand {
return true; return true;
} }
private int clean(VolmitSender s, File clean) { private int clean(VolmitSender s, File clean) {
int c = 0; int c = 0;
if (clean.isDirectory()) { if (clean.isDirectory()) {
@ -130,7 +132,6 @@ public class CommandIrisStudioBeautify extends MortarCommand {
} }
@Override @Override
protected String getArgsUsage() { protected String getArgsUsage() {
return "[project]"; return "[project]";

View File

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

View File

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

View File

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

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; 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.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
@ -48,7 +49,7 @@ public class CommandIrisStudioEditBiome extends MortarCommand {
return true; return true;
} }
if (!Iris.proj.isProjectOpen()) { if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender.sendMessage("There is not a studio currently loaded."); sender.sendMessage("There is not a studio currently loaded.");
return true; return true;
} }
@ -57,7 +58,7 @@ public class CommandIrisStudioEditBiome extends MortarCommand {
Player p = sender.player(); Player p = sender.player();
try { 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); Desktop.getDesktop().open(f);
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(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.IrisSettings;
import com.volmit.iris.core.gui.NoiseExplorerGUI; import com.volmit.iris.core.gui.NoiseExplorerGUI;
import com.volmit.iris.core.project.loader.IrisData; 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.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.noise.IrisGenerator; import com.volmit.iris.engine.object.noise.IrisGenerator;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
@ -75,9 +76,9 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand {
Supplier<Function2<Double, Double, Double>> l = () -> { Supplier<Function2<Double, Double, Double>> l = () -> {
long seed = 12345; long seed = 12345;
IrisGenerator generator; IrisGenerator generator;
if (Iris.proj.isProjectOpen()) { if (Iris.service(StudioSVC.class).isProjectOpen()) {
generator = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]); generator = Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]);
seed = Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().seed(); seed = Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getTarget().getWorld().seed();
} else { } else {
generator = IrisData.loadAnyGenerator(args[0]); 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.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.loot.IrisLootTable; import com.volmit.iris.engine.object.loot.IrisLootTable;
@ -58,7 +59,7 @@ public class CommandIrisStudioLoot extends MortarCommand {
Player p = sender.player(); Player p = sender.player();
Engine prov = IrisToolbelt.access(sender.player().getWorld()).getEngine(); 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."); sender.sendMessage("You can only use /iris studio loot in a studio world of iris.");
return true; return true;
} }
@ -67,7 +68,7 @@ public class CommandIrisStudioLoot extends MortarCommand {
Inventory inv = Bukkit.createInventory(null, 27 * 2); Inventory inv = Bukkit.createInventory(null, 27 * 2);
try { 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) { } catch (Throwable e) {
Iris.reportError(e); Iris.reportError(e);
sender.sendMessage("You can only use /iris loot in a studio world of iris."); 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(); 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)); }, 0, fast ? 5 : 35));
return true; return true;

View File

@ -21,6 +21,7 @@ package com.volmit.iris.core.command.studio;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.gui.VisionGUI; 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.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
@ -55,7 +56,7 @@ public class CommandIrisStudioMap extends MortarCommand {
Engine fe; Engine fe;
try { try {
Engine g = Iris.proj.getActiveProject().getActiveProvider().getEngine(); Engine g = Iris.service(StudioSVC.class).getActiveProject().getActiveProvider().getEngine();
VisionGUI.launch(g, 0); VisionGUI.launch(g, 0);
sender.sendMessage("Opening Map!"); sender.sendMessage("Opening Map!");
} catch (Throwable e) { } 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.Iris;
import com.volmit.iris.core.IrisSettings; 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.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
@ -50,7 +51,7 @@ public class CommandIrisStudioOpen extends MortarCommand {
} }
sender.sendMessage("Opening studio world..."); sender.sendMessage("Opening studio world...");
Iris.proj.open(sender, args[0]); Iris.service(StudioSVC.class).open(sender, args[0]);
return true; return true;
} }

View File

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

View File

@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.project.IrisProject; import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.project.loader.IrisData; 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.IrisBiome;
import com.volmit.iris.engine.object.biome.IrisBiomePaletteLayer; import com.volmit.iris.engine.object.biome.IrisBiomePaletteLayer;
import com.volmit.iris.engine.object.noise.IrisGenerator; import com.volmit.iris.engine.object.noise.IrisGenerator;
@ -70,12 +71,12 @@ public class CommandIrisStudioProfile extends MortarCommand {
File report = Iris.instance.getDataFile("profile.txt"); File report = Iris.instance.getDataFile("profile.txt");
KList<String> v = new KList<>(); KList<String> v = new KList<>();
if (args.length == 0) { 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."); sender.sendMessage("No open project. Either use /iris std beautify <project> or have a project open.");
return; return;
} }
f = Iris.proj.getActiveProject().getPath(); f = Iris.service(StudioSVC.class).getActiveProject().getPath();
} else { } else {
f = Iris.instance.getDataFolder("packs", args[0]); 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.Iris;
import com.volmit.iris.core.IrisSettings; 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.collection.KList;
import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
@ -50,14 +51,14 @@ public class CommandIrisStudioTPStudio extends MortarCommand {
return true; return true;
} }
if (!Iris.proj.isProjectOpen()) { if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender.sendMessage("There is not a studio currently loaded."); sender.sendMessage("There is not a studio currently loaded.");
return true; return true;
} }
try { try {
sender.sendMessage("Teleporting you to the active studio world."); 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); sender.player().setGameMode(GameMode.SPECTATOR);
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(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.IrisSettings;
import com.volmit.iris.core.project.IrisProject; import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.project.loader.IrisData; 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.engine.object.objects.IrisObject;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
@ -62,7 +63,7 @@ public class CommandIrisStudioUpdate extends MortarCommand {
for (String i : args) { for (String i : args) {
if (i.equals("--rewrite-objects")) { 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; int t = data.getObjectLoader().getPossibleKeys().length;
ChronoLatch cl = new ChronoLatch(250, false); ChronoLatch cl = new ChronoLatch(250, false);
MultiBurst bx = new MultiBurst("Object Rewriter", Thread.MIN_PRIORITY, Runtime.getRuntime().availableProcessors()); 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]); sender.sendMessage("Updated Code Workspace for " + args[0]);
} else { } else {
sender.sendMessage("Invalid project: " + args[0] + ". Try deleting the code-workspace file and try again."); 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.google.gson.Gson;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisToolbelt; 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.engine.object.feature.IrisFeaturePositional;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.json.JSONObject; 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.Iris;
import com.volmit.iris.core.IrisSettings; 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.IrisToolbelt;
import com.volmit.iris.core.tools.IrisWorldCreator;
import com.volmit.iris.engine.object.dimensional.IrisDimension; 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.collection.KList;
import com.volmit.iris.util.exceptions.IrisException; 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.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; 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.io.File;
import java.util.Random; import java.util.Random;
import java.util.concurrent.atomic.AtomicReference;
public class CommandIrisCreate extends MortarCommand { public class CommandIrisCreate extends MortarCommand {
public CommandIrisCreate() { public CommandIrisCreate() {
@ -128,7 +119,6 @@ public class CommandIrisCreate extends MortarCommand {
String finalDimensionName = dimensionName; String finalDimensionName = dimensionName;
long finalSeed = seed; long finalSeed = seed;
J.a(() -> { J.a(() -> {
try { try {

View File

@ -19,6 +19,7 @@
package com.volmit.iris.core.command.world; package com.volmit.iris.core.command.world;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.MortarCommand;
@ -64,10 +65,10 @@ public class CommandIrisUpdateWorld extends MortarCommand {
folder.mkdirs(); folder.mkdirs();
if (bfre) { 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; return true;

View File

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

View File

@ -20,6 +20,7 @@ package com.volmit.iris.core.decrees;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.dimensional.IrisDimension; import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.util.decree.DecreeExecutor; 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.Decree;
import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.decree.annotations.Param;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.M;
import java.io.File; 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") @Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command")
public class DecIris implements DecreeExecutor public class DecIris implements DecreeExecutor {
{
private DecStudio studio; private DecStudio studio;
private DecPregen pregen; private DecPregen pregen;
@ -40,19 +45,19 @@ public class DecIris implements DecreeExecutor
@Decree(description = "Create a new world", aliases = "+") @Decree(description = "Create a new world", aliases = "+")
public void create( public void create(
@Param(aliases = "world-name", description = "The name of the world to create", defaultValue = "IrisWorld") @Param(aliases = "world-name", description = "The name of the world to create", defaultValue = "IrisWorld")
String name, String name,
@Param(aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld") @Param(aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld")
IrisDimension type, IrisDimension type,
@Param(description = "The seed to generate the world with", defaultValue = "1337") @Param(description = "The seed to generate the world with", defaultValue = "1337")
long seed long seed
){ ) {
if (name.equals("iris")) { 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 + "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?"); sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?");
return; return;
} }
if (new File(name).exists()){ if (new File(name).exists()) {
sender().sendMessage(C.RED + "That folder already exists!"); sender().sendMessage(C.RED + "That folder already exists!");
return; return;
} }
@ -65,7 +70,7 @@ public class DecIris implements DecreeExecutor
.sender(sender()) .sender(sender())
.studio(false) .studio(false)
.create(); .create();
} catch (Throwable e){ } catch (Throwable e) {
sender().sendMessage(C.RED + "Exception raised during creation. See the console for more details."); sender().sendMessage(C.RED + "Exception raised during creation. See the console for more details.");
Iris.error("Exception raised during world creation: " + e.getMessage()); Iris.error("Exception raised during world creation: " + e.getMessage());
Iris.reportError(e); Iris.reportError(e);
@ -76,18 +81,18 @@ public class DecIris implements DecreeExecutor
} }
@Decree(description = "Print version information") @Decree(description = "Print version information")
public void version(){ public void version() {
sender().sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); sender().sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
} }
@Decree(description = "Set aura spins") @Decree(description = "Set aura spins")
public void aura( public void aura(
@Param(description = "The h color value", defaultValue = "-20") @Param(description = "The h color value", defaultValue = "-20")
int h, int h,
@Param(description = "The s color value", defaultValue = "7") @Param(description = "The s color value", defaultValue = "7")
int s, int s,
@Param(description = "The b color value", defaultValue = "8") @Param(description = "The b color value", defaultValue = "8")
int b int b
) { ) {
IrisSettings.get().getGeneral().setSpinh(h); IrisSettings.get().getGeneral().setSpinh(h);
IrisSettings.get().getGeneral().setSpins(s); IrisSettings.get().getGeneral().setSpins(s);
@ -99,14 +104,14 @@ public class DecIris implements DecreeExecutor
@Decree(description = "Bitwise calculations") @Decree(description = "Bitwise calculations")
public void bitwise( public void bitwise(
@Param(description = "The first value to run calculations on") @Param(description = "The first value to run calculations on")
int value1, int value1,
@Param(description = "The operator: | & ^ >> << %") @Param(description = "The operator: | & ^ >> << %")
String operator, String operator,
@Param(description = "The second value to run calculations on") @Param(description = "The second value to run calculations on")
int value2 int value2
) { ) {
Integer v = null; Integer v = null;
switch(operator) { switch (operator) {
case "|" -> v = value1 | value2; case "|" -> v = value1 | value2;
case "&" -> v = value1 & value2; case "&" -> v = value1 & value2;
case "^" -> v = value1 ^ value2; case "^" -> v = value1 ^ value2;
@ -124,7 +129,7 @@ public class DecIris implements DecreeExecutor
@Decree(description = "Toggle debug") @Decree(description = "Toggle debug")
public void debug( public void debug(
@Param(name = "on", description = "Whether or not debug should be on", defaultValue = "true") @Param(name = "on", description = "Whether or not debug should be on", defaultValue = "true")
boolean on boolean on
) { ) {
IrisSettings.get().getGeneral().setDebug(on); IrisSettings.get().getGeneral().setDebug(on);
} }
@ -132,21 +137,21 @@ public class DecIris implements DecreeExecutor
@Decree(description = "Download a project.") @Decree(description = "Download a project.")
public void download( public void download(
@Param(name = "pack", description = "The pack to download", defaultValue = "overworld", aliases = "project") @Param(name = "pack", description = "The pack to download", defaultValue = "overworld", aliases = "project")
String pack, String pack,
@Param(name = "branch", description = "The branch to download from", defaultValue = "master") @Param(name = "branch", description = "The branch to download from", defaultValue = "master")
String branch, String branch,
@Param(name = "trim", description = "Whether or not to download a trimmed version (do not enable when editing)", defaultValue = "false") @Param(name = "trim", description = "Whether or not to download a trimmed version (do not enable when editing)", defaultValue = "false")
boolean trim, boolean trim,
@Param(name = "overwrite", description = "Whether or not to overwrite the pack with the downloaded one", aliases = "force", defaultValue = "false") @Param(name = "overwrite", description = "Whether or not to overwrite the pack with the downloaded one", aliases = "force", defaultValue = "false")
boolean overwrite boolean overwrite
) { ) {
sender().sendMessage(C.GREEN + "Downloading pack: " + pack + "/" + branch + (trim ? " trimmed" : "")); 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) @Decree(description = "Get metrics for your world", aliases = "measure", origin = DecreeOrigin.PLAYER)
public void metrics() { public void metrics() {
if (!IrisToolbelt.isIrisWorld(world())){ if (!IrisToolbelt.isIrisWorld(world())) {
sender().sendMessage(C.RED + "You must be in an Iris world"); sender().sendMessage(C.RED + "You must be in an Iris world");
return; 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; package com.volmit.iris.core.decrees;
import com.volmit.iris.Iris; 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.decree.annotations.Param;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.Position2; import com.volmit.iris.util.math.Position2;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -17,12 +34,12 @@ import org.bukkit.util.Vector;
public class DecPregen implements DecreeExecutor { public class DecPregen implements DecreeExecutor {
@Decree(description = "Pregenerate a world") @Decree(description = "Pregenerate a world")
public void start( public void start(
@Param(description = "The world to pregen", contextual = true) @Param(description = "The world to pregen", contextual = true)
World world, World world,
@Param(description = "The radius of the pregen in blocks", aliases = "size") @Param(description = "The radius of the pregen in blocks", aliases = "size")
int radius, int radius,
@Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0") @Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0")
Vector center Vector center
) { ) {
try { try {
IrisToolbelt.pregenerate(PregenTask IrisToolbelt.pregenerate(PregenTask
@ -40,7 +57,7 @@ public class DecPregen implements DecreeExecutor {
} }
@Decree(description = "Stop the active pregeneration task", aliases = "x") @Decree(description = "Stop the active pregeneration task", aliases = "x")
public void stop(){ public void stop() {
if (PregeneratorJob.shutdownInstance()) { if (PregeneratorJob.shutdownInstance()) {
sender().sendMessage(C.GREEN + "Stopped pregeneration task"); sender().sendMessage(C.GREEN + "Stopped pregeneration task");
} else { } else {

View File

@ -20,7 +20,6 @@ package com.volmit.iris.core.decrees;
import com.volmit.iris.util.decree.DecreeExecutor; 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.gui.VisionGUI;
import com.volmit.iris.core.project.IrisProject; import com.volmit.iris.core.project.IrisProject;
import com.volmit.iris.core.project.loader.IrisData; 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.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.basic.IrisPosition; import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.engine.object.biome.IrisBiome; 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") @Param(defaultValue = "1337", description = "The seed to generate the studio with", aliases = "s")
long seed) { long seed) {
sender().sendMessage(C.GREEN + "Opening studio for the \"" + dimension.getName() + "\" pack (seed: " + 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) @Decree(description = "Close an open studio project", aliases = "x", sync = true)
public void close() { public void close() {
if (!Iris.proj.isProjectOpen()) { if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender().sendMessage(C.RED + "No open studio projects."); sender().sendMessage(C.RED + "No open studio projects.");
return; return;
} }
Iris.proj.close(); Iris.service(StudioSVC.class).close();
sender().sendMessage(C.GREEN + "Project Closed."); sender().sendMessage(C.GREEN + "Project Closed.");
} }
@ -108,12 +110,11 @@ public class DecStudio implements DecreeExecutor {
@Param(description = "The name of this new Iris Project.") @Param(description = "The name of this new Iris Project.")
String name, 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) @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) { if (template != null) {
Iris.proj.create(sender(), name, template.getLoadKey()); Iris.service(StudioSVC.class).create(sender(), name, template.getLoadKey());
} else { } 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); MultiBurst burst = new MultiBurst("Cleaner", Thread.MIN_PRIORITY, Runtime.getRuntime().availableProcessors() * 2);
jobs.add(new SingleJob("Updating Workspace", () -> { 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."); sender().sendMessage(C.GOLD + "Invalid project: " + project.getLoadKey() + ". Try deleting the code-workspace file and try again.");
} }
J.sleep(250); J.sleep(250);
@ -145,8 +146,7 @@ public class DecStudio implements DecreeExecutor {
sender().sendMessage("Files: " + files.size()); sender().sendMessage("Files: " + files.size());
if(fixIds) if (fixIds) {
{
QueueJob<File> r = new QueueJob<>() { QueueJob<File> r = new QueueJob<>() {
@Override @Override
public void execute(File f) { public void execute(File f) {
@ -171,8 +171,7 @@ public class DecStudio implements DecreeExecutor {
jobs.add(r); jobs.add(r);
} }
if(beautify) if (beautify) {
{
QueueJob<File> r = new QueueJob<>() { QueueJob<File> r = new QueueJob<>() {
@Override @Override
public void execute(File f) { public void execute(File f) {
@ -195,8 +194,7 @@ public class DecStudio implements DecreeExecutor {
jobs.add(r); jobs.add(r);
} }
if(rewriteObjects) if (rewriteObjects) {
{
QueueJob<Runnable> q = new QueueJob<>() { QueueJob<Runnable> q = new QueueJob<>() {
@Override @Override
public void execute(Runnable runnable) { 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()) { for (String f : data.getObjectLoader().getPossibleKeys()) {
CompletableFuture<?> gg = burst.complete(() ->{ CompletableFuture<?> gg = burst.complete(() -> {
File ff = data.getObjectLoader().findFile(f); File ff = data.getObjectLoader().findFile(f);
IrisObject oo = new IrisObject(0, 0, 0); IrisObject oo = new IrisObject(0, 0, 0);
try { try {
@ -256,14 +254,14 @@ public class DecStudio implements DecreeExecutor {
@Decree(description = "Convert objects in the \"convert\" folder") @Decree(description = "Convert objects in the \"convert\" folder")
public void convert() { public void convert() {
Iris.convert.check(sender()); Iris.service(ConversionSVC.class).check(sender());
} }
@Decree(description = "Edit the biome you are currently in", aliases = {"ebiome", "eb"}, origin = DecreeOrigin.PLAYER) @Decree(description = "Edit the biome you are currently in", aliases = {"ebiome", "eb"}, origin = DecreeOrigin.PLAYER)
public void editbiome( public void editbiome(
@Param(contextual = true, description = "The biome to edit") @Param(contextual = true, description = "The biome to edit")
IrisBiome biome IrisBiome biome
) { ) {
if (noStudio()) return; if (noStudio()) return;
@ -301,7 +299,7 @@ public class DecStudio implements DecreeExecutor {
IrisGenerator generator, IrisGenerator generator,
@Param(description = "The seed to generate with", defaultValue = "12345") @Param(description = "The seed to generate with", defaultValue = "12345")
long seed long seed
){ ) {
if (noGUI()) return; if (noGUI()) return;
sender().sendMessage(C.GREEN + "Opening Noise Explorer!"); sender().sendMessage(C.GREEN + "Opening Noise Explorer!");
@ -322,13 +320,13 @@ public class DecStudio implements DecreeExecutor {
IrisBiome biome, IrisBiome biome,
@Param(description = "The region to find", contextual = true) @Param(description = "The region to find", contextual = true)
IrisRegion region 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!"); sender().sendMessage(C.RED + "You must be in an Iris world to use this command!");
return; return;
} }
if (biome == null && region == null){ if (biome == null && region == null) {
sender().sendMessage(C.RED + "You must specify a biome or region!"); sender().sendMessage(C.RED + "You must specify a biome or region!");
return; return;
} }
@ -371,9 +369,9 @@ public class DecStudio implements DecreeExecutor {
@Decree(description = "Show loot if a chest were right here", origin = DecreeOrigin.PLAYER, sync = true) @Decree(description = "Show loot if a chest were right here", origin = DecreeOrigin.PLAYER, sync = true)
public void loot( public void loot(
@Param(description = "Fast insertion of items in virtual inventory (may cause performance drop)", defaultValue = "false") @Param(description = "Fast insertion of items in virtual inventory (may cause performance drop)", defaultValue = "false")
boolean fast, boolean fast,
@Param(description = "Whether or not to append to the inventory currently open (if false, clears opened inventory)", defaultValue = "true") @Param(description = "Whether or not to append to the inventory currently open (if false, clears opened inventory)", defaultValue = "true")
boolean add boolean add
) { ) {
if (noStudio()) return; if (noStudio()) return;
@ -382,7 +380,7 @@ public class DecStudio implements DecreeExecutor {
try { try {
engine().addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ(), 1); 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); Iris.reportError(e);
sender().sendMessage(C.RED + "Cannot add items to virtual inventory because of: " + e.getMessage()); sender().sendMessage(C.RED + "Cannot add items to virtual inventory because of: " + e.getMessage());
return; return;
@ -412,8 +410,7 @@ public class DecStudio implements DecreeExecutor {
} }
@Decree(description = "Render a world map (External GUI)", aliases = "render") @Decree(description = "Render a world map (External GUI)", aliases = "render")
public void map() public void map() {
{
if (noStudio()) return; if (noStudio()) return;
if (noGUI()) return; if (noGUI()) return;
@ -425,20 +422,20 @@ public class DecStudio implements DecreeExecutor {
@Decree(description = "Package a dimension into a compressed format", aliases = "package") @Decree(description = "Package a dimension into a compressed format", aliases = "package")
public void pkg( public void pkg(
@Param(name = "dimension", description = "The dimension pack to compress", contextual = true, defaultValue = "overworld") @Param(name = "dimension", description = "The dimension pack to compress", contextual = true, defaultValue = "overworld")
IrisDimension dimension, IrisDimension dimension,
@Param(name = "obfuscate", description = "Whether or not to obfuscate the pack", defaultValue = "false") @Param(name = "obfuscate", description = "Whether or not to obfuscate the pack", defaultValue = "false")
boolean obfuscate, boolean obfuscate,
@Param(name = "minify", description = "Whether or not to minify the pack", defaultValue = "true") @Param(name = "minify", description = "Whether or not to minify the pack", defaultValue = "true")
boolean minify 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) @Decree(description = "Profiles the performance of a dimension", origin = DecreeOrigin.PLAYER)
public void profile( public void profile(
@Param(description = "The dimension to profile", contextual = true, defaultValue = "overworld") @Param(description = "The dimension to profile", contextual = true, defaultValue = "overworld")
IrisDimension dimension IrisDimension dimension
){ ) {
File pack = dimension.getLoadFile().getParentFile().getParentFile(); File pack = dimension.getLoadFile().getParentFile().getParentFile();
File report = Iris.instance.getDataFile("profile.txt"); File report = Iris.instance.getDataFile("profile.txt");
IrisProject project = new IrisProject(pack); IrisProject project = new IrisProject(pack);
@ -625,13 +622,13 @@ public class DecStudio implements DecreeExecutor {
@Decree(description = "Summon an Iris Entity", origin = DecreeOrigin.PLAYER) @Decree(description = "Summon an Iris Entity", origin = DecreeOrigin.PLAYER)
public void summon( public void summon(
@Param(description = "The Iris Entity to spawn") @Param(description = "The Iris Entity to spawn")
IrisEntity entity 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)"); 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; return;
} }
if (IrisToolbelt.isIrisWorld(world())){ if (IrisToolbelt.isIrisWorld(world())) {
sender().sendMessage(C.RED + "You can only spawn entities in Iris worlds!"); sender().sendMessage(C.RED + "You can only spawn entities in Iris worlds!");
return; return;
} }
@ -640,27 +637,27 @@ public class DecStudio implements DecreeExecutor {
} }
@Decree(description = "Teleport to the active studio world", aliases = "stp", origin = DecreeOrigin.PLAYER, sync = true) @Decree(description = "Teleport to the active studio world", aliases = "stp", origin = DecreeOrigin.PLAYER, sync = true)
public void tpstudio(){ public void tpstudio() {
if (!Iris.proj.isProjectOpen()){ if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender().sendMessage(C.RED + "No studio world is open!"); sender().sendMessage(C.RED + "No studio world is open!");
return; return;
} }
if (IrisToolbelt.isIrisWorld(world()) && engine().isStudio()){ if (IrisToolbelt.isIrisWorld(world()) && engine().isStudio()) {
sender().sendMessage(C.RED + "You are already in a studio world!"); sender().sendMessage(C.RED + "You are already in a studio world!");
return; return;
} }
sender().sendMessage(C.GREEN + "Sending you to the studio world!"); 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); player().setGameMode(GameMode.SPECTATOR);
} }
@Decree(description = "Update your dimension project") @Decree(description = "Update your dimension project")
public void update( public void update(
@Param(description = "The dimension to update the workspace of", contextual = true, defaultValue = "overworld") @Param(description = "The dimension to update the workspace of", contextual = true, defaultValue = "overworld")
IrisDimension dimension IrisDimension dimension
){ ) {
if (new IrisProject(dimension.getLoadFile().getParentFile().getParentFile()).updateWorkspace()) { if (new IrisProject(dimension.getLoadFile().getParentFile().getParentFile()).updateWorkspace()) {
sender().sendMessage(C.GREEN + "Updated Code Workspace for " + dimension.getName()); sender().sendMessage(C.GREEN + "Updated Code Workspace for " + dimension.getName());
} else { } else {
@ -680,7 +677,7 @@ public class DecStudio implements DecreeExecutor {
boolean look, boolean look,
@Param(description = "Whether or not to show information about the block you are holding", defaultValue = "true") @Param(description = "Whether or not to show information about the block you are holding", defaultValue = "true")
boolean hand boolean hand
){ ) {
// Data // Data
BlockData handHeld = player().getInventory().getItemInMainHand().getType().createBlockData(); BlockData handHeld = player().getInventory().getItemInMainHand().getType().createBlockData();
Block targetBlock = player().getTargetBlockExact(128, FluidCollisionMode.NEVER); Block targetBlock = player().getTargetBlockExact(128, FluidCollisionMode.NEVER);
@ -706,7 +703,7 @@ public class DecStudio implements DecreeExecutor {
} }
// Target // Target
if (targetBlockData == null){ if (targetBlockData == null) {
sender().sendMessage(C.RED + "Not looking at any block"); sender().sendMessage(C.RED + "Not looking at any block");
} else if (look) { } else if (look) {
sender().sendMessage(C.GREEN + "" + C.BOLD + "Looked-at block information"); 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 * @return true if server GUIs are not enabled
*/ */
private boolean noGUI() { 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!"); sender().sendMessage(C.RED + "You must have server launched GUIs enabled in the settings!");
return true; 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 * @return true if no studio is open or the player is not in one
*/ */
private boolean noStudio(){ private boolean noStudio() {
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)"); 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; return true;
} }
if (!Iris.proj.isProjectOpen()){ if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender().sendMessage(C.RED + "No studio world is open!"); sender().sendMessage(C.RED + "No studio world is open!");
return true; return true;
} }
if (!engine().isStudio()){ if (!engine().isStudio()) {
sender().sendMessage(C.RED + "You must be in a studio world!"); sender().sendMessage(C.RED + "You must be in a studio world!");
return true; 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()) { if (clean.isDirectory()) {
for (File i : clean.listFiles()) { for (File i : clean.listFiles()) {
files(i, files); files(i, files);

View File

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

View File

@ -228,7 +228,7 @@ public class NMSBinding17_1 implements INMSBinding {
@Override @Override
public Object getCustomBiomeBaseFor(String mckey) { public Object getCustomBiomeBaseFor(String mckey) {
try { 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) { } catch (Throwable e) {
Iris.reportError(e); Iris.reportError(e);
} }

View File

@ -18,11 +18,15 @@
package com.volmit.iris.core.project; package com.volmit.iris.core.project;
import com.volmit.iris.core.project.loader.IrisData; import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.dimensional.IrisDimension; 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 lombok.Data;
import java.io.File; import java.io.File;
import java.net.MalformedURLException;
@Data @Data
public class IrisPack { public class IrisPack {
@ -33,8 +37,21 @@ public class IrisPack {
this.folder = folder; 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.google.gson.Gson;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; 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.IrisData;
import com.volmit.iris.core.project.loader.ResourceLoader; import com.volmit.iris.core.project.loader.ResourceLoader;
import com.volmit.iris.core.tools.IrisToolbelt; 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.biome.IrisBiome;
import com.volmit.iris.engine.object.block.IrisBlockData; import com.volmit.iris.engine.object.block.IrisBlockData;
import com.volmit.iris.engine.object.dimensional.IrisDimension; 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.KMap;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.exceptions.IrisException; 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.format.Form;
import com.volmit.iris.util.io.IO; import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.json.JSONArray; 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.O;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Data; import lombok.Data;
import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit;
import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.GameMode;
import org.bukkit.*;
import org.zeroturnaround.zip.ZipUtil; import org.zeroturnaround.zip.ZipUtil;
import java.awt.*; import java.awt.*;
@ -448,7 +444,6 @@ public class IrisProject {
} }
public static int clean(VolmitSender s, File clean) { public static int clean(VolmitSender s, File clean) {
int c = 0; int c = 0;
if (clean.isDirectory()) { if (clean.isDirectory()) {

View File

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

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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.Gson;
import com.volmit.iris.Iris; 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.CompoundTag;
import com.volmit.iris.util.nbt.tag.IntTag; import com.volmit.iris.util.nbt.tag.IntTag;
import com.volmit.iris.util.nbt.tag.ListTag; 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.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import org.bukkit.Material; import org.bukkit.Material;
@ -49,11 +50,9 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class ConversionManager { public class ConversionSVC implements IrisService {
private final KList<Converter> converters; @Override
private final File folder; public void onEnable() {
public ConversionManager() {
folder = Iris.instance.getDataFolder("convert"); folder = Iris.instance.getDataFolder("convert");
converters = new KList<>(); converters = new KList<>();
@ -64,6 +63,14 @@ public class ConversionManager {
}), 5); }), 5);
} }
@Override
public void onDisable() {
}
private KList<Converter> converters;
private File folder;
private String toPoolName(String poolReference) { private String toPoolName(String poolReference) {
return poolReference.split("\\Q:\\E")[1]; 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/>. * 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.Iris;
import com.volmit.iris.core.edit.BlockEditor; import com.volmit.iris.core.edit.BlockEditor;
import com.volmit.iris.core.edit.BukkitBlockEditor; import com.volmit.iris.core.edit.BukkitBlockEditor;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.plugin.IrisService;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.event.world.WorldUnloadEvent;
public class EditManager implements Listener { public class EditSVC implements IrisService {
private final KMap<World, BlockEditor> editors; private KMap<World, BlockEditor> editors;
public EditManager() { @Override
public void onEnable() {
this.editors = new KMap<>(); this.editors = new KMap<>();
Iris.instance.registerListener(this); Iris.info("EDIT SVC ENABLED!");
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::update, 0, 0); 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) { public BlockData get(World world, int x, int y, int z) {
@ -90,11 +96,10 @@ public class EditManager implements Listener {
return editors.get(world); return editors.get(world);
} }
BlockEditor e = null; BlockEditor e = new BukkitBlockEditor(world);
e = new BukkitBlockEditor(world);
editors.put(world, e); editors.put(world, e);
return e; return e;
} }
} }

View File

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

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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.Iris;
import com.volmit.iris.core.project.loader.IrisData; 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.data.Cuboid;
import com.volmit.iris.util.math.BlockPosition; import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.plugin.IrisService;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; 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.block.data.type.Sapling;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.StructureGrowEvent;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.function.Predicate; import java.util.function.Predicate;
public class TreeManager implements Listener { public class TreeSVC implements IrisService {
private boolean block = false; private boolean block = false;
public TreeManager() { @Override
Iris.instance.registerListener(this); 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.Iris;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.villager.IrisVillagerOverride; import com.volmit.iris.engine.object.villager.IrisVillagerOverride;
import com.volmit.iris.engine.object.villager.IrisVillagerTrade; import com.volmit.iris.engine.object.villager.IrisVillagerTrade;
import com.volmit.iris.util.plugin.IrisService;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.VillagerAcquireTradeEvent; 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 * 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/>. * 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.Iris;
import com.volmit.iris.core.edit.DustRevealer; 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.math.M;
import com.volmit.iris.util.matter.Matter; import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.matter.WorldMatter; 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.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import org.bukkit.*; import org.bukkit.*;
@ -35,7 +36,6 @@ import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
@ -49,12 +49,12 @@ import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
public class WandManager implements Listener { public class WandSVC implements IrisService {
private static ItemStack wand; private static ItemStack wand;
private static ItemStack dust; private static ItemStack dust;
public WandManager() { @Override
public void onEnable() {
wand = createWand(); wand = createWand();
dust = createDust(); dust = createDust();
@ -65,6 +65,11 @@ public class WandManager implements Listener {
}, 0); }, 0);
} }
@Override
public void onDisable() {
}
public void tick(Player p) { public void tick(Player p) {
try { try {
try { try {

View File

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

View File

@ -20,36 +20,22 @@ package com.volmit.iris.core.tools;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ProjectManager;
import com.volmit.iris.core.gui.PregeneratorJob; import com.volmit.iris.core.gui.PregeneratorJob;
import com.volmit.iris.core.pregenerator.PregenTask; import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.pregenerator.PregeneratorMethod; import com.volmit.iris.core.pregenerator.PregeneratorMethod;
import com.volmit.iris.core.pregenerator.methods.HeadlessPregenMethod; import com.volmit.iris.core.pregenerator.methods.HeadlessPregenMethod;
import com.volmit.iris.core.pregenerator.methods.HybridPregenMethod; 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.project.loader.IrisData;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.object.dimensional.IrisDimension; import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.engine.platform.HeadlessGenerator; import com.volmit.iris.engine.platform.HeadlessGenerator;
import com.volmit.iris.engine.platform.PlatformChunkGenerator; 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.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.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils;
import java.io.File; 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. * 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); File pack = Iris.instance.getDataFolder("packs", dimension);
if (!pack.exists()) { 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()) { if (!pack.exists()) {
@ -182,44 +168,11 @@ public class IrisToolbelt {
return false; 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 * Evacuate all players from the world
*
* @param world the world to leave * @param world the world to leave
* @param m the message * @param m the message
* @return true if it was evacuated. * @return true if it was evacuated.
*/ */
public static boolean evacuate(World world, String m) { public static boolean evacuate(World world, String m) {

View File

@ -65,6 +65,8 @@ import org.bukkit.generator.BlockPopulator;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Random; 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.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
@ -287,12 +289,11 @@ public class IrisEngine extends BlockPopulator implements Engine {
@Override @Override
public void close() { public void close() {
J.car(art);
closed = true; closed = true;
J.car(art);
getWorldManager().close(); getWorldManager().close();
getTarget().close(); getTarget().close();
saveEngineData(); saveEngineData();
getMantle().close();
getTerrainActuator().close(); getTerrainActuator().close();
getDecorantActuator().close(); getDecorantActuator().close();
getBiomeActuator().close(); getBiomeActuator().close();
@ -300,6 +301,8 @@ public class IrisEngine extends BlockPopulator implements Engine {
getRavineModifier().close(); getRavineModifier().close();
getCaveModifier().close(); getCaveModifier().close();
getPostModifier().close(); getPostModifier().close();
getMantle().close();
Iris.debug("Engine Fully Shutdown!");
} }
@Override @Override
@ -355,7 +358,12 @@ public class IrisEngine extends BlockPopulator implements Engine {
@BlockCoordinates @BlockCoordinates
@Override @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(); context.touch();
getEngineData().getStatistics().generatedChunk(); getEngineData().getStatistics().generatedChunk();
try { try {
@ -415,8 +423,16 @@ public class IrisEngine extends BlockPopulator implements Engine {
@ChunkCoordinates @ChunkCoordinates
@Override @Override
public void populate(World world, Random random, Chunk c) { public void populate(World world, Random random, Chunk c) {
updateChunk(c); try
placeTiles(c); {
updateChunk(c);
placeTiles(c);
}
catch(Throwable e)
{
e.printStackTrace();
}
} }
@Override @Override

View File

@ -139,7 +139,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
double modifyZ(double z); double modifyZ(double z);
@BlockCoordinates @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(); EngineMetrics getMetrics();

View File

@ -78,6 +78,13 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
Position2 pr = null; Position2 pr = null;
double d = Double.MAX_VALUE; double d = Double.MAX_VALUE;
Iris.debug("Ps: " + p.size());
for(Position2 i : p)
{
Iris.debug("- " + i.getX() + " " + i.getZ());
}
for (Position2 i : p) { for (Position2 i : p) {
double dx = i.distance(px); double dx = i.distance(px);
if (dx < d) { if (dx < d) {
@ -88,7 +95,9 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
if (pr != null) { if (pr != null) {
e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.ITEM_TRIDENT_THROW, 1f, 1.6f); 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; 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.Iris;
import com.volmit.iris.core.project.loader.IrisData; 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.core.tools.IrisToolbelt;
import com.volmit.iris.engine.object.dimensional.IrisDimension; import com.volmit.iris.engine.object.dimensional.IrisDimension;
import com.volmit.iris.engine.platform.BukkitChunkGenerator; import com.volmit.iris.engine.platform.BukkitChunkGenerator;
@ -60,7 +61,7 @@ public class HeadlessWorld {
new File(world.worldFolder(), "region").mkdirs(); new File(world.worldFolder(), "region").mkdirs();
if (!studio && !new File(world.worldFolder(), "iris/pack").exists()) { 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 write = false;
boolean changed = 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)) { for (IrisBiome i : getAllBiomes(data)) {
if (i.isCustom()) { if (i.isCustom()) {
write = true; write = true;
for (IrisBiomeCustom j : i.getCustomDerivitives()) { 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()) { if (!output.exists()) {
changed = true; changed = true;

View File

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

View File

@ -43,8 +43,7 @@ public class EngineProvider {
IrisData data = new IrisData(dataLocation); IrisData data = new IrisData(dataLocation);
IrisDimension realDimension = data.getDimensionLoader().load(dimension); 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); 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; package com.volmit.iris.engine.scripting;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.common.IrisScript;
import org.apache.bsf.BSFManager; import org.apache.bsf.BSFManager;
public interface EngineExecutionEnvironment { public interface EngineExecutionEnvironment {

View File

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

View File

@ -18,12 +18,28 @@
package com.volmit.iris.util.data; 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.Builder;
import lombok.Data; 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 @Data
@Builder @Builder
public class IrisProjectRepo { public class IrisPackRepository {
@Builder.Default @Builder.Default
private String user = "IrisDimensions"; private String user = "IrisDimensions";
@ -36,65 +52,45 @@ public class IrisProjectRepo {
@Builder.Default @Builder.Default
private String tag = ""; private String tag = "";
public static IrisProjectRepo from(String g) public static IrisPackRepository from(String g) {
{
// https://github.com/IrisDimensions/overworld // 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]; String sub = g.split("\\Qgithub.com/\\E")[1];
IrisProjectRepo r = IrisProjectRepo.builder() IrisPackRepository r = IrisPackRepository.builder()
.user(sub.split("\\Q/\\E")[0]) .user(sub.split("\\Q/\\E")[0])
.repo(sub.split("\\Q/\\E")[1]).build(); .repo(sub.split("\\Q/\\E")[1]).build();
if(g.contains("/tree/")) if (g.contains("/tree/")) {
{
r.setBranch(g.split("/tree/")[1]); r.setBranch(g.split("/tree/")[1]);
} }
return r; return r;
} } else if (g.contains("/")) {
else if(g.contains("/"))
{
String[] f = g.split("\\Q/\\E"); String[] f = g.split("\\Q/\\E");
if(f.length == 1) if (f.length == 1) {
{
return from(g); return from(g);
} } else if (f.length == 2) {
return IrisPackRepository.builder()
else if(f.length == 2)
{
return IrisProjectRepo.builder()
.user(f[0]) .user(f[0])
.repo(f[1]) .repo(f[1])
.build(); .build();
} } else if (f.length >= 3) {
IrisPackRepository r = IrisPackRepository.builder()
else if(f.length >= 3)
{
IrisProjectRepo r = IrisProjectRepo.builder()
.user(f[0]) .user(f[0])
.repo(f[1]) .repo(f[1])
.build(); .build();
if(f[2].startsWith("#")) if (f[2].startsWith("#")) {
{
r.setTag(f[2].substring(1)); r.setTag(f[2].substring(1));
} } else {
else
{
r.setBranch(f[2]); r.setBranch(f[2]);
} }
return r; return r;
} }
} } else {
return IrisPackRepository.builder()
else
{
return IrisProjectRepo.builder()
.user("IrisDimensions") .user("IrisDimensions")
.repo(g) .repo(g)
.branch(g.equals("overworld") ? "stable" : "master") .branch(g.equals("overworld") ? "stable" : "master")
@ -104,13 +100,31 @@ public class IrisProjectRepo {
return null; return null;
} }
public String toURL() public String toURL() {
{ if (!tag.trim().isEmpty()) {
if(!tag.trim().isEmpty())
{
return "https://codeload.github.com/" + user + "/" + repo + "/zip/refs/tags/" + tag; return "https://codeload.github.com/" + user + "/" + repo + "/zip/refs/tags/" + tag;
} }
return "https://codeload.github.com/" + user + "/" + repo + "/zip/refs/heads/" + branch; 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; package com.volmit.iris.util.decree;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
@ -5,19 +23,15 @@ import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
public interface DecreeContextHandler<T> { public interface DecreeContextHandler<T> {
static KMap<Class<?>, DecreeContextHandler<?>> contextHandlers = buildContextHandlers(); KMap<Class<?>, DecreeContextHandler<?>> contextHandlers = buildContextHandlers();
static KMap<Class<?>, DecreeContextHandler<?>> buildContextHandlers() { static KMap<Class<?>, DecreeContextHandler<?>> buildContextHandlers() {
KMap<Class<?>, DecreeContextHandler<?>> contextHandlers = new KMap<>(); KMap<Class<?>, DecreeContextHandler<?>> contextHandlers = new KMap<>();
try try {
{
Iris.initialize("com.volmit.iris.util.decree.context").forEach((i) Iris.initialize("com.volmit.iris.util.decree.context").forEach((i)
-> contextHandlers.put(((DecreeContextHandler<?>)i).getType(), (DecreeContextHandler<?>)i)); -> contextHandlers.put(((DecreeContextHandler<?>) i).getType(), (DecreeContextHandler<?>) i));
} } catch (Throwable e) {
catch(Throwable e)
{
Iris.reportError(e); Iris.reportError(e);
e.printStackTrace(); 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.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.platform.PlatformChunkGenerator; import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public interface DecreeExecutor { public interface DecreeExecutor {
default VolmitSender sender() default VolmitSender sender() {
{
return DecreeContext.get(); return DecreeContext.get();
} }
default Player player() default Player player() {
{
return sender().player(); return sender().player();
} }
default Engine engine() default Engine engine() {
{ if (sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null) {
if(sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null)
{
PlatformChunkGenerator gen = IrisToolbelt.access(sender().player().getWorld()); PlatformChunkGenerator gen = IrisToolbelt.access(sender().player().getWorld());
if (gen != null){ if (gen != null) {
return gen.getEngine(); return gen.getEngine();
} }
} }
@ -50,24 +45,21 @@ public interface DecreeExecutor {
return null; return null;
} }
default PlatformChunkGenerator access() default PlatformChunkGenerator access() {
{ if (sender().isPlayer()) {
if(sender().isPlayer()) {
return IrisToolbelt.access(world()); return IrisToolbelt.access(world());
} }
return null; return null;
} }
default World world() default World world() {
{ if (sender().isPlayer()) {
if (sender().isPlayer()){
return sender().player().getWorld(); return sender().player().getWorld();
} }
return null; return null;
} }
default <T> T get(T v, T ifUndefined) default <T> T get(T v, T ifUndefined) {
{
return v == null ? ifUndefined : v; return v == null ? ifUndefined : v;
} }
} }

View File

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

View File

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

View File

@ -34,7 +34,7 @@ public class DecreeParameter {
public DecreeParameter(Parameter parameter) { public DecreeParameter(Parameter parameter) {
this.parameter = parameter; this.parameter = parameter;
this.param = parameter.getDeclaredAnnotation(Param.class); 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"); 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() { public KList<String> getNames() {
KList<String> d = new KList<>(); KList<String> d = new KList<>();
for(String i : param.aliases()) for (String i : param.aliases()) {
{ if (i.isEmpty()) {
if(i.isEmpty())
{
continue; continue;
} }
@ -90,8 +88,7 @@ public class DecreeParameter {
KList<?> ff = getHandler().getPossibilities(); KList<?> ff = getHandler().getPossibilities();
ff = ff != null ? ff : new KList<>(); ff = ff != null ? ff : new KList<>();
KList<String> f = ff.convert((i) -> getHandler().toStringForce(i)); KList<String> f = ff.convert((i) -> getHandler().toStringForce(i));
if(f.isEmpty()) if (f.isEmpty()) {
{
f = new KList<>(); f = new KList<>();
f.add(getHandler().getRandomDefault()); 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.collection.KList;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException; import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.exceptions.DecreeWhichException; import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
public interface DecreeParameterHandler<T> { public interface DecreeParameterHandler<T> {
/** /**
* Should return the possible values for this type * Should return the possible values for this type
*
* @return Possibilities for this type. * @return Possibilities for this type.
*/ */
KList<T> getPossibilities(); KList<T> getPossibilities();
/** /**
* Converting the type back to a string (inverse of the {@link #parse(String) parse} method) * 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 * @param t The input of the designated type to convert to a String
* @return The resulting string * @return The resulting string
*/ */
@ -41,25 +42,27 @@ public interface DecreeParameterHandler<T> {
/** /**
* Forces conversion to the designated type before converting to a string using {@link #toString(T 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) * @param t The object to convert to string (that should be of this type)
* @return The resulting string. * @return The resulting string.
*/ */
default String toStringForce(Object t) default String toStringForce(Object t) {
{ return toString((T) t);
return toString((T)t);
} }
/** /**
* Should parse a String into the designated type * Should parse a String into the designated type
*
* @param in The string to parse * @param in The string to parse
* @return The value extracted from the string, of the designated type * @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) * @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
* @throws DecreeWhichException Thrown when multiple results are possible * @throws DecreeWhichException Thrown when multiple results are possible
*/ */
T parse(String in) throws DecreeParsingException, DecreeWhichException; T parse(String in) throws DecreeParsingException, DecreeWhichException;
/** /**
* Returns whether a certain type is supported by this handler<br> * Returns whether a certain type is supported by this handler<br>
*
* @param type The type to check * @param type The type to check
* @return True if supported, false if not * @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) * The possible entries for the inputted string (support for autocomplete on partial entries)
*
* @param input The inputted string to check against * @param input The inputted string to check against
* @return A {@link KList} of possibilities * @return A {@link KList} of possibilities
*/ */
default KList<T> getPossibilities(String input) default KList<T> getPossibilities(String input) {
{ if (input.trim().isEmpty()) {
if(input.trim().isEmpty())
{
KList<T> f = getPossibilities(); KList<T> f = getPossibilities();
return f == null ? new KList<>() : f; return f == null ? new KList<>() : f;
} }
@ -82,26 +84,23 @@ public interface DecreeParameterHandler<T> {
KList<T> possible = getPossibilities(); KList<T> possible = getPossibilities();
KList<T> matches = new KList<>(); KList<T> matches = new KList<>();
if (possible == null || possible.isEmpty()){ if (possible == null || possible.isEmpty()) {
return matches; return matches;
} }
if (input.isEmpty()) if (input.isEmpty()) {
{
return getPossibilities(); return getPossibilities();
} }
KList<String> converted = possible.convert(v -> toString(v).trim()); 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); String g = converted.get(i);
// if // if
// G == I or // G == I or
// I in G or // I in G or
// G in I // 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)); matches.add(possible.get(i));
} }
} }
@ -109,54 +108,36 @@ public interface DecreeParameterHandler<T> {
return matches; return matches;
} }
default String getRandomDefault() default String getRandomDefault() {
{
return "NOEXAMPLE"; return "NOEXAMPLE";
} }
default double getMultiplier(AtomicReference<String> g) default double getMultiplier(AtomicReference<String> g) {
{
double multiplier = 1; double multiplier = 1;
String in = g.get(); String in = g.get();
boolean valid = true; boolean valid = true;
while(valid) { while (valid) {
boolean trim = false; boolean trim = false;
if (in.toLowerCase().endsWith("k")) if (in.toLowerCase().endsWith("k")) {
{
multiplier *= 1000; multiplier *= 1000;
trim = true; trim = true;
} } else if (in.toLowerCase().endsWith("m")) {
else if(in.toLowerCase().endsWith("m"))
{
multiplier *= 1000000; multiplier *= 1000000;
trim = true; trim = true;
} } else if (in.toLowerCase().endsWith("h")) {
else if(in.toLowerCase().endsWith("h"))
{
multiplier *= 100; multiplier *= 100;
trim = true; trim = true;
} } else if (in.toLowerCase().endsWith("c")) {
else if(in.toLowerCase().endsWith("c"))
{
multiplier *= 16; multiplier *= 16;
trim = true; trim = true;
} } else if (in.toLowerCase().endsWith("r")) {
else if(in.toLowerCase().endsWith("r"))
{
multiplier *= (16 * 32); multiplier *= (16 * 32);
trim = true; trim = true;
} } else {
else {
valid = false; valid = false;
} }
if(trim) if (trim) {
{
in = in.substring(0, in.length() - 1); 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 * The root class to start command searching from
*
* @return * @return
*/ */
VirtualDecreeCommand getRoot(); VirtualDecreeCommand getRoot();
default boolean call(VolmitSender sender, String[] args) default boolean call(VolmitSender sender, String[] args) {
{
DecreeContext.touch(sender); DecreeContext.touch(sender);
return getRoot().invoke(sender, enhanceArgs(args)); return getRoot().invoke(sender, enhanceArgs(args));
} }
@ -61,108 +61,77 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
@Override @Override
default boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { default boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
J.aBukkit(() -> { J.aBukkit(() -> {
if(!call(new VolmitSender(sender), args)) if (!call(new VolmitSender(sender), args)) {
{
sender.sendMessage(C.RED + "Unknown Iris Command"); sender.sendMessage(C.RED + "Unknown Iris Command");
} }
}); });
return true; return true;
} }
static KList<String> enhanceArgs(String[] args) static KList<String> enhanceArgs(String[] args) {
{
return enhanceArgs(args, true); 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<>(); KList<String> a = new KList<>();
if(args.length == 0) if (args.length == 0) {
{
return a; return a;
} }
StringBuilder flat = new StringBuilder(); StringBuilder flat = new StringBuilder();
for(String i : args) for (String i : args) {
{ if (trim) {
if(trim) if (i.trim().isEmpty()) {
{
if(i.trim().isEmpty())
{
continue; continue;
} }
flat.append(" ").append(i.trim()); flat.append(" ").append(i.trim());
} } else {
if (i.endsWith(" ")) {
else
{
if(i.endsWith(" "))
{
flat.append(" ").append(i.trim()).append(" "); 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(); StringBuilder arg = new StringBuilder();
boolean quoting = false; 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 i = flat.charAt(x);
char j = x < flat.length() - 1 ? flat.charAt(x + 1) : i; char j = x < flat.length() - 1 ? flat.charAt(x + 1) : i;
boolean hasNext = x < flat.length(); boolean hasNext = x < flat.length();
if(i == ' ' && !quoting) if (i == ' ' && !quoting) {
{ if (!arg.toString().trim().isEmpty() && trim) {
if(!arg.toString().trim().isEmpty() && trim)
{
a.add(arg.toString().trim()); a.add(arg.toString().trim());
arg = new StringBuilder(); arg = new StringBuilder();
} }
} } else if (i == '"') {
if (!quoting && (arg.length() == 0)) {
else if(i == '"')
{
if(!quoting && (arg.length() == 0))
{
quoting = true; quoting = true;
} } else if (quoting) {
else if(quoting)
{
quoting = false; quoting = false;
if(hasNext && j == ' ') if (hasNext && j == ' ') {
{ if (!arg.toString().trim().isEmpty() && trim) {
if(!arg.toString().trim().isEmpty() && trim)
{
a.add(arg.toString().trim()); a.add(arg.toString().trim());
arg = new StringBuilder(); 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()); a.add(arg.toString().trim());
arg = new StringBuilder(); arg = new StringBuilder();
} }
} }
} }
} } else {
else
{
arg.append(i); arg.append(i);
} }
} }
if(!arg.toString().trim().isEmpty() && trim) if (!arg.toString().trim().isEmpty() && trim) {
{
a.add(arg.toString().trim()); a.add(arg.toString().trim());
} }
@ -171,14 +140,13 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
/** /**
* Get the handler for the specified type * Get the handler for the specified type
*
* @param type The type to handle * @param type The type to handle
* @return The corresponding {@link DecreeParameterHandler}, or null * @return The corresponding {@link DecreeParameterHandler}, or null
*/ */
static DecreeParameterHandler<?> getHandler(Class<?> type) { static DecreeParameterHandler<?> getHandler(Class<?> type) {
for(DecreeParameterHandler<?> i : handlers) for (DecreeParameterHandler<?> i : handlers) {
{ if (i.supports(type)) {
if(i.supports(type))
{
return i; return i;
} }
} }

View File

@ -38,6 +38,7 @@ public @interface Decree {
/** /**
* Only allow if studio mode is enabled * Only allow if studio mode is enabled
*
* @return defaults to false * @return defaults to false
*/ */
boolean studio() default 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; package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt; 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; import com.volmit.iris.util.plugin.VolmitSender;
public class BiomeContextHandler implements DecreeContextHandler<IrisBiome> { 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) public IrisBiome handle(VolmitSender sender) {
{ if (sender.isPlayer()
if(sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld()) && 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()); 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; package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt; 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; import com.volmit.iris.util.plugin.VolmitSender;
public class DimensionContextHandler implements DecreeContextHandler<IrisDimension> { 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) public IrisDimension handle(VolmitSender sender) {
{ if (sender.isPlayer()
if(sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld()) && 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(); 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; package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
@ -14,10 +32,9 @@ public class GeneratorContextHandler implements DecreeContextHandler<IrisGenerat
@Override @Override
public IrisGenerator handle(VolmitSender sender) { public IrisGenerator handle(VolmitSender sender) {
if(sender.isPlayer() if (sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld()) && 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(); Engine engine = IrisToolbelt.access(sender.player().getWorld()).getEngine();
return engine.getData().getGeneratorLoader().load(engine.getBiome(sender.player().getLocation()).getGenerators().getRandom().getGenerator()); 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; package com.volmit.iris.util.decree.context;
import com.volmit.iris.core.tools.IrisToolbelt; 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; import com.volmit.iris.util.plugin.VolmitSender;
public class RegionContextHandler implements DecreeContextHandler<IrisRegion> { 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) public IrisRegion handle(VolmitSender sender) {
{ if (sender.isPlayer()
if(sender.isPlayer()
&& IrisToolbelt.isIrisWorld(sender.player().getWorld()) && 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()); 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; package com.volmit.iris.util.decree.context;
import com.volmit.iris.util.decree.DecreeContextHandler; import com.volmit.iris.util.decree.DecreeContextHandler;
@ -5,10 +23,11 @@ import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.World; import org.bukkit.World;
public class WorldContextHandler implements DecreeContextHandler<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; 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 * Thrown when a decree parameter is parsed, but parsing fails
*/ */
public class DecreeParsingException extends Exception{ public class DecreeParsingException extends Exception {
public DecreeParsingException(String message) { public DecreeParsingException(String message) {
super(message); super(message);
} }

View File

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

View File

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

View File

@ -30,7 +30,6 @@ import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.FluidCollisionMode; import org.bukkit.FluidCollisionMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.BlockVector; import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> { public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
@Override @Override
@ -38,8 +37,7 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
KList<BlockVector> vx = new KList<>(); KList<BlockVector> vx = new KList<>();
VolmitSender s = DecreeContext.get(); VolmitSender s = DecreeContext.get();
if(s.isPlayer()) if (s.isPlayer()) {
{
vx.add(s.player().getLocation().toVector().toBlockVector()); vx.add(s.player().getLocation().toVector().toBlockVector());
} }
@ -48,9 +46,8 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
@Override @Override
public String toString(BlockVector v) { public String toString(BlockVector v) {
if(v.getY() == 0) if (v.getY() == 0) {
{ return Form.f(v.getBlockX(), 2) + "," + Form.f(v.getBlockZ(), 2);
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); 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 @Override
public BlockVector parse(String in) throws DecreeParsingException, DecreeWhichException { public BlockVector parse(String in) throws DecreeParsingException, DecreeWhichException {
try { try {
if (in.contains(",")) if (in.contains(",")) {
{
String[] comp = in.split("\\Q,\\E"); 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())); 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()), return new BlockVector(Integer.parseInt(comp[0].trim()),
Integer.parseInt(comp[1].trim()), Integer.parseInt(comp[1].trim()),
Integer.parseInt(comp[2].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."); 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."); throw new DecreeParsingException("You cannot specify me,self,here as a console.");
} }
return DecreeContext.get().player().getLocation().toVector().toBlockVector(); 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."); throw new DecreeParsingException("You cannot specify look,cursor,crosshair as a console.");
} }
return DecreeContext.get().player().getTargetBlockExact(256, FluidCollisionMode.NEVER).getLocation().toVector().toBlockVector(); 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]; String v = in.trim().split("\\Q:\\E")[1];
KList<?> px = DecreeSystem.getHandler(Player.class).getPossibilities(v); KList<?> px = DecreeSystem.getHandler(Player.class).getPossibilities(v);
if(px != null && px.isNotEmpty()) if (px != null && px.isNotEmpty()) {
{ return ((Player) px.get(0)).getLocation().toVector().toBlockVector();
return ((Player)px.get(0)).getLocation().toVector().toBlockVector(); } else if (px == null || px.isEmpty()) {
}
else if(px == null || px.isEmpty())
{
throw new DecreeParsingException("Cannot find player: " + v); 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); 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 @Override
public String getRandomDefault() public String getRandomDefault() {
{
return M.r(0.5) ? "0,0" : "0,0,0"; 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.DecreeParameterHandler;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException; import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
public class BooleanHandler implements DecreeParameterHandler<Boolean> { public class BooleanHandler implements DecreeParameterHandler<Boolean> {
@Override @Override
@ -37,13 +36,9 @@ public class BooleanHandler implements DecreeParameterHandler<Boolean> {
@Override @Override
public Boolean parse(String in) throws DecreeParsingException { public Boolean parse(String in) throws DecreeParsingException {
try try {
{
return Boolean.parseBoolean(in); return Boolean.parseBoolean(in);
} } catch (Throwable e) {
catch(Throwable e)
{
throw new DecreeParsingException("Unable to parse boolean \"" + in + "\""); throw new DecreeParsingException("Unable to parse boolean \"" + in + "\"");
} }
} }
@ -54,8 +49,7 @@ public class BooleanHandler implements DecreeParameterHandler<Boolean> {
} }
@Override @Override
public String getRandomDefault() public String getRandomDefault() {
{
return M.r(0.5) + ""; return M.r(0.5) + "";
} }
} }

View File

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

View File

@ -34,15 +34,11 @@ public class DoubleHandler implements DecreeParameterHandler<Double> {
@Override @Override
public Double parse(String in) throws DecreeParsingException { public Double parse(String in) throws DecreeParsingException {
try try {
{
AtomicReference<String> r = new AtomicReference<>(in); AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r); double m = getMultiplier(r);
return Double.parseDouble(r.get()) * m; return Double.parseDouble(r.get()) * m;
} } catch (Throwable e) {
catch(Throwable e)
{
throw new DecreeParsingException("Unable to parse double \"" + in + "\""); throw new DecreeParsingException("Unable to parse double \"" + in + "\"");
} }
} }
@ -58,8 +54,7 @@ public class DoubleHandler implements DecreeParameterHandler<Double> {
} }
@Override @Override
public String getRandomDefault() public String getRandomDefault() {
{
return Form.f(RNG.r.d(0, 99.99), 1) + ""; 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; package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.project.loader.IrisData; 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.engine.object.entity.IrisEntity;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
@ -24,12 +41,10 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
KMap<String, IrisEntity> p = new KMap<>(); KMap<String, IrisEntity> p = new KMap<>();
//noinspection ConstantConditions //noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles()) for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
{ if (i.isDirectory()) {
if(i.isDirectory()) {
IrisData data = new IrisData(i, true); 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); p.putIfAbsent(j.getLoadKey(), j);
} }
@ -61,27 +76,19 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
*/ */
@Override @Override
public IrisEntity parse(String in) throws DecreeParsingException, DecreeWhichException { public IrisEntity parse(String in) throws DecreeParsingException, DecreeWhichException {
try try {
{
KList<IrisEntity> options = getPossibilities(in); KList<IrisEntity> options = getPossibilities(in);
if(options.isEmpty()) if (options.isEmpty()) {
{
throw new DecreeParsingException("Unable to find Entity \"" + in + "\""); throw new DecreeParsingException("Unable to find Entity \"" + in + "\"");
} } else if (options.size() > 1) {
else if(options.size() > 1)
{
throw new DecreeWhichException(); throw new DecreeWhichException();
} }
return options.get(0); return options.get(0);
} } catch (DecreeParsingException e) {
catch(DecreeParsingException e){
throw e; throw e;
} } catch (Throwable e) {
catch(Throwable e)
{
throw new DecreeParsingException("Unable to find Entity \"" + in + "\" because of an uncaught exception: " + 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 @Override
public String getRandomDefault() public String getRandomDefault() {
{
return "entity"; return "entity";
} }
} }

View File

@ -34,15 +34,11 @@ public class FloatHandler implements DecreeParameterHandler<Float> {
@Override @Override
public Float parse(String in) throws DecreeParsingException { public Float parse(String in) throws DecreeParsingException {
try try {
{
AtomicReference<String> r = new AtomicReference<>(in); AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r); double m = getMultiplier(r);
return (float)(Float.parseFloat(r.get()) * m); return (float) (Float.parseFloat(r.get()) * m);
} } catch (Throwable e) {
catch(Throwable e)
{
throw new DecreeParsingException("Unable to parse float \"" + in + "\""); throw new DecreeParsingException("Unable to parse float \"" + in + "\"");
} }
} }
@ -58,8 +54,7 @@ public class FloatHandler implements DecreeParameterHandler<Float> {
} }
@Override @Override
public String getRandomDefault() public String getRandomDefault() {
{
return Form.f(RNG.r.d(0, 99.99), 1) + ""; 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; package com.volmit.iris.util.decree.handlers;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
@ -17,12 +35,10 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
KMap<String, IrisGenerator> p = new KMap<>(); KMap<String, IrisGenerator> p = new KMap<>();
//noinspection ConstantConditions //noinspection ConstantConditions
for(File i : Iris.instance.getDataFolder("packs").listFiles()) for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
{ if (i.isDirectory()) {
if(i.isDirectory()) {
IrisData data = new IrisData(i, true); 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); p.putIfAbsent(j.getLoadKey(), j);
} }
@ -40,27 +56,19 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
@Override @Override
public IrisGenerator parse(String in) throws DecreeParsingException, DecreeWhichException { public IrisGenerator parse(String in) throws DecreeParsingException, DecreeWhichException {
try try {
{
KList<IrisGenerator> options = getPossibilities(in); KList<IrisGenerator> options = getPossibilities(in);
if(options.isEmpty()) if (options.isEmpty()) {
{
throw new DecreeParsingException("Unable to find Generator \"" + in + "\""); throw new DecreeParsingException("Unable to find Generator \"" + in + "\"");
} } else if (options.size() > 1) {
else if(options.size() > 1)
{
throw new DecreeWhichException(); throw new DecreeWhichException();
} }
return options.get(0); return options.get(0);
} } catch (DecreeParsingException e) {
catch(DecreeParsingException e){
throw e; throw e;
} } catch (Throwable e) {
catch(Throwable e)
{
throw new DecreeParsingException("Unable to find Generator \"" + in + "\" because of an uncaught exception: " + 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 @Override
public String getRandomDefault() public String getRandomDefault() {
{
return "generator"; 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.collection.KList;
import com.volmit.iris.util.decree.DecreeParameterHandler; import com.volmit.iris.util.decree.DecreeParameterHandler;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException; import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
public class IntegerHandler implements DecreeParameterHandler<Integer> { public class IntegerHandler implements DecreeParameterHandler<Integer> {
@ -35,15 +33,11 @@ public class IntegerHandler implements DecreeParameterHandler<Integer> {
@Override @Override
public Integer parse(String in) throws DecreeParsingException { public Integer parse(String in) throws DecreeParsingException {
try try {
{
AtomicReference<String> r = new AtomicReference<>(in); AtomicReference<String> r = new AtomicReference<>(in);
double m = getMultiplier(r); double m = getMultiplier(r);
return (int)(Integer.valueOf(r.get()).doubleValue() * m); return (int) (Integer.valueOf(r.get()).doubleValue() * m);
} } catch (Throwable e) {
catch(Throwable e)
{
throw new DecreeParsingException("Unable to parse integer \"" + in + "\""); throw new DecreeParsingException("Unable to parse integer \"" + in + "\"");
} }
} }
@ -59,8 +53,7 @@ public class IntegerHandler implements DecreeParameterHandler<Integer> {
} }
@Override @Override
public String getRandomDefault() public String getRandomDefault() {
{
return RNG.r.i(0, 99) + ""; return RNG.r.i(0, 99) + "";
} }
} }

View File

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

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