mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Cleanup sources
This commit is contained in:
parent
af602a414a
commit
a462ab98e9
@ -107,7 +107,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
private void enable() {
|
private void enable() {
|
||||||
services = new KMap<>();
|
services = new KMap<>();
|
||||||
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
|
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);
|
||||||
sender = new VolmitSender(Bukkit.getConsoleSender());
|
sender = new VolmitSender(Bukkit.getConsoleSender());
|
||||||
sender.setTag(getTag());
|
sender.setTag(getTag());
|
||||||
|
@ -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.object;
|
package com.volmit.iris.core.command.object;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -74,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()) {
|
||||||
@ -131,7 +132,6 @@ public class CommandIrisStudioBeautify extends MortarCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getArgsUsage() {
|
protected String getArgsUsage() {
|
||||||
return "[project]";
|
return "[project]";
|
||||||
|
@ -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;
|
||||||
|
@ -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 {
|
||||||
|
@ -32,8 +32,7 @@ import com.volmit.iris.util.format.C;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@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;
|
||||||
@ -41,19 +40,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;
|
||||||
}
|
}
|
||||||
@ -66,7 +65,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);
|
||||||
@ -77,18 +76,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);
|
||||||
@ -100,22 +99,22 @@ 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;
|
||||||
case "%" -> v = value1 % value2;
|
case "%" -> v = value1 % value2;
|
||||||
case ">>" -> v = value1 >> value2;
|
case ">>" -> v = value1 >> value2;
|
||||||
case "<<" -> v = value1 << value2;
|
case "<<" -> v = value1 << value2;
|
||||||
};
|
}
|
||||||
if (v == null){
|
if (v == null) {
|
||||||
sender().sendMessage(C.RED + "The operator you entered: (" + operator + ") is invalid!");
|
sender().sendMessage(C.RED + "The operator you entered: (" + operator + ") is invalid!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -125,7 +124,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);
|
||||||
}
|
}
|
||||||
@ -133,13 +132,13 @@ 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.service(StudioSVC.class).downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim, overwrite);
|
Iris.service(StudioSVC.class).downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim, overwrite);
|
||||||
@ -147,7 +146,7 @@ public class DecIris implements DecreeExecutor
|
|||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
|
@ -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 {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -110,8 +110,7 @@ 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.service(StudioSVC.class).create(sender(), name, template.getLoadKey());
|
Iris.service(StudioSVC.class).create(sender(), name, template.getLoadKey());
|
||||||
} else {
|
} else {
|
||||||
@ -147,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) {
|
||||||
@ -173,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) {
|
||||||
@ -197,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) {
|
||||||
@ -214,7 +210,7 @@ public class DecStudio implements DecreeExecutor {
|
|||||||
|
|
||||||
IrisData data = new IrisData(Iris.service(StudioSVC.class).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 {
|
||||||
@ -265,7 +261,7 @@ public class DecStudio implements DecreeExecutor {
|
|||||||
@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;
|
||||||
|
|
||||||
@ -303,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!");
|
||||||
|
|
||||||
@ -324,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;
|
||||||
}
|
}
|
||||||
@ -373,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;
|
||||||
|
|
||||||
@ -384,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;
|
||||||
@ -414,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;
|
||||||
@ -427,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.service(StudioSVC.class).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);
|
||||||
@ -627,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;
|
||||||
}
|
}
|
||||||
@ -642,13 +637,13 @@ 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.service(StudioSVC.class).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;
|
||||||
}
|
}
|
||||||
@ -660,9 +655,9 @@ public class DecStudio implements DecreeExecutor {
|
|||||||
|
|
||||||
@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 {
|
||||||
@ -682,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);
|
||||||
@ -708,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");
|
||||||
@ -760,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;
|
||||||
}
|
}
|
||||||
@ -770,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.service(StudioSVC.class).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;
|
||||||
}
|
}
|
||||||
@ -787,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);
|
||||||
|
@ -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;
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.core.project;
|
package com.volmit.iris.core.project;
|
||||||
|
|
||||||
import com.volmit.iris.core.project.loader.IrisData;
|
|
||||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -28,13 +26,11 @@ import java.io.File;
|
|||||||
public class IrisPack {
|
public class IrisPack {
|
||||||
private final File folder;
|
private final File folder;
|
||||||
|
|
||||||
public IrisPack(File folder)
|
public IrisPack(File folder) {
|
||||||
{
|
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
|
||||||
return getFolder().getName();
|
return getFolder().getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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()) {
|
||||||
|
@ -35,7 +35,6 @@ 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.IrisService;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import com.volmit.iris.util.scheduling.GroupedExecutor;
|
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -49,7 +48,7 @@ import java.util.UUID;
|
|||||||
public class StudioSVC implements IrisService {
|
public class StudioSVC implements IrisService {
|
||||||
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<>();
|
||||||
|
|
||||||
@ -323,7 +322,8 @@ public class StudioSVC implements IrisService {
|
|||||||
|
|
||||||
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:");
|
||||||
@ -448,8 +448,7 @@ public class StudioSVC implements IrisService {
|
|||||||
create(sender, s, "example");
|
create(sender, s, "example");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisProject getActiveProject()
|
public IrisProject getActiveProject() {
|
||||||
{
|
|
||||||
return activeProject;
|
return activeProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -23,13 +23,9 @@ 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.core.service.StudioSVC;
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
|
||||||
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;
|
||||||
@ -38,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
|
||||||
@ -94,20 +87,17 @@ 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.service(StudioSVC.class).installIntoWorld(sender, d.getLoadKey(), new File(name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,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());
|
||||||
|
|
||||||
@ -189,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);
|
||||||
|
@ -25,7 +25,6 @@ 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.core.service.StudioSVC;
|
||||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||||
@ -47,7 +46,6 @@ import org.zeroturnaround.zip.commons.FileUtils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -184,15 +182,15 @@ public class IrisToolbelt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to ensure that the pack is installed
|
* Attempts to ensure that the pack is installed
|
||||||
|
*
|
||||||
* @param sender the sender
|
* @param sender the sender
|
||||||
* @param url the dimension
|
* @param url the dimension
|
||||||
* @throws Throwable shit happens
|
* @throws Throwable shit happens
|
||||||
*/
|
*/
|
||||||
public static void install(VolmitSender sender, String url) throws Throwable {
|
public static void install(VolmitSender sender, String url) throws Throwable {
|
||||||
IrisProjectRepo r = IrisProjectRepo.from(url);
|
IrisProjectRepo r = IrisProjectRepo.from(url);
|
||||||
|
|
||||||
if(r != null)
|
if (r != null) {
|
||||||
{
|
|
||||||
url = r.getRepo();
|
url = r.getRepo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,8 +216,9 @@ public class IrisToolbelt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 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) {
|
||||||
|
@ -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")
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,64 +36,44 @@ public class IrisProjectRepo {
|
|||||||
@Builder.Default
|
@Builder.Default
|
||||||
private String tag = "";
|
private String tag = "";
|
||||||
|
|
||||||
public static IrisProjectRepo from(String g)
|
public static IrisProjectRepo 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()
|
IrisProjectRepo r = IrisProjectRepo.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) {
|
||||||
|
|
||||||
else if(f.length == 2)
|
|
||||||
{
|
|
||||||
return IrisProjectRepo.builder()
|
return IrisProjectRepo.builder()
|
||||||
.user(f[0])
|
.user(f[0])
|
||||||
.repo(f[1])
|
.repo(f[1])
|
||||||
.build();
|
.build();
|
||||||
}
|
} else if (f.length >= 3) {
|
||||||
|
|
||||||
else if(f.length >= 3)
|
|
||||||
{
|
|
||||||
IrisProjectRepo r = IrisProjectRepo.builder()
|
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 {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return IrisProjectRepo.builder()
|
return IrisProjectRepo.builder()
|
||||||
.user("IrisDimensions")
|
.user("IrisDimensions")
|
||||||
.repo(g)
|
.repo(g)
|
||||||
@ -104,10 +84,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,25 +40,17 @@ public class PlayerHandler implements DecreeParameterHandler<Player> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Player parse(String in) throws DecreeParsingException, DecreeWhichException {
|
public Player parse(String in) throws DecreeParsingException, DecreeWhichException {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
KList<Player> options = getPossibilities(in);
|
KList<Player> options = getPossibilities(in);
|
||||||
|
|
||||||
if(options.isEmpty())
|
if (options.isEmpty()) {
|
||||||
{
|
|
||||||
throw new DecreeParsingException("Unable to find Player \"" + in + "\"");
|
throw new DecreeParsingException("Unable to find Player \"" + 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 (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
throw new DecreeParsingException("Unable to find Player \"" + in + "\" because of an uncaught exception: " + e);
|
throw new DecreeParsingException("Unable to find Player \"" + in + "\" because of an uncaught exception: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,8 +61,7 @@ public class PlayerHandler implements DecreeParameterHandler<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRandomDefault()
|
public String getRandomDefault() {
|
||||||
{
|
|
||||||
return "playername";
|
return "playername";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,12 +35,10 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
|
|||||||
KMap<String, IrisRegion> p = new KMap<>();
|
KMap<String, IrisRegion> 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 (IrisRegion j : data.getRegionLoader().loadAll(data.getRegionLoader().getPossibleKeys()))
|
for (IrisRegion j : data.getRegionLoader().loadAll(data.getRegionLoader().getPossibleKeys())) {
|
||||||
{
|
|
||||||
p.putIfAbsent(j.getLoadKey(), j);
|
p.putIfAbsent(j.getLoadKey(), j);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,27 +56,19 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisRegion parse(String in) throws DecreeParsingException, DecreeWhichException {
|
public IrisRegion parse(String in) throws DecreeParsingException, DecreeWhichException {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
KList<IrisRegion> options = getPossibilities(in);
|
KList<IrisRegion> options = getPossibilities(in);
|
||||||
|
|
||||||
if(options.isEmpty())
|
if (options.isEmpty()) {
|
||||||
{
|
|
||||||
throw new DecreeParsingException("Unable to find Region \"" + in + "\"");
|
throw new DecreeParsingException("Unable to find Region \"" + 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 Region \"" + in + "\" because of an uncaught exception: " + e);
|
throw new DecreeParsingException("Unable to find Region \"" + in + "\" because of an uncaught exception: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,8 +79,7 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRandomDefault()
|
public String getRandomDefault() {
|
||||||
{
|
|
||||||
return "region";
|
return "region";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 ScriptHandler implements DecreeParameterHandler<IrisScript> {
|
|||||||
KMap<String, IrisScript> p = new KMap<>();
|
KMap<String, IrisScript> 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 (IrisScript j : data.getScriptLoader().loadAll(data.getScriptLoader().getPossibleKeys()))
|
for (IrisScript j : data.getScriptLoader().loadAll(data.getScriptLoader().getPossibleKeys())) {
|
||||||
{
|
|
||||||
p.putIfAbsent(j.getLoadKey(), j);
|
p.putIfAbsent(j.getLoadKey(), j);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,27 +56,19 @@ public class ScriptHandler implements DecreeParameterHandler<IrisScript> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisScript parse(String in) throws DecreeParsingException, DecreeWhichException {
|
public IrisScript parse(String in) throws DecreeParsingException, DecreeWhichException {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
KList<IrisScript> options = getPossibilities(in);
|
KList<IrisScript> options = getPossibilities(in);
|
||||||
|
|
||||||
if(options.isEmpty())
|
if (options.isEmpty()) {
|
||||||
{
|
|
||||||
throw new DecreeParsingException("Unable to find Script \"" + in + "\"");
|
throw new DecreeParsingException("Unable to find Script \"" + 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 Script \"" + in + "\" because of an uncaught exception: " + e);
|
throw new DecreeParsingException("Unable to find Script \"" + in + "\" because of an uncaught exception: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,8 +79,7 @@ public class ScriptHandler implements DecreeParameterHandler<IrisScript> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRandomDefault()
|
public String getRandomDefault() {
|
||||||
{
|
|
||||||
return "script";
|
return "script";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,15 +33,11 @@ public class ShortHandler implements DecreeParameterHandler<Short> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Short parse(String in) throws DecreeParsingException {
|
public Short 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 (short)(Short.valueOf(r.get()).doubleValue() * m);
|
return (short) (Short.valueOf(r.get()).doubleValue() * m);
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
throw new DecreeParsingException("Unable to parse short \"" + in + "\"");
|
throw new DecreeParsingException("Unable to parse short \"" + in + "\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,8 +53,7 @@ public class ShortHandler implements DecreeParameterHandler<Short> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRandomDefault()
|
public String getRandomDefault() {
|
||||||
{
|
|
||||||
return RNG.r.i(0, 99) + "";
|
return RNG.r.i(0, 99) + "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ 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.math.RNG;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstraction can sometimes breed stupidity
|
* Abstraction can sometimes breed stupidity
|
||||||
@ -48,8 +47,7 @@ public class StringHandler implements DecreeParameterHandler<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRandomDefault()
|
public String getRandomDefault() {
|
||||||
{
|
|
||||||
return new KList<String>().qadd("text").qadd("string")
|
return new KList<String>().qadd("text").qadd("string")
|
||||||
.qadd("blah").qadd("derp").qadd("yolo").getRandom();
|
.qadd("blah").qadd("derp").qadd("yolo").getRandom();
|
||||||
}
|
}
|
||||||
|
@ -27,23 +27,18 @@ import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
|
|||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.FluidCollisionMode;
|
import org.bukkit.FluidCollisionMode;
|
||||||
import org.bukkit.World;
|
|
||||||
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;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class VectorHandler implements DecreeParameterHandler<Vector> {
|
public class VectorHandler implements DecreeParameterHandler<Vector> {
|
||||||
@Override
|
@Override
|
||||||
public KList<Vector> getPossibilities() {
|
public KList<Vector> getPossibilities() {
|
||||||
KList<Vector> vx = new KList<>();
|
KList<Vector> vx = new KList<>();
|
||||||
VolmitSender s = DecreeContext.get();
|
VolmitSender s = DecreeContext.get();
|
||||||
|
|
||||||
if(s.isPlayer())
|
if (s.isPlayer()) {
|
||||||
{
|
|
||||||
vx.add(s.player().getLocation().toVector());
|
vx.add(s.player().getLocation().toVector());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,9 +47,8 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(Vector v) {
|
public String toString(Vector v) {
|
||||||
if(v.getY() == 0)
|
if (v.getY() == 0) {
|
||||||
{
|
return Form.f(v.getX(), 2) + "," + Form.f(v.getZ(), 2);
|
||||||
return Form.f(v.getX(), 2)+ "," + Form.f(v.getZ(), 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Form.f(v.getX(), 2) + "," + Form.f(v.getY(), 2) + "," + Form.f(v.getZ(), 2);
|
return Form.f(v.getX(), 2) + "," + Form.f(v.getY(), 2) + "," + Form.f(v.getZ(), 2);
|
||||||
@ -63,69 +57,43 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
|
|||||||
@Override
|
@Override
|
||||||
public Vector parse(String in) throws DecreeParsingException, DecreeWhichException {
|
public Vector 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(Double.parseDouble(comp[0].trim()), 0, Double.parseDouble(comp[1].trim()));
|
return new BlockVector(Double.parseDouble(comp[0].trim()), 0, Double.parseDouble(comp[1].trim()));
|
||||||
}
|
} else if (comp.length == 3) {
|
||||||
|
|
||||||
else if(comp.length == 3)
|
|
||||||
{
|
|
||||||
return new BlockVector(Double.parseDouble(comp[0].trim()),
|
return new BlockVector(Double.parseDouble(comp[0].trim()),
|
||||||
Double.parseDouble(comp[1].trim()),
|
Double.parseDouble(comp[1].trim()),
|
||||||
Double.parseDouble(comp[2].trim()));
|
Double.parseDouble(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();
|
return DecreeContext.get().player().getLocation().toVector();
|
||||||
}
|
} 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();
|
return DecreeContext.get().player().getTargetBlockExact(256, FluidCollisionMode.NEVER).getLocation().toVector();
|
||||||
}
|
} 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();
|
||||||
return ((Player)px.get(0)).getLocation().toVector();
|
} 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,8 +106,7 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,27 +38,19 @@ public class WorldHandler implements DecreeParameterHandler<World> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World parse(String in) throws DecreeParsingException, DecreeWhichException {
|
public World parse(String in) throws DecreeParsingException, DecreeWhichException {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
KList<World> options = getPossibilities(in);
|
KList<World> options = getPossibilities(in);
|
||||||
|
|
||||||
if(options.isEmpty())
|
if (options.isEmpty()) {
|
||||||
{
|
|
||||||
throw new DecreeParsingException("Unable to find World \"" + in + "\"");
|
throw new DecreeParsingException("Unable to find World \"" + 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 World \"" + in + "\" because of an uncaught exception: " + e);
|
throw new DecreeParsingException("Unable to find World \"" + in + "\" because of an uncaught exception: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,8 +61,7 @@ public class WorldHandler implements DecreeParameterHandler<World> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRandomDefault()
|
public String getRandomDefault() {
|
||||||
{
|
|
||||||
return "world";
|
return "world";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,10 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
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.*;
|
import com.volmit.iris.util.decree.DecreeContext;
|
||||||
|
import com.volmit.iris.util.decree.DecreeContextHandler;
|
||||||
|
import com.volmit.iris.util.decree.DecreeNode;
|
||||||
|
import com.volmit.iris.util.decree.DecreeParameter;
|
||||||
import com.volmit.iris.util.decree.annotations.Decree;
|
import com.volmit.iris.util.decree.annotations.Decree;
|
||||||
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;
|
||||||
@ -31,15 +34,10 @@ import com.volmit.iris.util.format.Form;
|
|||||||
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 lombok.Data;
|
||||||
import lombok.Getter;
|
|
||||||
import org.apache.logging.log4j.core.impl.ThrowableFormatOptions;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ -49,8 +47,7 @@ public class VirtualDecreeCommand {
|
|||||||
private final KList<VirtualDecreeCommand> nodes;
|
private final KList<VirtualDecreeCommand> nodes;
|
||||||
private final DecreeNode node;
|
private final DecreeNode node;
|
||||||
|
|
||||||
private VirtualDecreeCommand(Class<?> type, VirtualDecreeCommand parent, KList<VirtualDecreeCommand> nodes, DecreeNode node)
|
private VirtualDecreeCommand(Class<?> type, VirtualDecreeCommand parent, KList<VirtualDecreeCommand> nodes, DecreeNode node) {
|
||||||
{
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.nodes = nodes;
|
this.nodes = nodes;
|
||||||
@ -64,23 +61,19 @@ public class VirtualDecreeCommand {
|
|||||||
public static VirtualDecreeCommand createRoot(VirtualDecreeCommand parent, Object v) throws Throwable {
|
public static VirtualDecreeCommand createRoot(VirtualDecreeCommand parent, Object v) throws Throwable {
|
||||||
VirtualDecreeCommand c = new VirtualDecreeCommand(v.getClass(), parent, new KList<>(), null);
|
VirtualDecreeCommand c = new VirtualDecreeCommand(v.getClass(), parent, new KList<>(), null);
|
||||||
|
|
||||||
for(Field i : v.getClass().getDeclaredFields())
|
for (Field i : v.getClass().getDeclaredFields()) {
|
||||||
{
|
if (Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isTransient(i.getModifiers()) || Modifier.isVolatile(i.getModifiers())) {
|
||||||
if(Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers())|| Modifier.isTransient(i.getModifiers())|| Modifier.isVolatile(i.getModifiers()))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!i.getType().isAnnotationPresent(Decree.class))
|
if (!i.getType().isAnnotationPresent(Decree.class)) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
i.setAccessible(true);
|
i.setAccessible(true);
|
||||||
Object childRoot = i.get(v);
|
Object childRoot = i.get(v);
|
||||||
|
|
||||||
if(childRoot == null)
|
if (childRoot == null) {
|
||||||
{
|
|
||||||
childRoot = i.getType().getConstructor().newInstance();
|
childRoot = i.getType().getConstructor().newInstance();
|
||||||
i.set(v, childRoot);
|
i.set(v, childRoot);
|
||||||
}
|
}
|
||||||
@ -88,15 +81,12 @@ public class VirtualDecreeCommand {
|
|||||||
c.getNodes().add(createRoot(c, childRoot));
|
c.getNodes().add(createRoot(c, childRoot));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Method i : v.getClass().getDeclaredMethods())
|
for (Method i : v.getClass().getDeclaredMethods()) {
|
||||||
{
|
if (Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isPrivate(i.getModifiers())) {
|
||||||
if(Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isPrivate(i.getModifiers()))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!i.isAnnotationPresent(Decree.class))
|
if (!i.isAnnotationPresent(Decree.class)) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,13 +96,11 @@ public class VirtualDecreeCommand {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath()
|
public String getPath() {
|
||||||
{
|
|
||||||
KList<String> n = new KList<>();
|
KList<String> n = new KList<>();
|
||||||
VirtualDecreeCommand cursor = this;
|
VirtualDecreeCommand cursor = this;
|
||||||
|
|
||||||
while(cursor.getParent() != null)
|
while (cursor.getParent() != null) {
|
||||||
{
|
|
||||||
cursor = cursor.getParent();
|
cursor = cursor.getParent();
|
||||||
n.add(cursor.getName());
|
n.add(cursor.getName());
|
||||||
}
|
}
|
||||||
@ -120,13 +108,11 @@ public class VirtualDecreeCommand {
|
|||||||
return "/" + n.reverse().qadd(getName()).toString(" ");
|
return "/" + n.reverse().qadd(getName()).toString(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParentPath()
|
public String getParentPath() {
|
||||||
{
|
return getParent().getPath();
|
||||||
return getParent().getPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
|
||||||
return isNode() ? getNode().getName() : getType().getDeclaredAnnotation(Decree.class).name();
|
return isNode() ? getNode().getName() : getType().getDeclaredAnnotation(Decree.class).name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,24 +120,19 @@ public class VirtualDecreeCommand {
|
|||||||
return isNode() ? getNode().getDecree().studio() : getType().getDeclaredAnnotation(Decree.class).studio();
|
return isNode() ? getNode().getDecree().studio() : getType().getDeclaredAnnotation(Decree.class).studio();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
|
||||||
return isNode() ? getNode().getDescription() : getType().getDeclaredAnnotation(Decree.class).description();
|
return isNode() ? getNode().getDescription() : getType().getDeclaredAnnotation(Decree.class).description();
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> getNames()
|
public KList<String> getNames() {
|
||||||
{
|
if (isNode()) {
|
||||||
if(isNode())
|
|
||||||
{
|
|
||||||
return getNode().getNames();
|
return getNode().getNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
KList<String> d = new KList<>();
|
KList<String> d = new KList<>();
|
||||||
Decree dc = getType().getDeclaredAnnotation(Decree.class);
|
Decree dc = getType().getDeclaredAnnotation(Decree.class);
|
||||||
for(String i : dc.aliases())
|
for (String i : dc.aliases()) {
|
||||||
{
|
if (i.isEmpty()) {
|
||||||
if(i.isEmpty())
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,56 +145,45 @@ public class VirtualDecreeCommand {
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNode()
|
public boolean isNode() {
|
||||||
{
|
|
||||||
return node != null;
|
return node != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> tabComplete(KList<String> args, String raw)
|
public KList<String> tabComplete(KList<String> args, String raw) {
|
||||||
{
|
|
||||||
KList<Integer> skip = new KList<>();
|
KList<Integer> skip = new KList<>();
|
||||||
KList<String> tabs = new KList<>();
|
KList<String> tabs = new KList<>();
|
||||||
invokeTabComplete(args, skip, tabs, raw);
|
invokeTabComplete(args, skip, tabs, raw);
|
||||||
return tabs;
|
return tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean invokeTabComplete(KList<String> args, KList<Integer> skip, KList<String> tabs, String raw)
|
private boolean invokeTabComplete(KList<String> args, KList<Integer> skip, KList<String> tabs, String raw) {
|
||||||
{
|
if (isStudio() && !IrisSettings.get().isStudio()) {
|
||||||
if(isStudio() && !IrisSettings.get().isStudio())
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isNode())
|
if (isNode()) {
|
||||||
{
|
|
||||||
tab(args, tabs);
|
tab(args, tabs);
|
||||||
skip.add(hashCode());
|
skip.add(hashCode());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.isEmpty())
|
if (args.isEmpty()) {
|
||||||
{
|
|
||||||
tab(args, tabs);
|
tab(args, tabs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String head = args.get(0);
|
String head = args.get(0);
|
||||||
|
|
||||||
if (args.size() > 1 || head.endsWith(" "))
|
if (args.size() > 1 || head.endsWith(" ")) {
|
||||||
{
|
|
||||||
VirtualDecreeCommand match = matchNode(head, skip);
|
VirtualDecreeCommand match = matchNode(head, skip);
|
||||||
|
|
||||||
if(match != null)
|
if (match != null) {
|
||||||
{
|
|
||||||
args.pop();
|
args.pop();
|
||||||
return match.invokeTabComplete(args, skip, tabs, raw);
|
return match.invokeTabComplete(args, skip, tabs, raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
skip.add(hashCode());
|
skip.add(hashCode());
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tab(args, tabs);
|
tab(args, tabs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,22 +196,18 @@ public class VirtualDecreeCommand {
|
|||||||
Runnable la = () -> {
|
Runnable la = () -> {
|
||||||
|
|
||||||
};
|
};
|
||||||
for(String a : args)
|
for (String a : args) {
|
||||||
{
|
|
||||||
la.run();
|
la.run();
|
||||||
last = a;
|
last = a;
|
||||||
la = () -> {
|
la = () -> {
|
||||||
if(isNode())
|
if (isNode()) {
|
||||||
{
|
|
||||||
String sea = a.contains("=") ? a.split("\\Q=\\E")[0] : a;
|
String sea = a.contains("=") ? a.split("\\Q=\\E")[0] : a;
|
||||||
sea = sea.trim();
|
sea = sea.trim();
|
||||||
|
|
||||||
searching: for(DecreeParameter i : getNode().getParameters())
|
searching:
|
||||||
{
|
for (DecreeParameter i : getNode().getParameters()) {
|
||||||
for(String m : i.getNames())
|
for (String m : i.getNames()) {
|
||||||
{
|
if (m.equalsIgnoreCase(sea) || m.toLowerCase().contains(sea.toLowerCase()) || sea.toLowerCase().contains(m.toLowerCase())) {
|
||||||
if(m.equalsIgnoreCase(sea) || m.toLowerCase().contains(sea.toLowerCase()) || sea.toLowerCase().contains(m.toLowerCase()))
|
|
||||||
{
|
|
||||||
ignore.add(i);
|
ignore.add(i);
|
||||||
continue searching;
|
continue searching;
|
||||||
}
|
}
|
||||||
@ -251,52 +217,37 @@ public class VirtualDecreeCommand {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if(last != null)
|
if (last != null) {
|
||||||
{
|
|
||||||
if (isNode()) {
|
if (isNode()) {
|
||||||
for(DecreeParameter i : getNode().getParameters())
|
for (DecreeParameter i : getNode().getParameters()) {
|
||||||
{
|
if (ignore.contains(i)) {
|
||||||
if(ignore.contains(i))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int g = 0;
|
int g = 0;
|
||||||
|
|
||||||
if(last.contains("="))
|
if (last.contains("=")) {
|
||||||
{
|
|
||||||
String[] vv = last.trim().split("\\Q=\\E");
|
String[] vv = last.trim().split("\\Q=\\E");
|
||||||
String vx = vv.length == 2 ? vv[1] : "";
|
String vx = vv.length == 2 ? vv[1] : "";
|
||||||
for(String f : i.getHandler().getPossibilities(vx).convert((v) -> i.getHandler().toStringForce(v)))
|
for (String f : i.getHandler().getPossibilities(vx).convert((v) -> i.getHandler().toStringForce(v))) {
|
||||||
{
|
|
||||||
g++;
|
g++;
|
||||||
tabs.add(i.getName() +"="+ f);
|
tabs.add(i.getName() + "=" + f);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (String f : i.getHandler().getPossibilities("").convert((v) -> i.getHandler().toStringForce(v))) {
|
||||||
|
g++;
|
||||||
|
tabs.add(i.getName() + "=" + f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
if (g == 0) {
|
||||||
{
|
|
||||||
for(String f : i.getHandler().getPossibilities("").convert((v) -> i.getHandler().toStringForce(v)))
|
|
||||||
{
|
|
||||||
g++;
|
|
||||||
tabs.add(i.getName() +"="+ f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(g == 0)
|
|
||||||
{
|
|
||||||
tabs.add(i.getName() + "=");
|
tabs.add(i.getName() + "=");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
for (VirtualDecreeCommand i : getNodes()) {
|
||||||
else
|
|
||||||
{
|
|
||||||
for(VirtualDecreeCommand i : getNodes())
|
|
||||||
{
|
|
||||||
String m = i.getName();
|
String m = i.getName();
|
||||||
if(m.equalsIgnoreCase(last) || m.toLowerCase().contains(last.toLowerCase()) || last.toLowerCase().contains(m.toLowerCase()))
|
if (m.equalsIgnoreCase(last) || m.toLowerCase().contains(last.toLowerCase()) || last.toLowerCase().contains(m.toLowerCase())) {
|
||||||
{
|
|
||||||
tabs.addAll(i.getNames());
|
tabs.addAll(i.getNames());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,40 +255,30 @@ public class VirtualDecreeCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private KMap<String, Object> map(VolmitSender sender, KList<String> in)
|
private KMap<String, Object> map(VolmitSender sender, KList<String> in) {
|
||||||
{
|
|
||||||
KMap<String, Object> data = new KMap<>();
|
KMap<String, Object> data = new KMap<>();
|
||||||
|
|
||||||
for(int ix = 0; ix < in.size(); ix++)
|
for (int ix = 0; ix < in.size(); ix++) {
|
||||||
{
|
|
||||||
String i = in.get(ix);
|
String i = in.get(ix);
|
||||||
if(i.contains("="))
|
if (i.contains("=")) {
|
||||||
{
|
|
||||||
String[] v = i.split("\\Q=\\E");
|
String[] v = i.split("\\Q=\\E");
|
||||||
String key = v[0];
|
String key = v[0];
|
||||||
String value = v[1];
|
String value = v[1];
|
||||||
DecreeParameter param = null;
|
DecreeParameter param = null;
|
||||||
|
|
||||||
for(DecreeParameter j : getNode().getParameters())
|
for (DecreeParameter j : getNode().getParameters()) {
|
||||||
{
|
for (String k : j.getNames()) {
|
||||||
for(String k : j.getNames())
|
if (k.equalsIgnoreCase(key)) {
|
||||||
{
|
|
||||||
if(k.equalsIgnoreCase(key))
|
|
||||||
{
|
|
||||||
param = j;
|
param = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(param == null)
|
if (param == null) {
|
||||||
{
|
for (DecreeParameter j : getNode().getParameters()) {
|
||||||
for(DecreeParameter j : getNode().getParameters())
|
for (String k : j.getNames()) {
|
||||||
{
|
if (k.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(k.toLowerCase())) {
|
||||||
for(String k : j.getNames())
|
|
||||||
{
|
|
||||||
if(k.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(k.toLowerCase()))
|
|
||||||
{
|
|
||||||
param = j;
|
param = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -345,8 +286,7 @@ public class VirtualDecreeCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(param == null)
|
if (param == null) {
|
||||||
{
|
|
||||||
Iris.debug("Can't find parameter key for " + key + "=" + value + " in " + getPath());
|
Iris.debug("Can't find parameter key for " + key + "=" + value + " in " + getPath());
|
||||||
sender.sendMessage(C.YELLOW + "Unknown Parameter: " + key);
|
sender.sendMessage(C.YELLOW + "Unknown Parameter: " + key);
|
||||||
continue;
|
continue;
|
||||||
@ -367,12 +307,8 @@ public class VirtualDecreeCommand {
|
|||||||
Iris.debug("Client chose " + update + " for " + key + "=" + value + " (old) in " + getPath());
|
Iris.debug("Client chose " + update + " for " + key + "=" + value + " (old) in " + getPath());
|
||||||
in.set(ix--, update);
|
in.set(ix--, update);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
try {
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DecreeParameter par = getNode().getParameters().get(ix);
|
DecreeParameter par = getNode().getParameters().get(ix);
|
||||||
try {
|
try {
|
||||||
data.put(par.getName(), par.getHandler().parse(i));
|
data.put(par.getName(), par.getHandler().parse(i));
|
||||||
@ -387,11 +323,8 @@ public class VirtualDecreeCommand {
|
|||||||
Iris.debug("Client chose " + update + " for " + par.getName() + "=" + i + " (old) in " + getPath());
|
Iris.debug("Client chose " + update + " for " + par.getName() + "=" + i + " (old) in " + getPath());
|
||||||
in.set(ix--, update);
|
in.set(ix--, update);
|
||||||
}
|
}
|
||||||
}
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
sender.sendMessage(C.YELLOW + "Unknown Parameter: " + i + " (" + Form.getNumberSuffixThStRd(ix + 1) + " argument)");
|
||||||
catch(IndexOutOfBoundsException e)
|
|
||||||
{
|
|
||||||
sender.sendMessage(C.YELLOW + "Unknown Parameter: " + i + " (" + Form.getNumberSuffixThStRd(ix+1) + " argument)");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,25 +332,20 @@ public class VirtualDecreeCommand {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean invoke(VolmitSender sender, KList<String> realArgs)
|
public boolean invoke(VolmitSender sender, KList<String> realArgs) {
|
||||||
{
|
|
||||||
return invoke(sender, realArgs, new KList<>());
|
return invoke(sender, realArgs, new KList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean invoke(VolmitSender sender, KList<String> args, KList<Integer> skip)
|
public boolean invoke(VolmitSender sender, KList<String> args, KList<Integer> skip) {
|
||||||
{
|
if (isStudio() && !IrisSettings.get().isStudio()) {
|
||||||
if(isStudio() && !IrisSettings.get().isStudio())
|
|
||||||
{
|
|
||||||
sender.sendMessage(C.RED + "To use Iris Studio Commands, please enable studio in Iris/settings.json (settings auto-reload)");
|
sender.sendMessage(C.RED + "To use Iris Studio Commands, please enable studio in Iris/settings.json (settings auto-reload)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iris.debug("@ " + getPath() + " with " + args.toString(", "));
|
Iris.debug("@ " + getPath() + " with " + args.toString(", "));
|
||||||
if(isNode())
|
if (isNode()) {
|
||||||
{
|
Iris.debug("Invoke " + getPath() + "(" + args.toString(",") + ") at ");
|
||||||
Iris.debug("Invoke " +getPath() + "(" + args.toString(",") + ") at ");
|
if (invokeNode(sender, map(sender, args))) {
|
||||||
if(invokeNode(sender, map(sender, args)))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,8 +353,7 @@ public class VirtualDecreeCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.isEmpty())
|
if (args.isEmpty()) {
|
||||||
{
|
|
||||||
sender.sendDecreeHelp(this);
|
sender.sendDecreeHelp(this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -435,8 +362,7 @@ public class VirtualDecreeCommand {
|
|||||||
String head = args.get(0);
|
String head = args.get(0);
|
||||||
VirtualDecreeCommand match = matchNode(head, skip);
|
VirtualDecreeCommand match = matchNode(head, skip);
|
||||||
|
|
||||||
if(match != null)
|
if (match != null) {
|
||||||
{
|
|
||||||
args.pop();
|
args.pop();
|
||||||
return match.invoke(sender, args, skip);
|
return match.invoke(sender, args, skip);
|
||||||
}
|
}
|
||||||
@ -447,25 +373,20 @@ public class VirtualDecreeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean invokeNode(VolmitSender sender, KMap<String, Object> map) {
|
private boolean invokeNode(VolmitSender sender, KMap<String, Object> map) {
|
||||||
if(map == null)
|
if (map == null) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object[] params = new Object[getNode().getMethod().getParameterCount()];
|
Object[] params = new Object[getNode().getMethod().getParameterCount()];
|
||||||
int vm = 0;
|
int vm = 0;
|
||||||
for(DecreeParameter i : getNode().getParameters())
|
for (DecreeParameter i : getNode().getParameters()) {
|
||||||
{
|
|
||||||
Object value = map.get(i.getName());
|
Object value = map.get(i.getName());
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
if (value == null && i.hasDefault()) {
|
||||||
if(value == null && i.hasDefault())
|
|
||||||
{
|
|
||||||
value = i.getDefaultValue();
|
value = i.getDefaultValue();
|
||||||
}
|
}
|
||||||
}
|
} catch (DecreeParsingException e) {
|
||||||
catch (DecreeParsingException e) {
|
|
||||||
Iris.debug("Can't parse parameter value for " + i.getName() + "=" + i + " in " + getPath() + " using handler " + i.getHandler().getClass().getSimpleName());
|
Iris.debug("Can't parse parameter value for " + i.getName() + "=" + i + " in " + getPath() + " using handler " + i.getHandler().getClass().getSimpleName());
|
||||||
sender.sendMessage(C.RED + "Cannot convert \"" + i + "\" into a " + i.getType().getSimpleName());
|
sender.sendMessage(C.RED + "Cannot convert \"" + i + "\" into a " + i.getType().getSimpleName());
|
||||||
return false;
|
return false;
|
||||||
@ -474,11 +395,9 @@ public class VirtualDecreeCommand {
|
|||||||
KList<?> validOptions = i.getHandler().getPossibilities(i.getParam().defaultValue());
|
KList<?> validOptions = i.getHandler().getPossibilities(i.getParam().defaultValue());
|
||||||
String update = null; // TODO: PICK ONE
|
String update = null; // TODO: PICK ONE
|
||||||
Iris.debug("Client chose " + update + " for " + i.getName() + "=" + i + " (old) in " + getPath());
|
Iris.debug("Client chose " + update + " for " + i.getName() + "=" + i + " (old) in " + getPath());
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
value = i.getDefaultValue();
|
value = i.getDefaultValue();
|
||||||
}
|
} catch (DecreeParsingException x) {
|
||||||
catch (DecreeParsingException x) {
|
|
||||||
x.printStackTrace();
|
x.printStackTrace();
|
||||||
Iris.debug("Can't parse parameter value for " + i.getName() + "=" + i + " in " + getPath() + " using handler " + i.getHandler().getClass().getSimpleName());
|
Iris.debug("Can't parse parameter value for " + i.getName() + "=" + i + " in " + getPath() + " using handler " + i.getHandler().getClass().getSimpleName());
|
||||||
sender.sendMessage(C.RED + "Cannot convert \"" + i + "\" into a " + i.getType().getSimpleName());
|
sender.sendMessage(C.RED + "Cannot convert \"" + i + "\" into a " + i.getType().getSimpleName());
|
||||||
@ -488,33 +407,23 @@ public class VirtualDecreeCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i.isContextual() && value == null)
|
if (i.isContextual() && value == null) {
|
||||||
{
|
|
||||||
DecreeContextHandler<?> ch = DecreeContextHandler.contextHandlers.get(i.getType());
|
DecreeContextHandler<?> ch = DecreeContextHandler.contextHandlers.get(i.getType());
|
||||||
|
|
||||||
if(ch != null)
|
if (ch != null) {
|
||||||
{
|
|
||||||
value = ch.handle(sender);
|
value = ch.handle(sender);
|
||||||
|
|
||||||
if(value != null)
|
if (value != null) {
|
||||||
{
|
|
||||||
Iris.debug("Null Parameter " + i.getName() + " derived a value of " + i.getHandler().toStringForce(value) + " from " + ch.getClass().getSimpleName());
|
Iris.debug("Null Parameter " + i.getName() + " derived a value of " + i.getHandler().toStringForce(value) + " from " + ch.getClass().getSimpleName());
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Iris.debug("Null Parameter " + i.getName() + " could not derive a value from " + ch.getClass().getSimpleName());
|
Iris.debug("Null Parameter " + i.getName() + " could not derive a value from " + ch.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Iris.debug("Null Parameter " + i.getName() + " is contextual but has no context handler for " + i.getType().getCanonicalName());
|
Iris.debug("Null Parameter " + i.getName() + " is contextual but has no context handler for " + i.getType().getCanonicalName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i.hasDefault() && value == null)
|
if (i.hasDefault() && value == null) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
Iris.debug("Null Parameter " + i.getName() + " is using default value " + i.getParam().defaultValue());
|
Iris.debug("Null Parameter " + i.getName() + " is using default value " + i.getParam().defaultValue());
|
||||||
value = i.getDefaultValue();
|
value = i.getDefaultValue();
|
||||||
@ -523,7 +432,7 @@ public class VirtualDecreeCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i.isRequired() && value == null) {
|
if (i.isRequired() && value == null) {
|
||||||
sender.sendMessage("Missing: " + i.getName() + " (" + i.getType().getSimpleName() + ") as the " + Form.getNumberSuffixThStRd(vm + 1) + " argument.");
|
sender.sendMessage("Missing: " + i.getName() + " (" + i.getType().getSimpleName() + ") as the " + Form.getNumberSuffixThStRd(vm + 1) + " argument.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -533,55 +442,41 @@ public class VirtualDecreeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Runnable rx = () -> {
|
Runnable rx = () -> {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
DecreeContext.touch(sender);
|
DecreeContext.touch(sender);
|
||||||
getNode().getMethod().setAccessible(true);
|
getNode().getMethod().setAccessible(true);
|
||||||
getNode().getMethod().invoke(getNode().getInstance(), params);
|
getNode().getMethod().invoke(getNode().getInstance(), params);
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new RuntimeException("Failed to execute <INSERT REAL NODE HERE>"); // TODO:
|
throw new RuntimeException("Failed to execute <INSERT REAL NODE HERE>"); // TODO:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(getNode().isSync())
|
if (getNode().isSync()) {
|
||||||
{
|
|
||||||
J.s(rx);
|
J.s(rx);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rx.run();
|
rx.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<VirtualDecreeCommand> matchAllNodes(String in)
|
public KList<VirtualDecreeCommand> matchAllNodes(String in) {
|
||||||
{
|
|
||||||
KList<VirtualDecreeCommand> g = new KList<>();
|
KList<VirtualDecreeCommand> g = new KList<>();
|
||||||
|
|
||||||
if(in.trim().isEmpty())
|
if (in.trim().isEmpty()) {
|
||||||
{
|
|
||||||
g.addAll(nodes);
|
g.addAll(nodes);
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(VirtualDecreeCommand i : nodes)
|
for (VirtualDecreeCommand i : nodes) {
|
||||||
{
|
if (i.matches(in)) {
|
||||||
if(i.matches(in))
|
|
||||||
{
|
|
||||||
g.add(i);
|
g.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(VirtualDecreeCommand i : nodes)
|
for (VirtualDecreeCommand i : nodes) {
|
||||||
{
|
if (i.deepMatches(in)) {
|
||||||
if(i.deepMatches(in))
|
|
||||||
{
|
|
||||||
g.add(i);
|
g.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -590,35 +485,27 @@ public class VirtualDecreeCommand {
|
|||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VirtualDecreeCommand matchNode(String in, KList<Integer> skip)
|
public VirtualDecreeCommand matchNode(String in, KList<Integer> skip) {
|
||||||
{
|
if (in.trim().isEmpty()) {
|
||||||
if(in.trim().isEmpty())
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(VirtualDecreeCommand i : nodes)
|
for (VirtualDecreeCommand i : nodes) {
|
||||||
{
|
if (skip.contains(i.hashCode())) {
|
||||||
if(skip.contains(i.hashCode()))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i.matches(in))
|
if (i.matches(in)) {
|
||||||
{
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(VirtualDecreeCommand i : nodes)
|
for (VirtualDecreeCommand i : nodes) {
|
||||||
{
|
if (skip.contains(i.hashCode())) {
|
||||||
if(skip.contains(i.hashCode()))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i.deepMatches(in))
|
if (i.deepMatches(in)) {
|
||||||
{
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -626,14 +513,11 @@ public class VirtualDecreeCommand {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deepMatches(String in)
|
public boolean deepMatches(String in) {
|
||||||
{
|
|
||||||
KList<String> a = getNames();
|
KList<String> a = getNames();
|
||||||
|
|
||||||
for(String i : a)
|
for (String i : a) {
|
||||||
{
|
if (i.toLowerCase().contains(in.toLowerCase()) || in.toLowerCase().contains(i.toLowerCase())) {
|
||||||
if(i.toLowerCase().contains(in.toLowerCase()) || in.toLowerCase().contains(i.toLowerCase()))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -642,26 +526,23 @@ public class VirtualDecreeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode(){
|
public int hashCode() {
|
||||||
return Objects.hash(getName(), getDescription(), getType(), getPath());
|
return Objects.hash(getName(), getDescription(), getType(), getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj){
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof VirtualDecreeCommand)){
|
if (!(obj instanceof VirtualDecreeCommand)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.hashCode() == obj.hashCode();
|
return this.hashCode() == obj.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(String in)
|
public boolean matches(String in) {
|
||||||
{
|
|
||||||
KList<String> a = getNames();
|
KList<String> a = getNames();
|
||||||
|
|
||||||
for(String i : a)
|
for (String i : a) {
|
||||||
{
|
if (i.equalsIgnoreCase(in)) {
|
||||||
if(i.equalsIgnoreCase(in))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.format;
|
package com.volmit.iris.util.format;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RollingSequence;
|
import com.volmit.iris.util.math.RollingSequence;
|
||||||
|
|
||||||
|
@ -136,8 +136,7 @@ public class Mantle {
|
|||||||
throw new RuntimeException("The Mantle is closed");
|
throw new RuntimeException("The Mantle is closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(y < 0)
|
if (y < 0) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,8 +169,7 @@ public class Mantle {
|
|||||||
throw new RuntimeException("The Mantle is closed");
|
throw new RuntimeException("The Mantle is closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(y < 0)
|
if (y < 0) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,8 +257,7 @@ public class Mantle {
|
|||||||
*/
|
*/
|
||||||
@RegionCoordinates
|
@RegionCoordinates
|
||||||
private TectonicPlate get(int x, int z) {
|
private TectonicPlate get(int x, int z) {
|
||||||
if(io.get())
|
if (io.get()) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
return getSafe(x, z).get();
|
return getSafe(x, z).get();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -272,8 +269,7 @@ public class Mantle {
|
|||||||
|
|
||||||
TectonicPlate p = loadedRegions.get(key(x, z));
|
TectonicPlate p = loadedRegions.get(key(x, z));
|
||||||
|
|
||||||
if(p != null)
|
if (p != null) {
|
||||||
{
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,305 +18,258 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.network;
|
package com.volmit.iris.util.network;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
|
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
import com.volmit.iris.util.io.IO;
|
import com.volmit.iris.util.io.IO;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
|
|
||||||
public abstract class DL
|
import java.io.*;
|
||||||
{
|
import java.net.URL;
|
||||||
protected File d;
|
import java.net.URLConnection;
|
||||||
protected URL u;
|
|
||||||
protected ChronoLatch latch;
|
|
||||||
protected KSet<DownloadFlag> flags;
|
|
||||||
protected MeteredOutputStream o;
|
|
||||||
protected DownloadState state;
|
|
||||||
protected int timeout;
|
|
||||||
protected long size;
|
|
||||||
protected long start;
|
|
||||||
protected long downloaded;
|
|
||||||
protected long currentChunk;
|
|
||||||
protected long lastChunk;
|
|
||||||
protected long bps;
|
|
||||||
protected int bufferSize;
|
|
||||||
protected long lastPull;
|
|
||||||
protected DownloadMonitor m;
|
|
||||||
|
|
||||||
public DL(URL u, File d, DownloadFlag...downloadFlags)
|
|
||||||
{
|
|
||||||
this.d = d;
|
|
||||||
this.u = u;
|
|
||||||
size = -1;
|
|
||||||
lastPull = -1;
|
|
||||||
downloaded = 0;
|
|
||||||
bufferSize = 8192 * 32;
|
|
||||||
currentChunk = 0;
|
|
||||||
lastChunk = -1;
|
|
||||||
bps = -1;
|
|
||||||
start = -1;
|
|
||||||
timeout = 10000;
|
|
||||||
state = DownloadState.NEW;
|
|
||||||
flags = new KSet<>();
|
|
||||||
latch = new ChronoLatch(500);
|
|
||||||
|
|
||||||
for(DownloadFlag i : downloadFlags)
|
public abstract class DL {
|
||||||
{
|
protected File d;
|
||||||
flags.add(i);
|
protected URL u;
|
||||||
}
|
protected ChronoLatch latch;
|
||||||
}
|
protected KSet<DownloadFlag> flags;
|
||||||
|
protected MeteredOutputStream o;
|
||||||
public void monitor(DownloadMonitor m)
|
protected DownloadState state;
|
||||||
{
|
protected int timeout;
|
||||||
this.m = m;
|
protected long size;
|
||||||
}
|
protected long start;
|
||||||
|
protected long downloaded;
|
||||||
public void update()
|
protected long currentChunk;
|
||||||
{
|
protected long lastChunk;
|
||||||
if(m != null)
|
protected long bps;
|
||||||
{
|
protected int bufferSize;
|
||||||
m.onUpdate(state, getProgress(), getElapsed(), getTimeLeft(), bps, getDiskBytesPerSecond(), size, downloaded, bufferSize, getBufferUse());
|
protected long lastPull;
|
||||||
}
|
protected DownloadMonitor m;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasFlag(DownloadFlag f)
|
|
||||||
{
|
|
||||||
return flags.contains(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isState(DownloadState s)
|
|
||||||
{
|
|
||||||
return state.equals(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void state(DownloadState s)
|
|
||||||
{
|
|
||||||
this.state = s;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBufferSize()
|
|
||||||
{
|
|
||||||
return bufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start() throws IOException
|
|
||||||
{
|
|
||||||
if(!isState(DownloadState.NEW))
|
|
||||||
{
|
|
||||||
throw new DownloadException("Cannot start download while " + state.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
state(DownloadState.STARTING);
|
|
||||||
|
|
||||||
if(hasFlag(DownloadFlag.CALCULATE_SIZE))
|
|
||||||
{
|
|
||||||
size = calculateSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
start = System.currentTimeMillis();
|
|
||||||
downloaded = 0;
|
|
||||||
bps = 0;
|
|
||||||
lastChunk = System.currentTimeMillis();
|
|
||||||
o = new MeteredOutputStream(new FileOutputStream(d), 100);
|
|
||||||
openStream();
|
|
||||||
state(DownloadState.DOWNLOADING);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract long download() throws IOException;
|
|
||||||
|
|
||||||
protected abstract void openStream() throws IOException;
|
|
||||||
|
|
||||||
protected abstract void closeStream() throws IOException;
|
|
||||||
|
|
||||||
public void downloadChunk() throws IOException
|
|
||||||
{
|
|
||||||
if(!isState(DownloadState.DOWNLOADING))
|
|
||||||
{
|
|
||||||
throw new DownloadException("Cannot download while " + state.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
long d = download();
|
|
||||||
lastPull = d;
|
|
||||||
|
|
||||||
if(d < 0)
|
|
||||||
{
|
|
||||||
finishDownload();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
downloaded += d;
|
|
||||||
currentChunk += d;
|
|
||||||
|
|
||||||
double chunkTime = (double)(System.currentTimeMillis() - lastChunk) / 1000D;
|
|
||||||
bps = (long) ((double)currentChunk / chunkTime);
|
|
||||||
|
|
||||||
if(latch.flip())
|
|
||||||
{
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getBufferUse()
|
|
||||||
{
|
|
||||||
return (double)lastPull / (double)bufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void finishDownload() throws IOException
|
|
||||||
{
|
|
||||||
if(!isState(DownloadState.NEW))
|
|
||||||
{
|
|
||||||
throw new DownloadException("Cannot finish download while " + state.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
closeStream();
|
|
||||||
o.close();
|
|
||||||
state(DownloadState.COMPLETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getElapsed()
|
public DL(URL u, File d, DownloadFlag... downloadFlags) {
|
||||||
{
|
this.d = d;
|
||||||
return System.currentTimeMillis() - start;
|
this.u = u;
|
||||||
}
|
size = -1;
|
||||||
|
lastPull = -1;
|
||||||
public long getRemaining()
|
downloaded = 0;
|
||||||
{
|
bufferSize = 8192 * 32;
|
||||||
return size - downloaded;
|
currentChunk = 0;
|
||||||
}
|
lastChunk = -1;
|
||||||
|
bps = -1;
|
||||||
public long getTimeLeft()
|
start = -1;
|
||||||
{
|
timeout = 10000;
|
||||||
return (long) (((double)getRemaining() / (double)bps) * 1000D);
|
state = DownloadState.NEW;
|
||||||
}
|
flags = new KSet<>();
|
||||||
|
latch = new ChronoLatch(500);
|
||||||
public long getDiskBytesPerSecond()
|
|
||||||
{
|
|
||||||
if(o == null)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return o.getBps();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getBytesPerSecond()
|
|
||||||
{
|
|
||||||
return bps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getProgress()
|
|
||||||
{
|
|
||||||
return hasProgress() ? ((double)downloaded / (double)size) : -1D;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasProgress()
|
|
||||||
{
|
|
||||||
return size > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private long calculateSize() throws IOException
|
for (DownloadFlag i : downloadFlags) {
|
||||||
{
|
flags.add(i);
|
||||||
URLConnection c = u.openConnection();
|
}
|
||||||
c.setConnectTimeout((int) timeout);
|
}
|
||||||
c.setReadTimeout((int) timeout);
|
|
||||||
c.connect();
|
|
||||||
return c.getContentLengthLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum DownloadFlag
|
|
||||||
{
|
|
||||||
CALCULATE_SIZE
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum DownloadState
|
|
||||||
{
|
|
||||||
NEW,
|
|
||||||
STARTING,
|
|
||||||
DOWNLOADING,
|
|
||||||
FINALIZING,
|
|
||||||
COMPLETE,
|
|
||||||
FAILED
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ThrottledDownload extends Download
|
|
||||||
{
|
|
||||||
private long mbps;
|
|
||||||
|
|
||||||
public ThrottledDownload(URL u, File d, long mbps, DownloadFlag... downloadFlags) {
|
|
||||||
super(u, d, downloadFlags);
|
|
||||||
this.mbps = mbps;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected long download() throws IOException
|
|
||||||
{
|
|
||||||
if(getBytesPerSecond() > mbps)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.sleep(40);
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return IO.transfer(in, o, 8192, mbps/20);
|
|
||||||
}
|
|
||||||
|
|
||||||
return IO.transfer(in, o, 8192, bufferSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DoubleBufferedDownload extends Download
|
|
||||||
{
|
|
||||||
protected BufferedOutputStream os;
|
|
||||||
|
|
||||||
public DoubleBufferedDownload(URL u, File d, DownloadFlag... downloadFlags)
|
|
||||||
{
|
|
||||||
super(u, d, downloadFlags);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void openStream() throws IOException
|
|
||||||
{
|
|
||||||
os = new BufferedOutputStream(o, 8192*16);
|
|
||||||
in = new BufferedInputStream(u.openStream(), 8192*16);
|
|
||||||
buf = new byte[8192 * 2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Download extends DL
|
|
||||||
{
|
|
||||||
protected InputStream in;
|
|
||||||
protected byte[] buf;
|
|
||||||
public Download(URL u, File d, DownloadFlag... downloadFlags) {
|
|
||||||
super(u, d, downloadFlags);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void monitor(DownloadMonitor m) {
|
||||||
protected long download() throws IOException
|
this.m = m;
|
||||||
{
|
}
|
||||||
return IO.transfer(in, o, buf, bufferSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void update() {
|
||||||
protected void openStream() throws IOException {
|
if (m != null) {
|
||||||
in = u.openStream();
|
m.onUpdate(state, getProgress(), getElapsed(), getTimeLeft(), bps, getDiskBytesPerSecond(), size, downloaded, bufferSize, getBufferUse());
|
||||||
buf = new byte[8192];
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean hasFlag(DownloadFlag f) {
|
||||||
protected void closeStream() throws IOException {
|
return flags.contains(f);
|
||||||
in.close();
|
}
|
||||||
}
|
|
||||||
}
|
public boolean isState(DownloadState s) {
|
||||||
|
return state.equals(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void state(DownloadState s) {
|
||||||
|
this.state = s;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBufferSize() {
|
||||||
|
return bufferSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() throws IOException {
|
||||||
|
if (!isState(DownloadState.NEW)) {
|
||||||
|
throw new DownloadException("Cannot start download while " + state.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
state(DownloadState.STARTING);
|
||||||
|
|
||||||
|
if (hasFlag(DownloadFlag.CALCULATE_SIZE)) {
|
||||||
|
size = calculateSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
start = System.currentTimeMillis();
|
||||||
|
downloaded = 0;
|
||||||
|
bps = 0;
|
||||||
|
lastChunk = System.currentTimeMillis();
|
||||||
|
o = new MeteredOutputStream(new FileOutputStream(d), 100);
|
||||||
|
openStream();
|
||||||
|
state(DownloadState.DOWNLOADING);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract long download() throws IOException;
|
||||||
|
|
||||||
|
protected abstract void openStream() throws IOException;
|
||||||
|
|
||||||
|
protected abstract void closeStream() throws IOException;
|
||||||
|
|
||||||
|
public void downloadChunk() throws IOException {
|
||||||
|
if (!isState(DownloadState.DOWNLOADING)) {
|
||||||
|
throw new DownloadException("Cannot download while " + state.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
long d = download();
|
||||||
|
lastPull = d;
|
||||||
|
|
||||||
|
if (d < 0) {
|
||||||
|
finishDownload();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
downloaded += d;
|
||||||
|
currentChunk += d;
|
||||||
|
|
||||||
|
double chunkTime = (double) (System.currentTimeMillis() - lastChunk) / 1000D;
|
||||||
|
bps = (long) ((double) currentChunk / chunkTime);
|
||||||
|
|
||||||
|
if (latch.flip()) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getBufferUse() {
|
||||||
|
return (double) lastPull / (double) bufferSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void finishDownload() throws IOException {
|
||||||
|
if (!isState(DownloadState.NEW)) {
|
||||||
|
throw new DownloadException("Cannot finish download while " + state.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
closeStream();
|
||||||
|
o.close();
|
||||||
|
state(DownloadState.COMPLETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getElapsed() {
|
||||||
|
return System.currentTimeMillis() - start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getRemaining() {
|
||||||
|
return size - downloaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimeLeft() {
|
||||||
|
return (long) (((double) getRemaining() / (double) bps) * 1000D);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getDiskBytesPerSecond() {
|
||||||
|
if (o == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return o.getBps();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBytesPerSecond() {
|
||||||
|
return bps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getProgress() {
|
||||||
|
return hasProgress() ? ((double) downloaded / (double) size) : -1D;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasProgress() {
|
||||||
|
return size > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long calculateSize() throws IOException {
|
||||||
|
URLConnection c = u.openConnection();
|
||||||
|
c.setConnectTimeout(timeout);
|
||||||
|
c.setReadTimeout(timeout);
|
||||||
|
c.connect();
|
||||||
|
return c.getContentLengthLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DownloadFlag {
|
||||||
|
CALCULATE_SIZE
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DownloadState {
|
||||||
|
NEW,
|
||||||
|
STARTING,
|
||||||
|
DOWNLOADING,
|
||||||
|
FINALIZING,
|
||||||
|
COMPLETE,
|
||||||
|
FAILED
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ThrottledDownload extends Download {
|
||||||
|
private final long mbps;
|
||||||
|
|
||||||
|
public ThrottledDownload(URL u, File d, long mbps, DownloadFlag... downloadFlags) {
|
||||||
|
super(u, d, downloadFlags);
|
||||||
|
this.mbps = mbps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected long download() throws IOException {
|
||||||
|
if (getBytesPerSecond() > mbps) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(40);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return IO.transfer(in, o, 8192, mbps / 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
return IO.transfer(in, o, 8192, bufferSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DoubleBufferedDownload extends Download {
|
||||||
|
protected BufferedOutputStream os;
|
||||||
|
|
||||||
|
public DoubleBufferedDownload(URL u, File d, DownloadFlag... downloadFlags) {
|
||||||
|
super(u, d, downloadFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void openStream() throws IOException {
|
||||||
|
os = new BufferedOutputStream(o, 8192 * 16);
|
||||||
|
in = new BufferedInputStream(u.openStream(), 8192 * 16);
|
||||||
|
buf = new byte[8192 * 2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Download extends DL {
|
||||||
|
protected InputStream in;
|
||||||
|
protected byte[] buf;
|
||||||
|
|
||||||
|
public Download(URL u, File d, DownloadFlag... downloadFlags) {
|
||||||
|
super(u, d, downloadFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected long download() throws IOException {
|
||||||
|
return IO.transfer(in, o, buf, bufferSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void openStream() throws IOException {
|
||||||
|
in = u.openStream();
|
||||||
|
buf = new byte[8192];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void closeStream() throws IOException {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,23 +20,22 @@ package com.volmit.iris.util.network;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class DownloadException extends IOException
|
public class DownloadException extends IOException {
|
||||||
{
|
private static final long serialVersionUID = 5137918663903349839L;
|
||||||
private static final long serialVersionUID = 5137918663903349839L;
|
|
||||||
|
|
||||||
public DownloadException() {
|
public DownloadException() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadException(String message, Throwable cause) {
|
public DownloadException(String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadException(String message) {
|
public DownloadException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadException(Throwable cause) {
|
public DownloadException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,7 +19,6 @@
|
|||||||
package com.volmit.iris.util.network;
|
package com.volmit.iris.util.network;
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface DownloadMonitor
|
public interface DownloadMonitor {
|
||||||
{
|
void onUpdate(DL.DownloadState state, double progress, long elapsed, long estimated, long bps, long iobps, long size, long downloaded, long buffer, double bufferuse);
|
||||||
public void onUpdate(DL.DownloadState state, double progress, long elapsed, long estimated, long bps, long iobps, long size, long downloaded, long buffer, double bufferuse);
|
|
||||||
}
|
}
|
@ -21,100 +21,85 @@ package com.volmit.iris.util.network;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
public class MeteredInputStream extends InputStream
|
public class MeteredInputStream extends InputStream {
|
||||||
{
|
private final InputStream os;
|
||||||
private InputStream os;
|
private long written;
|
||||||
private long written;
|
private long totalWritten;
|
||||||
private long totalWritten;
|
private long since;
|
||||||
private long since;
|
private boolean auto;
|
||||||
private boolean auto;
|
private long interval;
|
||||||
private long interval;
|
private long bps;
|
||||||
private long bps;
|
|
||||||
|
|
||||||
public MeteredInputStream(InputStream os, long interval)
|
|
||||||
{
|
|
||||||
this.os = os;
|
|
||||||
written = 0;
|
|
||||||
totalWritten = 0;
|
|
||||||
auto = true;
|
|
||||||
this.interval = interval;
|
|
||||||
bps = 0;
|
|
||||||
since = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MeteredInputStream(InputStream os)
|
|
||||||
{
|
|
||||||
this(os, 100);
|
|
||||||
auto = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public MeteredInputStream(InputStream os, long interval) {
|
||||||
public int read() throws IOException
|
this.os = os;
|
||||||
{
|
written = 0;
|
||||||
written++;
|
totalWritten = 0;
|
||||||
totalWritten++;
|
auto = true;
|
||||||
|
this.interval = interval;
|
||||||
if(auto && System.currentTimeMillis() - getSince() > interval)
|
bps = 0;
|
||||||
{
|
since = System.currentTimeMillis();
|
||||||
pollRead();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return os.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSince()
|
|
||||||
{
|
|
||||||
return since;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getRead()
|
|
||||||
{
|
|
||||||
return written;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long pollRead()
|
|
||||||
{
|
|
||||||
long w = written;
|
|
||||||
written = 0;
|
|
||||||
double secondsElapsedSince = (double) (System.currentTimeMillis() - since) / 1000.0;
|
|
||||||
bps = (long) ((double) w / secondsElapsedSince);
|
|
||||||
since = System.currentTimeMillis();
|
|
||||||
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() throws IOException
|
public MeteredInputStream(InputStream os) {
|
||||||
{
|
this(os, 100);
|
||||||
os.close();
|
auto = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuto()
|
@Override
|
||||||
{
|
public int read() throws IOException {
|
||||||
return auto;
|
written++;
|
||||||
}
|
totalWritten++;
|
||||||
|
|
||||||
public void setAuto(boolean auto)
|
if (auto && System.currentTimeMillis() - getSince() > interval) {
|
||||||
{
|
pollRead();
|
||||||
this.auto = auto;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getInterval()
|
return os.read();
|
||||||
{
|
}
|
||||||
return interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInterval(long interval)
|
public long getSince() {
|
||||||
{
|
return since;
|
||||||
this.interval = interval;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalRead()
|
public long getRead() {
|
||||||
{
|
return written;
|
||||||
return totalWritten;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getBps()
|
public long pollRead() {
|
||||||
{
|
long w = written;
|
||||||
return bps;
|
written = 0;
|
||||||
}
|
double secondsElapsedSince = (double) (System.currentTimeMillis() - since) / 1000.0;
|
||||||
|
bps = (long) ((double) w / secondsElapsedSince);
|
||||||
|
since = System.currentTimeMillis();
|
||||||
|
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() throws IOException {
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAuto() {
|
||||||
|
return auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuto(boolean auto) {
|
||||||
|
this.auto = auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getInterval() {
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterval(long interval) {
|
||||||
|
this.interval = interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalRead() {
|
||||||
|
return totalWritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBps() {
|
||||||
|
return bps;
|
||||||
|
}
|
||||||
}
|
}
|
@ -21,98 +21,83 @@ package com.volmit.iris.util.network;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
public class MeteredOutputStream extends OutputStream
|
public class MeteredOutputStream extends OutputStream {
|
||||||
{
|
private final OutputStream os;
|
||||||
private OutputStream os;
|
private long written;
|
||||||
private long written;
|
private long totalWritten;
|
||||||
private long totalWritten;
|
private long since;
|
||||||
private long since;
|
private boolean auto;
|
||||||
private boolean auto;
|
private long interval;
|
||||||
private long interval;
|
private long bps;
|
||||||
private long bps;
|
|
||||||
|
|
||||||
public MeteredOutputStream(OutputStream os, long interval)
|
|
||||||
{
|
|
||||||
this.os = os;
|
|
||||||
written = 0;
|
|
||||||
totalWritten = 0;
|
|
||||||
auto = true;
|
|
||||||
this.interval = interval;
|
|
||||||
bps = 0;
|
|
||||||
since = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MeteredOutputStream(OutputStream os)
|
|
||||||
{
|
|
||||||
this(os, 100);
|
|
||||||
auto = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public MeteredOutputStream(OutputStream os, long interval) {
|
||||||
public void write(int b) throws IOException
|
this.os = os;
|
||||||
{
|
written = 0;
|
||||||
os.write(b);
|
totalWritten = 0;
|
||||||
written++;
|
auto = true;
|
||||||
totalWritten++;
|
this.interval = interval;
|
||||||
|
bps = 0;
|
||||||
if(auto && System.currentTimeMillis() - getSince() > interval)
|
since = System.currentTimeMillis();
|
||||||
{
|
}
|
||||||
pollWritten();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSince()
|
|
||||||
{
|
|
||||||
return since;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getWritten()
|
|
||||||
{
|
|
||||||
return written;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long pollWritten()
|
|
||||||
{
|
|
||||||
long w = written;
|
|
||||||
written = 0;
|
|
||||||
double secondsElapsedSince = (double) (System.currentTimeMillis() - since) / 1000.0;
|
|
||||||
bps = (long) ((double) w / secondsElapsedSince);
|
|
||||||
since = System.currentTimeMillis();
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() throws IOException
|
public MeteredOutputStream(OutputStream os) {
|
||||||
{
|
this(os, 100);
|
||||||
os.close();
|
auto = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuto()
|
@Override
|
||||||
{
|
public void write(int b) throws IOException {
|
||||||
return auto;
|
os.write(b);
|
||||||
}
|
written++;
|
||||||
|
totalWritten++;
|
||||||
|
|
||||||
public void setAuto(boolean auto)
|
if (auto && System.currentTimeMillis() - getSince() > interval) {
|
||||||
{
|
pollWritten();
|
||||||
this.auto = auto;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getInterval()
|
public long getSince() {
|
||||||
{
|
return since;
|
||||||
return interval;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setInterval(long interval)
|
public long getWritten() {
|
||||||
{
|
return written;
|
||||||
this.interval = interval;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalWritten()
|
public long pollWritten() {
|
||||||
{
|
long w = written;
|
||||||
return totalWritten;
|
written = 0;
|
||||||
}
|
double secondsElapsedSince = (double) (System.currentTimeMillis() - since) / 1000.0;
|
||||||
|
bps = (long) ((double) w / secondsElapsedSince);
|
||||||
|
since = System.currentTimeMillis();
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
public long getBps()
|
public void close() throws IOException {
|
||||||
{
|
os.close();
|
||||||
return bps;
|
}
|
||||||
}
|
|
||||||
|
public boolean isAuto() {
|
||||||
|
return auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuto(boolean auto) {
|
||||||
|
this.auto = auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getInterval() {
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterval(long interval) {
|
||||||
|
this.interval = interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalWritten() {
|
||||||
|
return totalWritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBps() {
|
||||||
|
return bps;
|
||||||
|
}
|
||||||
}
|
}
|
@ -360,11 +360,9 @@ public class VolmitSender implements CommandSender {
|
|||||||
return s.spigot();
|
return s.spigot();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String pickRandoms(int max, VirtualDecreeCommand i)
|
private String pickRandoms(int max, VirtualDecreeCommand i) {
|
||||||
{
|
|
||||||
KList<String> m = new KList<>();
|
KList<String> m = new KList<>();
|
||||||
for(int ix = 0; ix < max; ix++)
|
for (int ix = 0; ix < max; ix++) {
|
||||||
{
|
|
||||||
m.add((i.isNode()
|
m.add((i.isNode()
|
||||||
? (i.getNode().getParameters().isNotEmpty())
|
? (i.getNode().getParameters().isNotEmpty())
|
||||||
? "<#aebef2>✦ <#5ef288>"
|
? "<#aebef2>✦ <#5ef288>"
|
||||||
@ -385,8 +383,7 @@ public class VolmitSender implements CommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void sendHeader(String name, int overrideLength)
|
public void sendHeader(String name, int overrideLength) {
|
||||||
{
|
|
||||||
int len = overrideLength;
|
int len = overrideLength;
|
||||||
int h = name.length() + 2;
|
int h = name.length() + 2;
|
||||||
String s = Form.repeat(" ", len - h - 4);
|
String s = Form.repeat(" ", len - h - 4);
|
||||||
@ -395,95 +392,80 @@ public class VolmitSender implements CommandSender {
|
|||||||
String sf = "[";
|
String sf = "[";
|
||||||
String se = "]";
|
String se = "]";
|
||||||
|
|
||||||
if(name.trim().isEmpty())
|
if (name.trim().isEmpty()) {
|
||||||
{
|
sendMessageRaw("<font:minecraft:uniform><strikethrough><gradient:#34eb6b:#32bfad>" + sf + s + "<reset><font:minecraft:uniform><strikethrough><gradient:#32bfad:#34eb6b>" + s + se);
|
||||||
sendMessageRaw("<font:minecraft:uniform><strikethrough><gradient:#34eb6b:#32bfad>" + sf + s + "<reset><font:minecraft:uniform><strikethrough><gradient:#32bfad:#34eb6b>" + s + se);
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sendMessageRaw("<font:minecraft:uniform><strikethrough><gradient:#34eb6b:#32bfad>" + sf + s + si + "<reset> <gradient:#3299bf:#323bbf>" + name + "<reset> <font:minecraft:uniform><strikethrough><gradient:#32bfad:#34eb6b>" + so + s + se);
|
sendMessageRaw("<font:minecraft:uniform><strikethrough><gradient:#34eb6b:#32bfad>" + sf + s + si + "<reset> <gradient:#3299bf:#323bbf>" + name + "<reset> <font:minecraft:uniform><strikethrough><gradient:#32bfad:#34eb6b>" + so + s + se);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendHeader(String name)
|
public void sendHeader(String name) {
|
||||||
{
|
sendHeader(name, 46);
|
||||||
sendHeader(name,46);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendDecreeHelp(VirtualDecreeCommand v) {
|
public void sendDecreeHelp(VirtualDecreeCommand v) {
|
||||||
int m = v.getNodes().size();
|
int m = v.getNodes().size();
|
||||||
|
|
||||||
if(v.getNodes().isNotEmpty())
|
if (v.getNodes().isNotEmpty()) {
|
||||||
{
|
|
||||||
sendHeader(Form.capitalize(v.getName()) + " Help");
|
sendHeader(Form.capitalize(v.getName()) + " Help");
|
||||||
if(isPlayer() && v.getParent() != null)
|
if (isPlayer() && v.getParent() != null) {
|
||||||
{
|
sendMessageRaw("<hover:show_text:'" + "<#b54b38>Click to go back to <#3299bf>" + Form.capitalize(v.getParent().getName()) + " Help" + "'><click:run_command:" + v.getParent().getPath() + "><font:minecraft:uniform><#f58571>〈 Back</click></hover>");
|
||||||
sendMessageRaw("<hover:show_text:'"+"<#b54b38>Click to go back to <#3299bf>" + Form.capitalize(v.getParent().getName()) + " Help" +"'><click:run_command:" + v.getParent().getPath() + "><font:minecraft:uniform><#f58571>〈 Back</click></hover>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(VirtualDecreeCommand i : v.getNodes())
|
for (VirtualDecreeCommand i : v.getNodes()) {
|
||||||
{
|
if (isPlayer()) {
|
||||||
if(isPlayer())
|
|
||||||
{
|
|
||||||
//@builder
|
//@builder
|
||||||
String s = (
|
String s = (
|
||||||
"<hover:show_text:'"+
|
"<hover:show_text:'" +
|
||||||
i.getNames().copy().reverse().convert((f) -> "<#42ecf5>" + f).toString(", ") + "\n"
|
i.getNames().copy().reverse().convert((f) -> "<#42ecf5>" + f).toString(", ") + "\n"
|
||||||
+ "<#3fe05a>✎ <#6ad97d><font:minecraft:uniform>" + i.getDescription() + "<reset>\n"
|
+ "<#3fe05a>✎ <#6ad97d><font:minecraft:uniform>" + i.getDescription() + "<reset>\n"
|
||||||
+ "<#bbe03f>✒ <#a8e0a2>" + (i.isNode()
|
+ "<#bbe03f>✒ <#a8e0a2>" + (i.isNode()
|
||||||
? ((i.getNode().getParameters().isEmpty()
|
? ((i.getNode().getParameters().isEmpty()
|
||||||
? "<font:minecraft:uniform>There are no parameters.<reset>"
|
? "<font:minecraft:uniform>There are no parameters.<reset>"
|
||||||
: "<font:minecraft:uniform>Hover over all of the parameters to learn more.<reset>") + "\n")
|
: "<font:minecraft:uniform>Hover over all of the parameters to learn more.<reset>") + "\n")
|
||||||
: "<font:minecraft:uniform>This is a command category. Run <reset><#98eda5>" + i.getPath())
|
: "<font:minecraft:uniform>This is a command category. Run <reset><#98eda5>" + i.getPath())
|
||||||
+ (i.isNode()
|
+ (i.isNode()
|
||||||
? (i.getNode().getParameters().isNotEmpty())
|
? (i.getNode().getParameters().isNotEmpty())
|
||||||
? "<#aebef2>✦ <#5ef288><font:minecraft:uniform>"
|
? "<#aebef2>✦ <#5ef288><font:minecraft:uniform>"
|
||||||
+ i.getParentPath()
|
+ i.getParentPath()
|
||||||
+ " <#42ecf5>"
|
+ " <#42ecf5>"
|
||||||
+ i.getName() + " "
|
+ i.getName() + " "
|
||||||
+ i.getNode().getParameters().convert((f)
|
+ i.getNode().getParameters().convert((f)
|
||||||
-> "<#d665f0>" + f.example())
|
-> "<#d665f0>" + f.example())
|
||||||
.toString(" ") + "\n"
|
.toString(" ") + "\n"
|
||||||
: ""
|
: ""
|
||||||
: "")
|
: "")
|
||||||
+ (i.isNode() ? "<font:minecraft:uniform>" + pickRandoms(Math.min(i.getNode().getParameters().size() + 1, 5), i) + "<reset>" : "")
|
+ (i.isNode() ? "<font:minecraft:uniform>" + pickRandoms(Math.min(i.getNode().getParameters().size() + 1, 5), i) + "<reset>" : "")
|
||||||
+ "'><click:" + (i.isNode() ? "suggest_command" : "run_command") + ":" + i.getPath() + " >"
|
+ "'><click:" + (i.isNode() ? "suggest_command" : "run_command") + ":" + i.getPath() + " >"
|
||||||
+ "<#46826a>⇀<gradient:#42ecf5:#428df5> " +i.getName() + "</click></hover>"
|
+ "<#46826a>⇀<gradient:#42ecf5:#428df5> " + i.getName() + "</click></hover>"
|
||||||
+ (i.isNode() ?
|
+ (i.isNode() ?
|
||||||
" " + i.getNode().getParameters().convert((f)
|
" " + i.getNode().getParameters().convert((f)
|
||||||
-> "<hover:show_text:'"
|
-> "<hover:show_text:'"
|
||||||
+ f.getNames().convert((ff) -> "<#d665f0>" + ff).toString(", ") + "\n"
|
+ f.getNames().convert((ff) -> "<#d665f0>" + ff).toString(", ") + "\n"
|
||||||
+ "<#3fe05a>✎ <#6ad97d><font:minecraft:uniform>" + f.getDescription() + "<reset>\n"
|
+ "<#3fe05a>✎ <#6ad97d><font:minecraft:uniform>" + f.getDescription() + "<reset>\n"
|
||||||
+ (f.isRequired()
|
+ (f.isRequired()
|
||||||
? "<#db4321>⚠ <#faa796><font:minecraft:uniform>This parameter is required."
|
? "<#db4321>⚠ <#faa796><font:minecraft:uniform>This parameter is required."
|
||||||
: (f.hasDefault()
|
: (f.hasDefault()
|
||||||
? "<#2181db>✔ <#78dcf0><font:minecraft:uniform>Defaults to \""+f.getParam().defaultValue()+"\" if undefined."
|
? "<#2181db>✔ <#78dcf0><font:minecraft:uniform>Defaults to \"" + f.getParam().defaultValue() + "\" if undefined."
|
||||||
: "<#a73abd>✔ <#78dcf0><font:minecraft:uniform>This parameter is optional.")) + "<reset>\n"
|
: "<#a73abd>✔ <#78dcf0><font:minecraft:uniform>This parameter is optional.")) + "<reset>\n"
|
||||||
+ (f.isContextual() ? "<#ff9900>➱ <#ffcc00><font:minecraft:uniform>The value may be derived from environment context <reset>\n" : "")
|
+ (f.isContextual() ? "<#ff9900>➱ <#ffcc00><font:minecraft:uniform>The value may be derived from environment context <reset>\n" : "")
|
||||||
+ "<#cc00ff>✢ <#ff33cc><font:minecraft:uniform>This parameter is of type " + f.getType().getSimpleName() + "<reset>\n"
|
+ "<#cc00ff>✢ <#ff33cc><font:minecraft:uniform>This parameter is of type " + f.getType().getSimpleName() + "<reset>\n"
|
||||||
+ "'>"
|
+ "'>"
|
||||||
+ (f.isRequired() ? "<red>[" : "")
|
+ (f.isRequired() ? "<red>[" : "")
|
||||||
+ "<gradient:#d665f0:#a37feb>" + f.getName()
|
+ "<gradient:#d665f0:#a37feb>" + f.getName()
|
||||||
+ (f.isRequired() ? "<red>]<gray>" : "")
|
+ (f.isRequired() ? "<red>]<gray>" : "")
|
||||||
+ "</hover>").toString(" ")
|
+ "</hover>").toString(" ")
|
||||||
: "<gradient:#afe3d3:#a2dae0> - Category of Commands"
|
: "<gradient:#afe3d3:#a2dae0> - Category of Commands"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
//@done
|
//@done
|
||||||
sendMessageRaw(s);
|
sendMessageRaw(s);
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sendMessage(i.getPath() + "()");
|
sendMessage(i.getPath() + "()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sendMessage(C.RED + "There are no subcommands in this group! Contact support, this is a command design issue!");
|
sendMessage(C.RED + "There are no subcommands in this group! Contact support, this is a command design issue!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ import java.io.IOException;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public class DownloadJob implements Job{
|
public class DownloadJob implements Job {
|
||||||
private DL.Download download;
|
private final DL.Download download;
|
||||||
private int tw;
|
private int tw;
|
||||||
private int cw;
|
private int cw;
|
||||||
|
|
||||||
@ -38,13 +38,9 @@ public class DownloadJob implements Job{
|
|||||||
download.monitor(new DownloadMonitor() {
|
download.monitor(new DownloadMonitor() {
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(DL.DownloadState state, double progress, long elapsed, long estimated, long bps, long iobps, long size, long downloaded, long buffer, double bufferuse) {
|
public void onUpdate(DL.DownloadState state, double progress, long elapsed, long estimated, long bps, long iobps, long size, long downloaded, long buffer, double bufferuse) {
|
||||||
if(size == -1)
|
if (size == -1) {
|
||||||
{
|
|
||||||
tw = 1;
|
tw = 1;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tw = (int) (size / 100);
|
tw = (int) (size / 100);
|
||||||
cw = (int) (downloaded / 100);
|
cw = (int) (downloaded / 100);
|
||||||
}
|
}
|
||||||
@ -61,8 +57,7 @@ public class DownloadJob implements Job{
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
try {
|
try {
|
||||||
download.start();
|
download.start();
|
||||||
while(download.isState(DL.DownloadState.DOWNLOADING))
|
while (download.isState(DL.DownloadState.DOWNLOADING)) {
|
||||||
{
|
|
||||||
download.downloadChunk();
|
download.downloadChunk();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.scheduling.jobs;
|
package com.volmit.iris.util.scheduling.jobs;
|
||||||
|
|
||||||
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.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
@ -26,8 +25,7 @@ import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
|||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public interface Job
|
public interface Job {
|
||||||
{
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
void execute();
|
void execute();
|
||||||
@ -36,35 +34,27 @@ public interface Job
|
|||||||
|
|
||||||
int getTotalWork();
|
int getTotalWork();
|
||||||
|
|
||||||
default int getWorkRemaining()
|
default int getWorkRemaining() {
|
||||||
{
|
|
||||||
return getTotalWork() - getWorkCompleted();
|
return getTotalWork() - getWorkCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getWorkCompleted();
|
int getWorkCompleted();
|
||||||
|
|
||||||
default String getProgressString()
|
default String getProgressString() {
|
||||||
{
|
|
||||||
return Form.pc(getProgress(), 0);
|
return Form.pc(getProgress(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
default double getProgress()
|
default double getProgress() {
|
||||||
{
|
return (double) getWorkCompleted() / (double) getTotalWork();
|
||||||
return (double)getWorkCompleted() / (double)getTotalWork();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default void execute(VolmitSender sender)
|
default void execute(VolmitSender sender) {
|
||||||
{
|
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
CompletableFuture<?> f = J.afut(this::execute);
|
CompletableFuture<?> f = J.afut(this::execute);
|
||||||
int c = J.ar(() -> {
|
int c = J.ar(() -> {
|
||||||
if(sender.isPlayer())
|
if (sender.isPlayer()) {
|
||||||
{
|
|
||||||
sender.sendProgress(getProgress(), getName());
|
sender.sendProgress(getProgress(), getName());
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage(getName() + ": " + getProgressString());
|
sender.sendMessage(getName() + ": " + getProgressString());
|
||||||
}
|
}
|
||||||
}, sender.isPlayer() ? 0 : 20);
|
}, sender.isPlayer() ? 0 : 20);
|
||||||
|
@ -25,13 +25,11 @@ public class JobCollection implements Job {
|
|||||||
private String status;
|
private String status;
|
||||||
private final KList<Job> jobs;
|
private final KList<Job> jobs;
|
||||||
|
|
||||||
public JobCollection(String name, Job... jobs)
|
public JobCollection(String name, Job... jobs) {
|
||||||
{
|
|
||||||
this(name, new KList<>(jobs));
|
this(name, new KList<>(jobs));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JobCollection(String name, KList<Job> jobs)
|
public JobCollection(String name, KList<Job> jobs) {
|
||||||
{
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
status = null;
|
status = null;
|
||||||
this.jobs = new KList<>(jobs);
|
this.jobs = new KList<>(jobs);
|
||||||
@ -44,8 +42,7 @@ public class JobCollection implements Job {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
for(Job i : jobs)
|
for (Job i : jobs) {
|
||||||
{
|
|
||||||
status = i.getName();
|
status = i.getName();
|
||||||
i.execute();
|
i.execute();
|
||||||
}
|
}
|
||||||
|
@ -25,21 +25,18 @@ public abstract class QueueJob<T> implements Job {
|
|||||||
private int totalWork;
|
private int totalWork;
|
||||||
private int completed;
|
private int completed;
|
||||||
|
|
||||||
public QueueJob()
|
public QueueJob() {
|
||||||
{
|
|
||||||
totalWork = 0;
|
totalWork = 0;
|
||||||
completed = 0;
|
completed = 0;
|
||||||
queue = new KList<>();
|
queue = new KList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queue(T t)
|
public void queue(T t) {
|
||||||
{
|
|
||||||
queue.add(t);
|
queue.add(t);
|
||||||
totalWork++;
|
totalWork++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queue(KList<T> f)
|
public void queue(KList<T> f) {
|
||||||
{
|
|
||||||
queue.addAll(f);
|
queue.addAll(f);
|
||||||
totalWork += f.size();
|
totalWork += f.size();
|
||||||
}
|
}
|
||||||
@ -49,8 +46,7 @@ public abstract class QueueJob<T> implements Job {
|
|||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
totalWork = queue.size();
|
totalWork = queue.size();
|
||||||
while(queue.isNotEmpty())
|
while (queue.isNotEmpty()) {
|
||||||
{
|
|
||||||
execute(queue.pop());
|
execute(queue.pop());
|
||||||
completeWork();
|
completeWork();
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,12 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.scheduling.jobs;
|
package com.volmit.iris.util.scheduling.jobs;
|
||||||
|
|
||||||
public class SingleJob implements Job{
|
public class SingleJob implements Job {
|
||||||
private boolean done;
|
private boolean done;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Runnable runnable;
|
private final Runnable runnable;
|
||||||
|
|
||||||
public SingleJob(String name, Runnable runnable)
|
public SingleJob(String name, Runnable runnable) {
|
||||||
{
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
done = false;
|
done = false;
|
||||||
this.runnable = runnable;
|
this.runnable = runnable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user