typeLore = ListUtil.createList("", "§8Left-click to select", "§8Right-click for more information");
switch (cropType) {
case POTATO:
- itemOne = new Item(XMaterial.SHORT_GRASS.parseItem()).setDisplayName("§bLow").setLore(ListUtil.createList("", "§8Left-click to select", "§8Right-click for more information")).build();
- itemTwo = new Item(XMaterial.TALL_GRASS.parseItem()).setDisplayName("§bTall").setLore(ListUtil.createList("", "§8Left-click to select", "§8Right-click for more information")).build();
+ itemOne = new Item(XMaterial.SHORT_GRASS.parseItem()).setDisplayName("§bLow").setLore(typeLore).build();
+ itemTwo = new Item(XMaterial.TALL_GRASS.parseItem()).setDisplayName("§bTall").setLore(typeLore).build();
break;
case WHEAT:
- itemOne = Item.create(XMaterial.BIRCH_FENCE.parseMaterial(), "§bLight", ListUtil.createList("", "§8Left-click to select", "§8Right-click for more information"));
- itemTwo = Item.create(XMaterial.DARK_OAK_FENCE.parseMaterial(), "§bDark", ListUtil.createList("", "§8Left-click to select", "§8Right-click for more information"));
+ itemOne = Item.create(XMaterial.BIRCH_FENCE.parseMaterial(), "§bLight", typeLore);
+ itemTwo = Item.create(XMaterial.DARK_OAK_FENCE.parseMaterial(), "§bDark", typeLore);
break;
case CORN:
- itemOne = new Item(XMaterial.SHORT_GRASS.parseItem()).setDisplayName("§bHarvested").setLore(ListUtil.createList("", "§8Left-click to select", "§8Right-click for more information")).build();
- itemTwo = new Item(XMaterial.TALL_GRASS.parseItem()).setDisplayName("§bTall").setLore(ListUtil.createList("", "§8Left-click to select", "§8Right-click for more information")).build();
+ itemOne = new Item(XMaterial.SHORT_GRASS.parseItem()).setDisplayName("§bHarvested").setLore(typeLore).build();
+ itemTwo = new Item(XMaterial.TALL_GRASS.parseItem()).setDisplayName("§bTall").setLore(typeLore).build();
break;
- case HARVESTED:
case OTHER:
- itemOne = Item.create(XMaterial.DEAD_BUSH.parseMaterial(), "§bDry", ListUtil.createList("", "§8Left-click to select", "§8Right-click for more information"));
- itemTwo = Item.create(XMaterial.WATER_BUCKET.parseMaterial(), "§bWet", ListUtil.createList("", "§8Left-click to select", "§8Right-click for more information"));
+ itemOne = Item.create(XMaterial.DEAD_BUSH.parseMaterial(), "§bDry", typeLore);
+ itemTwo = Item.create(XMaterial.WATER_BUCKET.parseMaterial(), "§bWet", typeLore);
break;
}
@@ -96,7 +99,6 @@ protected void setItemClickEventsAsync() {
case CORN:
cropstage = CropStage.HARVESTED;
break;
- case HARVESTED:
case OTHER:
cropstage = CropStage.DRY;
break;
@@ -112,19 +114,12 @@ protected void setItemClickEventsAsync() {
}
CropStage cropstage = CropStage.FALLBACK;
- switch (cropType) {
- case POTATO:
- case CORN:
- cropstage = CropStage.TALL;
- break;
- case WHEAT:
- cropstage = CropStage.DARK;
- break;
- case HARVESTED:
- case OTHER:
- cropstage = CropStage.WET;
- break;
- }
+ cropstage = switch (cropType) {
+ case POTATO, CORN -> CropStage.TALL;
+ case WHEAT -> CropStage.DARK;
+ case HARVESTED, OTHER -> CropStage.WET;
+ default -> cropstage;
+ };
performClickAction(clickPlayer, cropstage);
}));
@@ -144,22 +139,34 @@ private void performClickAction(Player p, CropStage cropStage) {
GeneratorModule.getInstance().getField().generate(p);
}
- private void sendMoreInformation(Player p, CropType cropType) {
+ public static void sendMoreInformation(Player p, @NonNull CropType cropType) {
switch (cropType) {
case POTATO:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#potato-requires-lines");
+ p.sendMessage(Component.text(WikiLinks.Gen.Field.CROP_POTATO, NamedTextColor.RED));
break;
case CORN:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#corn");
+ p.sendMessage(Component.text(WikiLinks.Gen.Field.CROP_CORN, NamedTextColor.RED));
break;
case WHEAT:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#wheat");
+ p.sendMessage(Component.text(WikiLinks.Gen.Field.CROP_WHEAT, NamedTextColor.RED));
break;
case HARVESTED:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#harvested-requires-lines");
+ p.sendMessage(Component.text(WikiLinks.Gen.Field.CROP_HARVESTED, NamedTextColor.RED));
break;
case OTHER:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#other-requires-lines");
+ p.sendMessage(Component.text(WikiLinks.Gen.Field.CROP_OTHER, NamedTextColor.RED));
+ break;
+ case VINEYARD:
+ p.sendMessage(Component.text(WikiLinks.Gen.Field.CROP_VINEYARD, NamedTextColor.RED));
+ break;
+ case PEAR:
+ p.sendMessage(Component.text(WikiLinks.Gen.Field.CROP_PEAR, NamedTextColor.RED));
+ break;
+ case CATTLE:
+ p.sendMessage(Component.text(WikiLinks.Gen.Field.CROP_CATTLE, NamedTextColor.RED));
+ break;
+ case MEADOW:
+ p.sendMessage(Component.text(WikiLinks.Gen.Field.CROP_MEADOW, NamedTextColor.RED));
break;
}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/field/menu/CropTypeMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/field/menu/CropTypeMenu.java
similarity index 70%
rename from src/main/java/net/buildtheearth/modules/generator/components/field/menu/CropTypeMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/field/menu/CropTypeMenu.java
index 7d9be6d9..0180412d 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/field/menu/CropTypeMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/field/menu/CropTypeMenu.java
@@ -1,23 +1,23 @@
-package net.buildtheearth.modules.generator.components.field.menu;
+package net.buildtheearth.buildteamtools.modules.generator.components.field.menu;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.components.field.CropType;
-import net.buildtheearth.modules.generator.components.field.FieldFlag;
-import net.buildtheearth.modules.generator.components.field.FieldSettings;
-import net.buildtheearth.modules.generator.menu.GeneratorMenu;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractMenu;
-import org.bukkit.ChatColor;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.field.CropType;
+import net.buildtheearth.buildteamtools.modules.generator.components.field.FieldFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.field.FieldSettings;
+import net.buildtheearth.buildteamtools.modules.generator.menu.GeneratorMenu;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.ipvp.canvas.mask.BinaryMask;
import org.ipvp.canvas.mask.Mask;
+import org.jspecify.annotations.NonNull;
public class CropTypeMenu extends AbstractMenu {
@@ -78,7 +78,7 @@ protected void setItemClickEventsAsync() {
// Set click events for the crop type items
getMenu().getSlot(POTATO_CROP_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, CropType.POTATO);
+ CropStageMenu.sendMoreInformation(clickPlayer, CropType.POTATO);
return;
}
performClickAction(clickPlayer, CropType.POTATO);
@@ -86,7 +86,7 @@ protected void setItemClickEventsAsync() {
getMenu().getSlot(WHEAT_CROP_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, CropType.WHEAT);
+ CropStageMenu.sendMoreInformation(clickPlayer, CropType.WHEAT);
return;
}
performClickAction(clickPlayer, CropType.WHEAT);
@@ -94,7 +94,7 @@ protected void setItemClickEventsAsync() {
getMenu().getSlot(CORN_CROP_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, CropType.CORN);
+ CropStageMenu.sendMoreInformation(clickPlayer, CropType.CORN);
return;
}
performClickAction(clickPlayer, CropType.CORN);
@@ -102,7 +102,7 @@ protected void setItemClickEventsAsync() {
getMenu().getSlot(VINEYARD_CROP_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, CropType.VINEYARD);
+ CropStageMenu.sendMoreInformation(clickPlayer, CropType.VINEYARD);
return;
}
performClickAction(clickPlayer, CropType.VINEYARD);
@@ -110,7 +110,7 @@ protected void setItemClickEventsAsync() {
getMenu().getSlot(PEAR_CROP_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, CropType.PEAR);
+ CropStageMenu.sendMoreInformation(clickPlayer, CropType.PEAR);
return;
}
performClickAction(clickPlayer, CropType.PEAR);
@@ -118,7 +118,7 @@ protected void setItemClickEventsAsync() {
getMenu().getSlot(CATTLE_CROP_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, CropType.CATTLE);
+ CropStageMenu.sendMoreInformation(clickPlayer, CropType.CATTLE);
return;
}
performClickAction(clickPlayer, CropType.CATTLE);
@@ -126,7 +126,7 @@ protected void setItemClickEventsAsync() {
getMenu().getSlot(MEADOW_CROP_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, CropType.MEADOW);
+ CropStageMenu.sendMoreInformation(clickPlayer, CropType.MEADOW);
return;
}
performClickAction(clickPlayer, CropType.MEADOW);
@@ -134,7 +134,7 @@ protected void setItemClickEventsAsync() {
getMenu().getSlot(HARVESTED_CROP_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, CropType.HARVESTED);
+ CropStageMenu.sendMoreInformation(clickPlayer, CropType.HARVESTED);
return;
}
performClickAction(clickPlayer, CropType.HARVESTED);
@@ -142,7 +142,7 @@ protected void setItemClickEventsAsync() {
getMenu().getSlot(OTHER_CROP_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, CropType.OTHER);
+ CropStageMenu.sendMoreInformation(clickPlayer, CropType.OTHER);
return;
}
performClickAction(clickPlayer, CropType.OTHER);
@@ -151,7 +151,7 @@ protected void setItemClickEventsAsync() {
}
- private void performClickAction(Player p, CropType cropType) {
+ private void performClickAction(@NonNull Player p, CropType cropType) {
Settings settings = GeneratorModule.getInstance().getField().getPlayerSettings().get(p.getUniqueId());
if (!(settings instanceof FieldSettings))
@@ -174,38 +174,6 @@ private void performClickAction(Player p, CropType cropType) {
GeneratorModule.getInstance().getField().generate(p);
}
- private void sendMoreInformation(Player p, CropType cropType) {
- switch (cropType) {
- case POTATO:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#potato-requires-lines");
- break;
- case CORN:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#corn");
- break;
- case WHEAT:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#wheat");
- break;
- case HARVESTED:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#harvested-requires-lines");
- break;
- case OTHER:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#other-requires-lines");
- break;
- case VINEYARD:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#vineyard-requires-lines");
- break;
- case PEAR:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#pear-requires-lines");
- break;
- case CATTLE:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#cattle");
- break;
- case MEADOW:
- p.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Crop-Types#meadow");
- break;
- }
- }
-
@Override
protected Mask getMask() {
return BinaryMask.builder(getMenu())
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/field/menu/FenceTypeMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/field/menu/FenceTypeMenu.java
similarity index 66%
rename from src/main/java/net/buildtheearth/modules/generator/components/field/menu/FenceTypeMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/field/menu/FenceTypeMenu.java
index 07350dff..85d0c503 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/field/menu/FenceTypeMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/field/menu/FenceTypeMenu.java
@@ -1,13 +1,13 @@
-package net.buildtheearth.modules.generator.components.field.menu;
+package net.buildtheearth.buildteamtools.modules.generator.components.field.menu;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.components.field.FieldFlag;
-import net.buildtheearth.modules.generator.components.field.FieldSettings;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.BlockListMenu;
+import com.alpsbte.alpslib.utils.item.Item;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.field.FieldFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.field.FieldSettings;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.BlockListMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@@ -33,7 +33,7 @@ protected void setItemClickEventsAsync() {
return;
FieldSettings fieldSettings = (FieldSettings) settings;
- fieldSettings.setValue(FieldFlag.FENCE, Item.createStringFromItemList(selectedMaterials));
+ fieldSettings.setValue(FieldFlag.FENCE, Item.createStringFromItemStringList(selectedMaterials));
clickPlayer.closeInventory();
clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/house/House.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/House.java
similarity index 59%
rename from src/main/java/net/buildtheearth/modules/generator/components/house/House.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/House.java
index 71065264..e0da3777 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/house/House.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/House.java
@@ -1,9 +1,8 @@
-package net.buildtheearth.modules.generator.components.house;
+package net.buildtheearth.buildteamtools.modules.generator.components.house;
-import com.sk89q.worldedit.regions.Region;
-import net.buildtheearth.modules.generator.model.GeneratorComponent;
-import net.buildtheearth.modules.generator.model.GeneratorType;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
+import com.alpsbte.alpslib.utils.GeneratorUtils;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorComponent;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorType;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -11,7 +10,6 @@ public class House extends GeneratorComponent {
public House() {
super(GeneratorType.HOUSE);
- wikiPage = "https://github.com/BuildTheEarth/BuildTeamTools/wiki/House-Command";
}
@Override
@@ -19,15 +17,15 @@ public boolean checkForPlayer(Player p) {
if (GeneratorUtils.checkForNoWorldEditSelection(p))
return false;
- if (getPlayerSettings().get(p.getUniqueId()).getBlocks() == null)
+ if (getPlayerSettings().get(p.getUniqueId()).getBlocks() == null) // Needed because block checks are made afterwards
getPlayerSettings().get(p.getUniqueId()).setBlocks(GeneratorUtils.analyzeRegion(p, p.getWorld()));
Block[][][] blocks = getPlayerSettings().get(p.getUniqueId()).getBlocks();
- if (!GeneratorUtils.checkForBrickOutline(blocks, p))
+ if (!GeneratorUtils.checkForBrickOutline(blocks, p, this))
return false;
- return GeneratorUtils.checkForWoolBlock(blocks, p);
+ return GeneratorUtils.checkForWoolBlock(blocks, p, this);
}
@Override
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/house/HouseFlag.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/HouseFlag.java
similarity index 84%
rename from src/main/java/net/buildtheearth/modules/generator/components/house/HouseFlag.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/HouseFlag.java
index b1685bfe..117d011b 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/house/HouseFlag.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/HouseFlag.java
@@ -1,7 +1,7 @@
-package net.buildtheearth.modules.generator.components.house;
+package net.buildtheearth.buildteamtools.modules.generator.components.house;
-import net.buildtheearth.modules.generator.model.FlagType;
-import net.buildtheearth.modules.generator.model.Flag;
+import net.buildtheearth.buildteamtools.modules.generator.model.Flag;
+import net.buildtheearth.buildteamtools.modules.generator.model.FlagType;
public enum HouseFlag implements Flag {
WALL_COLOR("w", FlagType.XMATERIAL_LIST),
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/house/HouseScripts.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/HouseScripts.java
similarity index 97%
rename from src/main/java/net/buildtheearth/modules/generator/components/house/HouseScripts.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/HouseScripts.java
index fe19b864..c972420b 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/house/HouseScripts.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/HouseScripts.java
@@ -1,17 +1,18 @@
-package net.buildtheearth.modules.generator.components.house;
+package net.buildtheearth.buildteamtools.modules.generator.components.house;
+import com.alpsbte.alpslib.utils.GeneratorUtils;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
-import net.buildtheearth.modules.generator.model.Flag;
-import net.buildtheearth.modules.generator.model.GeneratorComponent;
-import net.buildtheearth.modules.generator.model.Script;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
-import org.bukkit.Material;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.generator.model.Flag;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorComponent;
+import net.buildtheearth.buildteamtools.modules.generator.model.Script;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@@ -22,8 +23,7 @@ public class HouseScripts extends Script {
public HouseScripts(Player player, GeneratorComponent generatorComponent) {
super(player, generatorComponent);
-
- buildscript_v_1_2();
+ Bukkit.getScheduler().runTaskAsynchronously(BuildTeamTools.getInstance(), this::buildscript_v_1_2);
}
public void buildscript_v_1_2(){
@@ -424,7 +424,7 @@ public void buildscript_v_1_2(){
for(int i = 0; i < maxRoofHeight; i++) {
if(roofType == RoofType.FLATTER_SLABS || roofType == RoofType.MEDIUM_SLABS)
//Only select air block that are surrounded by other stone slabs below or which are directly neighbors to lime wool or blue wool
- replaceBlocksWithMask("=queryRel(0,-1,0,43)&&" +
+ replaceBlocksWithMask("=queryRel(0,-1,0,43,0)&&" +
"(" +
"(" +
"queryRel(1,-1,0,43,-1)&&queryRel(-1,-1,0,43,-1)&&queryRel(0,-1,1,43,-1)&&queryRel(0,-1,-1,43,-1)" +
@@ -506,7 +506,7 @@ public void buildscript_v_1_2(){
BlockState[] doubleSlabs = new BlockState[roofColor.length];
for(int i = 0; i < roofColor.length; i++){
- BlockType bt = Item.convertXMaterialToBlockType(roofColor[i]);
+ BlockType bt = Item.convertXMaterialToWEBlockType(roofColor[i]);
if(bt == null)
continue;
@@ -729,7 +729,7 @@ else if(property.getName().equalsIgnoreCase("shape"))
// Convert all stair blocks to the correct orientation
BlockState[] stairsWithOrientation = new BlockState[roofColor.length];
for(int i = 0; i < roofColor.length; i++){
- BlockType bt = Item.convertXMaterialToBlockType(roofColor[i]);
+ BlockType bt = Item.convertXMaterialToWEBlockType(roofColor[i]);
if(bt == null)
continue;
@@ -760,7 +760,7 @@ else if(property.getName().equalsIgnoreCase("shape"))
BlockState[] doubleSlabs = new BlockState[roofColor.length];
for(int i = 0; i < roofColor.length; i++){
- BlockType bt = Item.convertXMaterialToBlockType(roofColor[i]);
+ BlockType bt = Item.convertXMaterialToWEBlockType(roofColor[i]);
if(bt == null)
continue;
@@ -768,7 +768,7 @@ else if(property.getName().equalsIgnoreCase("shape"))
doubleSlabs[i] = getSlab(bt, "double");
}
- replaceBlocks(Item.convertXMaterialToBlockType(XMaterial.DISPENSER).getDefaultState(), doubleSlabs);
+ replaceBlocks(Item.convertXMaterialToWEBlockType(XMaterial.DISPENSER).getDefaultState(), doubleSlabs);
// Finish the script
finish(blocks, selectionPoints);
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/house/HouseSettings.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/HouseSettings.java
similarity index 91%
rename from src/main/java/net/buildtheearth/modules/generator/components/house/HouseSettings.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/HouseSettings.java
index ae0caa54..95c0ef45 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/house/HouseSettings.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/HouseSettings.java
@@ -1,9 +1,9 @@
-package net.buildtheearth.modules.generator.components.house;
+package net.buildtheearth.buildteamtools.modules.generator.components.house;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.Utils;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.Utils;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/house/RoofType.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/RoofType.java
similarity index 87%
rename from src/main/java/net/buildtheearth/modules/generator/components/house/RoofType.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/RoofType.java
index 41e51280..9312da19 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/house/RoofType.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/RoofType.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.generator.components.house;
+package net.buildtheearth.buildteamtools.modules.generator.components.house;
public enum RoofType {
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/house/menu/AdvancedSettingsMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/AdvancedSettingsMenu.java
similarity index 89%
rename from src/main/java/net/buildtheearth/modules/generator/components/house/menu/AdvancedSettingsMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/AdvancedSettingsMenu.java
index cfe85206..69dd70a7 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/house/menu/AdvancedSettingsMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/AdvancedSettingsMenu.java
@@ -1,13 +1,13 @@
-package net.buildtheearth.modules.generator.components.house.menu;
-
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.house.House;
-import net.buildtheearth.modules.generator.components.house.HouseFlag;
-import net.buildtheearth.modules.generator.components.house.HouseSettings;
-import net.buildtheearth.utils.CustomHeads;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractMenu;
+package net.buildtheearth.buildteamtools.modules.generator.components.house.menu;
+
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.House;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseSettings;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.ipvp.canvas.mask.BinaryMask;
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/house/menu/BaseColorMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/BaseColorMenu.java
similarity index 66%
rename from src/main/java/net/buildtheearth/modules/generator/components/house/menu/BaseColorMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/BaseColorMenu.java
index b8e8468a..cecb09af 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/house/menu/BaseColorMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/BaseColorMenu.java
@@ -1,12 +1,12 @@
-package net.buildtheearth.modules.generator.components.house.menu;
-
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.house.HouseFlag;
-import net.buildtheearth.modules.generator.components.house.HouseSettings;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.BlockListMenu;
+package net.buildtheearth.buildteamtools.modules.generator.components.house.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseSettings;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.BlockListMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@@ -31,7 +31,7 @@ protected void setItemClickEventsAsync() {
return;
HouseSettings houseSettings = (HouseSettings) settings;
- houseSettings.setValue(HouseFlag.BASE_COLOR, Item.createStringFromItemList(selectedMaterials));
+ houseSettings.setValue(HouseFlag.BASE_COLOR, Item.createStringFromItemStringList(selectedMaterials));
clickPlayer.closeInventory();
clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/house/menu/RoofColorMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/RoofColorMenu.java
similarity index 77%
rename from src/main/java/net/buildtheearth/modules/generator/components/house/menu/RoofColorMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/RoofColorMenu.java
index 390c16d6..698a53a5 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/house/menu/RoofColorMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/RoofColorMenu.java
@@ -1,20 +1,18 @@
-package net.buildtheearth.modules.generator.components.house.menu;
-
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.house.HouseFlag;
-import net.buildtheearth.modules.generator.components.house.HouseSettings;
-import net.buildtheearth.modules.generator.components.house.RoofType;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.BlockListMenu;
-import org.bukkit.Material;
+package net.buildtheearth.buildteamtools.modules.generator.components.house.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.RoofType;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.BlockListMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
public class RoofColorMenu extends BlockListMenu {
@@ -38,7 +36,7 @@ protected void setItemClickEventsAsync() {
return;
HouseSettings houseSettings = (HouseSettings) settings;
- houseSettings.setValue(HouseFlag.ROOF_COLOR, Item.createStringFromItemList(selectedMaterials));
+ houseSettings.setValue(HouseFlag.ROOF_COLOR, Item.createStringFromItemStringList(selectedMaterials));
clickPlayer.closeInventory();
clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/house/menu/RoofTypeMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/RoofTypeMenu.java
similarity index 86%
rename from src/main/java/net/buildtheearth/modules/generator/components/house/menu/RoofTypeMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/RoofTypeMenu.java
index dcc858d2..204384c0 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/house/menu/RoofTypeMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/RoofTypeMenu.java
@@ -1,16 +1,15 @@
-package net.buildtheearth.modules.generator.components.house.menu;
+package net.buildtheearth.buildteamtools.modules.generator.components.house.menu;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.house.HouseFlag;
-import net.buildtheearth.modules.generator.components.house.HouseSettings;
-import net.buildtheearth.modules.generator.components.house.RoofType;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractMenu;
-import org.bukkit.Material;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.RoofType;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/house/menu/WallColorMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/WallColorMenu.java
similarity index 63%
rename from src/main/java/net/buildtheearth/modules/generator/components/house/menu/WallColorMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/WallColorMenu.java
index 408ef2a5..bb68936e 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/house/menu/WallColorMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/house/menu/WallColorMenu.java
@@ -1,13 +1,13 @@
-package net.buildtheearth.modules.generator.components.house.menu;
-
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.menu.GeneratorMenu;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.house.HouseFlag;
-import net.buildtheearth.modules.generator.components.house.HouseSettings;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.BlockListMenu;
+package net.buildtheearth.buildteamtools.modules.generator.components.house.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseSettings;
+import net.buildtheearth.buildteamtools.modules.generator.menu.GeneratorMenu;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.BlockListMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@@ -32,7 +32,7 @@ protected void setItemClickEventsAsync() {
return;
HouseSettings houseSettings = (HouseSettings) settings;
- houseSettings.setValue(HouseFlag.WALL_COLOR, Item.createStringFromItemList(selectedMaterials));
+ houseSettings.setValue(HouseFlag.WALL_COLOR, Item.createStringFromItemStringList(selectedMaterials));
clickPlayer.closeInventory();
clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/kml/BlockCreationMode.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/BlockCreationMode.java
similarity index 63%
rename from src/main/java/net/buildtheearth/modules/generator/components/kml/BlockCreationMode.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/BlockCreationMode.java
index a9a40065..00a47a48 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/kml/BlockCreationMode.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/BlockCreationMode.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.generator.components.kml;
+package net.buildtheearth.buildteamtools.modules.generator.components.kml;
public enum BlockCreationMode {
POINTS, //geopoints
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/kml/ChangeTransaction.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/ChangeTransaction.java
similarity index 96%
rename from src/main/java/net/buildtheearth/modules/generator/components/kml/ChangeTransaction.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/ChangeTransaction.java
index 3125360d..d545b900 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/kml/ChangeTransaction.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/ChangeTransaction.java
@@ -1,18 +1,16 @@
-package net.buildtheearth.modules.generator.components.kml;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+package net.buildtheearth.buildteamtools.modules.generator.components.kml;
+import net.buildtheearth.buildteamtools.utils.BlockLocation;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
-
-import net.buildtheearth.utils.BlockLocation;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
/**
* A set of block changes that should be bundled together.
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/KmlCommand.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/KmlCommand.java
new file mode 100644
index 00000000..78520890
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/KmlCommand.java
@@ -0,0 +1,639 @@
+package net.buildtheearth.buildteamtools.modules.generator.components.kml;
+
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.cryptomorin.xseries.XMaterial;
+import de.micromata.opengis.kml.v_2_2_0.Coordinate;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.utils.BlockLocation;
+import net.buildtheearth.buildteamtools.utils.GeometricUtils;
+import net.buildtheearth.buildteamtools.utils.LineRasterization;
+import net.buildtheearth.buildteamtools.utils.PolygonTools;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockState;
+import org.bukkit.block.CommandBlock;
+import org.bukkit.command.BlockCommandSender;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.metadata.FixedMetadataValue;
+import org.jspecify.annotations.NonNull;
+
+import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+
+/**
+ * Class to handle kml command and its aliases
+ *
+ * Since kml content easily exceeds the normal chat/character limit,
+ * we use the following workflow:
+ * 1) If sent from a player, generates a CommandBlock and adds some metadata to it
+ * the player then pastes the kml contents and confirms the command
+ * 2) The CommandBlock then sends a kml command with the contents, which is parsed by the server
+ *
+ * note: this command differentiates between aliases to determine wether to
+ * generate intermediate points between the geo-coordinates from the kml linestrings.
+ * Players should only use /geopoints or /geopath aliases,
+ * direct use of the /kml command is restricted to CommandBlockSender
+ *
+ */
+public class KmlCommand implements CommandExecutor {
+
+ /**
+ * Handles the execution of KML-related commands (/geopoints, /geopath, /georing, /kml).
+ *
+ * This method has two main execution paths:
+ *
+ * - If sender is a CommandBlock: directly processes the KML content
+ * - If sender is a Player: creates a CommandBlock UI for pasting KML content or handles undo
+ *
+ *
+ * @param sender The command sender (Player or CommandBlock)
+ * @param cmd The command object
+ * @param alias The alias used to invoke this command (geopoints/geopath/georing/kml)
+ * @param args Command arguments (KML content if from CommandBlock, block type if from Player)
+ * @return true if the command was handled successfully, false otherwise
+ */
+ public boolean onCommand(@NonNull CommandSender sender, @NonNull Command cmd, @NonNull String alias, String @NonNull [] args) {
+ if (sender instanceof BlockCommandSender cmdbSender) {
+ Block senderBlock = cmdbSender.getBlock();
+
+ return processKml(senderBlock, args);
+ }
+
+ if (!(sender instanceof Player p)) {
+ sender.sendMessage("§cOnly players can execute this command.");
+ return false;
+ }
+
+ if (args.length > 0 && args[0].equals("undo")) {
+ return undoCommand(p);
+ }
+
+ //check if alias is geopoints or geopath (direct /kml is only allowed for undo)
+ if (alias.equals("kml")) {
+ sender.sendMessage("§cPlease use /geopoints or /geopath to execute this command.");
+ return false;
+ }
+
+ return createPasteUI(p, cmd, alias, args);
+ }
+
+ /**
+ * Adds a single block location to the transaction, optionally extending down to terrain.
+ *
+ * If extendToGround is enabled, this will also fill all blocks vertically from the terrain
+ * elevation up to the specified location height.
+ *
+ * @param loc The block location to add
+ * @param extendToGround Whether to fill blocks down to terrain level
+ * @param world The world containing the blocks
+ * @param container The set to add the block location to
+ * @param fillPositions The set to add vertical fill positions to
+ */
+ void addSingleLocation(BlockLocation loc, boolean extendToGround, World world, @NonNull Set container, Set fillPositions) {
+ container.add(loc);
+ if (extendToGround) fillVerticalToTerrain(loc, world, fillPositions);
+ }
+
+ /**
+ * Adds multiple block locations to the transaction, optionally extending each down to terrain.
+ *
+ * This is a convenience method that calls {@link #addSingleLocation(BlockLocation, boolean, World, Set, Set)}
+ * for each location in the list.
+ *
+ * @param locs List of block locations to add
+ * @param extendToGround Whether to fill blocks down to terrain level for each location
+ * @param world The world containing the blocks
+ * @param container The set to add the block locations to
+ * @param fillPositions The set to add vertical fill positions to
+ */
+ void addLocations(@NonNull List locs, boolean extendToGround, World world, Set container, Set fillPositions) {
+ for (BlockLocation loc : locs)
+ addSingleLocation(loc, extendToGround, world, container, fillPositions);
+ }
+
+ /**
+ * Fills all block positions vertically from terrain level up to the specified location.
+ *
+ * This is used when the "extend to ground" feature is enabled, creating a vertical
+ * column of blocks from the highest block at the XZ coordinates up to the target height.
+ *
+ * @param locationOverGround The target block location (height to extend to)
+ * @param world The world to query for terrain height
+ * @param container The set to add the vertical fill positions to
+ */
+ void fillVerticalToTerrain(BlockLocation locationOverGround, @NonNull World world, Set container) {
+ int terrainElevation = world.getHighestBlockYAt(locationOverGround.x, locationOverGround.z);
+ for (int y = terrainElevation; y < locationOverGround.y; y++) {
+ container.add(new BlockLocation(locationOverGround.x, y, locationOverGround.z));
+ }
+ }
+
+ /**
+ * Processes KML content from a CommandBlock and places blocks in the world.
+ *
+ * This method performs the following steps:
+ *
+ * - Reads metadata from the command block (player, block type, operation mode)
+ * - Parses the KML content to extract geographic coordinates
+ * - Converts geographic coordinates to Minecraft coordinates (async)
+ * - Rasterizes lines/points based on the operation mode
+ * - Filters blocks by distance and chunk loading
+ * - Commits block changes to the world (sync)
+ * - Cleans up the command block
+ *
+ *
+ * The coordinate conversion and processing is done asynchronously to avoid blocking
+ * the server thread, then syncs back to the main thread for actual block changes.
+ *
+ * Blocks are only placed if:
+ *
+ * - The chunk is loaded
+ * - The block is within 1000 blocks of the player
+ *
+ *
+ * @param senderBlock The CommandBlock that sent this command (contains metadata)
+ * @param args The KML content as a string array
+ * @return true if processing started successfully, false if validation failed
+ */
+ public boolean processKml(@NonNull Block senderBlock, String[] args) {
+
+ //read metadata to get player name/ID
+ BlockState blockState = senderBlock.getState();
+ String playerName = blockState.getMetadata("kmlPlayerName").getFirst().asString();
+ String blocktypeString = blockState.getMetadata("kmlBlocktype").getFirst().asString();
+ String previousCommandBlockType = blockState.getMetadata("kmlPreviousBlocktype").getFirst().asString();
+ String blockCreationCommand = blockState.getMetadata("kmlBlockCreationCommand").getFirst().asString();
+ BlockCreationMode operationMode = commandToCreationMode(blockCreationCommand);
+
+ boolean extendToGround = blockState.getMetadata("kmlExtendToGround").getFirst().asBoolean();
+ String extendToGroundBlockType = blockState.getMetadata("kmlExtendToGroundBlocktype").getFirst().asString();
+
+
+ if (playerName.isEmpty() || blocktypeString.isEmpty()) {
+ //invalid metadata, cancel
+ //send error message to all players within 50m of the command block
+ ChatHelper.sendMessageToPlayersNearLocation(senderBlock.getLocation(), "§cReceived /kml command from CommandBlock without sufficient metadata.\nThis command can only be executed from a CommandBlock created with the /kml command!", 50);
+ return false;
+ }
+
+ Player player = Bukkit.getServer().getPlayer(playerName);
+
+ if (player == null) {
+ return false;
+ }
+
+ String kml_content = String.join(" ", args);
+
+ Material matchedBlockMaterial = Material.matchMaterial(blocktypeString);
+ final Material blockMaterial = (matchedBlockMaterial != null && matchedBlockMaterial.isBlock()) ? matchedBlockMaterial : Material.BRICKS;
+ if (matchedBlockMaterial == null || !matchedBlockMaterial.isBlock()) {
+ player.sendMessage("§cServer received /kml command with invalid blocktype string metadata. Using bricks as fallback.");
+ }
+
+ Material matchedExtendMaterial = Material.matchMaterial(extendToGroundBlockType);
+ final Material extendMaterial = (matchedExtendMaterial != null && matchedExtendMaterial.isBlock()) ? matchedExtendMaterial : Material.BRICKS;
+ if (matchedExtendMaterial == null || !matchedExtendMaterial.isBlock()) {
+ player.sendMessage("§cServer received /kml command with invalid blocktype string metadata. Using bricks as fallback.");
+ }
+
+ //parse kml
+ long time_beforeKMLParse = System.currentTimeMillis();
+
+ KmlParser parser = new KmlParser(player); // we pass the player here to be able to report parsing errors
+ List> geoCoords = parser.extractCoordinates(kml_content);
+ long time_afterKMLParse = System.currentTimeMillis();
+
+ World world = senderBlock.getWorld();
+
+ // Run the coordinate conversion asynchronously to avoid blocking the server thread
+ Bukkit.getScheduler().runTaskAsynchronously(BuildTeamTools.getInstance(), () -> {
+ List> mcLocations = convertToMC(geoCoords, world);
+ long time_afterProjection = System.currentTimeMillis();
+
+
+ //set up a transaction (collection of block changes)
+ ChangeTransaction transaction = new ChangeTransaction(player);
+
+ //collect all blocklocations in a set
+ //if just iterate and create blocks one by one, we create multiple blocks at the same XZ coordinates,
+ // this also stacks them vertically because we check terrain altitude.
+ Set blockPositions = new HashSet<>();
+ Set fillPositions = new HashSet<>();
+
+
+ for (List polyline : mcLocations) {
+ if (operationMode == BlockCreationMode.FILLED) blockPositions = triangulateAndFill(polyline);
+ else {
+ //rasterize line and create intermediate blocks
+ //note: iteration starts at second block, so we always have a previous block to draw the line
+ //for single point mode, we explicitly add the first block
+ if (operationMode == BlockCreationMode.POINTS) {
+ BlockLocation loc = new BlockLocation(polyline.getFirst());
+ addSingleLocation(loc, extendToGround, world, blockPositions, fillPositions);
+ }
+
+ // For PATH/CLOSED_PATH modes, start from the first point
+ int startIndex = (operationMode == BlockCreationMode.POINTS) ? 1 : 0;
+
+ for (int i = startIndex + 1; i < polyline.size(); ++i) {
+ if (operationMode == BlockCreationMode.POINTS) {
+ BlockLocation loc = new BlockLocation(polyline.get(i));
+ addSingleLocation(loc, extendToGround, world, blockPositions, fillPositions);
+ } else //interpolate
+ {
+ addLocations(LineRasterization.rasterizeLine(polyline.get(i - 1), polyline.get(i)), extendToGround, world, blockPositions, fillPositions);
+ }
+ }
+
+ //for closed-path-mode, add extra line between start and end
+ if (operationMode == BlockCreationMode.CLOSED_PATH) {
+ addLocations(LineRasterization.rasterizeLine(polyline.getFirst(), polyline.getLast()), extendToGround, world, blockPositions, fillPositions);
+ }
+ }
+ }
+
+ //now create the blocks
+ // restrictions: only if block is loaded, and only within 1000 blocks of the current player location
+ final boolean[] preventedUnloadedChunkChanges = {false};
+ final boolean[] preventedFarChanges = {false};
+
+ float maxDistanceToPlayer = 1000; //TODO server config
+
+ for (BlockLocation pt : blockPositions) {
+ Location loc = pt.getLocation(world);
+ if (!loc.getChunk().isLoaded()) preventedUnloadedChunkChanges[0] = true;
+ else if (loc.distance(player.getLocation()) > maxDistanceToPlayer) preventedFarChanges[0] = true;
+ else {
+ transaction.addBlockChange(pt, world, blockMaterial);
+ }
+ }
+
+ for (BlockLocation pt : fillPositions) {
+ Location loc = pt.getLocation(world);
+ if (!loc.getChunk().isLoaded()) preventedUnloadedChunkChanges[0] = true;
+ else if (loc.distance(player.getLocation()) > maxDistanceToPlayer) preventedFarChanges[0] = true;
+ else {
+ transaction.addBlockChange(pt, world, extendMaterial);
+ }
+ }
+
+
+ if (transaction.size() == 0) {
+ StringBuilder debugMessage = new StringBuilder("§ckml command did not contain any allowed block changes. ");
+ debugMessage.append("Total positions calculated: ").append(blockPositions.size() + fillPositions.size()).append(". ");
+ debugMessage.append("Player at: X=").append(player.getLocation().getBlockX());
+ debugMessage.append(" Y=").append(player.getLocation().getBlockY());
+ debugMessage.append(" Z=").append(player.getLocation().getBlockZ()).append(". ");
+
+ // Show first calculated block location for debugging
+ if (!blockPositions.isEmpty()) {
+ BlockLocation firstBlock = blockPositions.iterator().next();
+ debugMessage.append("First block would be at: X=").append(firstBlock.x);
+ debugMessage.append(" Y=").append(firstBlock.y);
+ debugMessage.append(" Z=").append(firstBlock.z).append(". ");
+ }
+
+ if (preventedUnloadedChunkChanges[0]) {
+ debugMessage.append("Some blocks are in unloaded chunks. ");
+ }
+ if (preventedFarChanges[0]) {
+ debugMessage.append("Some blocks are >1000 blocks from your location (max distance 1000). ");
+ }
+ if (!preventedUnloadedChunkChanges[0] && !preventedFarChanges[0]) {
+ debugMessage.append("No positions were calculated from the KML. Check your coordinates and alias (/geopoints, /geopath, /georing).");
+ }
+ player.sendMessage(debugMessage.toString());
+ return;
+ }
+
+ // Sync back to main thread for block changes and player history management
+ Bukkit.getScheduler().runTask(BuildTeamTools.getInstance(), () -> {
+ //create commandHistory if not exits
+ if (KmlCommand.this.playerHistories == null) KmlCommand.this.playerHistories = new HashMap<>();
+
+ if (!KmlCommand.this.playerHistories.containsKey(player))
+ KmlCommand.this.playerHistories.put(player, new Stack<>());
+
+ Stack playerHistory = KmlCommand.this.playerHistories.get(player);
+
+ playerHistory.push(transaction);
+
+
+ long time_beforeBlockChange = System.currentTimeMillis();
+
+
+ player.sendMessage(String.format("KML parsing: %d ms. BTE Projection: %d ms, Transaction preparation: %d ms. Changing %d blocks, please stand by.", (time_afterKMLParse - time_beforeKMLParse), (time_afterProjection - time_afterKMLParse), (time_beforeBlockChange - time_afterProjection), transaction.size()));
+
+ int blocksChanged = transaction.commit();
+
+ long time_afterBlockChanged = System.currentTimeMillis();
+ player.sendMessage(String.format("KML command changed %d blocks (%d ms).", blocksChanged, (time_afterBlockChanged - time_beforeBlockChange)));
+
+
+ if (preventedUnloadedChunkChanges[0]) {
+ player.sendMessage("§cSome block changes target unloaded chunks and were not applied.");
+ }
+ if (preventedFarChanges[0]) {
+ player.sendMessage("§cSome block changes target blocks too far away from the player and were not applied.");
+ }
+
+ Material material = Material.matchMaterial(previousCommandBlockType);
+
+ if (material == null) {
+ player.sendMessage("§cServer received /kml command with invalid blocktype string metadata. Using bricks as fallback.");
+ material = Material.BRICKS;
+ }
+
+ //Delete command block, restore previous type
+ senderBlock.setType(material);
+ });
+ });
+ return true;
+ }
+
+ /**
+ * Triangulates a polygon defined by a polyline and fills it with blocks.
+ *
+ * This method:
+ *
+ * - Triangulates the polygon into triangles using {@link PolygonTools#triangulatePolygon(List)}
+ * - Rasterizes each triangle to fill it with blocks
+ * - Also adds triangle borders for debugging purposes
+ *
+ *
+ * @param polyline The list of locations defining the polygon boundary
+ * @return A set of all block locations that should be filled
+ */
+ private @NonNull Set triangulateAndFill(List polyline) {
+ Set result = new HashSet<>();
+ //triangulate the polygon
+ List triangles = PolygonTools.triangulatePolygon(polyline);
+ //fill with bresenham. for now, just all border-lines
+ for (PolygonTools.Triangle tri : triangles) {
+ result.addAll(PolygonTools.rasterizeTriangle(tri));
+
+ //dEBUG: ALL triangle borders
+ result.addAll(LineRasterization.rasterizeLine(tri.getVertex1(), tri.getVertex2()));
+ result.addAll(LineRasterization.rasterizeLine(tri.getVertex1(), tri.getVertex3()));
+ result.addAll(LineRasterization.rasterizeLine(tri.getVertex2(), tri.getVertex3()));
+ }
+ return result;
+ }
+
+
+ /**
+ * Creates a CommandBlock UI for pasting KML content.
+ *
+ * This method:
+ *
+ * - Parses command arguments for block type and extend options
+ * - Spawns a CommandBlock 2 blocks in front of the player
+ * - Stores metadata on the CommandBlock (player, block types, operation mode)
+ * - Configures the CommandBlock to execute /kml when triggered
+ *
+ *
+ * Arguments:
+ *
+ * - Optional block type (e.g., "STONE", "GLASS") - defaults to "BRICKS"
+ * - Optional -extend:BLOCKTYPE to fill vertically down to terrain
+ *
+ *
+ * After creation, the player should:
+ *
+ * - Right-click the CommandBlock
+ * - Paste the KML content after "/kml "
+ * - Set the CommandBlock to "Always Active"
+ * - Confirm to execute
+ *
+ *
+ * @param player The player creating the CommandBlock UI
+ * @param cmd The command object (unused)
+ * @param alias The command alias used (determines operation mode)
+ * @param args Command arguments (block type and extend options)
+ * @return true if the CommandBlock was created successfully
+ */
+ public boolean createPasteUI(Player player, Command cmd, String alias, String @NonNull [] args) {
+ //The command either creates a command-block at the player location
+ //arguments are an
+ // optional blocktype
+ // optional -toGround:blockType
+ String blocktype = "BRICKS";
+ boolean extendToGround = false;
+ String extendToGroundBlockType = "GREEN_WOOL";
+ String prefix_extendParam = "-extend:";
+ for (String arg : args) {
+ if (arg.startsWith(prefix_extendParam)) {
+ extendToGround = true;
+ extendToGroundBlockType = arg.substring(prefix_extendParam.length()).toUpperCase();
+
+ if (Material.matchMaterial(extendToGroundBlockType) == null) {
+ player.sendMessage(String.format("§cInvalid block type for extend parameter '%s'. Using bricks as fallback.", extendToGroundBlockType));
+ extendToGroundBlockType = "BRICKS";
+ }
+ } else {
+ blocktype = arg.toUpperCase();
+
+ if (Material.matchMaterial(blocktype) == null) {
+ player.sendMessage(String.format("§cInvalid block type '%s'. Using bricks as fallback.", blocktype));
+ blocktype = "BRICKS";
+ }
+ }
+ }
+
+ //spawn a command block in front of the player
+ Location commandBlockLocation = player.getLocation().add(player.getLocation().getDirection().multiply(2));
+ commandBlockLocation = commandBlockLocation.add(0, 2, 0);
+
+ World world = commandBlockLocation.getWorld();
+ Block block = world.getBlockAt(commandBlockLocation);
+
+ Material previousMaterial = block.getType(); //remember old blocktype to replace after command processing
+
+ if (XMaterial.COMMAND_BLOCK.get() != null) block.setType(XMaterial.COMMAND_BLOCK.get());
+
+ //for now, user has to manually set the command to "auto" to get it immediately triggered on confirm
+ CommandBlock cmdBlock = (CommandBlock) block.getState();
+
+ cmdBlock.setCommand("/kml "); //ready to paste kml content
+ cmdBlock.setMetadata("kmlPlayerName", new FixedMetadataValue(BuildTeamTools.getInstance(), player.getName()));
+ //cmdBlock.setMetadata("kmlPlayerID", new FixedMetadataValue(BuildTeamTools.getInstance(), p.getUniqueId()));
+ cmdBlock.setMetadata("kmlBlocktype", new FixedMetadataValue(BuildTeamTools.getInstance(), blocktype));
+ cmdBlock.setMetadata("kmlExtendToGround", new FixedMetadataValue(BuildTeamTools.getInstance(), extendToGround));
+ cmdBlock.setMetadata("kmlExtendToGroundBlocktype", new FixedMetadataValue(BuildTeamTools.getInstance(), extendToGroundBlockType));
+
+ cmdBlock.setMetadata("kmlPreviousBlocktype", new FixedMetadataValue(BuildTeamTools.getInstance(), previousMaterial.toString()));
+
+ cmdBlock.setMetadata("kmlBlockCreationCommand", new FixedMetadataValue(BuildTeamTools.getInstance(), alias));
+
+ cmdBlock.update();
+ player.sendMessage("§6Command block created. Right click the block, paste the KML content, set it to 'always on' and confirm");
+ return true;
+
+ }
+
+ /**
+ * Undoes the last KML command executed by the player.
+ *
+ * This method retrieves the most recent {@link ChangeTransaction} from the player's
+ * history and reverses all block changes made by that transaction.
+ *
+ * The undo history is maintained per-player in a stack, so multiple undos can be
+ * performed in sequence to revert multiple KML commands.
+ *
+ * @param player The player requesting the undo
+ * @return true if undo was successful, false if no history exists
+ */
+ public boolean undoCommand(Player player) {
+ if (playerHistories == null) {
+ player.sendMessage("kml undo failed - no command history available.");
+ return false;
+ }
+
+ Stack playerHistory = playerHistories.get(player);
+
+ if (playerHistory == null || playerHistory.empty()) {
+ player.sendMessage("kml undo failed - there is no previously executed kml command.");
+ return false;
+ }
+
+ ChangeTransaction transaction = playerHistory.pop();
+ transaction.undo();
+ player.sendMessage(String.format("undo successful. Restored %d blocks.", transaction.size()));
+ return true;
+ }
+
+ /**
+ * Converts geographic coordinates (latitude/longitude) to a Minecraft Location.
+ *
+ * This method:
+ *
+ * - Converts lat/lon to Minecraft X/Z using {@link GeometricUtils#getLocationFromCoordinates(double[])}
+ * - Applies the KML altitude offset (Google Earth altitudes are relative to ground)
+ *
+ *
+ * Note: GeometricUtils already adds +2 to terrain elevation, so we don't subtract it here anymore.
+ *
+ * @param coordinates Array of [latitude, longitude] in degrees
+ * @param altitudeFromKML Altitude from the KML file (relative to ground level)
+ * @return A Bukkit Location with X/Z from projection and Y adjusted for altitude
+ */
+ private @NonNull Location getLocationFromCoordinates(double[] coordinates, double altitudeFromKML) {
+ Location mcLocation = GeometricUtils.getLocationFromCoordinates(coordinates);
+ //add altitude from kml (altitude from Google Earth is always relative to ground)
+ //note: the "-2" is only neccesary because
+ // getLocationFromCoordinates returns terrain altitude + 2
+ // (one from Bukkits getHighestBlockY and one from our geoutils)
+ mcLocation.add(0, altitudeFromKML, 0);
+ return mcLocation;
+ }
+
+ /**
+ * Converts multiple lists of geographic coordinates to Minecraft Locations.
+ *
+ * This method parallelizes the coordinate conversion using a thread pool to improve
+ * performance when processing large KML files with many coordinates. Each coordinate
+ * conversion is executed asynchronously, and the method waits for all conversions
+ * to complete before returning.
+ *
+ * For each list of coordinates (representing a polyline), it:
+ *
+ * - Creates a thread pool sized to the number of coordinates
+ * - Submits each coordinate conversion as a CompletableFuture
+ * - Waits for all futures to complete using {@link CompletableFuture#join()}
+ * - Collects the results into a list of Locations
+ *
+ *
+ * Note: This method is called from an async task, so the .join() call won't block
+ * the main server thread.
+ *
+ * @param geocoords_lists List of polylines, where each polyline is a list of KML Coordinates
+ * @param world The world context (currently unused but available for future use)
+ * @return List of polylines converted to Minecraft Locations
+ */
+ private @NonNull List> convertToMC(@NonNull List> geocoords_lists, World world) {
+
+ List> mcLines = new ArrayList<>();
+
+ //This lat/long to xyz conversion takes most of the runtime for this command
+ // since the conversions do not influence each other, we can parallelize them.
+ for (List geocoords : geocoords_lists) {
+ // ExecutorService to manage the threads
+ try (ExecutorService executorService = Executors.newFixedThreadPool(geocoords.size())) {
+
+ // List to store CompletableFuture results
+ List> completableFutureList = new ArrayList<>();
+
+ // Create a CompletableFuture for each set of coordinates
+ for (Coordinate geocoord : geocoords) {
+ double[] coordinates = new double[]{geocoord.getLatitude(), geocoord.getLongitude()};
+
+ CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> getLocationFromCoordinates(coordinates, geocoord.getAltitude()), executorService);
+ completableFutureList.add(completableFuture);
+ }
+
+ // Combine all CompletableFutures into a single CompletableFuture representing all of them
+ CompletableFuture allOf = CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0]));
+
+ // Wait for all CompletableFutures to complete
+ allOf.join();
+
+ // Collect the results from the CompletableFutures
+ List mcLine = completableFutureList.stream().map(CompletableFuture::join).toList();
+
+ mcLines.add(mcLine);
+
+ // Shutdown the ExecutorService
+ executorService.shutdown();
+ }
+ }
+ return mcLines;
+ }
+
+ /**
+ * Maps command aliases to their corresponding block creation modes.
+ *
+ * This method determines how KML coordinates should be processed:
+ *
+ * - geopoints → {@link BlockCreationMode#POINTS}: Places blocks only at coordinate points
+ * - geopath → {@link BlockCreationMode#PATH}: Draws lines between consecutive points
+ * - georing → {@link BlockCreationMode#CLOSED_PATH}: Draws lines and closes the path (connects last to first)
+ * - geosurface → {@link BlockCreationMode#FILLED}: Triangulates and fills the polygon (not yet implemented)
+ *
+ *
+ * @param command The command alias used to invoke the KML command
+ * @return The BlockCreationMode corresponding to the command
+ * @throws UnsupportedOperationException if command is "geosurface" (not implemented)
+ * @throws IllegalArgumentException if command is not recognized
+ */
+ private BlockCreationMode commandToCreationMode(@NonNull String command) {
+ return switch (command) {
+ case "geopoints" -> BlockCreationMode.POINTS;
+ case "geopath" -> BlockCreationMode.PATH;
+ case "georing" -> BlockCreationMode.CLOSED_PATH;
+ case "geosurface" ->
+ throw new UnsupportedOperationException("Operation mode 'filled surface' is not yet implemented");
+ //return BlockCreationMode.FILLED;
+ default -> throw new IllegalArgumentException(command);
+ };
+
+ }
+
+ /**
+ * Per-player history of KML command transactions for undo functionality.
+ *
+ * Each player has a stack of {@link ChangeTransaction} objects representing their
+ * executed KML commands. This allows players to undo their changes using /kml undo.
+ *
+ * The most recent transaction is at the top of the stack and will be undone first.
+ */
+ private HashMap> playerHistories;
+}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/kml/KmlParser.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/KmlParser.java
similarity index 72%
rename from src/main/java/net/buildtheearth/modules/generator/components/kml/KmlParser.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/KmlParser.java
index 69df0bd3..8b9f92dc 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/kml/KmlParser.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/KmlParser.java
@@ -1,21 +1,11 @@
-package net.buildtheearth.modules.generator.components.kml;
+package net.buildtheearth.buildteamtools.modules.generator.components.kml;
-import java.util.List;
-import java.util.ArrayList;
-
+import de.micromata.opengis.kml.v_2_2_0.*;
import org.bukkit.entity.Player;
-import de.micromata.opengis.kml.v_2_2_0.Coordinate;
-import de.micromata.opengis.kml.v_2_2_0.Document;
-import de.micromata.opengis.kml.v_2_2_0.Feature;
-import de.micromata.opengis.kml.v_2_2_0.Geometry;
-import de.micromata.opengis.kml.v_2_2_0.Kml;
-import de.micromata.opengis.kml.v_2_2_0.LineString;
-import de.micromata.opengis.kml.v_2_2_0.LinearRing;
-import de.micromata.opengis.kml.v_2_2_0.MultiGeometry;
-import de.micromata.opengis.kml.v_2_2_0.Placemark;
-import de.micromata.opengis.kml.v_2_2_0.Polygon;
+import java.util.ArrayList;
+import java.util.List;
public class KmlParser {
private Player player;
@@ -32,18 +22,26 @@ public List> extractCoordinates(String kmlString)
//https://github.com/micromata/javaapiforkml
try {
- Kml kml = Kml.unmarshal(kmlString);
-
- //Top-level element will be a document
- Document doc = (Document) kml.getFeature();
- List placemarks = findPlacemarks(doc);
-
-
- for (Placemark placemark : placemarks){
- // get all geometries from placemark (might be multiple lists)
- //each list creates a separate entry list in the result
- List> placemark_coords_lists = getCoordinates(placemark.getGeometry());
- result_lists.addAll(placemark_coords_lists);
+ // Set the context class loader to ensure JAXB service loader can find the implementation
+ // This is necessary when running in a PluginClassLoader environment
+ ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ Kml kml = Kml.unmarshal(kmlString);
+
+ //Top-level element will be a document
+ Document doc = (Document) kml.getFeature();
+ List placemarks = findPlacemarks(doc);
+
+
+ for (Placemark placemark : placemarks) {
+ // get all geometries from placemark (might be multiple lists)
+ //each list creates a separate entry list in the result
+ List> placemark_coords_lists = getCoordinates(placemark.getGeometry());
+ result_lists.addAll(placemark_coords_lists);
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalClassLoader);
}
} catch (Exception ex) {
@@ -70,16 +68,24 @@ public List extractLinestrings(String kmlString)
//https://github.com/micromata/javaapiforkml
try {
- Kml kml = Kml.unmarshal(kmlString);
- //Top-level element will be a document
- Document doc = (Document) kml.getFeature();
- List placemarks = findPlacemarks(doc);
-
-
- for (Placemark placemark : placemarks){
- // #extract coordinates assuming geometry is linestring
- List lines = findLineStrings(placemark);
- linestrings.addAll(lines);
+ // Set the context class loader to ensure JAXB service loader can find the implementation
+ // This is necessary when running in a PluginClassLoader environment
+ ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ Kml kml = Kml.unmarshal(kmlString);
+ //Top-level element will be a document
+ Document doc = (Document) kml.getFeature();
+ List placemarks = findPlacemarks(doc);
+
+
+ for (Placemark placemark : placemarks) {
+ // #extract coordinates assuming geometry is linestring
+ List lines = findLineStrings(placemark);
+ linestrings.addAll(lines);
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalClassLoader);
}
} catch (Exception ex) {
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/kml/KmlTabCompleter.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/KmlTabCompleter.java
similarity index 97%
rename from src/main/java/net/buildtheearth/modules/generator/components/kml/KmlTabCompleter.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/KmlTabCompleter.java
index 2d2a3ecc..3695e2f8 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/kml/KmlTabCompleter.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/kml/KmlTabCompleter.java
@@ -1,8 +1,4 @@
-package net.buildtheearth.modules.generator.components.kml;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+package net.buildtheearth.buildteamtools.modules.generator.components.kml;
import org.bukkit.Material;
import org.bukkit.command.Command;
@@ -10,6 +6,10 @@
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
public class KmlTabCompleter implements TabCompleter{
public KmlTabCompleter(){
//compile list of block material types for completion
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/Rail.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/Rail.java
new file mode 100644
index 00000000..b0a7b913
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/Rail.java
@@ -0,0 +1,27 @@
+package net.buildtheearth.buildteamtools.modules.generator.components.rail;
+
+import com.alpsbte.alpslib.utils.GeneratorUtils;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorComponent;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorType;
+import org.bukkit.entity.Player;
+
+public class Rail extends GeneratorComponent {
+
+ public Rail() {
+ super(GeneratorType.RAILWAY);
+ }
+
+ @Override
+ public boolean checkForPlayer(Player p) {
+ return !GeneratorUtils.checkForNoWorldEditSelection(p);
+ }
+
+ @Override
+ public void generate(Player p) {
+ if (!GeneratorModule.getInstance().getRail().checkForPlayer(p))
+ return;
+
+ new RailScripts(p, this);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/rail/RailFlag.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/RailFlag.java
similarity index 74%
rename from src/main/java/net/buildtheearth/modules/generator/components/rail/RailFlag.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/RailFlag.java
index e0d17484..a78994b0 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/rail/RailFlag.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/RailFlag.java
@@ -1,7 +1,7 @@
-package net.buildtheearth.modules.generator.components.rail;
+package net.buildtheearth.buildteamtools.modules.generator.components.rail;
-import net.buildtheearth.modules.generator.model.FlagType;
-import net.buildtheearth.modules.generator.model.Flag;
+import net.buildtheearth.buildteamtools.modules.generator.model.Flag;
+import net.buildtheearth.buildteamtools.modules.generator.model.FlagType;
public enum RailFlag implements Flag {
LANE_COUNT("c", FlagType.INTEGER);
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/rail/RailScripts.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/RailScripts.java
similarity index 89%
rename from src/main/java/net/buildtheearth/modules/generator/components/rail/RailScripts.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/RailScripts.java
index 7cd126ef..ab1156d2 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/rail/RailScripts.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/RailScripts.java
@@ -1,7 +1,8 @@
-package net.buildtheearth.modules.generator.components.rail;
+package net.buildtheearth.buildteamtools.modules.generator.components.rail;
-import net.buildtheearth.modules.generator.model.*;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
+import com.alpsbte.alpslib.utils.GeneratorUtils;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorComponent;
+import net.buildtheearth.buildteamtools.modules.generator.model.Script;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@@ -14,7 +15,9 @@ public class RailScripts extends Script {
public RailScripts(Player player, GeneratorComponent generatorComponent) {
super(player, generatorComponent);
- railScript_v_1_3();
+ throw new UnsupportedOperationException("RailScripts is currently broken.");
+ //getPlayer().chat("/clearhistory");
+ //Bukkit.getScheduler().runTaskAsynchronously(BuildTeamTools.getInstance(), this::railScript_v_1_3);
}
public void railScript_v_1_3() {
@@ -25,7 +28,6 @@ public void railScript_v_1_3() {
int zPos = getPlayer().getLocation().getBlockZ();
int operations = 0;
- getPlayer().chat("/clearhistory");
int railWidth = 5;
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/rail/RailSettings.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/RailSettings.java
similarity index 65%
rename from src/main/java/net/buildtheearth/modules/generator/components/rail/RailSettings.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/RailSettings.java
index 9b62c40e..0d7ef243 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/rail/RailSettings.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/RailSettings.java
@@ -1,6 +1,6 @@
-package net.buildtheearth.modules.generator.components.rail;
+package net.buildtheearth.buildteamtools.modules.generator.components.rail;
-import net.buildtheearth.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
import org.bukkit.entity.Player;
public class RailSettings extends Settings {
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/Road.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/Road.java
new file mode 100644
index 00000000..dc133d3f
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/Road.java
@@ -0,0 +1,27 @@
+package net.buildtheearth.buildteamtools.modules.generator.components.road;
+
+import com.alpsbte.alpslib.utils.GeneratorUtils;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorComponent;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorType;
+import org.bukkit.entity.Player;
+
+public class Road extends GeneratorComponent {
+
+ public Road() {
+ super(GeneratorType.ROAD);
+ }
+
+ @Override
+ public boolean checkForPlayer(Player p) {
+ return !GeneratorUtils.checkForNoWorldEditSelection(p);
+ }
+
+ @Override
+ public void generate(Player p) {
+ if (!GeneratorModule.getInstance().getRoad().checkForPlayer(p))
+ return;
+
+ new RoadScripts(p, this);
+ }
+}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/road/RoadFlag.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/RoadFlag.java
similarity index 85%
rename from src/main/java/net/buildtheearth/modules/generator/components/road/RoadFlag.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/RoadFlag.java
index 9205134b..79760261 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/road/RoadFlag.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/RoadFlag.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.modules.generator.components.road;
+package net.buildtheearth.buildteamtools.modules.generator.components.road;
-import net.buildtheearth.modules.generator.model.FlagType;
-import net.buildtheearth.modules.generator.model.Flag;
+import net.buildtheearth.buildteamtools.modules.generator.model.Flag;
+import net.buildtheearth.buildteamtools.modules.generator.model.FlagType;
public enum RoadFlag implements Flag {
LANE_COUNT("c", FlagType.INTEGER),
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/road/RoadScripts.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/RoadScripts.java
similarity index 97%
rename from src/main/java/net/buildtheearth/modules/generator/components/road/RoadScripts.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/RoadScripts.java
index 0b722385..7fbaa368 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/road/RoadScripts.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/RoadScripts.java
@@ -1,13 +1,13 @@
-package net.buildtheearth.modules.generator.components.road;
+package net.buildtheearth.buildteamtools.modules.generator.components.road;
+import com.alpsbte.alpslib.utils.GeneratorUtils;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.common.CommonModule;
-import net.buildtheearth.modules.generator.model.Flag;
-import net.buildtheearth.modules.generator.model.GeneratorComponent;
-import net.buildtheearth.modules.generator.model.Script;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
-import net.buildtheearth.utils.Item;
+import net.buildtheearth.buildteamtools.modules.common.CommonModule;
+import net.buildtheearth.buildteamtools.modules.generator.model.Flag;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorComponent;
+import net.buildtheearth.buildteamtools.modules.generator.model.Script;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/road/RoadSettings.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/RoadSettings.java
similarity index 88%
rename from src/main/java/net/buildtheearth/modules/generator/components/road/RoadSettings.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/RoadSettings.java
index 430a5c36..1cda8457 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/road/RoadSettings.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/RoadSettings.java
@@ -1,11 +1,8 @@
-package net.buildtheearth.modules.generator.components.road;
+package net.buildtheearth.buildteamtools.modules.generator.components.road;
+import com.alpsbte.alpslib.utils.GeneratorUtils;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.generator.model.Flag;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
-import net.buildtheearth.utils.Item;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
import org.bukkit.entity.Player;
import java.io.File;
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/road/menu/AdvancedColorMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/AdvancedColorMenu.java
similarity index 70%
rename from src/main/java/net/buildtheearth/modules/generator/components/road/menu/AdvancedColorMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/AdvancedColorMenu.java
index 4cda5a9d..0a4e79c6 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/road/menu/AdvancedColorMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/AdvancedColorMenu.java
@@ -1,11 +1,11 @@
-package net.buildtheearth.modules.generator.components.road.menu;
-
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.road.RoadFlag;
-import net.buildtheearth.modules.generator.components.road.RoadSettings;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.menus.BlockListMenu;
+package net.buildtheearth.buildteamtools.modules.generator.components.road.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadSettings;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.menus.BlockListMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -35,7 +35,7 @@ protected void setItemClickEventsAsync() {
return;
RoadSettings roadSettings = (RoadSettings) settings;
- roadSettings.setValue(roadFlag, Item.createStringFromItemList(selectedMaterials));
+ roadSettings.setValue(roadFlag, Item.createStringFromItemStringList(selectedMaterials));
clickPlayer.closeInventory();
clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/road/menu/AdvancedSettingsMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/AdvancedSettingsMenu.java
similarity index 92%
rename from src/main/java/net/buildtheearth/modules/generator/components/road/menu/AdvancedSettingsMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/AdvancedSettingsMenu.java
index a5a9f222..40334242 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/road/menu/AdvancedSettingsMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/AdvancedSettingsMenu.java
@@ -1,16 +1,16 @@
-package net.buildtheearth.modules.generator.components.road.menu;
+package net.buildtheearth.buildteamtools.modules.generator.components.road.menu;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.road.Road;
-import net.buildtheearth.modules.generator.components.road.RoadFlag;
-import net.buildtheearth.modules.generator.components.road.RoadSettings;
-import net.buildtheearth.utils.CustomHeads;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.Road;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadSettings;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/road/menu/RoadColorMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/RoadColorMenu.java
similarity index 63%
rename from src/main/java/net/buildtheearth/modules/generator/components/road/menu/RoadColorMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/RoadColorMenu.java
index 6de0d1a6..d76379f6 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/road/menu/RoadColorMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/RoadColorMenu.java
@@ -1,13 +1,13 @@
-package net.buildtheearth.modules.generator.components.road.menu;
-
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.menu.GeneratorMenu;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.road.RoadFlag;
-import net.buildtheearth.modules.generator.components.road.RoadSettings;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.BlockListMenu;
+package net.buildtheearth.buildteamtools.modules.generator.components.road.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadSettings;
+import net.buildtheearth.buildteamtools.modules.generator.menu.GeneratorMenu;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.BlockListMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@@ -32,7 +32,7 @@ protected void setItemClickEventsAsync() {
return;
RoadSettings roadSettings = (RoadSettings) settings;
- roadSettings.setValue(RoadFlag.ROAD_MATERIAL, Item.createStringFromItemList(selectedMaterials));
+ roadSettings.setValue(RoadFlag.ROAD_MATERIAL, Item.createStringFromItemStringList(selectedMaterials));
clickPlayer.closeInventory();
clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/road/menu/SidewalkColorMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/SidewalkColorMenu.java
similarity index 66%
rename from src/main/java/net/buildtheearth/modules/generator/components/road/menu/SidewalkColorMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/SidewalkColorMenu.java
index 058797e2..8f79bf8d 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/road/menu/SidewalkColorMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/road/menu/SidewalkColorMenu.java
@@ -1,12 +1,12 @@
-package net.buildtheearth.modules.generator.components.road.menu;
-
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.road.RoadFlag;
-import net.buildtheearth.modules.generator.components.road.RoadSettings;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.BlockListMenu;
+package net.buildtheearth.buildteamtools.modules.generator.components.road.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadSettings;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.BlockListMenu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@@ -32,7 +32,7 @@ protected void setItemClickEventsAsync() {
return;
RoadSettings roadSettings = (RoadSettings) settings;
- roadSettings.setValue(RoadFlag.SIDEWALK_MATERIAL, Item.createStringFromItemList(selectedMaterials));
+ roadSettings.setValue(RoadFlag.SIDEWALK_MATERIAL, Item.createStringFromItemStringList(selectedMaterials));
clickPlayer.closeInventory();
clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/Tree.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/Tree.java
new file mode 100644
index 00000000..6c5e747f
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/Tree.java
@@ -0,0 +1,57 @@
+package net.buildtheearth.buildteamtools.modules.generator.components.tree;
+
+import com.alpsbte.alpslib.utils.GeneratorUtils;
+import lombok.Getter;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorCollections;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorComponent;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorType;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class Tree extends GeneratorComponent {
+
+ public static final String TREE_PACK_VERSION = "v2.0";
+ @Getter
+ private Set heights = new HashSet<>();
+
+ public Tree() {
+ super(GeneratorType.TREE);
+ Bukkit.getScheduler().runTaskAsynchronously(BuildTeamTools.getInstance(), () -> {
+ Path basePath = Path.of(GeneratorUtils.getWorldEditSchematicsFolderPath(), "GeneratorCollections", "treepack");
+ try (Stream paths = Files.walk(basePath, 2)) {
+ heights = paths
+ .filter(p -> basePath.relativize(p).getNameCount() == 2)
+ .filter(Files::isDirectory)
+ .map(p -> p.getFileName().toString())
+ .collect(Collectors.toSet());
+ } catch (IOException e) {
+ BuildTeamTools.getInstance().getComponentLogger().warn("Failed to load tree pack heights:", e);
+ }
+ });
+ }
+
+ @Override
+ public boolean checkForPlayer(Player p) {
+ if (!GeneratorCollections.hasUpdatedGeneratorCollections(p))
+ return false;
+
+ return GeneratorUtils.checkIfSchematicBrushIsInstalled(p);
+ }
+
+ @Override
+ public void generate(Player p) {
+ if (!checkForPlayer(p))
+ return;
+
+ TreeScripts.treescript_v_1_0(p, this);
+ }
+}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeFlag.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeFlag.java
similarity index 53%
rename from src/main/java/net/buildtheearth/modules/generator/components/tree/TreeFlag.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeFlag.java
index bece460a..e23308bc 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeFlag.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeFlag.java
@@ -1,15 +1,20 @@
-package net.buildtheearth.modules.generator.components.tree;
+package net.buildtheearth.buildteamtools.modules.generator.components.tree;
-import net.buildtheearth.modules.generator.model.FlagType;
-import net.buildtheearth.modules.generator.model.Flag;
+import lombok.Getter;
+import net.buildtheearth.buildteamtools.modules.generator.model.Flag;
+import net.buildtheearth.buildteamtools.modules.generator.model.FlagType;
+import org.jspecify.annotations.Nullable;
public enum TreeFlag implements Flag {
TYPE("t", FlagType.TREE_TYPE),
WIDTH("w", FlagType.TREE_WIDTH),
- HEIGHT("h", FlagType.INTEGER);
+ HEIGHT("h", FlagType.STRING);
+ @Getter
private final String flag;
+
+ @Getter
private final FlagType flagType;
TreeFlag(String flag, FlagType flagType){
@@ -17,16 +22,7 @@ public enum TreeFlag implements Flag {
this.flagType = flagType;
}
- public String getFlag() {
- return flag;
- }
-
- @Override
- public FlagType getFlagType() {
- return null;
- }
-
- public static TreeFlag byString(String flag){
+ public static @Nullable TreeFlag byString(String flag) {
for(TreeFlag treeFlag : TreeFlag.values())
if(treeFlag.getFlag().equalsIgnoreCase(flag))
return treeFlag;
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeScripts.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeScripts.java
new file mode 100644
index 00000000..143a1c8c
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeScripts.java
@@ -0,0 +1,35 @@
+package net.buildtheearth.buildteamtools.modules.generator.components.tree;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import com.cryptomorin.xseries.XMaterial;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.jspecify.annotations.NonNull;
+
+public class TreeScripts {
+
+ public static void treescript_v_1_0(@NonNull Player p, @NonNull Tree tree) {
+ Settings settings = tree.getPlayerSettings().get(p.getUniqueId());
+ TreeType treeType = (TreeType) settings.getValues().get(TreeFlag.TYPE);
+ if (treeType == null) treeType = TreeType.ANY;
+ String height = String.valueOf(settings.getValues().get(TreeFlag.HEIGHT));
+ TreeWidth treeWidth = (TreeWidth) settings.getValues().get(TreeFlag.WIDTH);
+ if (treeWidth == null) treeWidth = TreeWidth.ANY;
+
+ // In case the player is holding no item, give him a diamond sword
+ if (p.getInventory().getItemInMainHand().getType() == Material.AIR)
+ p.getInventory().setItem(p.getInventory().getHeldItemSlot(), Item.create(XMaterial.DIAMOND_SWORD.get()));
+
+ if (treeType.getName().equalsIgnoreCase("any")) {
+ p.chat("/schbr $GeneratorCollections/treepack/* -place:bottom -yoff:2");
+ } else if (height.equalsIgnoreCase("null") || height.equalsIgnoreCase("any")) {
+ p.chat("/schbr $GeneratorCollections/treepack/" + treeType.getName() + "/* -place:bottom -yoff:2");
+ } else if (treeWidth.getName().equalsIgnoreCase("any")) {
+ p.chat("/schbr $GeneratorCollections/treepack/" + treeType.getName() + "/" + height + "/* -place:bottom -yoff:2");
+ } else {
+ p.chat("/schbr $GeneratorCollections/treepack/" + treeType.getName() + "/" + height + "/"
+ + treeWidth.getName() + "/* -place:bottom -yoff:2");
+ }
+ }
+}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeSettings.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeSettings.java
similarity index 66%
rename from src/main/java/net/buildtheearth/modules/generator/components/tree/TreeSettings.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeSettings.java
index d751d0b5..dcf183e9 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeSettings.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeSettings.java
@@ -1,7 +1,7 @@
-package net.buildtheearth.modules.generator.components.tree;
+package net.buildtheearth.buildteamtools.modules.generator.components.tree;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.road.RoadFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadFlag;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
import org.bukkit.entity.Player;
public class TreeSettings extends Settings {
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeType.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeType.java
similarity index 76%
rename from src/main/java/net/buildtheearth/modules/generator/components/tree/TreeType.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeType.java
index b4ed37ad..31d88fc3 100644
--- a/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeType.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeType.java
@@ -1,6 +1,7 @@
-package net.buildtheearth.modules.generator.components.tree;
+package net.buildtheearth.buildteamtools.modules.generator.components.tree;
import lombok.Getter;
+import org.jspecify.annotations.Nullable;
public enum TreeType {
@@ -50,4 +51,12 @@ public enum TreeType {
TreeType(String name) {
this.name = name;
}
+
+ public static @Nullable TreeType byString(String check) {
+ for (TreeType type : TreeType.values())
+ if (type.getName().equalsIgnoreCase(check))
+ return type;
+
+ return null;
+ }
}
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeWidth.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeWidth.java
new file mode 100644
index 00000000..3b958fe8
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/TreeWidth.java
@@ -0,0 +1,29 @@
+package net.buildtheearth.buildteamtools.modules.generator.components.tree;
+
+import lombok.Getter;
+import org.jspecify.annotations.Nullable;
+
+public enum TreeWidth {
+
+ ANY("any"),
+ THIN("thin"),
+ NORMAL("normal"),
+ WIDE("wide"),
+ XXL("xxl"),
+ DEAD("dead");
+
+ @Getter
+ private final String name;
+
+ TreeWidth(String name) {
+ this.name = name;
+ }
+
+ public static @Nullable TreeWidth byString(String width) {
+ for (TreeWidth treeWidth : TreeWidth.values())
+ if (treeWidth.getName().equalsIgnoreCase(width))
+ return treeWidth;
+
+ return null;
+ }
+}
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/menu/TreeHeightMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/menu/TreeHeightMenu.java
new file mode 100644
index 00000000..1683d870
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/menu/TreeHeightMenu.java
@@ -0,0 +1,62 @@
+package net.buildtheearth.buildteamtools.modules.generator.components.tree.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import com.cryptomorin.xseries.XMaterial;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeSettings;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.menus.NameListMenu;
+import net.daporkchop.lib.common.misc.Tuple;
+import org.apache.commons.lang3.StringUtils;
+import org.bukkit.Sound;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.jspecify.annotations.NonNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TreeHeightMenu extends NameListMenu {
+
+ public static final String TREE_TYPE_INV_NAME = "Choose a Tree Width";
+
+ public TreeHeightMenu(Player player, boolean autoLoad) {
+ super(player, TREE_TYPE_INV_NAME, getTreeHeights(), new TreeTypeMenu(player, false), autoLoad);
+ }
+
+ /**
+ * Get a list of all tree widths
+ */
+ private static @NonNull List> getTreeHeights() {
+ List> treeHeights = new ArrayList<>();
+
+ treeHeights.add(new Tuple<>(new Item(XMaterial.LIME_CONCRETE.parseItem()).setDisplayName("Any").build(), "Any"));
+
+ GeneratorModule.getInstance().getTree().getHeights().forEach(h ->
+ treeHeights.add(new Tuple<>(Item.create(XMaterial.PAPER.get(), StringUtils.capitalize(h)), h)));
+
+ return treeHeights;
+ }
+
+ @Override
+ protected void setItemClickEventsAsync() {
+ super.setItemClickEventsAsync();
+
+ // Set click event for next item
+ if (canProceed())
+ getMenu().getSlot(NEXT_ITEM_SLOT).setClickHandler((clickPlayer, clickInformation) -> {
+ Settings settings = GeneratorModule.getInstance().getTree().getPlayerSettings().get(clickPlayer.getUniqueId());
+
+ if (!(settings instanceof TreeSettings treeSettings))
+ return;
+
+ treeSettings.setValue(TreeFlag.HEIGHT, selectedNames.getFirst());
+
+ clickPlayer.closeInventory();
+ clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
+
+ new TreeWidthMenu(clickPlayer, true);
+ });
+ }
+}
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/menu/TreeTypeMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/menu/TreeTypeMenu.java
new file mode 100644
index 00000000..d2de1d4a
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/menu/TreeTypeMenu.java
@@ -0,0 +1,62 @@
+package net.buildtheearth.buildteamtools.modules.generator.components.tree.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import com.cryptomorin.xseries.XMaterial;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeType;
+import net.buildtheearth.buildteamtools.modules.generator.menu.GeneratorMenu;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.menus.NameListMenu;
+import net.daporkchop.lib.common.misc.Tuple;
+import org.apache.commons.lang3.StringUtils;
+import org.bukkit.Sound;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.jspecify.annotations.NonNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TreeTypeMenu extends NameListMenu {
+
+ public static final String TREE_TYPE_INV_NAME = "Choose a Tree Type";
+
+ public TreeTypeMenu(Player player, boolean autoLoad) {
+ super(player, TREE_TYPE_INV_NAME, getTreeTypes(), new GeneratorMenu(player, false), autoLoad);
+ }
+
+ /** Get a list of all tree types */
+ private static @NonNull List> getTreeTypes() {
+ List> treeTypes = new ArrayList<>();
+
+ treeTypes.add(new Tuple<>(new Item(XMaterial.LIME_CONCRETE.parseItem()).setDisplayName("Any").build(), "Any"));
+
+ for(TreeType treeType : TreeType.values())
+ treeTypes.add(new Tuple<>(Item.create(XMaterial.OAK_SAPLING.get(), StringUtils.capitalize(treeType.getName())), treeType.getName()));
+
+ return treeTypes;
+ }
+
+ @Override
+ protected void setItemClickEventsAsync() {
+ super.setItemClickEventsAsync();
+
+ // Set click event for next item
+ if(canProceed())
+ getMenu().getSlot(NEXT_ITEM_SLOT).setClickHandler((clickPlayer, clickInformation) -> {
+ Settings settings = GeneratorModule.getInstance().getTree().getPlayerSettings().get(clickPlayer.getUniqueId());
+
+ if (!(settings instanceof TreeSettings treeSettings))
+ return;
+
+ treeSettings.setValue(TreeFlag.TYPE, selectedNames.getFirst());
+
+ clickPlayer.closeInventory();
+ clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
+
+ new TreeHeightMenu(clickPlayer, true);
+ });
+ }
+}
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/menu/TreeWidthMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/menu/TreeWidthMenu.java
new file mode 100644
index 00000000..a8fb57a4
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/tree/menu/TreeWidthMenu.java
@@ -0,0 +1,63 @@
+package net.buildtheearth.buildteamtools.modules.generator.components.tree.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import com.cryptomorin.xseries.XMaterial;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeWidth;
+import net.buildtheearth.buildteamtools.modules.generator.model.Settings;
+import net.buildtheearth.buildteamtools.utils.menus.NameListMenu;
+import net.daporkchop.lib.common.misc.Tuple;
+import org.apache.commons.lang3.StringUtils;
+import org.bukkit.Sound;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.jspecify.annotations.NonNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TreeWidthMenu extends NameListMenu {
+
+ public static final String TREE_TYPE_INV_NAME = "Choose a Tree Width";
+
+ public TreeWidthMenu(Player player, boolean autoLoad) {
+ super(player, TREE_TYPE_INV_NAME, getTreeWidths(), new TreeTypeMenu(player, false), autoLoad);
+ }
+
+ /**
+ * Get a list of all tree widths
+ */
+ private static @NonNull List> getTreeWidths() {
+ List> treeWidths = new ArrayList<>();
+
+ treeWidths.add(new Tuple<>(new Item(XMaterial.LIME_CONCRETE.parseItem()).setDisplayName("Any").build(), "Any"));
+
+ for (TreeWidth treeWidth : TreeWidth.values())
+ treeWidths.add(new Tuple<>(Item.create(XMaterial.JUNGLE_SAPLING.get(), StringUtils.capitalize(treeWidth.getName())), treeWidth.getName()));
+
+ return treeWidths;
+ }
+
+ @Override
+ protected void setItemClickEventsAsync() {
+ super.setItemClickEventsAsync();
+
+ // Set click event for next item
+ if (canProceed())
+ getMenu().getSlot(NEXT_ITEM_SLOT).setClickHandler((clickPlayer, clickInformation) -> {
+ Settings settings = GeneratorModule.getInstance().getTree().getPlayerSettings().get(clickPlayer.getUniqueId());
+
+ if (!(settings instanceof TreeSettings treeSettings))
+ return;
+
+ treeSettings.setValue(TreeFlag.WIDTH, selectedNames.getFirst());
+
+ clickPlayer.closeInventory();
+ clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
+
+ GeneratorModule.getInstance().getTree().generate(clickPlayer);
+ });
+ }
+}
diff --git a/src/main/java/net/buildtheearth/modules/generator/listeners/GeneratorListener.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/listeners/GeneratorListener.java
similarity index 88%
rename from src/main/java/net/buildtheearth/modules/generator/listeners/GeneratorListener.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/listeners/GeneratorListener.java
index 02068ab3..1d4523ae 100644
--- a/src/main/java/net/buildtheearth/modules/generator/listeners/GeneratorListener.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/listeners/GeneratorListener.java
@@ -1,7 +1,7 @@
-package net.buildtheearth.modules.generator.listeners;
+package net.buildtheearth.buildteamtools.modules.generator.listeners;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/menu/GeneratorMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/menu/GeneratorMenu.java
new file mode 100644
index 00000000..ef738425
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/menu/GeneratorMenu.java
@@ -0,0 +1,232 @@
+package net.buildtheearth.buildteamtools.modules.generator.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import com.cryptomorin.xseries.XMaterial;
+import net.buildtheearth.buildteamtools.modules.common.CommonModule;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.House;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.RoofType;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.menu.WallColorMenu;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.Road;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.menu.RoadColorMenu;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.Tree;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.menu.TreeTypeMenu;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorCollections;
+import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorType;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
+import org.bukkit.Sound;
+import org.bukkit.entity.Player;
+import org.bukkit.event.inventory.ClickType;
+import org.bukkit.inventory.ItemStack;
+import org.ipvp.canvas.mask.BinaryMask;
+import org.ipvp.canvas.mask.Mask;
+import org.jspecify.annotations.NonNull;
+
+import java.util.ArrayList;
+
+public class GeneratorMenu extends AbstractMenu {
+
+ public static final String GENERATOR_INV_NAME = "What do you want to generate?";
+
+ public static final int HOUSE_ITEM_SLOT = 9;
+
+ public static final int ROAD_ITEM_SLOT = 11;
+
+ public static final int RAILWAY_ITEM_SLOT = 13;
+
+ public static final int TREE_ITEM_SLOT = 15;
+
+ public static final int FIELD_ITEM_SLOT = 17;
+
+
+ public GeneratorMenu(Player player, boolean autoLoad) {
+ super(3, GENERATOR_INV_NAME, player, autoLoad);
+ }
+
+ @Override
+ protected void setPreviewItems() {
+ // HOUSE ITEM
+ ArrayList houseLore = ListUtil.createList("", "§eDescription:", "Generate basic building shells", "with multiple floors, windows and roofs", "", "§eFeatures:", "- " + RoofType.values().length + " Roof Types", "- Custom Wall, Base and Roof Color", "- Custom Floor and Window Sizes", "", "§8Left-click to generate", "§8Right-click for Tutorial");
+
+ ItemStack houseItem = Item.create(XMaterial.BIRCH_DOOR.get(), "§cGenerate House", houseLore);
+
+ // Set navigator item
+ getMenu().getSlot(HOUSE_ITEM_SLOT).setItem(houseItem);
+
+
+ // ROAD ITEM
+ ArrayList roadLore = ListUtil.createList("", "§eDescription:", "Generate roads and highways", "with multiple lanes and sidewalks", "", "§eFeatures:", "- Custom Road Width and Color", "- Custom Sidewalk Width and Color", "- Custom Lane Count", "", "§8Left-click to generate", "§8Right-click for Tutorial");
+
+
+ ItemStack roadItem = new Item(XMaterial.SMOOTH_STONE_SLAB.parseItem()).setDisplayName("§bGenerate Road").setLore(roadLore).build();
+
+ // Set navigator item
+ getMenu().getSlot(ROAD_ITEM_SLOT).setItem(roadItem);
+
+
+ // RAILWAY ITEM
+ ArrayList railwayLore = ListUtil.createList("", "§eDescription:", "Generate railways with multiple tracks", "and many different designs", "", "§eFeatures:", "- Custom Railway Width and Color (TODO)", "- Custom Track Count (TODO)", "", "§8Left-click to generate", "§8Right-click for Tutorial");
+
+ railwayLore = ListUtil.createList("", "§cThis §eGenerator §cis currently broken", "§cRailway Generator is disabled", "", "§8If you want to help fixing ask on Dev Hub!");
+
+ ItemStack railwayItem = Item.create(XMaterial.RAIL.get(), "§9Generate Railway §c(DISABLED)", railwayLore);
+
+ // Set navigator item
+ getMenu().getSlot(RAILWAY_ITEM_SLOT).setItem(railwayItem);
+
+
+ if (!CommonModule.getInstance().getDependencyComponent().isSchematicBrushEnabled()) {
+ // TREE ITEM
+ ArrayList treeLore = ListUtil.createList("", "§cPlugin §eSchematicBrush §cis not installed", "§cTree Generator is disabled", "", "§8Leftclick for Installation Instructions");
+
+ ItemStack treeItem = Item.create(XMaterial.OAK_SAPLING.get(), "§aGenerate Tree & Forest §c(DISABLED)", treeLore);
+
+ // Set navigator item
+ getMenu().getSlot(TREE_ITEM_SLOT).setItem(treeItem);
+ } else if (!GeneratorCollections.hasUpdatedGeneratorCollections(getMenuPlayer())) {
+ // TREE ITEM
+ ArrayList treeLore = ListUtil.createList("", "§cThe §eTree Pack " + Tree.TREE_PACK_VERSION + " §cis not installed", "§cTree Generator is disabled", "", "§8Leftclick for Installation Instructions");
+
+ ItemStack treeItem = Item.create(XMaterial.OAK_SAPLING.get(), "§aGenerate Tree & Forest §c(DISABLED)", treeLore);
+
+ // Set navigator item
+ getMenu().getSlot(TREE_ITEM_SLOT).setItem(treeItem);
+ } else {
+ // TREE ITEM
+ ArrayList treeLore = ListUtil.createList("", "§eDescription:", "Generate trees from a set of", "hundreds of different types", "", "§eFeatures:", "- Custom Tree Type", "", "§8Left-click to generate", "§8Right-click for Tutorial");
+
+ ItemStack treeItem = Item.create(XMaterial.OAK_SAPLING.get(), "§aGenerate Tree & Forest", treeLore);
+
+ // Set navigator item
+ getMenu().getSlot(TREE_ITEM_SLOT).setItem(treeItem);
+ }
+
+
+ // FIELD ITEM
+ ArrayList fieldLore = ListUtil.createList("", "§eDescription:", "Generate fields with different", "crops and plants", "", "§eFeatures:", "- Custom Crop Type", "- Custom Crop Size", "", "§8Left-click to generate", "§8Right-click for Tutorial");
+
+ fieldLore = ListUtil.createList("", "§cThis §eGenerator §cis currently broken", "§cField Generator is disabled", "", "§8If you want to help fixing ask on Dev Hub!");
+
+ ItemStack fieldItem = Item.create(XMaterial.WHEAT.get(), "§6Generate Field §c(DISABLED)", fieldLore);
+
+ // Set navigator item
+ getMenu().getSlot(FIELD_ITEM_SLOT).setItem(fieldItem);
+
+
+ super.setPreviewItems();
+ }
+
+ @Override
+ protected void setMenuItemsAsync() {
+ // No Async / DB Items
+ }
+
+ @Override
+ protected void setItemClickEventsAsync() {
+ // Set click event for house item
+ getMenu().getSlot(HOUSE_ITEM_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
+ if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
+ sendMoreInformation(clickPlayer, GeneratorType.HOUSE);
+ return;
+ }
+
+ House house = GeneratorModule.getInstance().getHouse();
+ house.getPlayerSettings().put(clickPlayer.getUniqueId(), new HouseSettings(clickPlayer));
+
+ if (!house.checkForPlayer(clickPlayer)) return;
+
+ clickPlayer.closeInventory();
+ clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
+ new WallColorMenu(clickPlayer, true);
+ }));
+
+ // Set click event for road item
+ getMenu().getSlot(ROAD_ITEM_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
+ if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
+ sendMoreInformation(clickPlayer, GeneratorType.ROAD);
+ return;
+ }
+
+ Road road = GeneratorModule.getInstance().getRoad();
+ road.getPlayerSettings().put(clickPlayer.getUniqueId(), new RoadSettings(clickPlayer));
+
+ if (!road.checkForPlayer(clickPlayer)) return;
+
+ clickPlayer.closeInventory();
+ clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
+ new RoadColorMenu(clickPlayer, true);
+ }));
+
+ // Set click event for railway item
+ getMenu().getSlot(RAILWAY_ITEM_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
+ if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
+ sendMoreInformation(clickPlayer, GeneratorType.RAILWAY);
+ return;
+ }
+ sendMoreInformation(clickPlayer, GeneratorType.RAILWAY);
+
+ /*Rail rail = GeneratorModule.getInstance().getRail();
+ rail.getPlayerSettings().put(clickPlayer.getUniqueId(), new RailSettings(clickPlayer));
+
+ if(!rail.checkForPlayer(clickPlayer))
+ return;
+
+ clickPlayer.closeInventory();
+ clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
+
+ GeneratorModule.getInstance().getRail().generate(clickPlayer);*/
+ }));
+
+ // Set click event for tree item
+ getMenu().getSlot(TREE_ITEM_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
+ if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
+ sendMoreInformation(clickPlayer, GeneratorType.TREE);
+ return;
+ }
+
+ Tree tree = GeneratorModule.getInstance().getTree();
+ tree.getPlayerSettings().put(clickPlayer.getUniqueId(), new TreeSettings(clickPlayer));
+
+ if (!tree.checkForPlayer(clickPlayer)) return;
+
+ clickPlayer.closeInventory();
+ clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
+ new TreeTypeMenu(clickPlayer, true);
+ }));
+
+ // Set click event for field item
+ getMenu().getSlot(FIELD_ITEM_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
+ if (clickInformation.getClickType().equals(ClickType.RIGHT)) {
+ sendMoreInformation(clickPlayer, GeneratorType.FIELD);
+ return;
+ }
+ sendMoreInformation(clickPlayer, GeneratorType.FIELD);
+
+ /*Field field = GeneratorModule.getInstance().getField();
+ field.getPlayerSettings().put(clickPlayer.getUniqueId(), new FieldSettings(clickPlayer));
+
+ if(!field.checkForPlayer(clickPlayer))
+ return;
+
+ clickPlayer.closeInventory();
+ clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
+ new CropTypeMenu(clickPlayer, true);*/
+ }));
+ }
+
+ private void sendMoreInformation(@NonNull Player clickPlayer, @NonNull GeneratorType generator) {
+ clickPlayer.sendMessage(Component.text(generator.getWikiPage(), NamedTextColor.RED));
+ }
+
+ @Override
+ protected Mask getMask() {
+ return BinaryMask.builder(getMenu()).item(MenuItems.ITEM_BACKGROUND).pattern("111111111").pattern("010101010").pattern("111111111").build();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/buildtheearth/modules/generator/model/Command.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Command.java
similarity index 93%
rename from src/main/java/net/buildtheearth/modules/generator/model/Command.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Command.java
index ef91b560..4ac228fd 100644
--- a/src/main/java/net/buildtheearth/modules/generator/model/Command.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Command.java
@@ -1,5 +1,7 @@
-package net.buildtheearth.modules.generator.model;
+package net.buildtheearth.buildteamtools.modules.generator.model;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.GeneratorUtils;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.regions.Region;
@@ -9,10 +11,8 @@
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import lombok.Getter;
-import net.buildtheearth.modules.common.CommonModule;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.MenuItems;
+import net.buildtheearth.buildteamtools.modules.common.CommonModule;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -235,8 +235,14 @@ public void processOperation(Operation operation){
if(future != null){
threadActive = true;
- future.thenRun(() -> {
+ // Ensure we clear threadActive and remove the operation regardless of success or exception
+ future.whenComplete((v, ex) -> {
threadActive = false;
+ if (ex != null) {
+ ChatHelper.logError("Async operation failed: " + operation.getOperationType() + " - " + operation.getValuesAsString());
+ ex.printStackTrace();
+ }
+ // Remove the processed operation from the queue
operations.remove(0);
});
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Flag.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Flag.java
new file mode 100644
index 00000000..c95f7177
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Flag.java
@@ -0,0 +1,26 @@
+package net.buildtheearth.buildteamtools.modules.generator.model;
+
+import net.buildtheearth.buildteamtools.modules.generator.components.field.FieldFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.rail.RailFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadFlag;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeFlag;
+import org.jspecify.annotations.NonNull;
+
+public interface Flag {
+
+ String getFlag();
+
+ FlagType getFlagType();
+
+ /** @return the flag by the given string and generator type */
+ static Flag byString(@NonNull GeneratorType generatorType, String flag) {
+ return switch (generatorType) {
+ case HOUSE -> HouseFlag.byString(flag);
+ case ROAD -> RoadFlag.byString(flag);
+ case TREE -> TreeFlag.byString(flag);
+ case RAILWAY -> RailFlag.byString(flag);
+ case FIELD -> FieldFlag.byString(flag);
+ };
+ }
+}
diff --git a/src/main/java/net/buildtheearth/modules/generator/model/FlagType.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/FlagType.java
similarity index 80%
rename from src/main/java/net/buildtheearth/modules/generator/model/FlagType.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/FlagType.java
index b7b5d18e..ed9dc8dd 100644
--- a/src/main/java/net/buildtheearth/modules/generator/model/FlagType.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/FlagType.java
@@ -1,14 +1,14 @@
-package net.buildtheearth.modules.generator.model;
+package net.buildtheearth.buildteamtools.modules.generator.model;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
import lombok.Getter;
-import net.buildtheearth.modules.generator.components.field.CropStage;
-import net.buildtheearth.modules.generator.components.field.CropType;
-import net.buildtheearth.modules.generator.components.house.RoofType;
-import net.buildtheearth.modules.generator.components.tree.TreeType;
-import net.buildtheearth.modules.generator.components.tree.TreeWidth;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.Item;
+import net.buildtheearth.buildteamtools.modules.generator.components.field.CropStage;
+import net.buildtheearth.buildteamtools.modules.generator.components.field.CropType;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.RoofType;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeType;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeWidth;
public enum FlagType {
@@ -86,9 +86,9 @@ public static Object convertToFlagType(Flag flag, String value){
case CROP_STAGE:
return CropStage.getByIdentifier(value);
case TREE_TYPE:
- return TreeType.valueOf(value);
+ return TreeType.byString(value);
case TREE_WIDTH:
- return TreeWidth.valueOf(value);
+ return TreeWidth.byString(value);
}
return null;
}
diff --git a/src/main/java/net/buildtheearth/modules/generator/model/GeneratorCollections.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/GeneratorCollections.java
similarity index 68%
rename from src/main/java/net/buildtheearth/modules/generator/model/GeneratorCollections.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/GeneratorCollections.java
index 8628c8d2..fb9c3924 100644
--- a/src/main/java/net/buildtheearth/modules/generator/model/GeneratorCollections.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/GeneratorCollections.java
@@ -1,37 +1,41 @@
-package net.buildtheearth.modules.generator.model;
+package net.buildtheearth.buildteamtools.modules.generator.model;
+import com.alpsbte.alpslib.utils.ChatHelper;
import com.fastasyncworldedit.core.FaweAPI;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.common.CommonModule;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.utils.ChatHelper;
+import lombok.experimental.UtilityClass;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.common.CommonModule;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
+import org.codehaus.plexus.util.FileUtils;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.json.JSONArray;
import org.json.JSONObject;
+import org.jspecify.annotations.NonNull;
-import javax.annotation.Nullable;
import java.io.*;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
+import java.net.URI;
import java.net.URL;
import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
import java.util.logging.Level;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+@UtilityClass
public class GeneratorCollections {
- public static String GENERATOR_COLLECTIONS_VERSION;
-
+ public static String generatorCollectionsVersion;
/**
* Checks if the GeneratorCollections is installed and sends the player a message if it isn't.
@@ -39,7 +43,7 @@ public class GeneratorCollections {
* @param p The player to check for. If null, the console will be used instead.
* @return Whether the Generator Collections package is installed
*/
- public static boolean checkIfGeneratorCollectionsIsInstalled(@Nullable Player p){
+ public static boolean hasUpdatedGeneratorCollections(@Nullable Player p) {
// Load the schematic file
try {
String folder;
@@ -78,7 +82,7 @@ else if(CommonModule.getInstance().getDependencyComponent().isWorldEditEnabled()
if(p != null)
bukkitWorld = new BukkitWorld(p.getWorld());
else
- bukkitWorld = new BukkitWorld(Bukkit.getWorlds().get(0));
+ bukkitWorld = new BukkitWorld(Bukkit.getWorlds().getFirst());
if (reader != null){
Class> readerClass = reader.getClass();
@@ -114,7 +118,7 @@ else if(CommonModule.getInstance().getDependencyComponent().isWorldEditEnabled()
return checkIfGeneratorCollectionsIsUpToDate(p);
} catch (Exception e) {
- e.printStackTrace();
+ BuildTeamTools.getInstance().getComponentLogger().warn("Failed to check if Generator Collections is installed:", e);
return installGeneratorCollections(p, true);
}
}
@@ -126,11 +130,11 @@ else if(CommonModule.getInstance().getDependencyComponent().isWorldEditEnabled()
* @param repo The name of the repository
* @return The latest release version of the repository
*/
- public static String getRepositoryReleaseVersionString(String owner, String repo){
+ public static @Nullable String getRepositoryReleaseVersionString(String owner, String repo) {
try {
String url = "https://api.github.com/repos/" + owner + "/" + repo + "/releases";
- HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
+ HttpURLConnection con = (HttpURLConnection) URI.create(url).toURL().openConnection();
con.setRequestProperty("User-Agent", "Mozilla/5.0");
con.setRequestMethod("GET");
@@ -147,7 +151,7 @@ public static String getRepositoryReleaseVersionString(String owner, String repo
in.close();
JSONArray releases = new JSONArray(response.toString());
- if (releases.length() > 0) {
+ if (!releases.isEmpty()) {
JSONObject latestRelease = releases.getJSONObject(0); // The first object in the array is the latest release
return latestRelease.getString("tag_name").replace("v", "");
@@ -156,7 +160,7 @@ public static String getRepositoryReleaseVersionString(String owner, String repo
} else
return null;
} catch (Exception e) {
- e.printStackTrace();
+ BuildTeamTools.getInstance().getComponentLogger().warn("Failed to get latest release version of repository {}/{}:", owner, repo, e);
return null;
}
}
@@ -168,13 +172,17 @@ public static String getRepositoryReleaseVersionString(String owner, String repo
*
* @param filename The name of the zip folder to install. Example: "newtrees.zip"
* @param path The path to extract the zip folder to. Parent Folder is the plugin folder. Example: "/../WorldEdit/schematics/"
+ * @param extractionFolder The path where the downloaded zip file is temporarily saved
*/
- private static boolean installZipFolder(String parentURL, String filename, String path) throws IOException {
- path = BuildTeamTools.getInstance().getDataFolder().getAbsolutePath() + path;
- String zipFilePath = path + "/" + filename;
- URL url = new URL(parentURL + filename);
+ private static boolean installZipFolder(String parentURL, String filename, Path path, @NonNull Path extractionFolder) throws IOException {
+ if (!extractionFolder.toFile().exists() && !extractionFolder.toFile().mkdirs()) {
+ throw new IOException("Failed to create generator module folder: " + extractionFolder);
+ }
+
+ var zipFilePath = extractionFolder.resolve(filename);
+ URL url = URI.create(parentURL + filename).toURL();
- File file = new File(path);
+ File file = path.toFile();
if(!file.exists()) {
boolean created = file.mkdir();
@@ -192,7 +200,7 @@ private static boolean installZipFolder(String parentURL, String filename, Strin
// Save the zip file to the path
try (BufferedInputStream in = new BufferedInputStream(httpConn.getInputStream());
- FileOutputStream out = new FileOutputStream(path + "/" + filename)) {
+ FileOutputStream out = new FileOutputStream(zipFilePath.toFile())) {
byte[] buffer = new byte[4096];
int bytesRead;
@@ -200,7 +208,7 @@ private static boolean installZipFolder(String parentURL, String filename, Strin
out.write(buffer, 0, bytesRead);
}
}catch (Exception e){
- e.printStackTrace();
+ BuildTeamTools.getInstance().getComponentLogger().warn("Failed to download zip file from {}:", url, e);
return false;
}
} else {
@@ -215,33 +223,30 @@ private static boolean installZipFolder(String parentURL, String filename, Strin
/** Extracts a zip folder on the system
*
- * @param zipFilePath The path to the zip folder. Example: "/../WorldEdit/schematics/newtrees.zip"
+ * @param zipFilePath The path to the zip folder. Example: "/../BuildTeamTols/modules/generator/GeneratorCollections.zip"
* @param destDirectory The path to extract the zip folder to. Parent Folder is the plugin folder. Example: "/../WorldEdit/schematics/"
*/
- private static boolean unzip(String zipFilePath, String destDirectory) {
- File destDir = new File(destDirectory);
+ private static boolean unzip(Path zipFilePath, @NonNull Path destDirectory) {
+ File destDir = destDirectory.toFile();
if (!destDir.exists()) {
boolean success = destDir.mkdir();
if(!success)
return false;
}
- try (ZipInputStream zipIn = new ZipInputStream(Files.newInputStream(Paths.get(zipFilePath)))) {
+ try (ZipInputStream zipIn = new ZipInputStream(Files.newInputStream(zipFilePath))) {
ZipEntry entry = zipIn.getNextEntry();
while (entry != null) {
- String filePath = destDirectory + File.separator + entry.getName();
+ var filePath = destDirectory.resolve(entry.getName());
if (!entry.isDirectory()) {
- File file = new File(filePath);
- File parentDir = file.getParentFile();
- if (!parentDir.exists()) {
- if (!parentDir.mkdirs()) {
+ File parentDir = filePath.getParent().toFile();
+ if (!parentDir.exists() && !parentDir.mkdirs()) {
throw new IOException("Failed to create parent directories for: " + filePath);
}
- }
- try (BufferedOutputStream bos = new BufferedOutputStream(Files.newOutputStream(Paths.get(filePath)))) {
+ try (BufferedOutputStream bos = new BufferedOutputStream(Files.newOutputStream(filePath))) {
byte[] bytesIn = new byte[4096];
int read;
while ((read = zipIn.read(bytesIn)) != -1) {
@@ -249,8 +254,7 @@ private static boolean unzip(String zipFilePath, String destDirectory) {
}
}
} else {
- File dir = new File(filePath);
- boolean success = dir.mkdirs();
+ boolean success = filePath.toFile().mkdirs();
if(!success)
return false;
@@ -259,10 +263,9 @@ private static boolean unzip(String zipFilePath, String destDirectory) {
entry = zipIn.getNextEntry();
}
- // Delete the old zip file
- deleteFile(zipFilePath);
+ deleteFile(zipFilePath); // Delete the old zip file
}catch (Exception e){
- e.printStackTrace();
+ BuildTeamTools.getInstance().getComponentLogger().warn("Failed to unzip zip file:", e);
return false;
}
@@ -272,23 +275,13 @@ private static boolean unzip(String zipFilePath, String destDirectory) {
/** Deletes a directory from the system
*
* @param path The path to the directory to delete
- * @return Whether the directory was deleted successfully
*/
- private static boolean deleteDirectory(String path) {
- File dir = new File(path);
-
- if (dir.isDirectory()) {
- String[] children = dir.list();
-
- if (children != null)
- for (String child : children) {
- boolean success = deleteDirectory(new File(dir, child).getAbsolutePath());
- if (!success) {
- return false; // Return false if deletion is unsuccessful
- }
- }
+ private static void deleteDirectory(@NonNull Path path) {
+ try {
+ FileUtils.deleteDirectory(path.toFile());
+ } catch (IOException e) {
+ BuildTeamTools.getInstance().getComponentLogger().warn("Failed to delete directory: {}", path);
}
- return dir.delete(); // Return true if directory is deleted successfully
}
/**
@@ -296,11 +289,12 @@ private static boolean deleteDirectory(String path) {
*
* @param path The path to the file to delete
*/
- private static void deleteFile(String path) {
- File file = new File(path);
- boolean success = file.delete();
- if(!success)
- System.out.println("Failed to delete file: " + path);
+ private static void deleteFile(@NonNull Path path) {
+ try {
+ Files.delete(path);
+ } catch (IOException e) {
+ BuildTeamTools.getInstance().getComponentLogger().warn("Failed to delete file: {}", path, e);
+ }
}
/**
@@ -312,23 +306,15 @@ private static void deleteFile(String path) {
private static boolean checkIfGeneratorCollectionsIsUpToDate(Player p){
// Load the schematic file
try {
- String folder;
- if(CommonModule.getInstance().getDependencyComponent().isFastAsyncWorldEditEnabled())
- folder = "/../FastAsyncWorldEdit/schematics/";
- else if(CommonModule.getInstance().getDependencyComponent().isWorldEditEnabled())
- folder = "/../WorldEdit/schematics/";
- else
- return false;
-
- String filepath = "GeneratorCollections/";
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(new File(BuildTeamTools.getInstance().getDataFolder().getAbsolutePath() + folder + filepath, "config.yml"));
+ var cfgFile = BuildTeamTools.getInstance().getDataFolder().toPath().resolve("modules").resolve("generator").resolve("generatorCollectionsVersion.yml");
+ FileConfiguration cfg = YamlConfiguration.loadConfiguration(cfgFile.toFile());
if(!cfg.contains("version"))
return installGeneratorCollections(p, true);
String oldVersion = cfg.getString("version");
- if(!CommonModule.getInstance().getUpdaterComponent().shouldUpdate(GENERATOR_COLLECTIONS_VERSION, oldVersion))
+ if (!CommonModule.getInstance().getUpdaterComponent().shouldUpdate(generatorCollectionsVersion, oldVersion))
return true;
else
return installGeneratorCollections(p, true);
@@ -341,16 +327,12 @@ else if(CommonModule.getInstance().getDependencyComponent().isWorldEditEnabled()
/**
* Sends the player and console a message with more information about the generator collections package in case it isn't installed.
*
- * @see #checkIfGeneratorCollectionsIsInstalled(Player)
+ * @see #hasUpdatedGeneratorCollections(Player)
*
* @param p The player to send the message to
*/
private static void sendGeneratorCollectionsError(@Nullable Player p){
- ChatHelper.logPlayerAndConsole(p, "§cAn error occurred while installing the Generator Collections.", Level.INFO);
- ChatHelper.logPlayerAndConsole(p, "§cPlease install the Generator Collections v" + GENERATOR_COLLECTIONS_VERSION + " to use this tool. You can ask the server administrator to install it.", Level.INFO);
- ChatHelper.logPlayerAndConsole(p, " ", Level.INFO);
- ChatHelper.logPlayerAndConsole(p, "§cFor more installation help, please see the wiki:", Level.INFO);
- ChatHelper.logPlayerAndConsole(p, "§c" + GeneratorModule.INSTALL_WIKI, Level.INFO);
+ ChatHelper.logPlayerAndConsole(p, "§cAn error occurred while installing the Generator Collections. Please report that with the log!", Level.INFO);
}
@@ -365,28 +347,28 @@ private static boolean installGeneratorCollections(@Nullable Player p, boolean u
String filename = "GeneratorCollections.zip";
String fileDirectory = "GeneratorCollections/";
- String path;
+ var path = Bukkit.getPluginsFolder().toPath();
if(CommonModule.getInstance().getDependencyComponent().isFastAsyncWorldEditEnabled())
- path = "/../FastAsyncWorldEdit/schematics/";
+ path = path.resolve("FastAsyncWorldEdit").resolve("schematics");
else if(CommonModule.getInstance().getDependencyComponent().isWorldEditEnabled())
- path = "/../WorldEdit/schematics/";
+ path = path.resolve("WorldEdit").resolve("schematics");
else
return false;
if(update) {
ChatHelper.logPlayerAndConsole(p, "§cThe Generator Collections package is outdated. Updating...", Level.INFO);
-
- deleteDirectory(BuildTeamTools.getInstance().getDataFolder().getAbsolutePath() + path + fileDirectory);
+ deleteDirectory(path.resolve(fileDirectory));
} else
ChatHelper.logPlayerAndConsole(p, "§cThe Generator Collections package wasn't found on your server. Installing...", Level.INFO);
-
-
+ var generatorModulePath = BuildTeamTools.getInstance().getDataFolder().toPath().resolve("modules").resolve("generator");
try {
- boolean success = installZipFolder(parentURL, filename, path);
+ boolean success = installZipFolder(parentURL, filename, path, generatorModulePath);
+ if (success)
+ success = moveVersionFile(generatorModulePath, path.resolve("GeneratorCollections"), "config.yml", "generatorCollectionsVersion.yml");
if(success) {
- ChatHelper.logPlayerAndConsole(p, "§7Successfully installed §eGenerator Collections v" + GENERATOR_COLLECTIONS_VERSION + "§7!", Level.INFO);
+ ChatHelper.logPlayerAndConsole(p, "§7Successfully installed §eGenerator Collections v" + generatorCollectionsVersion + "§7!", Level.INFO);
return true;
}else {
@@ -400,4 +382,32 @@ else if(CommonModule.getInstance().getDependencyComponent().isWorldEditEnabled()
}
}
+ /**
+ * Moves a file from the old directory to the new directory
+ *
+ * @param newDir The new directory to move the file to
+ * @param oldDir The old directory to move the file from
+ * @param oldFileName The name of the file to move
+ * @param newFileName The new name of the file
+ * @return Whether the move was successful
+ */
+ private static boolean moveVersionFile(@NotNull Path newDir, @NotNull Path oldDir, String oldFileName, String newFileName) {
+ Path source = oldDir.resolve(oldFileName);
+ Path target = newDir.resolve(newFileName);
+
+ try {
+ // Ensure target parent exists
+ Files.createDirectories(target.getParent());
+
+ // Move with replace to avoid failure if target exists
+ Files.move(source, target, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
+
+ return true;
+ } catch (IOException e) {
+ BuildTeamTools.getInstance().getComponentLogger()
+ .warn("Failed to move '{}' to '{}': {}", source, target, e.toString());
+ return false;
+ }
+ }
+
}
diff --git a/src/main/java/net/buildtheearth/modules/generator/model/GeneratorComponent.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/GeneratorComponent.java
similarity index 70%
rename from src/main/java/net/buildtheearth/modules/generator/model/GeneratorComponent.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/GeneratorComponent.java
index d40ee6f4..67f41622 100644
--- a/src/main/java/net/buildtheearth/modules/generator/model/GeneratorComponent.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/GeneratorComponent.java
@@ -1,14 +1,15 @@
-package net.buildtheearth.modules.generator.model;
+package net.buildtheearth.buildteamtools.modules.generator.model;
+import com.alpsbte.alpslib.utils.GeneratorUtils;
+import com.alpsbte.alpslib.utils.WikiDocumented;
import lombok.Getter;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.ModuleComponent;
-import net.buildtheearth.modules.generator.components.field.FieldSettings;
-import net.buildtheearth.modules.generator.components.house.HouseSettings;
-import net.buildtheearth.modules.generator.components.rail.RailSettings;
-import net.buildtheearth.modules.generator.components.road.RoadSettings;
-import net.buildtheearth.modules.generator.components.tree.TreeSettings;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.ModuleComponent;
+import net.buildtheearth.buildteamtools.modules.generator.components.field.FieldSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.HouseSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.rail.RailSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.road.RoadSettings;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeSettings;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
@@ -18,22 +19,19 @@
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
+import org.jspecify.annotations.NonNull;
import java.util.HashMap;
import java.util.UUID;
-public abstract class GeneratorComponent extends ModuleComponent {
-
-
- public String wikiPage;
-
+public abstract class GeneratorComponent extends ModuleComponent implements WikiDocumented {
@Getter
private final GeneratorType generatorType;
@Getter
private final HashMap playerSettings = new HashMap<>();
- public GeneratorComponent(GeneratorType type) {
+ protected GeneratorComponent(@NonNull GeneratorType type) {
super(type.getName());
generatorType = type;
}
@@ -74,50 +72,40 @@ public void addPlayerSetting(Player p){
}
}
- public void sendHelp(Player p, String[] args){
- if (args.length == 2)
- if (args[1].equals("info") || args[1].equals("help") || args[1].equals("?"))
+ public void sendHelp(Player p, String @NonNull [] args) {
+ if (args.length == 2 && (args[1].equals("info") || args[1].equals("help") || args[1].equals("?")))
sendHelp(p);
}
- public void sendHelp(Player p){
- //TODO send houses help
- p.sendMessage("TODO send Houses Help");
+ public void sendHelp(@NonNull Player p) {
+ p.sendMessage(Component.text(getWikiPage(), NamedTextColor.YELLOW));
}
public void sendMoreInfo(Player p) {
p.sendMessage(" ");
p.sendMessage("§cFor more information take a look at the wiki:");
- p.sendMessage("§c" + wikiPage);
+ p.sendMessage("§c" + getWikiPage());
}
public void sendError(Player p) {
p.sendMessage("§cThere was an error while generating the house. Please contact the admins");
}
- public String getCommand(Player p) {
+ public String getCommand(@NonNull Player p) {
HashMap flags = getPlayerSettings().get(p.getUniqueId()).getValuesAsString();
- String type = "house";
-
- switch (generatorType) {
- case HOUSE:
- type = "house";
- break;
- case ROAD:
- type = "road";
- break;
- case RAILWAY:
- type = "railway";
- break;
- case TREE:
- type = "tree";
- break;
- }
+ String type = switch (generatorType) {
+ case HOUSE -> "house";
+ case ROAD -> "road";
+ case RAILWAY -> "railway";
+ case TREE -> "tree";
+ case FIELD -> "field";
+ };
StringBuilder command = new StringBuilder("/gen " + type);
- for(Flag flag : flags.keySet())
- command.append(" -").append(flag.getFlag()).append(" ").append(flags.get(flag));
+
+ for (var flag : flags.entrySet())
+ command.append(" -").append(flag.getKey().getFlag()).append(" ").append(flag.getValue());
return command.toString();
}
@@ -137,23 +125,14 @@ public void sendSuccessMessage(Player p){
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
}
- private TextComponent getMessage() {
- String type = "Building";
-
- switch (generatorType){
- case HOUSE:
- type = "House";
- break;
- case ROAD:
- type = "Road";
- break;
- case RAILWAY:
- type = "Railway";
- break;
- case TREE:
- type = "Tree";
- break;
- }
+ private @NonNull TextComponent getMessage() {
+ String type = switch (generatorType) {
+ case HOUSE -> "House";
+ case ROAD -> "Road";
+ case RAILWAY -> "Railway";
+ case TREE -> "Tree";
+ case FIELD -> "Field";
+ };
return LegacyComponentSerializer.legacyAmpersand().deserialize(BuildTeamTools.PREFIX + type + "§a successfully §7generated.");
}
@@ -194,4 +173,8 @@ protected void convertArgsToSettings(Player p, String[] args){
if(getPlayerSettings().get(p.getUniqueId()).getValues().isEmpty() && args.length > 1)
sendHelp(p);
}
+
+ public String getWikiPage() {
+ return generatorType.getWikiPage();
+ }
}
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/GeneratorType.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/GeneratorType.java
new file mode 100644
index 00000000..53b53551
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/GeneratorType.java
@@ -0,0 +1,25 @@
+package net.buildtheearth.buildteamtools.modules.generator.model;
+
+import lombok.Getter;
+import net.buildtheearth.buildteamtools.utils.WikiLinks;
+
+public enum GeneratorType {
+
+ HOUSE("House", WikiLinks.Gen.HOUSE),
+ ROAD("Road", WikiLinks.Gen.ROAD),
+ RAILWAY("Railway", WikiLinks.Gen.RAIL),
+ TREE("Tree", WikiLinks.Gen.TREE),
+ FIELD("Field", WikiLinks.Gen.FIELD);
+
+ @Getter
+ private final String name;
+
+ @Getter
+ private final String wikiPage;
+
+ GeneratorType(String name, String wikiPage) {
+ this.name = name;
+ this.wikiPage = wikiPage;
+ }
+
+}
diff --git a/src/main/java/net/buildtheearth/modules/generator/model/History.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/History.java
similarity index 94%
rename from src/main/java/net/buildtheearth/modules/generator/model/History.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/History.java
index c88f9101..02e8473f 100644
--- a/src/main/java/net/buildtheearth/modules/generator/model/History.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/History.java
@@ -1,17 +1,16 @@
-package net.buildtheearth.modules.generator.model;
+package net.buildtheearth.buildteamtools.modules.generator.model;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.GeneratorUtils;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.extension.platform.Actor;
import lombok.Getter;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
-import net.buildtheearth.utils.ChatHelper;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
-import org.bukkit.NamespacedKey;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
diff --git a/src/main/java/net/buildtheearth/modules/generator/model/Operation.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Operation.java
similarity index 98%
rename from src/main/java/net/buildtheearth/modules/generator/model/Operation.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Operation.java
index 6fdddc1d..0d230139 100644
--- a/src/main/java/net/buildtheearth/modules/generator/model/Operation.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Operation.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.generator.model;
+package net.buildtheearth.buildteamtools.modules.generator.model;
import com.sk89q.worldedit.world.block.BlockState;
import lombok.Getter;
diff --git a/src/main/java/net/buildtheearth/modules/generator/model/Script.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Script.java
similarity index 99%
rename from src/main/java/net/buildtheearth/modules/generator/model/Script.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Script.java
index 3af5cf03..0a5dc7a0 100644
--- a/src/main/java/net/buildtheearth/modules/generator/model/Script.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Script.java
@@ -1,5 +1,6 @@
-package net.buildtheearth.modules.generator.model;
+package net.buildtheearth.buildteamtools.modules.generator.model;
+import com.alpsbte.alpslib.utils.GeneratorUtils;
import com.cryptomorin.xseries.XMaterial;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.LocalSession;
@@ -12,8 +13,7 @@
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import lombok.Getter;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
+import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -54,7 +54,6 @@ public Script(Player player, GeneratorComponent generatorComponent) {
GeneratorUtils.setGmask(localSession, null);
}
-
protected void finish(Block[][][] blocks, List points){
createSelection(points);
//setGmask(null);
diff --git a/src/main/java/net/buildtheearth/modules/generator/model/Settings.java b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Settings.java
similarity index 86%
rename from src/main/java/net/buildtheearth/modules/generator/model/Settings.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Settings.java
index 1fb58aaa..7bed4c57 100644
--- a/src/main/java/net/buildtheearth/modules/generator/model/Settings.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/generator/model/Settings.java
@@ -1,14 +1,13 @@
-package net.buildtheearth.modules.generator.model;
+package net.buildtheearth.buildteamtools.modules.generator.model;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
import lombok.Getter;
import lombok.Setter;
-import net.buildtheearth.modules.generator.components.field.CropStage;
-import net.buildtheearth.modules.generator.components.field.CropType;
-import net.buildtheearth.modules.generator.components.house.RoofType;
-import net.buildtheearth.modules.generator.components.tree.TreeWidth;
-import net.buildtheearth.utils.Item;
-import org.bukkit.TreeType;
+import net.buildtheearth.buildteamtools.modules.generator.components.field.CropStage;
+import net.buildtheearth.buildteamtools.modules.generator.components.field.CropType;
+import net.buildtheearth.buildteamtools.modules.generator.components.house.RoofType;
+import net.buildtheearth.buildteamtools.modules.generator.components.tree.TreeWidth;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/MiscModule.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/MiscModule.java
similarity index 73%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/MiscModule.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/MiscModule.java
index a2af3b9a..c24b9136 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/MiscModule.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/MiscModule.java
@@ -1,13 +1,15 @@
-package net.buildtheearth.modules.miscellaneous;
+package net.buildtheearth.buildteamtools.modules.miscellaneous;
-import net.buildtheearth.modules.Module;
-import net.buildtheearth.modules.miscellaneous.blockpalettegui.BlockPaletteGUI;
-import net.buildtheearth.modules.miscellaneous.blockpalettegui.BlockPaletteManager;
-import net.buildtheearth.modules.miscellaneous.blockpalettegui.BlockPaletteCommand;
+import net.buildtheearth.buildteamtools.modules.Module;
+import net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui.BlockPaletteCommand;
+import net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui.BlockPaletteGUI;
+import net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui.BlockPaletteManager;
+import net.buildtheearth.buildteamtools.utils.WikiLinks;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.plugin.java.JavaPlugin;
+import org.jspecify.annotations.NonNull;
import java.lang.reflect.Constructor;
@@ -17,7 +19,7 @@ public class MiscModule extends Module {
private static MiscModule instance = null;
public MiscModule() {
- super("Misc");
+ super("Misc", WikiLinks.MISC);
}
public static MiscModule getInstance() {
@@ -50,17 +52,18 @@ public void disable() {
@Override
public void registerListeners() {
+ // No Listeners
}
- private JavaPlugin resolvePlugin() {
+ private @NonNull JavaPlugin resolvePlugin() {
try {
return JavaPlugin.getProvidingPlugin(MiscModule.class);
- } catch (Throwable t) {
+ } catch (Exception t) {
throw new IllegalStateException("Cannot resolve JavaPlugin for MiscModule", t);
}
}
- private void registerCommandSafely(JavaPlugin plugin, String name, BlockPaletteManager manager) {
+ private void registerCommandSafely(@NonNull JavaPlugin plugin, String name, BlockPaletteManager manager) {
PluginCommand cmd = plugin.getCommand(name);
if (cmd == null) {
return;
@@ -71,7 +74,7 @@ private void registerCommandSafely(JavaPlugin plugin, String name, BlockPaletteM
if (obj instanceof TabCompleter tab) cmd.setTabCompleter(tab);
}
- private Object createCommandInstance(BlockPaletteManager manager, JavaPlugin plugin) {
+ private @NonNull Object createCommandInstance(BlockPaletteManager manager, JavaPlugin plugin) {
try {
Class> c = BlockPaletteCommand.class;
Constructor> k;
@@ -92,7 +95,7 @@ private Object createCommandInstance(BlockPaletteManager manager, JavaPlugin plu
} catch (NoSuchMethodException ignored) {}
return c.getDeclaredConstructor().newInstance();
- } catch (Throwable t) {
+ } catch (Exception t) {
throw new RuntimeException("Cannot construct BlockPaletteCommand", t);
}
}
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteCommand.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteCommand.java
similarity index 97%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteCommand.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteCommand.java
index b8b9632a..b94edbc6 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteCommand.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteCommand.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.miscellaneous.blockpalettegui;
+package net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteGUI.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteGUI.java
similarity index 83%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteGUI.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteGUI.java
index 5236b432..305eae06 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteGUI.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteGUI.java
@@ -1,6 +1,6 @@
-package net.buildtheearth.modules.miscellaneous.blockpalettegui;
+package net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui;
-import net.buildtheearth.modules.ModuleComponent;
+import net.buildtheearth.buildteamtools.modules.ModuleComponent;
import org.bukkit.plugin.java.JavaPlugin;
public class BlockPaletteGUI extends ModuleComponent {
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteManager.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteManager.java
similarity index 99%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteManager.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteManager.java
index 0ce4e00c..8633a183 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteManager.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteManager.java
@@ -1,15 +1,15 @@
-package net.buildtheearth.modules.miscellaneous.blockpalettegui;
+package net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui;
import com.cryptomorin.xseries.XMaterial;
+import lombok.Getter;
+import lombok.Setter;
import org.bukkit.Material;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-import lombok.Getter;
-import lombok.Setter;
import java.io.File;
import java.io.IOException;
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteMenuType.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteMenuType.java
similarity index 92%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteMenuType.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteMenuType.java
index d799338d..a84281b6 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/BlockPaletteMenuType.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/BlockPaletteMenuType.java
@@ -1,14 +1,10 @@
-package net.buildtheearth.modules.miscellaneous.blockpalettegui;
+package net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui;
-import net.buildtheearth.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
import org.bukkit.inventory.ItemStack;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
import java.util.function.Supplier;
-import java.util.List;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.stream.Collectors;
public enum BlockPaletteMenuType {
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/ChoosePaletteBlocksMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/ChoosePaletteBlocksMenu.java
similarity index 98%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/ChoosePaletteBlocksMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/ChoosePaletteBlocksMenu.java
index 4d5e92ec..0ebc9542 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/ChoosePaletteBlocksMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/ChoosePaletteBlocksMenu.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.modules.miscellaneous.blockpalettegui;
+package net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.menus.AbstractPaginatedMenu;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractPaginatedMenu;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
@@ -11,10 +11,10 @@
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.plugin.java.JavaPlugin;
import org.ipvp.canvas.Menu;
import org.ipvp.canvas.mask.BinaryMask;
import org.ipvp.canvas.mask.Mask;
-import org.bukkit.plugin.java.JavaPlugin;
import java.util.*;
import java.util.function.Consumer;
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/ChoosePaletteMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/ChoosePaletteMenu.java
similarity index 98%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/ChoosePaletteMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/ChoosePaletteMenu.java
index b1448091..9026673d 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/ChoosePaletteMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/ChoosePaletteMenu.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.modules.miscellaneous.blockpalettegui;
+package net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/CreatePaletteMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/CreatePaletteMenu.java
similarity index 98%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/CreatePaletteMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/CreatePaletteMenu.java
index f27ef7d7..64a2ccbe 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/CreatePaletteMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/CreatePaletteMenu.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.modules.miscellaneous.blockpalettegui;
+package net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/EditPaletteMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/EditPaletteMenu.java
similarity index 98%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/EditPaletteMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/EditPaletteMenu.java
index d43dfc80..5fd56f0e 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/EditPaletteMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/EditPaletteMenu.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.modules.miscellaneous.blockpalettegui;
+package net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/PaletteBlockListMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/PaletteBlockListMenu.java
similarity index 95%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/PaletteBlockListMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/PaletteBlockListMenu.java
index c03e3067..d66c4b75 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/blockpalettegui/PaletteBlockListMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/blockpalettegui/PaletteBlockListMenu.java
@@ -1,9 +1,9 @@
-package net.buildtheearth.modules.miscellaneous.blockpalettegui;
+package net.buildtheearth.buildteamtools.modules.miscellaneous.blockpalettegui;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractPaginatedMenu;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractPaginatedMenu;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
diff --git a/src/main/java/net/buildtheearth/modules/miscellaneous/signtextgenerator/SignTextGenerator.java b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/signtextgenerator/SignTextGenerator.java
similarity index 72%
rename from src/main/java/net/buildtheearth/modules/miscellaneous/signtextgenerator/SignTextGenerator.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/signtextgenerator/SignTextGenerator.java
index e10cd54c..ee93e0b3 100644
--- a/src/main/java/net/buildtheearth/modules/miscellaneous/signtextgenerator/SignTextGenerator.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/miscellaneous/signtextgenerator/SignTextGenerator.java
@@ -1,6 +1,6 @@
-package net.buildtheearth.modules.miscellaneous.signtextgenerator;
+package net.buildtheearth.buildteamtools.modules.miscellaneous.signtextgenerator;
-import net.buildtheearth.modules.ModuleComponent;
+import net.buildtheearth.buildteamtools.modules.ModuleComponent;
public class SignTextGenerator extends ModuleComponent {
diff --git a/src/main/java/net/buildtheearth/modules/navigation/NavUtils.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/NavUtils.java
similarity index 90%
rename from src/main/java/net/buildtheearth/modules/navigation/NavUtils.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/NavUtils.java
index 03864890..83c575c8 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/NavUtils.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/NavUtils.java
@@ -1,13 +1,13 @@
-package net.buildtheearth.modules.navigation;
+package net.buildtheearth.buildteamtools.modules.navigation;
+import com.alpsbte.alpslib.utils.ChatHelper;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import lombok.experimental.UtilityClass;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.navigation.components.warps.model.WarpGroup;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.utils.ChatHelper;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@@ -113,8 +113,8 @@ public static void switchToTeam(BuildTeam team, Player clickPlayer) {
}
}
- public static @NotNull WarpGroup createOtherWarpGroup() {
+ public static @NotNull WarpGroup createOtherWarpGroup(BuildTeam team) {
// Create an "other" Warp Group for warps that don't belong to a warp group
- return new WarpGroup(NetworkModule.getInstance().getBuildTeam(), "Other", "Other warps", -1, null);
+ return new WarpGroup(team, "Other", "Other warps", -1, null);
}
}
diff --git a/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/NavigationModule.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/NavigationModule.java
new file mode 100644
index 00000000..d63c5e21
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/NavigationModule.java
@@ -0,0 +1,77 @@
+package net.buildtheearth.buildteamtools.modules.navigation;
+
+import lombok.Getter;
+import net.buildtheearth.buildteamtools.modules.Module;
+import net.buildtheearth.buildteamtools.modules.navigation.components.navigator.NavigatorComponent;
+import net.buildtheearth.buildteamtools.modules.navigation.components.navigator.commands.BuildteamCommand;
+import net.buildtheearth.buildteamtools.modules.navigation.components.navigator.commands.NavigatorCommand;
+import net.buildtheearth.buildteamtools.modules.navigation.components.navigator.listeners.NavigatorJoinListener;
+import net.buildtheearth.buildteamtools.modules.navigation.components.navigator.listeners.NavigatorOpenListener;
+import net.buildtheearth.buildteamtools.modules.navigation.components.tpll.TpllComponent;
+import net.buildtheearth.buildteamtools.modules.navigation.components.tpll.listeners.TpllJoinListener;
+import net.buildtheearth.buildteamtools.modules.navigation.components.tpll.listeners.TpllListener;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.WarpsComponent;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.commands.WarpCommand;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.commands.WarpsBtCommand;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.listeners.WarpJoinListener;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.utils.WikiLinks;
+
+/**
+ * Manages all things related to universal tpll
+ */
+public class NavigationModule extends Module {
+
+
+ @Getter
+ private WarpsComponent warpsComponent;
+ @Getter
+ private NavigatorComponent navigatorComponent;
+ @Getter
+ private TpllComponent tpllComponent;
+
+
+ private static NavigationModule instance = null;
+
+ public NavigationModule() {
+ super("Navigation", WikiLinks.NAV, NetworkModule.getInstance());
+ }
+
+ public static NavigationModule getInstance() {
+ return instance == null ? instance = new NavigationModule() : instance;
+ }
+
+
+ @Override
+ public void enable() {
+ if(NetworkModule.getInstance().getBuildTeam() == null) {
+ shutdown("The Network Module failed to load the Build Team.");
+ return;
+ }
+
+ warpsComponent = new WarpsComponent();
+ navigatorComponent = new NavigatorComponent();
+ tpllComponent = new TpllComponent();
+
+ super.enable();
+ }
+
+ @Override
+ public void registerCommands() {
+ registerCommand("warp", new WarpCommand());
+ registerCommand("navigator", new NavigatorCommand());
+ registerCommand("buildteam", new BuildteamCommand());
+ registerCommand("warpsbt", new WarpsBtCommand());
+ }
+
+ @Override
+ public void registerListeners() {
+ super.registerListeners(
+ new TpllJoinListener(),
+ new TpllListener(),
+ new WarpJoinListener(),
+ new NavigatorJoinListener(),
+ new NavigatorOpenListener()
+ );
+ }
+}
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/navigator/NavigatorComponent.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/NavigatorComponent.java
similarity index 84%
rename from src/main/java/net/buildtheearth/modules/navigation/components/navigator/NavigatorComponent.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/NavigatorComponent.java
index bc21d043..f65d0179 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/navigator/NavigatorComponent.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/NavigatorComponent.java
@@ -1,14 +1,14 @@
-package net.buildtheearth.modules.navigation.components.navigator;
+package net.buildtheearth.buildteamtools.modules.navigation.components.navigator;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
import com.sk89q.worldedit.WorldEdit;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.ModuleComponent;
-import net.buildtheearth.modules.common.CommonModule;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.io.ConfigPaths;
-import net.buildtheearth.utils.io.ConfigUtil;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.ModuleComponent;
+import net.buildtheearth.buildteamtools.modules.common.CommonModule;
+import net.buildtheearth.buildteamtools.utils.io.ConfigPaths;
+import net.buildtheearth.buildteamtools.utils.io.ConfigUtil;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/navigator/commands/BuildteamCommand.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/commands/BuildteamCommand.java
similarity index 85%
rename from src/main/java/net/buildtheearth/modules/navigation/components/navigator/commands/BuildteamCommand.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/commands/BuildteamCommand.java
index 3a4c1c46..6ec563e6 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/navigator/commands/BuildteamCommand.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/commands/BuildteamCommand.java
@@ -1,10 +1,10 @@
-package net.buildtheearth.modules.navigation.components.navigator.commands;
+package net.buildtheearth.buildteamtools.modules.navigation.components.navigator.commands;
-import net.buildtheearth.modules.navigation.NavUtils;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.modules.network.model.Permissions;
-import net.buildtheearth.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import net.buildtheearth.buildteamtools.modules.navigation.NavUtils;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
+import net.buildtheearth.buildteamtools.modules.network.model.Permissions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/navigator/commands/NavigatorCommand.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/commands/NavigatorCommand.java
similarity index 75%
rename from src/main/java/net/buildtheearth/modules/navigation/components/navigator/commands/NavigatorCommand.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/commands/NavigatorCommand.java
index b368777c..f1dbe38c 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/navigator/commands/NavigatorCommand.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/commands/NavigatorCommand.java
@@ -1,9 +1,9 @@
-package net.buildtheearth.modules.navigation.components.navigator.commands;
+package net.buildtheearth.buildteamtools.modules.navigation.components.navigator.commands;
-import net.buildtheearth.modules.navigation.menu.MainMenu;
-import net.buildtheearth.modules.navigation.NavigationModule;
-import net.buildtheearth.modules.network.model.Permissions;
-import net.buildtheearth.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import net.buildtheearth.buildteamtools.modules.navigation.NavigationModule;
+import net.buildtheearth.buildteamtools.modules.navigation.menu.MainMenu;
+import net.buildtheearth.buildteamtools.modules.network.model.Permissions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/navigator/listeners/NavigatorJoinListener.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/listeners/NavigatorJoinListener.java
similarity index 67%
rename from src/main/java/net/buildtheearth/modules/navigation/components/navigator/listeners/NavigatorJoinListener.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/listeners/NavigatorJoinListener.java
index 6638b371..5afda224 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/navigator/listeners/NavigatorJoinListener.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/listeners/NavigatorJoinListener.java
@@ -1,9 +1,9 @@
-package net.buildtheearth.modules.navigation.components.navigator.listeners;
+package net.buildtheearth.buildteamtools.modules.navigation.components.navigator.listeners;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.navigation.NavigationModule;
-import net.buildtheearth.utils.io.ConfigPaths;
-import net.buildtheearth.utils.io.ConfigUtil;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.navigation.NavigationModule;
+import net.buildtheearth.buildteamtools.utils.io.ConfigPaths;
+import net.buildtheearth.buildteamtools.utils.io.ConfigUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/navigator/listeners/NavigatorOpenListener.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/listeners/NavigatorOpenListener.java
similarity index 93%
rename from src/main/java/net/buildtheearth/modules/navigation/components/navigator/listeners/NavigatorOpenListener.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/listeners/NavigatorOpenListener.java
index 70880293..c564a8e6 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/navigator/listeners/NavigatorOpenListener.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/navigator/listeners/NavigatorOpenListener.java
@@ -1,7 +1,7 @@
-package net.buildtheearth.modules.navigation.components.navigator.listeners;
+package net.buildtheearth.buildteamtools.modules.navigation.components.navigator.listeners;
-import net.buildtheearth.modules.navigation.menu.MainMenu;
-import net.buildtheearth.modules.navigation.NavigationModule;
+import net.buildtheearth.buildteamtools.modules.navigation.NavigationModule;
+import net.buildtheearth.buildteamtools.modules.navigation.menu.MainMenu;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/tpll/TpllComponent.java
similarity index 90%
rename from src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/tpll/TpllComponent.java
index c49435c5..ddd1bac9 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/tpll/TpllComponent.java
@@ -1,14 +1,14 @@
-package net.buildtheearth.modules.navigation.components.tpll;
+package net.buildtheearth.buildteamtools.modules.navigation.components.tpll;
+import com.alpsbte.alpslib.utils.ChatHelper;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.ModuleComponent;
-import net.buildtheearth.modules.navigation.NavUtils;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.GeometricUtils;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.ModuleComponent;
+import net.buildtheearth.buildteamtools.modules.navigation.NavUtils;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.utils.GeometricUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
@@ -95,7 +95,8 @@ public void tpllPlayer(@NotNull Player player, double @NotNull [] coordinates, S
out.writeUTF("TPLL");
out.writeUTF(targetServerName);
out.writeUTF(player.getUniqueId().toString());
- out.writeUTF(String.valueOf(coordinates[0] + coordinates[1]));
+ out.writeUTF(String.valueOf(coordinates[0]));
+ out.writeUTF(String.valueOf(coordinates[1]));
player.sendPluginMessage(BuildTeamTools.getInstance(), "btt:buildteam", out.toByteArray());
// Switch the player to the target server
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/listeners/TpllJoinListener.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/tpll/listeners/TpllJoinListener.java
similarity index 76%
rename from src/main/java/net/buildtheearth/modules/navigation/components/tpll/listeners/TpllJoinListener.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/tpll/listeners/TpllJoinListener.java
index af8b28d5..8750abb3 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/listeners/TpllJoinListener.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/tpll/listeners/TpllJoinListener.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.modules.navigation.components.tpll.listeners;
+package net.buildtheearth.buildteamtools.modules.navigation.components.tpll.listeners;
-import net.buildtheearth.modules.navigation.NavigationModule;
-import net.buildtheearth.modules.navigation.components.tpll.TpllComponent;
-import net.buildtheearth.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import net.buildtheearth.buildteamtools.modules.navigation.NavigationModule;
+import net.buildtheearth.buildteamtools.modules.navigation.components.tpll.TpllComponent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/listeners/TpllListener.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/tpll/listeners/TpllListener.java
similarity index 89%
rename from src/main/java/net/buildtheearth/modules/navigation/components/tpll/listeners/TpllListener.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/tpll/listeners/TpllListener.java
index 0f4d0934..b3f967c5 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/listeners/TpllListener.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/tpll/listeners/TpllListener.java
@@ -1,13 +1,13 @@
-package net.buildtheearth.modules.navigation.components.tpll.listeners;
+package net.buildtheearth.buildteamtools.modules.navigation.components.tpll.listeners;
import com.alpsbte.alpslib.utils.AlpsUtils;
-import net.buildtheearth.modules.navigation.NavUtils;
-import net.buildtheearth.modules.navigation.NavigationModule;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.api.OpenStreetMapAPI;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.modules.network.model.Region;
-import net.buildtheearth.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import net.buildtheearth.buildteamtools.modules.navigation.NavUtils;
+import net.buildtheearth.buildteamtools.modules.navigation.NavigationModule;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.api.OpenStreetMapAPI;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
+import net.buildtheearth.buildteamtools.modules.network.model.Region;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/WarpsComponent.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/WarpsComponent.java
similarity index 87%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/WarpsComponent.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/WarpsComponent.java
index 0064ace7..43cc4da5 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/WarpsComponent.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/WarpsComponent.java
@@ -1,24 +1,24 @@
-package net.buildtheearth.modules.navigation.components.warps;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps;
+import com.alpsbte.alpslib.utils.ChatHelper;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.ModuleComponent;
-import net.buildtheearth.modules.navigation.NavUtils;
-import net.buildtheearth.modules.navigation.components.warps.menu.WarpEditMenu;
-import net.buildtheearth.modules.navigation.components.warps.menu.WarpGroupEditMenu;
-import net.buildtheearth.modules.navigation.components.warps.menu.WarpGroupMenu;
-import net.buildtheearth.modules.navigation.components.warps.menu.WarpMenu;
-import net.buildtheearth.modules.navigation.components.warps.model.Warp;
-import net.buildtheearth.modules.navigation.components.warps.model.WarpGroup;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.api.OpenStreetMapAPI;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.GeometricUtils;
-import net.buildtheearth.utils.geo.CoordinateConversion;
-import net.buildtheearth.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.ModuleComponent;
+import net.buildtheearth.buildteamtools.modules.navigation.NavUtils;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu.WarpEditMenu;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu.WarpGroupEditMenu;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu.WarpGroupMenu;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu.WarpMenu;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.Warp;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.api.OpenStreetMapAPI;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
+import net.buildtheearth.buildteamtools.utils.GeometricUtils;
+import net.buildtheearth.buildteamtools.utils.geo.CoordinateConversion;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
@@ -142,7 +142,7 @@ public WarpGroup getOtherWarpGroup() {
public void createWarp(Player creator) {
WarpGroup group = getOtherWarpGroup();
if (group == null) {
- group = NavUtils.createOtherWarpGroup();
+ group = NavUtils.createOtherWarpGroup(NetworkModule.getInstance().getBuildTeam());
}
createWarp(creator, group);
}
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/commands/WarpCommand.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/commands/WarpCommand.java
similarity index 87%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/commands/WarpCommand.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/commands/WarpCommand.java
index c7363d17..37938a69 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/commands/WarpCommand.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/commands/WarpCommand.java
@@ -1,11 +1,11 @@
-package net.buildtheearth.modules.navigation.components.warps.commands;
-
-import net.buildtheearth.modules.navigation.NavigationModule;
-import net.buildtheearth.modules.navigation.components.warps.WarpsComponent;
-import net.buildtheearth.modules.navigation.components.warps.model.Warp;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.model.Permissions;
-import net.buildtheearth.utils.ChatHelper;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.commands;
+
+import com.alpsbte.alpslib.utils.ChatHelper;
+import net.buildtheearth.buildteamtools.modules.navigation.NavigationModule;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.WarpsComponent;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.Warp;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.model.Permissions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/commands/WarpsBtCommand.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/commands/WarpsBtCommand.java
similarity index 61%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/commands/WarpsBtCommand.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/commands/WarpsBtCommand.java
index e7336706..fb5648bb 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/commands/WarpsBtCommand.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/commands/WarpsBtCommand.java
@@ -1,9 +1,9 @@
-package net.buildtheearth.modules.navigation.components.warps.commands;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.commands;
-import net.buildtheearth.modules.navigation.components.navigator.commands.BuildteamCommand;
-import net.buildtheearth.modules.navigation.components.warps.WarpsComponent;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.modules.network.model.Permissions;
+import net.buildtheearth.buildteamtools.modules.navigation.components.navigator.commands.BuildteamCommand;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.WarpsComponent;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
+import net.buildtheearth.buildteamtools.modules.network.model.Permissions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/listeners/WarpJoinListener.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/listeners/WarpJoinListener.java
similarity index 77%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/listeners/WarpJoinListener.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/listeners/WarpJoinListener.java
index 6771a91c..a054afcf 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/listeners/WarpJoinListener.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/listeners/WarpJoinListener.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.modules.navigation.components.warps.listeners;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.listeners;
-import net.buildtheearth.modules.navigation.NavigationModule;
-import net.buildtheearth.modules.navigation.components.warps.WarpsComponent;
-import net.buildtheearth.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import net.buildtheearth.buildteamtools.modules.navigation.NavigationModule;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.WarpsComponent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/AddressTypeSelectionMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/AddressTypeSelectionMenu.java
similarity index 93%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/AddressTypeSelectionMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/AddressTypeSelectionMenu.java
index 10321e68..9cb831ba 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/AddressTypeSelectionMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/AddressTypeSelectionMenu.java
@@ -1,13 +1,13 @@
-package net.buildtheearth.modules.navigation.components.warps.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.navigation.components.warps.model.Warp;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.Utils;
-import net.buildtheearth.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.Warp;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.Utils;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import net.wesjd.anvilgui.AnvilGUI;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/MaterialSelectionMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/MaterialSelectionMenu.java
similarity index 89%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/MaterialSelectionMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/MaterialSelectionMenu.java
index 91352685..9e45e8f2 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/MaterialSelectionMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/MaterialSelectionMenu.java
@@ -1,12 +1,16 @@
-package net.buildtheearth.modules.navigation.components.warps.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.navigation.components.warps.model.WarpGroup;
-import net.buildtheearth.utils.*;
-import net.buildtheearth.utils.menus.AbstractMenu;
-import net.buildtheearth.modules.navigation.components.warps.model.Warp;
-import net.buildtheearth.utils.menus.BookMenu;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.Warp;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.utils.menus.BookMenu;
import net.wesjd.anvilgui.AnvilGUI;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@@ -43,7 +47,7 @@ public MaterialSelectionMenu(Player menuPlayer, Object object, boolean alreadyEx
@Override
protected void setMenuItemsAsync() {
- getMenu().getSlot(MATERIAL_SLOT).setItem(Item.create(XMaterial.STONE.parseMaterial(), "§6§lItem", ListUtil.createList("", "Change the material of the warp", "to a minecraft item.", "", "§eExample:", "Stone")));
+ getMenu().getSlot(MATERIAL_SLOT).setItem(Item.create(XMaterial.STONE.get(), "§6§lItem", ListUtil.createList("", "Change the material of the warp", "to a minecraft item.", "", "§eExample:", "Stone")));
getMenu().getSlot(CUSTOM_HEAD_SLOT).setItem(CustomHeads.getLetterHead("?", CustomHeads.LetterType.WOODEN, "§6§lCustom Head", ListUtil.createList("", "Change the material of the warp", "to a custom head texture URL.", "", "§eExample:", "https://textures.minecraft.net/texture/...")));
if(object instanceof Warp)
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpEditMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpEditMenu.java
similarity index 92%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpEditMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpEditMenu.java
index 1a65bb87..7f5de25c 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpEditMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpEditMenu.java
@@ -1,14 +1,18 @@
-package net.buildtheearth.modules.navigation.components.warps.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.api.OpenStreetMapAPI;
-import net.buildtheearth.modules.network.model.Permissions;
-import net.buildtheearth.utils.*;
-import net.buildtheearth.utils.geo.CoordinateConversion;
-import net.buildtheearth.utils.menus.AbstractMenu;
-import net.buildtheearth.modules.navigation.components.warps.model.Warp;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.Warp;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.api.OpenStreetMapAPI;
+import net.buildtheearth.buildteamtools.modules.network.model.Permissions;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.geo.CoordinateConversion;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import net.wesjd.anvilgui.AnvilGUI;
import org.bukkit.Location;
import org.bukkit.Sound;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpGroupEditMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpGroupEditMenu.java
similarity index 93%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpGroupEditMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpGroupEditMenu.java
index 2abc56e2..b2ba0a6a 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpGroupEditMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpGroupEditMenu.java
@@ -1,14 +1,18 @@
-package net.buildtheearth.modules.navigation.components.warps.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu;
import com.alpsbte.alpslib.utils.AlpsUtils;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.model.Permissions;
-import net.buildtheearth.utils.*;
-import net.buildtheearth.utils.menus.AbstractMenu;
-import net.buildtheearth.utils.menus.BookMenu;
-import net.buildtheearth.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.model.Permissions;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.utils.menus.BookMenu;
import net.wesjd.anvilgui.AnvilGUI;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@@ -20,7 +24,7 @@
import java.util.Collections;
import java.util.List;
-import static net.buildtheearth.modules.navigation.components.warps.menu.WarpEditMenu.CONFIRM_SLOT;
+import static net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu.WarpEditMenu.CONFIRM_SLOT;
public class WarpGroupEditMenu extends AbstractMenu {
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpGroupMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpGroupMenu.java
similarity index 89%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpGroupMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpGroupMenu.java
index 235e32c4..a40f7b79 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpGroupMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpGroupMenu.java
@@ -1,21 +1,21 @@
-package net.buildtheearth.modules.navigation.components.warps.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.item.Item;
import com.google.gson.Gson;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.navigation.NavigationModule;
-import net.buildtheearth.modules.navigation.components.warps.model.WarpGroup;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.modules.network.model.Permissions;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.CustomHeads;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.io.ConfigPaths;
-import net.buildtheearth.utils.io.ConfigUtil;
-import net.buildtheearth.utils.menus.AbstractMenu;
-import net.buildtheearth.utils.menus.AbstractPaginatedMenu;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.navigation.NavigationModule;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
+import net.buildtheearth.buildteamtools.modules.network.model.Permissions;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.io.ConfigPaths;
+import net.buildtheearth.buildteamtools.utils.io.ConfigUtil;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractPaginatedMenu;
import org.bukkit.entity.Player;
import org.ipvp.canvas.mask.BinaryMask;
import org.ipvp.canvas.mask.Mask;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpGroupSelectionMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpGroupSelectionMenu.java
similarity index 82%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpGroupSelectionMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpGroupSelectionMenu.java
index 70df51eb..25ca84a1 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpGroupSelectionMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpGroupSelectionMenu.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.modules.navigation.components.warps.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.modules.navigation.components.warps.model.Warp;
-import net.buildtheearth.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.Warp;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpMenu.java
similarity index 85%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpMenu.java
index d80c4438..8b5d85bd 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/menu/WarpMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/menu/WarpMenu.java
@@ -1,15 +1,15 @@
-package net.buildtheearth.modules.navigation.components.warps.menu;
-
-import net.buildtheearth.modules.navigation.NavigationModule;
-import net.buildtheearth.modules.navigation.components.warps.model.Warp;
-import net.buildtheearth.modules.navigation.components.warps.model.WarpGroup;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.model.Permissions;
-import net.buildtheearth.utils.CustomHeads;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractPaginatedMenu;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.menu;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import net.buildtheearth.buildteamtools.modules.navigation.NavigationModule;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.Warp;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.model.Permissions;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractPaginatedMenu;
import org.bukkit.entity.Player;
import org.ipvp.canvas.mask.BinaryMask;
import org.ipvp.canvas.mask.Mask;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/model/Warp.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/model/Warp.java
similarity index 94%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/model/Warp.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/model/Warp.java
index ac5d7039..456753c6 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/model/Warp.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/model/Warp.java
@@ -1,9 +1,12 @@
-package net.buildtheearth.modules.navigation.components.warps.model;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.model;
+import com.alpsbte.alpslib.utils.item.Item;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
-import net.buildtheearth.utils.*;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.Utils;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.json.JSONObject;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/warps/model/WarpGroup.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/model/WarpGroup.java
similarity index 90%
rename from src/main/java/net/buildtheearth/modules/navigation/components/warps/model/WarpGroup.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/model/WarpGroup.java
index e51282e8..833a9f48 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/components/warps/model/WarpGroup.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/components/warps/model/WarpGroup.java
@@ -1,11 +1,11 @@
-package net.buildtheearth.modules.navigation.components.warps.model;
+package net.buildtheearth.buildteamtools.modules.navigation.components.warps.model;
+import com.alpsbte.alpslib.utils.item.Item;
import lombok.Getter;
import lombok.Setter;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.utils.CustomHeads;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.json.JSONObject;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/menu/CountrySelectorMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/CountrySelectorMenu.java
similarity index 87%
rename from src/main/java/net/buildtheearth/modules/navigation/menu/CountrySelectorMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/CountrySelectorMenu.java
index aafb89d1..cbde5bfe 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/menu/CountrySelectorMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/CountrySelectorMenu.java
@@ -1,18 +1,18 @@
-package net.buildtheearth.modules.navigation.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.menu;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.item.Item;
import lombok.NonNull;
-import net.buildtheearth.modules.navigation.NavUtils;
-import net.buildtheearth.modules.navigation.components.warps.WarpsComponent;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.modules.network.model.Continent;
-import net.buildtheearth.modules.network.model.Permissions;
-import net.buildtheearth.modules.network.model.Region;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractPaginatedMenu;
+import net.buildtheearth.buildteamtools.modules.navigation.NavUtils;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.WarpsComponent;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
+import net.buildtheearth.buildteamtools.modules.network.model.Continent;
+import net.buildtheearth.buildteamtools.modules.network.model.Permissions;
+import net.buildtheearth.buildteamtools.modules.network.model.Region;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractPaginatedMenu;
import org.bukkit.entity.Player;
import org.ipvp.canvas.mask.BinaryMask;
import org.ipvp.canvas.mask.Mask;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/menu/ExploreMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/ExploreMenu.java
similarity index 86%
rename from src/main/java/net/buildtheearth/modules/navigation/menu/ExploreMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/ExploreMenu.java
index ba3a6a97..3b3690f7 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/menu/ExploreMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/ExploreMenu.java
@@ -1,12 +1,12 @@
-package net.buildtheearth.modules.navigation.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.menu;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.network.model.Continent;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.modules.network.model.Continent;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.entity.Player;
import org.ipvp.canvas.mask.BinaryMask;
import org.ipvp.canvas.mask.Mask;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/menu/MainMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/MainMenu.java
similarity index 92%
rename from src/main/java/net/buildtheearth/modules/navigation/menu/MainMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/MainMenu.java
index 1d9b7dbc..cf433250 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/menu/MainMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/MainMenu.java
@@ -1,16 +1,16 @@
-package net.buildtheearth.modules.navigation.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.menu;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.navigation.NavUtils;
-import net.buildtheearth.modules.navigation.components.warps.WarpsComponent;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.io.ConfigPaths;
-import net.buildtheearth.utils.io.ConfigUtil;
-import net.buildtheearth.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.navigation.NavUtils;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.WarpsComponent;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.io.ConfigPaths;
+import net.buildtheearth.buildteamtools.utils.io.ConfigUtil;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import net.kyori.adventure.text.format.NamedTextColor;
import org.apache.commons.lang3.BooleanUtils;
import org.bukkit.configuration.file.FileConfiguration;
@@ -19,12 +19,7 @@
import org.ipvp.canvas.mask.Mask;
import org.jetbrains.annotations.NotNull;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Deque;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
/**
* The main menu for the BTE universal navigator.
diff --git a/src/main/java/net/buildtheearth/modules/navigation/menu/StateSelectorMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/StateSelectorMenu.java
similarity index 89%
rename from src/main/java/net/buildtheearth/modules/navigation/menu/StateSelectorMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/StateSelectorMenu.java
index a239bc8f..c9a59567 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/menu/StateSelectorMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/StateSelectorMenu.java
@@ -1,15 +1,15 @@
-package net.buildtheearth.modules.navigation.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.menu;
+import com.alpsbte.alpslib.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.item.Item;
import lombok.NonNull;
-import net.buildtheearth.modules.navigation.NavUtils;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.model.Region;
-import net.buildtheearth.modules.network.model.RegionType;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractPaginatedMenu;
+import net.buildtheearth.buildteamtools.modules.navigation.NavUtils;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.model.Region;
+import net.buildtheearth.buildteamtools.modules.network.model.RegionType;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractPaginatedMenu;
import org.bukkit.entity.Player;
import org.ipvp.canvas.mask.BinaryMask;
import org.ipvp.canvas.mask.Mask;
diff --git a/src/main/java/net/buildtheearth/modules/navigation/menu/TutorialsMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/TutorialsMenu.java
similarity index 87%
rename from src/main/java/net/buildtheearth/modules/navigation/menu/TutorialsMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/TutorialsMenu.java
index 4c4a3c15..e58ed572 100644
--- a/src/main/java/net/buildtheearth/modules/navigation/menu/TutorialsMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/navigation/menu/TutorialsMenu.java
@@ -1,6 +1,6 @@
-package net.buildtheearth.modules.navigation.menu;
+package net.buildtheearth.buildteamtools.modules.navigation.menu;
-import net.buildtheearth.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.entity.Player;
import org.ipvp.canvas.mask.Mask;
diff --git a/src/main/java/net/buildtheearth/modules/network/NetworkModule.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/NetworkModule.java
similarity index 85%
rename from src/main/java/net/buildtheearth/modules/network/NetworkModule.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/NetworkModule.java
index 355dc8a0..7f5f78a4 100644
--- a/src/main/java/net/buildtheearth/modules/network/NetworkModule.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/NetworkModule.java
@@ -1,20 +1,21 @@
-package net.buildtheearth.modules.network;
+package net.buildtheearth.buildteamtools.modules.network;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import lombok.Getter;
import lombok.Setter;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.Module;
-import net.buildtheearth.modules.network.api.NetworkAPI;
-import net.buildtheearth.modules.network.listeners.NetworkJoinListener;
-import net.buildtheearth.modules.network.listeners.NetworkQuitListener;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.modules.network.model.Region;
-import net.buildtheearth.modules.network.model.RegionType;
-import net.buildtheearth.utils.io.ConfigPaths;
-import net.buildtheearth.utils.io.Constants;
-import net.buildtheearth.utils.io.Errors;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.Module;
+import net.buildtheearth.buildteamtools.modules.network.api.NetworkAPI;
+import net.buildtheearth.buildteamtools.modules.network.listeners.NetworkJoinListener;
+import net.buildtheearth.buildteamtools.modules.network.listeners.NetworkQuitListener;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
+import net.buildtheearth.buildteamtools.modules.network.model.Region;
+import net.buildtheearth.buildteamtools.modules.network.model.RegionType;
+import net.buildtheearth.buildteamtools.utils.WikiLinks;
+import net.buildtheearth.buildteamtools.utils.io.ConfigPaths;
+import net.buildtheearth.buildteamtools.utils.io.Constants;
+import net.buildtheearth.buildteamtools.utils.io.Errors;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@@ -51,7 +52,7 @@ public class NetworkModule extends Module {
private static NetworkModule instance = null;
public NetworkModule() {
- super("Network");
+ super("Network", WikiLinks.ENTRY);
}
public static NetworkModule getInstance() {
@@ -130,7 +131,7 @@ public void ping(Player p) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Ping");
out.writeUTF(p.getUniqueId().toString());
- out.writeUTF("Version: " + BuildTeamTools.getInstance().getDescription().getVersion());
+ out.writeUTF("Version: " + BuildTeamTools.getInstance().getPluginMeta().getVersion());
p.sendPluginMessage(BuildTeamTools.getInstance(), "btt:buildteam", out.toByteArray());
}
diff --git a/src/main/java/net/buildtheearth/modules/network/api/API.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/api/API.java
similarity index 97%
rename from src/main/java/net/buildtheearth/modules/network/api/API.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/api/API.java
index 00b688e7..326cf005 100644
--- a/src/main/java/net/buildtheearth/modules/network/api/API.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/api/API.java
@@ -1,12 +1,7 @@
-package net.buildtheearth.modules.network.api;
-
-import net.buildtheearth.BuildTeamTools;
-import okhttp3.Call;
-import okhttp3.Callback;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.RequestBody;
-import okhttp3.Response;
+package net.buildtheearth.buildteamtools.modules.network.api;
+
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import okhttp3.*;
import okio.Buffer;
import org.jetbrains.annotations.NotNull;
import org.json.simple.JSONArray;
diff --git a/src/main/java/net/buildtheearth/modules/network/api/NetworkAPI.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/api/NetworkAPI.java
similarity index 89%
rename from src/main/java/net/buildtheearth/modules/network/api/NetworkAPI.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/api/NetworkAPI.java
index 69a8346b..35c6e7b8 100644
--- a/src/main/java/net/buildtheearth/modules/network/api/NetworkAPI.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/api/NetworkAPI.java
@@ -1,17 +1,17 @@
-package net.buildtheearth.modules.network.api;
+package net.buildtheearth.buildteamtools.modules.network.api;
+import com.alpsbte.alpslib.utils.ChatHelper;
import lombok.experimental.UtilityClass;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.navigation.NavUtils;
-import net.buildtheearth.modules.navigation.components.warps.model.Warp;
-import net.buildtheearth.modules.navigation.components.warps.model.WarpGroup;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.model.BuildTeam;
-import net.buildtheearth.modules.network.model.Continent;
-import net.buildtheearth.modules.network.model.Region;
-import net.buildtheearth.modules.network.model.RegionType;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.io.ConfigPaths;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.navigation.NavUtils;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.Warp;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.model.BuildTeam;
+import net.buildtheearth.buildteamtools.modules.network.model.Continent;
+import net.buildtheearth.buildteamtools.modules.network.model.Region;
+import net.buildtheearth.buildteamtools.modules.network.model.RegionType;
+import net.buildtheearth.buildteamtools.utils.io.ConfigPaths;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.bukkit.Bukkit;
@@ -29,6 +29,7 @@ public class NetworkAPI {
/**
* Notifies the network API about the presence of the plugin
+ *
* @param installed if the plugin is installed
*/
public static void setBuildTeamToolsInstalled(boolean installed) {
@@ -48,7 +49,7 @@ public void onResponse(String response) {
@Override
public void onFailure(IOException e) {
- ChatHelper.logError("Something went wrong while notifying the network API of the plugins presence: %s", e.getMessage());
+ ChatHelper.logError("Something went wrong while notifying the network API of the plugins presence: " + e.getMessage());
}
});
}
@@ -105,7 +106,7 @@ public void onResponse(String response) {
isConnected, hasBuildTeamToolsInstalled, allowsTransfers, tag);
NetworkModule.getInstance().getBuildTeams().add(buildTeam);
- WarpGroup otherWarpGroup = NavUtils.createOtherWarpGroup();
+ WarpGroup otherWarpGroup = NavUtils.createOtherWarpGroup(buildTeam);
// Add all the warp groups of the team to their respective build teams
for (Object warpGroupJSON : warpGroups.toArray()) {
@@ -122,8 +123,6 @@ public void onResponse(String response) {
buildTeam.getWarpGroups().add(warpGroup);
}
- if (!otherWarpGroup.getWarps().isEmpty()) buildTeam.getWarpGroups().add(otherWarpGroup);
-
// Add all the warps of the team to their respective warp groups
for (Object warpJSON : warps.toArray()) {
if (!(warpJSON instanceof JSONObject warpObject)) continue;
@@ -162,23 +161,21 @@ public void onResponse(String response) {
Warp warp = new Warp(warpID, warpGroup, warpName, countryCode, "cca3", address, addressType, material, warpWorldName, warpLat, warpLon, warpHeight, warpYaw, warpPitch, isHighlight);
// If the warp belongs to a warp group, add it to that, otherwise add it to the "other" warp group.
- if (warpGroupID == null) {
+ boolean added = false;
+
+ for (WarpGroup wg : buildTeam.getWarpGroups())
+ if (wg.getId().equals(warpGroup.getId())) {
+ wg.getWarps().add(warp);
+ added = true;
+ break;
+ }
+
+ if (!added)
otherWarpGroup.getWarps().add(warp);
- } else {
- boolean added = false;
-
- for (WarpGroup wg : buildTeam.getWarpGroups())
- if (wg.getId().equals(warpGroupID)) {
- wg.getWarps().add(warp);
- added = true;
- break;
- }
-
- if (!added)
- otherWarpGroup.getWarps().add(warp);
- }
}
+ if (!otherWarpGroup.getWarps().isEmpty()) buildTeam.getWarpGroups().add(otherWarpGroup);
+
// Add all the regions of the team to their respective continents
for (Object regionJSON : regions.toArray()) {
if (!(regionJSON instanceof JSONObject regionObject)) continue;
@@ -205,7 +202,7 @@ public void onResponse(String response) {
NetworkModule.getInstance().getRegions().add(region);
}
}
- }catch (Exception e) {
+ } catch (Exception e) {
future.completeExceptionally(e);
return;
}
@@ -214,25 +211,24 @@ public void onResponse(String response) {
}
-
private String getMainServerName(JSONObject teamObject) {
String mainServerIP = (String) teamObject.get("MainServerIP");
Object serversObject = teamObject.get("Servers");
if (!(serversObject instanceof JSONArray serversArray)) return null;
- for(Object object : serversArray.toArray()) {
+ for (Object object : serversArray.toArray()) {
if (!(object instanceof JSONObject serverObject)) return null;
String serverIP = (String) serverObject.get("IP");
- if(serverIP.equals(mainServerIP)) return (String) serverObject.get("Name");
+ if (serverIP.equals(mainServerIP)) return (String) serverObject.get("Name");
}
return null;
}
private int getArea(JSONObject regionObject) {
- if(regionObject == null) return 0;
- if(regionObject.get("area") == null) return 0;
+ if (regionObject == null) return 0;
+ if (regionObject.get("area") == null) return 0;
if (regionObject.get("area") instanceof Long area)
return Math.toIntExact(area);
@@ -242,7 +238,7 @@ private int getArea(JSONObject regionObject) {
@Override
public void onFailure(IOException e) {
- ChatHelper.logError("Failed to get teams information from the network API: %s", e);
+ ChatHelper.logError("Failed to get teams information from the network API: " + e.getMessage());
// Handle failure scenario
future.completeExceptionally(e);
@@ -289,28 +285,28 @@ public static void createWarp(Warp warp, API.ApiResponseCallback callback) {
String apiKey = BuildTeamTools.getInstance().getConfig().getString(ConfigPaths.API_KEY);
RequestBody requestBody = RequestBody.create(warp.toJSON().toString(), MediaType.parse("application/json"));
- API.postAsync("https://nwapi.buildtheearth.net/api/teams/"+apiKey+"/warps", requestBody, callback);
+ API.postAsync("https://nwapi.buildtheearth.net/api/teams/" + apiKey + "/warps", requestBody, callback);
}
public static void createWarpGroup(WarpGroup warpGroup, API.ApiResponseCallback callback) {
String apiKey = BuildTeamTools.getInstance().getConfig().getString(ConfigPaths.API_KEY);
RequestBody requestBody = RequestBody.create(warpGroup.toJSON().toString(), MediaType.parse("application/json"));
- API.postAsync("https://nwapi.buildtheearth.net/api/teams/"+apiKey+"/warpgroups", requestBody, callback);
+ API.postAsync("https://nwapi.buildtheearth.net/api/teams/" + apiKey + "/warpgroups", requestBody, callback);
}
public static void updateWarp(Warp warp, API.ApiResponseCallback callback) {
String apiKey = BuildTeamTools.getInstance().getConfig().getString(ConfigPaths.API_KEY);
RequestBody requestBody = RequestBody.create(warp.toJSON().toString(), MediaType.parse("application/json"));
- API.putAsync("https://nwapi.buildtheearth.net/api/teams/"+apiKey+"/warps", requestBody, callback);
+ API.putAsync("https://nwapi.buildtheearth.net/api/teams/" + apiKey + "/warps", requestBody, callback);
}
public static void updateWarpGroup(WarpGroup warpGroup, API.ApiResponseCallback callback) {
String apiKey = BuildTeamTools.getInstance().getConfig().getString(ConfigPaths.API_KEY);
RequestBody requestBody = RequestBody.create(warpGroup.toJSON().toString(), MediaType.parse("application/json"));
- API.putAsync("https://nwapi.buildtheearth.net/api/teams/"+apiKey+"/warpgroups", requestBody, callback);
+ API.putAsync("https://nwapi.buildtheearth.net/api/teams/" + apiKey + "/warpgroups", requestBody, callback);
}
public static void deleteWarp(Warp warp, API.ApiResponseCallback callback) {
@@ -322,7 +318,7 @@ public static void deleteWarp(Warp warp, API.ApiResponseCallback callback) {
RequestBody requestBody = RequestBody.create(requestBodyString, MediaType.parse("application/json"));
- API.deleteAsync("https://nwapi.buildtheearth.net/api/teams/"+apiKey+"/warps", requestBody, callback);
+ API.deleteAsync("https://nwapi.buildtheearth.net/api/teams/" + apiKey + "/warps", requestBody, callback);
}
public static void deleteWarpGroup(WarpGroup warpGroup, API.ApiResponseCallback callback) {
@@ -333,11 +329,11 @@ public static void deleteWarpGroup(WarpGroup warpGroup, API.ApiResponseCallback
String requestBodyString = requestBodyJson.toString();
RequestBody requestBody = RequestBody.create(requestBodyString, MediaType.parse("application/json"));
- API.deleteAsync("https://nwapi.buildtheearth.net/api/teams/"+apiKey+"/warpgroups", requestBody, callback);
+ API.deleteAsync("https://nwapi.buildtheearth.net/api/teams/" + apiKey + "/warpgroups", requestBody, callback);
}
public static void syncPlayerList() {
- if(NetworkModule.getInstance().getBuildTeam().isConnected())
+ if (NetworkModule.getInstance().getBuildTeam().isConnected())
return;
String apiKey = BuildTeamTools.getInstance().getConfig().getString(ConfigPaths.API_KEY);
@@ -348,7 +344,7 @@ public static void syncPlayerList() {
RequestBody requestBody = RequestBody.create(requestBodyArray.toString(), MediaType.parse("application/json"));
- API.postAsync("https://nwapi.buildtheearth.net/api/teams/"+apiKey+"/playerlist", requestBody, new API.ApiResponseCallback() {
+ API.postAsync("https://nwapi.buildtheearth.net/api/teams/" + apiKey + "/playerlist", requestBody, new API.ApiResponseCallback() {
@Override
public void onResponse(String response) {
ChatHelper.logDebug("Synced the player list with the network API: %s", response);
diff --git a/src/main/java/net/buildtheearth/modules/network/api/OpenStreetMapAPI.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/api/OpenStreetMapAPI.java
similarity index 94%
rename from src/main/java/net/buildtheearth/modules/network/api/OpenStreetMapAPI.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/api/OpenStreetMapAPI.java
index 41cd903e..92d7993e 100644
--- a/src/main/java/net/buildtheearth/modules/network/api/OpenStreetMapAPI.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/api/OpenStreetMapAPI.java
@@ -1,6 +1,6 @@
-package net.buildtheearth.modules.network.api;
+package net.buildtheearth.buildteamtools.modules.network.api;
-import net.buildtheearth.utils.ChatHelper;
+import com.alpsbte.alpslib.utils.ChatHelper;
import org.jetbrains.annotations.NotNull;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
diff --git a/src/main/java/net/buildtheearth/modules/network/listeners/NetworkJoinListener.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/listeners/NetworkJoinListener.java
similarity index 71%
rename from src/main/java/net/buildtheearth/modules/network/listeners/NetworkJoinListener.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/listeners/NetworkJoinListener.java
index b60a6c47..2a1b7d82 100644
--- a/src/main/java/net/buildtheearth/modules/network/listeners/NetworkJoinListener.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/listeners/NetworkJoinListener.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.modules.network.listeners;
+package net.buildtheearth.buildteamtools.modules.network.listeners;
-import net.buildtheearth.modules.common.CommonModule;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.api.NetworkAPI;
+import net.buildtheearth.buildteamtools.modules.common.CommonModule;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.api.NetworkAPI;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
diff --git a/src/main/java/net/buildtheearth/modules/network/listeners/NetworkQuitListener.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/listeners/NetworkQuitListener.java
similarity index 69%
rename from src/main/java/net/buildtheearth/modules/network/listeners/NetworkQuitListener.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/listeners/NetworkQuitListener.java
index 00735bd7..9a48777f 100644
--- a/src/main/java/net/buildtheearth/modules/network/listeners/NetworkQuitListener.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/listeners/NetworkQuitListener.java
@@ -1,7 +1,7 @@
-package net.buildtheearth.modules.network.listeners;
+package net.buildtheearth.buildteamtools.modules.network.listeners;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.api.NetworkAPI;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.api.NetworkAPI;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
diff --git a/src/main/java/net/buildtheearth/modules/network/model/BuildTeam.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/model/BuildTeam.java
similarity index 94%
rename from src/main/java/net/buildtheearth/modules/network/model/BuildTeam.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/model/BuildTeam.java
index 3472a30c..7f5dddf4 100644
--- a/src/main/java/net/buildtheearth/modules/network/model/BuildTeam.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/model/BuildTeam.java
@@ -1,12 +1,12 @@
-package net.buildtheearth.modules.network.model;
+package net.buildtheearth.buildteamtools.modules.network.model;
+import com.alpsbte.alpslib.utils.ChatHelper;
import lombok.Getter;
-import net.buildtheearth.modules.navigation.components.warps.model.Warp;
-import net.buildtheearth.modules.navigation.components.warps.model.WarpGroup;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.network.api.API;
-import net.buildtheearth.modules.network.api.NetworkAPI;
-import net.buildtheearth.utils.ChatHelper;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.Warp;
+import net.buildtheearth.buildteamtools.modules.navigation.components.warps.model.WarpGroup;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.network.api.API;
+import net.buildtheearth.buildteamtools.modules.network.api.NetworkAPI;
import org.bukkit.entity.Player;
import java.io.IOException;
diff --git a/src/main/java/net/buildtheearth/modules/network/model/Continent.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/model/Continent.java
similarity index 94%
rename from src/main/java/net/buildtheearth/modules/network/model/Continent.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/model/Continent.java
index 5c704384..c5ad9bf0 100644
--- a/src/main/java/net/buildtheearth/modules/network/model/Continent.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/model/Continent.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.network.model;
+package net.buildtheearth.buildteamtools.modules.network.model;
import lombok.Getter;
import lombok.NonNull;
diff --git a/src/main/java/net/buildtheearth/modules/network/model/Permissions.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/model/Permissions.java
similarity index 95%
rename from src/main/java/net/buildtheearth/modules/network/model/Permissions.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/model/Permissions.java
index f2cf1dff..d29ee740 100644
--- a/src/main/java/net/buildtheearth/modules/network/model/Permissions.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/model/Permissions.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.network.model;
+package net.buildtheearth.buildteamtools.modules.network.model;
public abstract class Permissions {
diff --git a/src/main/java/net/buildtheearth/modules/network/model/Region.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/model/Region.java
similarity index 97%
rename from src/main/java/net/buildtheearth/modules/network/model/Region.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/model/Region.java
index 41f5a3a4..ff60aa64 100644
--- a/src/main/java/net/buildtheearth/modules/network/model/Region.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/model/Region.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.network.model;
+package net.buildtheearth.buildteamtools.modules.network.model;
import lombok.Getter;
diff --git a/src/main/java/net/buildtheearth/modules/network/model/RegionType.java b/src/main/java/net/buildtheearth/buildteamtools/modules/network/model/RegionType.java
similarity index 89%
rename from src/main/java/net/buildtheearth/modules/network/model/RegionType.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/network/model/RegionType.java
index 6279a005..a58d40e7 100644
--- a/src/main/java/net/buildtheearth/modules/network/model/RegionType.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/network/model/RegionType.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.network.model;
+package net.buildtheearth.buildteamtools.modules.network.model;
import lombok.Getter;
import lombok.NonNull;
diff --git a/src/main/java/net/buildtheearth/modules/plotsystem/PlotSystemModule.java b/src/main/java/net/buildtheearth/buildteamtools/modules/plotsystem/PlotSystemModule.java
similarity index 78%
rename from src/main/java/net/buildtheearth/modules/plotsystem/PlotSystemModule.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/plotsystem/PlotSystemModule.java
index 5d4b6cb6..edbf1950 100644
--- a/src/main/java/net/buildtheearth/modules/plotsystem/PlotSystemModule.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/plotsystem/PlotSystemModule.java
@@ -1,29 +1,14 @@
-package net.buildtheearth.modules.plotsystem;
-
-
-import com.alpsbte.alpslib.libpsterra.core.Connection;
-import com.alpsbte.alpslib.libpsterra.core.PSTerraSetup;
-import com.alpsbte.alpslib.libpsterra.core.config.ConfigManager;
-import com.alpsbte.alpslib.libpsterra.core.config.PSInitializer;
-import com.alpsbte.alpslib.libpsterra.core.plotsystem.PlotCreator;
-import com.alpsbte.alpslib.libpsterra.core.plotsystem.PlotPaster;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.Module;
-import net.buildtheearth.modules.common.CommonModule;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.plotsystem.commands.PlotSystemTerraCommand;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.io.ConfigPaths;
-import net.buildtheearth.utils.io.ConfigUtil;
-import net.buildtheearth.utils.io.Constants;
-import net.buildtheearth.utils.io.Errors;
-import org.bukkit.Bukkit;
+package net.buildtheearth.buildteamtools.modules.plotsystem;
+
+import net.buildtheearth.buildteamtools.modules.Module;
+import net.buildtheearth.buildteamtools.modules.plotsystem.commands.PlotSystemTerraCommand;
+import net.buildtheearth.buildteamtools.utils.WikiLinks;
public class PlotSystemModule extends Module {
private static PlotSystemModule instance = null;
-
+/*
private ConfigManager configManager;
private PlotPaster plotPaster;
@@ -34,10 +19,10 @@ public class PlotSystemModule extends Module {
private Connection connection;
- private PlotCreator plotCreator;
+ private PlotCreator plotCreator;*/
public PlotSystemModule() {
- super("PlotSystem");
+ super("PlotSystem", WikiLinks.PLOT);
}
public static PlotSystemModule getInstance() {
@@ -47,6 +32,8 @@ public static PlotSystemModule getInstance() {
@Override
public void enable() {
+ shutdown("This module is currently oudated & broken.");
+ /*
// Check if WorldEdit is enabled
if (!CommonModule.getInstance().getDependencyComponent().isWorldEditEnabled()) {
shutdown(Errors.WORLD_EDIT_NOT_INSTALLED);
@@ -124,7 +111,7 @@ public void enable() {
return;
}
- super.enable();
+ super.enable();*/
}
@@ -134,7 +121,9 @@ public void registerCommands() {
}
@Override
- public void registerListeners() {}
+ public void registerListeners() {
+ // No Listeners
+ }
}
diff --git a/src/main/java/net/buildtheearth/modules/plotsystem/commands/PlotSystemTerraCommand.java b/src/main/java/net/buildtheearth/buildteamtools/modules/plotsystem/commands/PlotSystemTerraCommand.java
similarity index 81%
rename from src/main/java/net/buildtheearth/modules/plotsystem/commands/PlotSystemTerraCommand.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/plotsystem/commands/PlotSystemTerraCommand.java
index 3b84735e..d318c2c8 100644
--- a/src/main/java/net/buildtheearth/modules/plotsystem/commands/PlotSystemTerraCommand.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/plotsystem/commands/PlotSystemTerraCommand.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.plotsystem.commands;
+package net.buildtheearth.buildteamtools.modules.plotsystem.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
diff --git a/src/main/java/net/buildtheearth/modules/stats/StatsModule.java b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/StatsModule.java
similarity index 65%
rename from src/main/java/net/buildtheearth/modules/stats/StatsModule.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/stats/StatsModule.java
index 35001cf9..90df7693 100644
--- a/src/main/java/net/buildtheearth/modules/stats/StatsModule.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/StatsModule.java
@@ -1,13 +1,15 @@
-package net.buildtheearth.modules.stats;
+package net.buildtheearth.buildteamtools.modules.stats;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.Module;
-import net.buildtheearth.modules.network.NetworkModule;
-import net.buildtheearth.modules.stats.listeners.StatsListener;
-import net.buildtheearth.modules.stats.model.StatsPlayer;
-import net.buildtheearth.modules.stats.model.StatsServer;
+import lombok.Getter;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.modules.Module;
+import net.buildtheearth.buildteamtools.modules.network.NetworkModule;
+import net.buildtheearth.buildteamtools.modules.stats.listeners.StatsListener;
+import net.buildtheearth.buildteamtools.modules.stats.model.StatsPlayer;
+import net.buildtheearth.buildteamtools.modules.stats.model.StatsServer;
+import net.buildtheearth.buildteamtools.utils.WikiLinks;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.json.JSONArray;
@@ -19,8 +21,9 @@
public class StatsModule extends Module {
- public static int RATE_LIMIT = NetworkModule.CACHE_UPLOAD_SPEED / 20;
+ public static final int RATE_LIMIT = NetworkModule.CACHE_UPLOAD_SPEED / 20;
+ @Getter
private StatsServer statsServer;
private HashMap statsPlayerList;
@@ -29,7 +32,7 @@ public class StatsModule extends Module {
private static StatsModule instance = null;
public StatsModule() {
- super("Stats");
+ super("Stats", WikiLinks.STATS);
}
public static StatsModule getInstance() {
@@ -40,6 +43,16 @@ public static StatsModule getInstance() {
@Override
public void enable() {
+ if (NetworkModule.getInstance().getBuildTeam() == null) {
+ shutdown("The Network Module failed to load the Build Team.");
+ return;
+ }
+
+ if (!NetworkModule.getInstance().getBuildTeam().isConnected() || !Bukkit.getServerConfig().isProxyEnabled()) {
+ shutdown("The Build Team have to be connected to the BtE Network (Proxy).");
+ return;
+ }
+
statsServer = new StatsServer();
statsPlayerList = new HashMap<>();
@@ -61,13 +74,6 @@ public void registerListeners() {
super.registerListeners(new StatsListener());
}
-
-
-
- public StatsServer getStatsServer() {
- return statsServer;
- }
-
public StatsPlayer getStatsPlayer(UUID uuid) {
if (statsPlayerList.get(uuid) == null)
addStatsPlayer(uuid);
@@ -93,18 +99,18 @@ public void addStatsPlayer(UUID uuid) {
*/
public boolean updateAndSave() {
List communicators = NetworkModule.getInstance().getCommunicators();
- if (communicators.size() == 0) return false;
+ if (communicators.isEmpty()) return false;
if (!BuildTeamTools.getInstance().isEnabled()) return false;
- Player p = Bukkit.getPlayer(communicators.get(0));
+ Player p = Bukkit.getPlayer(communicators.getFirst());
if (p == null) {
- communicators.remove(0);
+ communicators.removeFirst();
return false;
}
if (!p.isOnline()) {
- communicators.remove(0);
+ communicators.removeFirst();
return false;
}
@@ -123,8 +129,8 @@ public JSONObject getCurrentCache() {
//Player Stats
JSONArray jsonArray = new JSONArray();
- for (UUID uuid : statsPlayerList.keySet())
- jsonArray.put(statsPlayerList.get(uuid).toJSON());
+ for (StatsPlayer statsPlayer : statsPlayerList.values())
+ jsonArray.put(statsPlayer.toJSON());
jsonObject.put("PLAYERS", jsonArray);
return jsonObject;
diff --git a/src/main/java/net/buildtheearth/modules/stats/listeners/StatsListener.java b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/listeners/StatsListener.java
similarity index 89%
rename from src/main/java/net/buildtheearth/modules/stats/listeners/StatsListener.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/stats/listeners/StatsListener.java
index dce7ad88..4f6ad9f1 100644
--- a/src/main/java/net/buildtheearth/modules/stats/listeners/StatsListener.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/listeners/StatsListener.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.modules.stats.listeners;
+package net.buildtheearth.buildteamtools.modules.stats.listeners;
-import net.buildtheearth.modules.stats.StatsModule;
-import net.buildtheearth.modules.stats.model.StatsPlayerType;
-import net.buildtheearth.modules.stats.model.StatsServerType;
+import net.buildtheearth.buildteamtools.modules.stats.StatsModule;
+import net.buildtheearth.buildteamtools.modules.stats.model.StatsPlayerType;
+import net.buildtheearth.buildteamtools.modules.stats.model.StatsServerType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
diff --git a/src/main/java/net/buildtheearth/modules/stats/menu/StatsMenu.java b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/menu/StatsMenu.java
similarity index 87%
rename from src/main/java/net/buildtheearth/modules/stats/menu/StatsMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/stats/menu/StatsMenu.java
index 0745c4d1..60a778fa 100644
--- a/src/main/java/net/buildtheearth/modules/stats/menu/StatsMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/menu/StatsMenu.java
@@ -1,14 +1,14 @@
-package net.buildtheearth.modules.stats.menu;
+package net.buildtheearth.buildteamtools.modules.stats.menu;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.stats.StatsModule;
-import net.buildtheearth.modules.stats.model.StatsPlayer;
-import net.buildtheearth.modules.stats.model.StatsServer;
-import net.buildtheearth.utils.CustomHeads;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractMenu;
+import net.buildtheearth.buildteamtools.modules.stats.StatsModule;
+import net.buildtheearth.buildteamtools.modules.stats.model.StatsPlayer;
+import net.buildtheearth.buildteamtools.modules.stats.model.StatsServer;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.ListUtil;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.buildtheearth.buildteamtools.utils.menus.AbstractMenu;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.ipvp.canvas.mask.BinaryMask;
diff --git a/src/main/java/net/buildtheearth/modules/stats/model/StatsPlayer.java b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsPlayer.java
similarity index 93%
rename from src/main/java/net/buildtheearth/modules/stats/model/StatsPlayer.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsPlayer.java
index f2a79004..99bd57f5 100644
--- a/src/main/java/net/buildtheearth/modules/stats/model/StatsPlayer.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsPlayer.java
@@ -1,6 +1,6 @@
-package net.buildtheearth.modules.stats.model;
+package net.buildtheearth.buildteamtools.modules.stats.model;
-import net.buildtheearth.modules.stats.StatsModule;
+import net.buildtheearth.buildteamtools.modules.stats.StatsModule;
import org.json.simple.JSONObject;
import java.util.HashMap;
diff --git a/src/main/java/net/buildtheearth/modules/stats/model/StatsPlayerType.java b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsPlayerType.java
similarity index 70%
rename from src/main/java/net/buildtheearth/modules/stats/model/StatsPlayerType.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsPlayerType.java
index 23dc6313..61f63a77 100644
--- a/src/main/java/net/buildtheearth/modules/stats/model/StatsPlayerType.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsPlayerType.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.stats.model;
+package net.buildtheearth.buildteamtools.modules.stats.model;
public enum StatsPlayerType {
PLAYTIME,
diff --git a/src/main/java/net/buildtheearth/modules/stats/model/StatsServer.java b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsServer.java
similarity index 92%
rename from src/main/java/net/buildtheearth/modules/stats/model/StatsServer.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsServer.java
index ba53c4c0..d8b9052c 100644
--- a/src/main/java/net/buildtheearth/modules/stats/model/StatsServer.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsServer.java
@@ -1,6 +1,6 @@
-package net.buildtheearth.modules.stats.model;
+package net.buildtheearth.buildteamtools.modules.stats.model;
-import net.buildtheearth.modules.stats.StatsModule;
+import net.buildtheearth.buildteamtools.modules.stats.StatsModule;
import org.json.simple.JSONObject;
import java.util.HashMap;
diff --git a/src/main/java/net/buildtheearth/modules/stats/model/StatsServerType.java b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsServerType.java
similarity index 72%
rename from src/main/java/net/buildtheearth/modules/stats/model/StatsServerType.java
rename to src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsServerType.java
index cbcfcf5f..460c9a16 100644
--- a/src/main/java/net/buildtheearth/modules/stats/model/StatsServerType.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/modules/stats/model/StatsServerType.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.modules.stats.model;
+package net.buildtheearth.buildteamtools.modules.stats.model;
public enum StatsServerType {
UPTIME,
diff --git a/src/main/java/net/buildtheearth/utils/BlockLocation.java b/src/main/java/net/buildtheearth/buildteamtools/utils/BlockLocation.java
similarity index 93%
rename from src/main/java/net/buildtheearth/utils/BlockLocation.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/BlockLocation.java
index 46a42657..909b2305 100644
--- a/src/main/java/net/buildtheearth/utils/BlockLocation.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/BlockLocation.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
import org.bukkit.Location;
import org.bukkit.World;
diff --git a/src/main/java/net/buildtheearth/utils/Config.java b/src/main/java/net/buildtheearth/buildteamtools/utils/Config.java
similarity index 97%
rename from src/main/java/net/buildtheearth/utils/Config.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/Config.java
index 26d200c0..68963917 100644
--- a/src/main/java/net/buildtheearth/utils/Config.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/Config.java
@@ -1,6 +1,6 @@
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
-import net.buildtheearth.BuildTeamTools;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
diff --git a/src/main/java/net/buildtheearth/utils/CustomHeads.java b/src/main/java/net/buildtheearth/buildteamtools/utils/CustomHeads.java
similarity index 99%
rename from src/main/java/net/buildtheearth/utils/CustomHeads.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/CustomHeads.java
index a9866201..c56c9076 100644
--- a/src/main/java/net/buildtheearth/utils/CustomHeads.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/CustomHeads.java
@@ -1,5 +1,6 @@
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
+import com.alpsbte.alpslib.utils.item.Item;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
diff --git a/src/main/java/net/buildtheearth/utils/GeometricUtils.java b/src/main/java/net/buildtheearth/buildteamtools/utils/GeometricUtils.java
similarity index 89%
rename from src/main/java/net/buildtheearth/utils/GeometricUtils.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/GeometricUtils.java
index fd492a50..ee2e3c48 100644
--- a/src/main/java/net/buildtheearth/utils/GeometricUtils.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/GeometricUtils.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.utils.geo.CoordinateConversion;
-import net.buildtheearth.utils.io.ConfigPaths;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.utils.geo.CoordinateConversion;
+import net.buildtheearth.buildteamtools.utils.io.ConfigPaths;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@@ -56,10 +56,10 @@ public static Location getLocationFromCoordinatesYawPitch(double[] coordinates,
* @return A bukkit location matching the coordinates. Height is terrain elevation +2.
*/
public static Location getLocationFromCoordinates(double[] coordinates) {
- double[] xz = CoordinateConversion.convertToGeo(coordinates[0], coordinates[1]);
+ double[] xz = CoordinateConversion.convertFromGeo(coordinates[0], coordinates[1]);
double x = xz[0];
- double z = -xz[1];
+ double z = xz[1];
//Creates the location
Location location;
diff --git a/src/main/java/net/buildtheearth/utils/JsonUtils.java b/src/main/java/net/buildtheearth/buildteamtools/utils/JsonUtils.java
similarity index 95%
rename from src/main/java/net/buildtheearth/utils/JsonUtils.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/JsonUtils.java
index fc800e99..b9dff456 100644
--- a/src/main/java/net/buildtheearth/utils/JsonUtils.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/JsonUtils.java
@@ -18,13 +18,9 @@
*
*/
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonIOException;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonSyntaxException;
+import com.google.gson.*;
import com.google.gson.internal.Streams;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
diff --git a/src/main/java/net/buildtheearth/utils/LineRasterization.java b/src/main/java/net/buildtheearth/buildteamtools/utils/LineRasterization.java
similarity index 97%
rename from src/main/java/net/buildtheearth/utils/LineRasterization.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/LineRasterization.java
index 40fa6f80..d8d0432e 100644
--- a/src/main/java/net/buildtheearth/utils/LineRasterization.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/LineRasterization.java
@@ -1,9 +1,9 @@
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
import org.bukkit.Location;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
public class LineRasterization {
diff --git a/src/main/java/net/buildtheearth/utils/ListUtil.java b/src/main/java/net/buildtheearth/buildteamtools/utils/ListUtil.java
similarity index 87%
rename from src/main/java/net/buildtheearth/utils/ListUtil.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/ListUtil.java
index cb832636..fff5eac6 100644
--- a/src/main/java/net/buildtheearth/utils/ListUtil.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/ListUtil.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
import java.util.ArrayList;
diff --git a/src/main/java/net/buildtheearth/utils/MathUtils.java b/src/main/java/net/buildtheearth/buildteamtools/utils/MathUtils.java
similarity index 98%
rename from src/main/java/net/buildtheearth/utils/MathUtils.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/MathUtils.java
index 4d112945..85ab6bd1 100644
--- a/src/main/java/net/buildtheearth/utils/MathUtils.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/MathUtils.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
public class MathUtils {
/**
diff --git a/src/main/java/net/buildtheearth/utils/MenuItems.java b/src/main/java/net/buildtheearth/buildteamtools/utils/MenuItems.java
similarity index 99%
rename from src/main/java/net/buildtheearth/utils/MenuItems.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/MenuItems.java
index f4e1cc29..4f9ddba3 100644
--- a/src/main/java/net/buildtheearth/utils/MenuItems.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/MenuItems.java
@@ -1,5 +1,6 @@
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
diff --git a/src/main/java/net/buildtheearth/utils/PolygonTools.java b/src/main/java/net/buildtheearth/buildteamtools/utils/PolygonTools.java
similarity index 95%
rename from src/main/java/net/buildtheearth/utils/PolygonTools.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/PolygonTools.java
index d768faf0..24bbd70b 100644
--- a/src/main/java/net/buildtheearth/utils/PolygonTools.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/PolygonTools.java
@@ -1,8 +1,7 @@
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
import org.bukkit.Location;
-
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/net/buildtheearth/utils/Utils.java b/src/main/java/net/buildtheearth/buildteamtools/utils/Utils.java
similarity index 98%
rename from src/main/java/net/buildtheearth/utils/Utils.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/Utils.java
index d1446a9d..6780d572 100644
--- a/src/main/java/net/buildtheearth/utils/Utils.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/Utils.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils;
+package net.buildtheearth.buildteamtools.utils;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/net/buildtheearth/buildteamtools/utils/WikiLinks.java b/src/main/java/net/buildtheearth/buildteamtools/utils/WikiLinks.java
new file mode 100644
index 00000000..efa27b07
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/WikiLinks.java
@@ -0,0 +1,37 @@
+package net.buildtheearth.buildteamtools.utils;
+
+import lombok.experimental.UtilityClass;
+
+@UtilityClass
+public class WikiLinks {
+ private static final String WIKI_BASE_URL = "https://resources.buildtheearth.net/doc/";
+ public static final String ENTRY = WIKI_BASE_URL + "build-team-tools-gwhwx9xRsX";
+ public static final String GEN = WIKI_BASE_URL + "generator-module-13zqgI4yFA";
+ public static final String NAV = WIKI_BASE_URL + "sledgehammer-module-T7I0PWPsTD";
+ public static final String MISC = WIKI_BASE_URL + "miscellaneous-appUzeNc5I";
+ public static final String STATS = WIKI_BASE_URL + "statistics-module-iM7IfoKroF";
+ public static final String PLOT = "https://github.com/AlpsBTE/Plot-System/wiki/Installation#setting-up-the-terra-servers";
+
+ @UtilityClass
+ public static class Gen {
+ public static final String RAIL = WIKI_BASE_URL + "rail-generator-EfgKXdBvk1";
+ public static final String ROAD = WIKI_BASE_URL + "road-generator-QqKBBP0nqO";
+ public static final String TREE = WIKI_BASE_URL + "tree-generator-pnDmYC9hzW";
+ public static final String HOUSE = WIKI_BASE_URL + "house-generator-YKQunon6Bp";
+ public static final String FIELD = WIKI_BASE_URL + "field-generator-OqIN2BrZT7";
+
+ @UtilityClass
+ public static class Field {
+ private static final String CROP_BASE = WIKI_BASE_URL + "crop-types-z7ww6RZK2J";
+ public static final String CROP_POTATO = CROP_BASE + "#h-potato-field";
+ public static final String CROP_CORN = CROP_BASE + "#h-corn-field";
+ public static final String CROP_WHEAT = CROP_BASE + "#h-wheat-field";
+ public static final String CROP_HARVESTED = CROP_BASE + "#h-harvested-field";
+ public static final String CROP_OTHER = CROP_BASE + "#h-other";
+ public static final String CROP_VINEYARD = CROP_BASE + "#h-vineyard-field";
+ public static final String CROP_PEAR = CROP_BASE + "#h-pear-field";
+ public static final String CROP_CATTLE = CROP_BASE + "#h-cattle";
+ public static final String CROP_MEADOW = CROP_BASE + "#h-meadow";
+ }
+ }
+}
diff --git a/src/main/java/net/buildtheearth/utils/geo/CoordinateConversion.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/CoordinateConversion.java
similarity index 92%
rename from src/main/java/net/buildtheearth/utils/geo/CoordinateConversion.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/CoordinateConversion.java
index 52b35bdd..c725b53e 100644
--- a/src/main/java/net/buildtheearth/utils/geo/CoordinateConversion.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/CoordinateConversion.java
@@ -22,12 +22,12 @@
* SOFTWARE.
*/
-package net.buildtheearth.utils.geo;
+package net.buildtheearth.buildteamtools.utils.geo;
-import net.buildtheearth.utils.geo.projection.GeographicProjection;
-import net.buildtheearth.utils.geo.projection.OffsetProjectionTransform;
-import net.buildtheearth.utils.geo.projection.OutOfProjectionBoundsException;
-import net.buildtheearth.utils.geo.projection.ScaleProjectionTransform;
+import net.buildtheearth.buildteamtools.utils.geo.projection.GeographicProjection;
+import net.buildtheearth.buildteamtools.utils.geo.projection.OffsetProjectionTransform;
+import net.buildtheearth.buildteamtools.utils.geo.projection.OutOfProjectionBoundsException;
+import net.buildtheearth.buildteamtools.utils.geo.projection.ScaleProjectionTransform;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
diff --git a/src/main/java/net/buildtheearth/utils/geo/projection/GeographicProjection.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/GeographicProjection.java
similarity index 93%
rename from src/main/java/net/buildtheearth/utils/geo/projection/GeographicProjection.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/GeographicProjection.java
index 04b8b61d..06ec5ce6 100644
--- a/src/main/java/net/buildtheearth/utils/geo/projection/GeographicProjection.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/GeographicProjection.java
@@ -1,9 +1,9 @@
-package net.buildtheearth.utils.geo.projection;
+package net.buildtheearth.buildteamtools.utils.geo.projection;
-import net.buildtheearth.utils.geo.projection.airocean.Airocean;
-import net.buildtheearth.utils.geo.projection.airocean.ConformalEstimate;
-import net.buildtheearth.utils.geo.projection.airocean.ModifiedAirocean;
+import net.buildtheearth.buildteamtools.utils.geo.projection.airocean.Airocean;
+import net.buildtheearth.buildteamtools.utils.geo.projection.airocean.ConformalEstimate;
+import net.buildtheearth.buildteamtools.utils.geo.projection.airocean.ModifiedAirocean;
import java.util.HashMap;
import java.util.Map;
diff --git a/src/main/java/net/buildtheearth/utils/geo/projection/InvertableVectorField.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/InvertableVectorField.java
similarity index 96%
rename from src/main/java/net/buildtheearth/utils/geo/projection/InvertableVectorField.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/InvertableVectorField.java
index 19923822..caf88399 100644
--- a/src/main/java/net/buildtheearth/utils/geo/projection/InvertableVectorField.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/InvertableVectorField.java
@@ -1,7 +1,7 @@
-package net.buildtheearth.utils.geo.projection;
+package net.buildtheearth.buildteamtools.utils.geo.projection;
-import net.buildtheearth.utils.MathUtils;
+import net.buildtheearth.buildteamtools.utils.MathUtils;
public class InvertableVectorField {
diff --git a/src/main/java/net/buildtheearth/utils/geo/projection/OffsetProjectionTransform.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/OffsetProjectionTransform.java
similarity index 95%
rename from src/main/java/net/buildtheearth/utils/geo/projection/OffsetProjectionTransform.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/OffsetProjectionTransform.java
index 92d09bd4..28ac4d19 100644
--- a/src/main/java/net/buildtheearth/utils/geo/projection/OffsetProjectionTransform.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/OffsetProjectionTransform.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils.geo.projection;
+package net.buildtheearth.buildteamtools.utils.geo.projection;
import com.google.common.base.Preconditions;
diff --git a/src/main/java/net/buildtheearth/utils/geo/projection/OutOfProjectionBoundsException.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/OutOfProjectionBoundsException.java
similarity index 90%
rename from src/main/java/net/buildtheearth/utils/geo/projection/OutOfProjectionBoundsException.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/OutOfProjectionBoundsException.java
index 93c45e2e..fc5e8ef9 100644
--- a/src/main/java/net/buildtheearth/utils/geo/projection/OutOfProjectionBoundsException.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/OutOfProjectionBoundsException.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils.geo.projection;
+package net.buildtheearth.buildteamtools.utils.geo.projection;
public final class OutOfProjectionBoundsException extends Exception {
private static final OutOfProjectionBoundsException INSTANCE = new OutOfProjectionBoundsException(false);
diff --git a/src/main/java/net/buildtheearth/utils/geo/projection/ProjectionTransform.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/ProjectionTransform.java
similarity index 89%
rename from src/main/java/net/buildtheearth/utils/geo/projection/ProjectionTransform.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/ProjectionTransform.java
index 95e07a9b..9a1dd0aa 100644
--- a/src/main/java/net/buildtheearth/utils/geo/projection/ProjectionTransform.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/ProjectionTransform.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils.geo.projection;
+package net.buildtheearth.buildteamtools.utils.geo.projection;
public abstract class ProjectionTransform extends GeographicProjection {
protected final GeographicProjection input;
diff --git a/src/main/java/net/buildtheearth/utils/geo/projection/ScaleProjectionTransform.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/ScaleProjectionTransform.java
similarity index 96%
rename from src/main/java/net/buildtheearth/utils/geo/projection/ScaleProjectionTransform.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/ScaleProjectionTransform.java
index ab108a2d..50ca09b6 100644
--- a/src/main/java/net/buildtheearth/utils/geo/projection/ScaleProjectionTransform.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/ScaleProjectionTransform.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils.geo.projection;
+package net.buildtheearth.buildteamtools.utils.geo.projection;
import com.google.common.base.Preconditions;
diff --git a/src/main/java/net/buildtheearth/utils/geo/projection/UprightOrientationProjectionTransform.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/UprightOrientationProjectionTransform.java
similarity index 93%
rename from src/main/java/net/buildtheearth/utils/geo/projection/UprightOrientationProjectionTransform.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/UprightOrientationProjectionTransform.java
index 856500f1..05701260 100644
--- a/src/main/java/net/buildtheearth/utils/geo/projection/UprightOrientationProjectionTransform.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/UprightOrientationProjectionTransform.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils.geo.projection;
+package net.buildtheearth.buildteamtools.utils.geo.projection;
/**
* Mirrors the warped projection vertically.
diff --git a/src/main/java/net/buildtheearth/utils/geo/projection/airocean/Airocean.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/airocean/Airocean.java
similarity index 97%
rename from src/main/java/net/buildtheearth/utils/geo/projection/airocean/Airocean.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/airocean/Airocean.java
index 19defd96..a8e636da 100644
--- a/src/main/java/net/buildtheearth/utils/geo/projection/airocean/Airocean.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/airocean/Airocean.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.utils.geo.projection.airocean;
+package net.buildtheearth.buildteamtools.utils.geo.projection.airocean;
-import net.buildtheearth.utils.MathUtils;
-import net.buildtheearth.utils.geo.projection.GeographicProjection;
-import net.buildtheearth.utils.geo.projection.OutOfProjectionBoundsException;
+import net.buildtheearth.buildteamtools.utils.MathUtils;
+import net.buildtheearth.buildteamtools.utils.geo.projection.GeographicProjection;
+import net.buildtheearth.buildteamtools.utils.geo.projection.OutOfProjectionBoundsException;
/**
* Implementation of the Dynmaxion projection.
diff --git a/src/main/java/net/buildtheearth/utils/geo/projection/airocean/ConformalEstimate.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/airocean/ConformalEstimate.java
similarity index 93%
rename from src/main/java/net/buildtheearth/utils/geo/projection/airocean/ConformalEstimate.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/airocean/ConformalEstimate.java
index 57715f45..b868ad55 100644
--- a/src/main/java/net/buildtheearth/utils/geo/projection/airocean/ConformalEstimate.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/airocean/ConformalEstimate.java
@@ -1,7 +1,7 @@
-package net.buildtheearth.utils.geo.projection.airocean;
+package net.buildtheearth.buildteamtools.utils.geo.projection.airocean;
-import net.buildtheearth.utils.MathUtils;
-import net.buildtheearth.utils.geo.projection.InvertableVectorField;
+import net.buildtheearth.buildteamtools.utils.MathUtils;
+import net.buildtheearth.buildteamtools.utils.geo.projection.InvertableVectorField;
import java.io.IOException;
import java.io.InputStream;
diff --git a/src/main/java/net/buildtheearth/utils/geo/projection/airocean/ModifiedAirocean.java b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/airocean/ModifiedAirocean.java
similarity index 94%
rename from src/main/java/net/buildtheearth/utils/geo/projection/airocean/ModifiedAirocean.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/airocean/ModifiedAirocean.java
index 3e84fb75..0f224892 100644
--- a/src/main/java/net/buildtheearth/utils/geo/projection/airocean/ModifiedAirocean.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/geo/projection/airocean/ModifiedAirocean.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.utils.geo.projection.airocean;
+package net.buildtheearth.buildteamtools.utils.geo.projection.airocean;
-import net.buildtheearth.utils.MathUtils;
-import net.buildtheearth.utils.geo.projection.OutOfProjectionBoundsException;
+import net.buildtheearth.buildteamtools.utils.MathUtils;
+import net.buildtheearth.buildteamtools.utils.geo.projection.OutOfProjectionBoundsException;
/**
* Implementation of the BTE modified Dynmaxion projection.
diff --git a/src/main/java/net/buildtheearth/utils/io/ConfigPaths.java b/src/main/java/net/buildtheearth/buildteamtools/utils/io/ConfigPaths.java
similarity index 98%
rename from src/main/java/net/buildtheearth/utils/io/ConfigPaths.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/io/ConfigPaths.java
index e8831afa..9258c538 100644
--- a/src/main/java/net/buildtheearth/utils/io/ConfigPaths.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/io/ConfigPaths.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils.io;
+package net.buildtheearth.buildteamtools.utils.io;
public abstract class ConfigPaths {
diff --git a/src/main/java/net/buildtheearth/utils/io/ConfigUtil.java b/src/main/java/net/buildtheearth/buildteamtools/utils/io/ConfigUtil.java
similarity index 97%
rename from src/main/java/net/buildtheearth/utils/io/ConfigUtil.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/io/ConfigUtil.java
index b043f629..e7b20228 100644
--- a/src/main/java/net/buildtheearth/utils/io/ConfigUtil.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/io/ConfigUtil.java
@@ -22,7 +22,7 @@
* SOFTWARE.
*/
-package net.buildtheearth.utils.io;
+package net.buildtheearth.buildteamtools.utils.io;
import com.alpsbte.alpslib.io.config.ConfigNotImplementedException;
import com.alpsbte.alpslib.io.config.ConfigurationUtil;
diff --git a/src/main/java/net/buildtheearth/utils/io/Constants.java b/src/main/java/net/buildtheearth/buildteamtools/utils/io/Constants.java
similarity index 89%
rename from src/main/java/net/buildtheearth/utils/io/Constants.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/io/Constants.java
index 463e3b33..a1e85fa2 100644
--- a/src/main/java/net/buildtheearth/utils/io/Constants.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/io/Constants.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils.io;
+package net.buildtheearth.buildteamtools.utils.io;
public class Constants {
diff --git a/src/main/java/net/buildtheearth/utils/io/Errors.java b/src/main/java/net/buildtheearth/buildteamtools/utils/io/Errors.java
similarity index 92%
rename from src/main/java/net/buildtheearth/utils/io/Errors.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/io/Errors.java
index ba5fcb12..823f0e9d 100644
--- a/src/main/java/net/buildtheearth/utils/io/Errors.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/io/Errors.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils.io;
+package net.buildtheearth.buildteamtools.utils.io;
public class Errors {
diff --git a/src/main/java/net/buildtheearth/utils/io/LangPaths.java b/src/main/java/net/buildtheearth/buildteamtools/utils/io/LangPaths.java
similarity index 96%
rename from src/main/java/net/buildtheearth/utils/io/LangPaths.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/io/LangPaths.java
index d10ac862..91ba9860 100644
--- a/src/main/java/net/buildtheearth/utils/io/LangPaths.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/io/LangPaths.java
@@ -22,7 +22,7 @@
* SOFTWARE.
*/
-package net.buildtheearth.utils.io;
+package net.buildtheearth.buildteamtools.utils.io;
public abstract class LangPaths {
private static final String LANG = "lang.";
diff --git a/src/main/java/net/buildtheearth/utils/io/LangUtil.java b/src/main/java/net/buildtheearth/buildteamtools/utils/io/LangUtil.java
similarity index 97%
rename from src/main/java/net/buildtheearth/utils/io/LangUtil.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/io/LangUtil.java
index c94657d0..a7a66d50 100644
--- a/src/main/java/net/buildtheearth/utils/io/LangUtil.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/io/LangUtil.java
@@ -22,7 +22,7 @@
* SOFTWARE.
*/
-package net.buildtheearth.utils.io;
+package net.buildtheearth.buildteamtools.utils.io;
import com.alpsbte.alpslib.io.lang.LanguageUtil;
diff --git a/src/main/java/net/buildtheearth/utils/menus/AbstractMenu.java b/src/main/java/net/buildtheearth/buildteamtools/utils/menus/AbstractMenu.java
similarity index 96%
rename from src/main/java/net/buildtheearth/utils/menus/AbstractMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/menus/AbstractMenu.java
index 1b588b8f..94d30121 100644
--- a/src/main/java/net/buildtheearth/utils/menus/AbstractMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/menus/AbstractMenu.java
@@ -1,10 +1,9 @@
-package net.buildtheearth.utils.menus;
+package net.buildtheearth.buildteamtools.utils.menus;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.CustomHeads;
-import net.buildtheearth.utils.Item;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
diff --git a/src/main/java/net/buildtheearth/utils/menus/AbstractPaginatedMenu.java b/src/main/java/net/buildtheearth/buildteamtools/utils/menus/AbstractPaginatedMenu.java
similarity index 96%
rename from src/main/java/net/buildtheearth/utils/menus/AbstractPaginatedMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/menus/AbstractPaginatedMenu.java
index fe022cf9..b6eb6ae1 100644
--- a/src/main/java/net/buildtheearth/utils/menus/AbstractPaginatedMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/menus/AbstractPaginatedMenu.java
@@ -1,7 +1,7 @@
-package net.buildtheearth.utils.menus;
+package net.buildtheearth.buildteamtools.utils.menus;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
diff --git a/src/main/java/net/buildtheearth/utils/menus/BlockListMenu.java b/src/main/java/net/buildtheearth/buildteamtools/utils/menus/BlockListMenu.java
similarity index 95%
rename from src/main/java/net/buildtheearth/utils/menus/BlockListMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/menus/BlockListMenu.java
index a59b0a20..5aee3e70 100644
--- a/src/main/java/net/buildtheearth/utils/menus/BlockListMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/menus/BlockListMenu.java
@@ -1,8 +1,8 @@
-package net.buildtheearth.utils.menus;
+package net.buildtheearth.buildteamtools.utils.menus;
-import net.buildtheearth.utils.CustomHeads;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
+import com.alpsbte.alpslib.utils.item.Item;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
diff --git a/src/main/java/net/buildtheearth/utils/menus/BookMenu.java b/src/main/java/net/buildtheearth/buildteamtools/utils/menus/BookMenu.java
similarity index 96%
rename from src/main/java/net/buildtheearth/utils/menus/BookMenu.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/menus/BookMenu.java
index f04828a3..20962aa4 100644
--- a/src/main/java/net/buildtheearth/utils/menus/BookMenu.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/menus/BookMenu.java
@@ -1,11 +1,10 @@
-package net.buildtheearth.utils.menus;
+package net.buildtheearth.buildteamtools.utils.menus;
+import com.alpsbte.alpslib.utils.item.Item;
import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.MenuItems;
+import net.buildtheearth.buildteamtools.BuildTeamTools;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
import org.bukkit.Bukkit;
-import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
diff --git a/src/main/java/net/buildtheearth/buildteamtools/utils/menus/NameListMenu.java b/src/main/java/net/buildtheearth/buildteamtools/utils/menus/NameListMenu.java
new file mode 100644
index 00000000..f22ee90f
--- /dev/null
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/menus/NameListMenu.java
@@ -0,0 +1,133 @@
+package net.buildtheearth.buildteamtools.utils.menus;
+
+import com.alpsbte.alpslib.utils.item.Item;
+import net.buildtheearth.buildteamtools.utils.CustomHeads;
+import net.buildtheearth.buildteamtools.utils.MenuItems;
+import net.daporkchop.lib.common.misc.Tuple;
+import org.bukkit.enchantments.Enchantment;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.ipvp.canvas.mask.BinaryMask;
+import org.ipvp.canvas.mask.Mask;
+import org.jspecify.annotations.NonNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A menu that allows the player to select a block from a list of blocks. It is possible to switch pages and to proceed to the next menu once a block has been selected. It is also possible to select multiple blocks.
+ * To change the items that are displayed in the menu, override the {@link #getSource()} method.
+ * To perform an action when a block is selected, override the {@link #setItemClickEventsAsync()} method.
+ */
+public class NameListMenu extends AbstractPaginatedMenu {
+
+ public static final int SWITCH_PAGE_ITEM_SLOT = 31;
+ public static final int NEXT_ITEM_SLOT = 35;
+ public static final int BACK_ITEM_SLOT = 27;
+
+ protected final List selectedNames;
+ private final List> items;
+
+ private final AbstractMenu backMenu;
+
+
+ public NameListMenu(Player player, String invName, List> items, AbstractMenu backMenu, boolean autoLoad) {
+ super(4, 3, invName, player, autoLoad);
+
+ this.items = items;
+ this.backMenu = backMenu;
+ selectedNames = new ArrayList<>();
+ }
+
+ @Override
+ protected void setPreviewItems() {
+ if (backMenu != null)
+ setBackItem(BACK_ITEM_SLOT, backMenu);
+
+ setSwitchPageItems(SWITCH_PAGE_ITEM_SLOT);
+
+ if (canProceed())
+ getMenu().getSlot(NEXT_ITEM_SLOT).setItem(CustomHeads.getCheckmarkItem("§eNext"));
+ else
+ getMenu().getSlot(NEXT_ITEM_SLOT).setItem(MenuItems.ITEM_BACKGROUND);
+
+ super.setPreviewItems();
+ }
+
+ @Override
+ protected void setMenuItemsAsync() {
+ //
+ }
+
+ @Override
+ protected void setItemClickEventsAsync() {
+ setSwitchPageItemClickEvents(SWITCH_PAGE_ITEM_SLOT);
+ }
+
+ @Override
+ protected Mask getMask() {
+ String backSlot = backMenu == null ? "1" : "0";
+
+ return BinaryMask.builder(getMenu())
+ .item(MenuItems.ITEM_BACKGROUND)
+ .pattern("000000000")
+ .pattern("000000000")
+ .pattern("000000000")
+ .pattern(backSlot + "11000110")
+ .build();
+ }
+
+ @Override
+ protected List> getSource() {
+ return items;
+ }
+
+ @Override
+ protected void setPaginatedPreviewItems(List> source) {
+ // Set pagignated items
+ List> pagItems = source.stream().map(l -> (Tuple) l).toList();
+ int slot = 0;
+ for (Tuple item : pagItems) {
+ if (selectedNames.contains(item.getB()))
+ item.setA(new Item(item.getA()).setAmount(1).addEnchantment(Enchantment.LUCK_OF_THE_SEA, 1).hideEnchantments(true).build());
+
+ getMenu().getSlot(slot).setItem(item.getA());
+ slot++;
+ }
+ }
+
+ @Override
+ protected void setPaginatedMenuItemsAsync(List> source) {
+ // No Async / DB Items
+ }
+
+ @Override
+ protected void setPaginatedItemClickEventsAsync(@NonNull List> source) {
+ List> pagItems = source.stream().map(l -> (Tuple) l).toList();
+ int slot = 0;
+ for (Tuple item : pagItems) {
+ final int _slot = slot;
+ getMenu().getSlot(_slot).setClickHandler((clickPlayer, clickInformation) -> {
+ String type = (item.getB().toLowerCase());
+
+ if (selectedNames.contains(type))
+ selectedNames.remove(type);
+ else
+ selectedNames.add(type);
+
+ reloadMenuAsync();
+ });
+ slot++;
+ }
+ }
+
+ /**
+ * Checks if the player has selected at least one block.
+ *
+ * @return true if the player has selected at least one block, false otherwise.
+ */
+ protected boolean canProceed() {
+ return !selectedNames.isEmpty();
+ }
+}
+
diff --git a/src/main/java/net/buildtheearth/utils/raycast/Raycast.java b/src/main/java/net/buildtheearth/buildteamtools/utils/raycast/Raycast.java
similarity index 99%
rename from src/main/java/net/buildtheearth/utils/raycast/Raycast.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/raycast/Raycast.java
index b400cef6..bd68a22c 100644
--- a/src/main/java/net/buildtheearth/utils/raycast/Raycast.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/raycast/Raycast.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils.raycast;
+package net.buildtheearth.buildteamtools.utils.raycast;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Location;
diff --git a/src/main/java/net/buildtheearth/utils/raycast/RaycastAPIMath.java b/src/main/java/net/buildtheearth/buildteamtools/utils/raycast/RaycastAPIMath.java
similarity index 97%
rename from src/main/java/net/buildtheearth/utils/raycast/RaycastAPIMath.java
rename to src/main/java/net/buildtheearth/buildteamtools/utils/raycast/RaycastAPIMath.java
index b60510b7..17f2c3a9 100644
--- a/src/main/java/net/buildtheearth/utils/raycast/RaycastAPIMath.java
+++ b/src/main/java/net/buildtheearth/buildteamtools/utils/raycast/RaycastAPIMath.java
@@ -1,4 +1,4 @@
-package net.buildtheearth.utils.raycast;
+package net.buildtheearth.buildteamtools.utils.raycast;
import org.bukkit.util.Vector;
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/kml/KmlCommand.java b/src/main/java/net/buildtheearth/modules/generator/components/kml/KmlCommand.java
deleted file mode 100644
index f0e4dd42..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/components/kml/KmlCommand.java
+++ /dev/null
@@ -1,502 +0,0 @@
-package net.buildtheearth.modules.generator.components.kml;
-
-import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.utils.BlockLocation;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.GeometricUtils;
-import net.buildtheearth.utils.LineRasterization;
-import net.buildtheearth.utils.PolygonTools;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.Stack;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.stream.Collectors;
-import java.util.HashSet;
-
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.Material;
-
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.command.BlockCommandSender;
-
-import org.bukkit.entity.Player;
-
-import de.micromata.opengis.kml.v_2_2_0.Coordinate;
-
-import org.bukkit.World;
-
-import org.bukkit.block.Block;
-import org.bukkit.block.BlockState;
-import org.bukkit.block.CommandBlock;
-
-import org.bukkit.metadata.FixedMetadataValue;
-
-
- /** Class to handle kml command and its aliases
- *
- * Since kml content easily exceeds the normal chat/character limit,
- * we use the following workflow:
- *
- * if sent from a player, generates a CommandBlock and adds some metadata to it
- * the player then pastes the kml contents and confirms the command
- *
- * the CommandBlock then sends a kml command with the contents, which is parsed by the server
- *
- * note: this command differentiates between aliases to determine wether to
- * generate intermediate points between the geo-coordinates from the kml linestrings.
- * Players should only use /geopoints or /geopath aliases,
- * direct use of the /kml command is restricted to CommandBlockSender
- *
- */
-public class KmlCommand implements CommandExecutor {
-
-
- /** Command handling
- *
- */
- public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
- if (sender instanceof BlockCommandSender){
- Block senderBlock = ((BlockCommandSender)sender).getBlock();
-
- return processKml(senderBlock, args);
- }
-
- if(!(sender instanceof Player)){
- sender.sendMessage("§cOnly players can execute this command.");
- return false;
- }
-
-
- Player p = (Player) sender;
- if (args.length > 0 && args[0].equals("undo")){
- return undoCommand(p);
- }
-
- // //TESTING location/elevation code
- // Block targetedBlock = p.getTargetBlock(null, 10);
- // Location targetedLocation = targetedBlock.getLocation();
- // int highY = p.getWorld().getHighestBlockYAt(targetedLocation);
- // p.sendMessage(String.format("elevation test: targeted block (%s) location Y %d (%f), highestY %d",
- // targetedBlock.getType().toString(), targetedLocation.getBlockY(), targetedLocation.getY(),highY));
-
-
- //check if alias is geopoints or geopath (direct /kml is only allowed for undo)
- if (alias.equals("kml")){
- sender.sendMessage("§cPlease use /geopoints or /geopath to execute this command.");
- return false;
- }
-
- return createPasteUI(p, cmd, alias, args);
- }
-
- void addSingleLocation(BlockLocation loc, boolean extendToGround, World world, Set container, Set fillPositions)
- {
- container.add(loc);
- if (extendToGround)
- fillVerticalToTerrain(loc, world, fillPositions);
- }
-
- void addLocations(List locs, boolean extendToGround, World world, Set container, Set fillPositions)
- {
- for (BlockLocation loc : locs)
- addSingleLocation(loc, extendToGround, world, container, fillPositions);
- }
-
- void fillVerticalToTerrain(BlockLocation locationOverGround, World world, Set container)
- {
- int terrainElevation = world.getHighestBlockYAt(locationOverGround.x, locationOverGround.z);
- for (int y = terrainElevation; y < locationOverGround.y; y++){
- container.add(new BlockLocation(locationOverGround.x, y, locationOverGround.z));
- }
- }
- /**
- * @param senderBlock
- * @param args
- * @return boolean
- */
- public boolean processKml(Block senderBlock, String[] args){
- long time_start = System.currentTimeMillis();
-
-
- //read metadata to get player name/ID
- BlockState blockState = senderBlock.getState();
- String playerName = blockState.getMetadata("kmlPlayerName").get(0).asString();
- String blocktypeString = blockState.getMetadata("kmlBlocktype").get(0).asString();
- String previousCommandBlockType = blockState.getMetadata("kmlPreviousBlocktype").get(0).asString();
- String blockCreationCommand = blockState.getMetadata("kmlBlockCreationCommand").get(0).asString();
- BlockCreationMode operationMode = commandToCreationMode(blockCreationCommand);
-
- boolean extendToGround = blockState.getMetadata("kmlExtendToGround").get(0).asBoolean();
- String extendToGroundBlockType = blockState.getMetadata("kmlExtendToGroundBlocktype").get(0).asString();
-
-
- if (playerName == "" || blocktypeString == ""){
- //invalid metadata, cancel
- //send error message to all players within 50m of the command block
- ChatHelper.sendMessageToPlayersNearLocation(
- senderBlock.getLocation(),
- "§cReceived /kml command from CommandBlock without sufficient metadata.\nThis command can only be executed from a CommandBlock created with the /kml command!",
- 50);
- return false;
- }
-
- Player player = Bukkit.getServer().getPlayer(playerName);
-
- if (player == null){
- return false;
- }
-
- String kml_content = String.join(" ", args);
- // player.sendMessage(String.format("§creceived /kml command with blocktypestring %s and and kml length %d: %s",
- // blocktypeString, kml_content.length(), kml_content));
-
- Material blockMaterial = Material.matchMaterial(blocktypeString);
- if (blockMaterial == null){
- player.sendMessage("§cServer received /kml command with invalid blocktype string metadata. Using bricks as fallback.");
- blockMaterial = Material.BRICK;
- }
- Material extendMaterial = Material.matchMaterial(extendToGroundBlockType);
- if (extendMaterial == null){
- player.sendMessage("§cServer received /kml command with invalid blocktype string metadata. Using bricks as fallback.");
- extendMaterial = Material.BRICK;
- }
-
-
- //parse kml
- long time_beforeKMLParse = System.currentTimeMillis();
-
-
-
- KmlParser parser = new KmlParser(player); // we pass the player here to be able to report parsing errors
- List> geoCoords = parser.extractCoordinates(kml_content);
- long time_afterKMLParse = System.currentTimeMillis();
-
-
- World world = senderBlock.getWorld();
-
- List> mcLocations = convertToMC(geoCoords, world);
- long time_afterProjection = System.currentTimeMillis();
-
-
- //set up a transaction (collection of block changes)
- ChangeTransaction transaction = new ChangeTransaction(player);
-
- //collect all blocklocations in a set
- //if just iterate and create blocks one by one, we create multiple blocks at the same XZ coordinates,
- // this also stacks them vertically because we check terrain altitude.
- Set blockPositions = new HashSet<>();
- Set fillPositions = new HashSet<>();
-
-
-
- for (List polyline : mcLocations)
- {
- if (operationMode == BlockCreationMode.FILLED)
- blockPositions = triangulateAndFill(polyline);
- else{
- //rasterize line and create intermediate blocks
- //note: iteration starts at second block, so we always have a previous block to draw the line
- //for single point mode, we explicitly add the first block
- if (operationMode == BlockCreationMode.POINTS)
- {
- BlockLocation loc = new BlockLocation(polyline.get(0));
- addSingleLocation(loc, extendToGround, world, blockPositions, fillPositions);
- }
-
- for (int i = 1; i < polyline.size(); ++i)
- {
- if (operationMode == BlockCreationMode.POINTS)
- {
- BlockLocation loc = new BlockLocation(polyline.get(i));
- addSingleLocation(loc, extendToGround, world, blockPositions, fillPositions);
- }
- else //interpolate
- {
- addLocations(LineRasterization.rasterizeLine(polyline.get(i-1), polyline.get(i)),
- extendToGround, world, blockPositions, fillPositions);
- }
- }
-
- //for closed-path-mode, add extra line between start and end
- if (operationMode == BlockCreationMode.CLOSED_PATH)
- {
- addLocations(LineRasterization.rasterizeLine(polyline.get(0), polyline.get(polyline.size()-1))
- , extendToGround, world, blockPositions, fillPositions);
- }
- }
-
- }
-
- //now create the blocks
- // restrictions: only if block is loaded, and only within 1000 blocks of the current player location
- boolean preventedUnloadedChunkChanges = false;
- boolean preventedFarChanges = false;
-
- float maxDistanceToPlayer = 1000; //TODO server config
-
- for (BlockLocation pt : blockPositions)
- {
- Location loc = pt.getLocation(world);
- if (!loc.getChunk().isLoaded())
- preventedUnloadedChunkChanges = true;
- else if (loc.distance(player.getLocation()) > maxDistanceToPlayer)
- preventedFarChanges = true;
- else
- {
- transaction.addBlockChange(pt, world, blockMaterial);
- }
- }
-
- for (BlockLocation pt : fillPositions)
- {
- Location loc = pt.getLocation(world);
- if (!loc.getChunk().isLoaded())
- preventedUnloadedChunkChanges = true;
- else if (loc.distance(player.getLocation()) > maxDistanceToPlayer)
- preventedFarChanges = true;
- else
- {
- transaction.addBlockChange(pt, world, extendMaterial);
- }
- }
-
-
- if (transaction.size() == 0){
- player.sendMessage("§ckml command did not contain any allowed block changes.\nThis command can only change blocks near your current location, and cannot load new chunks.");
- return false;
- }
-
- //create commandHistory if not exits
- if (this.playerHistories == null)
- this.playerHistories = new HashMap<>();
-
- if (! playerHistories.containsKey(player))
- playerHistories.put(player, new Stack<>());
-
- Stack playerHistory = playerHistories.get(player);
-
- playerHistory.push(transaction);
-
-
- long time_beforeBlockChange = System.currentTimeMillis();
-
-
- player.sendMessage(String.format("KML parsing: %d ms. BTE Projection: %d ms, Transaction preparation: %d ms. Changing %d blocks, please stand by."
- , (time_afterKMLParse-time_beforeKMLParse)
- , (time_afterProjection - time_afterKMLParse )
- , (time_beforeBlockChange - time_afterProjection), transaction.size()));
-
- int blocksChanged = transaction.commit();
-
- long time_afterBlockChanged = System.currentTimeMillis();
- player.sendMessage(String.format("KML command changed %d blocks (%d ms).", blocksChanged, (time_afterBlockChanged - time_beforeBlockChange)));
-
-
- if (preventedUnloadedChunkChanges){
- player.sendMessage("§cSome block changes target unloaded chunks and were not applied.");
- }
- if (preventedFarChanges){
- player.sendMessage("§cSome block changes target blocks too far away from the player and were not applied.");
- }
-
- Material material = Material.matchMaterial(previousCommandBlockType);
-
- if (material == null){
- player.sendMessage("§cServer received /kml command with invalid blocktype string metadata. Using bricks as fallback.");
- material = Material.BRICK;
- }
-
- //Delete command block, restore previous type
- senderBlock.setType(material);
- return true;
- }
-
- private Set triangulateAndFill(List polyline) {
- Setresult = new HashSet<>();
- //triangulate the polygon
- List triangles = PolygonTools.triangulatePolygon(polyline);
- //fill with bresenham. for now, just all border-lines
- for (PolygonTools.Triangle tri : triangles){
- result.addAll(PolygonTools.rasterizeTriangle(tri));
-
- //dEBUG: ALL triangle borders
- result.addAll(LineRasterization.rasterizeLine(tri.getVertex1(), tri.getVertex2()));
- result.addAll(LineRasterization.rasterizeLine(tri.getVertex1(), tri.getVertex3()));
- result.addAll(LineRasterization.rasterizeLine(tri.getVertex2(), tri.getVertex3()));
- }
- return result;
- }
-
-
-
- public boolean createPasteUI(Player player, Command cmd, String alias, String[] args){
- //The command either creates a command-block at the player location
- //arguments are an
- // optional blocktype
- // optional -toGround:blockType
- String blocktype = "BRICK";
- boolean extendToGround = false;
- String extendToGroundBlockType = "GREEN_WOOL";
- String prefix_extendParam = "-extend:";
- for (String arg : args)
- {
- if (arg.startsWith(prefix_extendParam)){
- extendToGround = true;
- extendToGroundBlockType = arg.substring(prefix_extendParam.length()).toUpperCase();
-
- if (Material.matchMaterial(extendToGroundBlockType) == null) {
- player.sendMessage(String.format("§cInvalid block type for extend parameter '%s'. Using bricks as fallback.", extendToGroundBlockType));
- extendToGroundBlockType = "BRICK";
- }
- }else{
- blocktype = arg.toUpperCase();
-
- if (Material.matchMaterial(blocktype) == null) {
- player.sendMessage(String.format("§cInvalid block type '%s'. Using bricks as fallback.", blocktype));
- blocktype = "BRICK";
- }
- }
-
-
- }
-
-
- //spawn a command block in front of the player
- Location commandBlockLocation = player.getLocation().add(player.getLocation().getDirection().multiply(2));
- commandBlockLocation = commandBlockLocation.add(0, 2, 0);
-
- World world = commandBlockLocation.getWorld();
- Block block = world.getBlockAt(commandBlockLocation);
-
- Material previousMaterial = block.getType(); //remember old blocktype to replace after command processing
-
- if(XMaterial.COMMAND_BLOCK.parseMaterial() != null)
- block.setType(XMaterial.COMMAND_BLOCK.parseMaterial());
-
- //for now, user has to manually set the command to "auto" to get it immediately triggered on confirm
- CommandBlock cmdBlock = (CommandBlock) block.getState();
-
- cmdBlock.setCommand("/kml "); //ready to paste kml content
- cmdBlock.setMetadata("kmlPlayerName", new FixedMetadataValue(BuildTeamTools.getInstance(), player.getName()));
- //cmdBlock.setMetadata("kmlPlayerID", new FixedMetadataValue(BuildTeamTools.getInstance(), p.getUniqueId()));
- cmdBlock.setMetadata("kmlBlocktype", new FixedMetadataValue(BuildTeamTools.getInstance(), blocktype));
- cmdBlock.setMetadata("kmlExtendToGround", new FixedMetadataValue(BuildTeamTools.getInstance(), extendToGround));
- cmdBlock.setMetadata("kmlExtendToGroundBlocktype", new FixedMetadataValue(BuildTeamTools.getInstance(), extendToGroundBlockType));
-
- cmdBlock.setMetadata("kmlPreviousBlocktype", new FixedMetadataValue(BuildTeamTools.getInstance(), previousMaterial.toString()));
-
- cmdBlock.setMetadata("kmlBlockCreationCommand", new FixedMetadataValue(BuildTeamTools.getInstance(), alias));
-
- cmdBlock.update();
- player.sendMessage("§6Command block created. Right click the block, paste the KML content, set it to 'always on' and confirm");
- return true;
-
- }
-
- public boolean undoCommand(Player player){
- if (playerHistories==null){
- player.sendMessage("kml undo failed - no command history available.");
- return false;
- }
-
- Stack playerHistory = playerHistories.get(player);
-
- if (playerHistory == null || playerHistory.empty()){
- player.sendMessage("kml undo failed - there is no previously executed kml command.");
- return false;
- }
-
- ChangeTransaction transaction = playerHistory.pop();
- transaction.undo();
- player.sendMessage(String.format("undo successful. Restored %d blocks.", transaction.size()));
- return true;
- }
-
- public static void sendHelp(CommandSender sender){
- //ChatUtil.sendMessageBox(sender, "GML Command", () -> {
- // sender.sendMessage("§eHouse Generator:§7 /gml help");
- //});
- }
-
- private Location getLocationFromCoordinates(double[] coordinates, double altitudeFromKML)
- {
- Location mcLocation = GeometricUtils.getLocationFromCoordinates(coordinates);
- //add altitude from kml (altitude from Google Earth is always relative to ground)
- //note: the "-2" is only neccesary because
- // getLocationFromCoordinates returns terrain altitude + 2
- // (one from Bukkits getHighestBlockY and one from our geoutils)
- mcLocation.add(0, altitudeFromKML - 2, 0);
- return mcLocation;
- }
-
- private List > convertToMC(List> geocoords_lists, World world){
-
- List > mcLines = new ArrayList<>();
-
- //This lat/long to xyz conversion takes most of the runtime for this command
- // since the conversions do not influence each other, we can parallelize them.
- for (List geocoords : geocoords_lists){
- // ExecutorService to manage the threads
- ExecutorService executorService = Executors.newFixedThreadPool(geocoords.size());
-
- // List to store CompletableFuture results
- List> completableFutureList = new ArrayList<>();
-
- // Create a CompletableFuture for each set of coordinates
- for (Coordinate geocoord : geocoords) {
- double[] coordinates = new double[]{geocoord.getLatitude(), geocoord.getLongitude()};
-
- CompletableFuture completableFuture = CompletableFuture.supplyAsync(() ->
- getLocationFromCoordinates(coordinates, geocoord.getAltitude()), executorService);
- completableFutureList.add(completableFuture);
- }
-
- // Combine all CompletableFutures into a single CompletableFuture representing all of them
- CompletableFuture allOf = CompletableFuture.allOf(
- completableFutureList.toArray(new CompletableFuture[0])
- );
-
- // Wait for all CompletableFutures to complete
- allOf.join();
-
- // Collect the results from the CompletableFutures
- List mcLine = completableFutureList.stream()
- .map(CompletableFuture::join)
- .collect(Collectors.toList());
-
- mcLines.add(mcLine);
-
- // Shutdown the ExecutorService
- executorService.shutdown();
- }
- return mcLines;
- }
-
- private BlockCreationMode commandToCreationMode(String command){
- if (command.equals("geopoints"))
- return BlockCreationMode.POINTS;
- else if (command.equals("geopath"))
- return BlockCreationMode.PATH;
- else if (command.equals("georing"))
- return BlockCreationMode.CLOSED_PATH;
- else if (command.equals("geosurface"))
- {
- throw new UnsupportedOperationException("Operation mode 'filled surface' is not yet implemented");
- //return BlockCreationMode.FILLED;
- }
- else
- throw new IllegalArgumentException(command);
-
- }
-
- private HashMap> playerHistories;
-}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/rail/Rail.java b/src/main/java/net/buildtheearth/modules/generator/components/rail/Rail.java
deleted file mode 100644
index c7056f34..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/components/rail/Rail.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package net.buildtheearth.modules.generator.components.rail;
-
-import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
-import com.sk89q.worldedit.regions.Region;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.GeneratorComponent;
-import net.buildtheearth.modules.generator.model.GeneratorType;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-public class Rail extends GeneratorComponent {
-
- public Rail() {
- super(GeneratorType.RAILWAY);
-
- wikiPage = "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Road-Command";
- }
-
- @Override
- public boolean checkForPlayer(Player p) {
- return !GeneratorUtils.checkForNoWorldEditSelection(p);
-
- /* Only needed if block checks are made afterwards like in House Generator
- if (getPlayerSettings().get(p.getUniqueId()).getBlocks() == null)
- getPlayerSettings().get(p.getUniqueId()).setBlocks(GeneratorUtils.analyzeRegion(p, p.getWorld()));*/
- }
-
- @Override
- public void generate(Player p) {
- if (!GeneratorModule.getInstance().getRail().checkForPlayer(p))
- return;
-
- new RailScripts(p, this);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/road/Road.java b/src/main/java/net/buildtheearth/modules/generator/components/road/Road.java
deleted file mode 100644
index 50ec00ca..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/components/road/Road.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package net.buildtheearth.modules.generator.components.road;
-
-import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
-import com.sk89q.worldedit.regions.Region;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.GeneratorComponent;
-import net.buildtheearth.modules.generator.model.GeneratorType;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
-import org.bukkit.entity.Player;
-
-public class Road extends GeneratorComponent {
-
- public Road() {
- super(GeneratorType.ROAD);
-
- wikiPage = "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Road-Command";
- }
-
- @Override
- public boolean checkForPlayer(Player p) {
- return !GeneratorUtils.checkForNoWorldEditSelection(p);
-
- /* Only needed if block checks are made afterwards like in House Generator
- if (getPlayerSettings().get(p.getUniqueId()).getBlocks() == null)
- getPlayerSettings().get(p.getUniqueId()).setBlocks(GeneratorUtils.analyzeRegion(p, p.getWorld()));*/
- }
-
- @Override
- public void generate(Player p) {
- if (!GeneratorModule.getInstance().getRoad().checkForPlayer(p))
- return;
-
- new RoadScripts(p, this);
- }
-}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/tree/Tree.java b/src/main/java/net/buildtheearth/modules/generator/components/tree/Tree.java
deleted file mode 100644
index d1474bbc..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/components/tree/Tree.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package net.buildtheearth.modules.generator.components.tree;
-
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.GeneratorCollections;
-import net.buildtheearth.modules.generator.model.GeneratorComponent;
-import net.buildtheearth.modules.generator.model.GeneratorType;
-import net.buildtheearth.modules.generator.utils.GeneratorUtils;
-import org.bukkit.entity.Player;
-
-public class Tree extends GeneratorComponent {
-
- public static String TREE_PACK_VERSION = "v2.0";
-
-
- public Tree() {
- super(GeneratorType.TREE);
-
- wikiPage = "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Tree-Command";
- }
-
- @Override
- public boolean checkForPlayer(Player p) {
- if (!GeneratorCollections.checkIfGeneratorCollectionsIsInstalled(p))
- return false;
-
- /* Only needed if block checks are made afterwards like in House Generator
- if (getPlayerSettings().get(p.getUniqueId()).getBlocks() == null)
- getPlayerSettings().get(p.getUniqueId()).setBlocks(GeneratorUtils.analyzeRegion(p, p.getWorld()));*/
-
- return GeneratorUtils.checkIfSchematicBrushIsInstalled(p);
- }
-
- @Override
- public void generate(Player p) {
- if (!GeneratorModule.getInstance().getRoad().checkForPlayer(p))
- return;
-
- TreeScripts.treescript_v_1_0(p, this);
- }
-}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeScripts.java b/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeScripts.java
deleted file mode 100644
index e6c2dfe4..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeScripts.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package net.buildtheearth.modules.generator.components.tree;
-
-import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.utils.Item;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-
-public class TreeScripts {
-
- public static void treescript_v_1_0(Player p, Tree tree) {
- String[] args = new String[4];
-
- Settings settings = tree.getPlayerSettings().get(p.getUniqueId());
- args[1] = (String) settings.getValues().get(TreeFlag.TYPE);
- args[2] = (String) settings.getValues().get(TreeFlag.HEIGHT);
- args[3] = (String) settings.getValues().get(TreeFlag.WIDTH);
-
-
- // In case the player is holding no item, give him a diamond sword
- if(p.getItemOnCursor() == null || p.getInventory().getItemInMainHand().getType() == Material.AIR)
- p.getInventory().setItem(p.getInventory().getHeldItemSlot(), Item.create(XMaterial.DIAMOND_SWORD.parseMaterial()));
-
-
- if(args.length == 1) {
- p.chat("//schbr newtrees/*@** -place:bottom -yoff:2");
-
- }else if(args.length >= 2) {
- String type = args[1];
-
- if(args.length == 2) {
- if(type.equalsIgnoreCase("any"))
- p.chat("//schbr newtrees/*@** -place:bottom -yoff:2");
- else
- p.chat("//schbr newtrees/" + type + "*@** -place:bottom -yoff:2");
-
- }else if(args.length == 3) {
- String scale = args[2];
-
- if(type.equalsIgnoreCase("any"))
- p.chat("//schbr newtrees/*/" + scale + "/*@** -place:bottom -yoff:2");
- else
- p.chat("//schbr newtrees/"+ type + "/" + scale + "/*@** -place:bottom -yoff:2");
-
- }else if(args.length == 4) {
- String scale = args[2];
- String option = args[3];
-
- if(type.equalsIgnoreCase("any")) {
- if(scale.equalsIgnoreCase("any"))
- p.chat("//schbr newtrees/*/*/*"+ option +"/*@** -place:bottom -yoff:2");
- else
- p.chat("//schbr newtrees/*/" + scale + "/*" + option + "/*@** -place:bottom -yoff:2");
- } else {
- if(scale.equalsIgnoreCase("any"))
- p.chat("//schbr newtrees/" + type + "/*/*" + option + "/*@** -place:bottom -yoff:2");
- else
- p.chat("//schbr newtrees/" + type + "/" + scale + "/*" + option + "/*@** -place:bottom -yoff:2");
- }
- }
- }
- }
-}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeWidth.java b/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeWidth.java
deleted file mode 100644
index dace5fa6..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/components/tree/TreeWidth.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package net.buildtheearth.modules.generator.components.tree;
-
-import lombok.Getter;
-
-public enum TreeWidth {
-
- ANY("any"),
- THIN("thin"),
- NORMAL("normal"),
- WIDE("wide"),
- XXL("xxl"),
- DEAD("dead");
-
- @Getter
- private final String name;
-
- TreeWidth(String name) {
- this.name = name;
- }
-}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/tree/menu/TreeTypeMenu.java b/src/main/java/net/buildtheearth/modules/generator/components/tree/menu/TreeTypeMenu.java
deleted file mode 100644
index ac766927..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/components/tree/menu/TreeTypeMenu.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package net.buildtheearth.modules.generator.components.tree.menu;
-
-import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.menu.GeneratorMenu;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.road.RoadFlag;
-import net.buildtheearth.modules.generator.components.road.RoadSettings;
-import net.buildtheearth.modules.generator.components.tree.TreeType;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.menus.BlockListMenu;
-import org.apache.commons.lang3.StringUtils;
-import org.bukkit.Material;
-import org.bukkit.Sound;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class TreeTypeMenu extends BlockListMenu {
-
- public static final String TREE_TYPE_INV_NAME = "Choose a Tree Type";
-
- public TreeTypeMenu(Player player, boolean autoLoad) {
- super(player, TREE_TYPE_INV_NAME, getTreeTypes(), new GeneratorMenu(player, false), autoLoad);
- }
-
- /** Get a list of all tree types */
- private static List getTreeTypes() {
- List treeTypes = new ArrayList<>();
-
- treeTypes.add(new Item(XMaterial.LIME_CONCRETE.parseItem()).setDisplayName("Any").build());
-
- for(TreeType treeType : TreeType.values())
- treeTypes.add(Item.create(XMaterial.OAK_SAPLING.parseMaterial(), StringUtils.capitalize(treeType.getName())));
-
- return treeTypes;
- }
-
- @Override
- protected void setItemClickEventsAsync() {
- super.setItemClickEventsAsync();
-
- // Set click event for next item
- if(canProceed())
- getMenu().getSlot(NEXT_ITEM_SLOT).setClickHandler((clickPlayer, clickInformation) -> {
- Settings settings = GeneratorModule.getInstance().getRoad().getPlayerSettings().get(clickPlayer.getUniqueId());
-
- if(!(settings instanceof RoadSettings))
- return;
-
- RoadSettings roadSettings = (RoadSettings) settings;
- roadSettings.setValue(RoadFlag.ROAD_MATERIAL, Item.createStringFromItemList(selectedMaterials));
-
- clickPlayer.closeInventory();
- clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
- });
- }
-}
diff --git a/src/main/java/net/buildtheearth/modules/generator/components/tree/menu/TreeWidthMenu.java b/src/main/java/net/buildtheearth/modules/generator/components/tree/menu/TreeWidthMenu.java
deleted file mode 100644
index fe184127..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/components/tree/menu/TreeWidthMenu.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package net.buildtheearth.modules.generator.components.tree.menu;
-
-import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.Settings;
-import net.buildtheearth.modules.generator.components.road.RoadFlag;
-import net.buildtheearth.modules.generator.components.road.RoadSettings;
-import net.buildtheearth.modules.generator.components.tree.TreeWidth;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.menus.BlockListMenu;
-import org.apache.commons.lang3.StringUtils;
-import org.bukkit.Sound;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class TreeWidthMenu extends BlockListMenu {
-
- public static final String TREE_TYPE_INV_NAME = "Choose a Tree Width";
-
- public TreeWidthMenu(Player player, boolean autoLoad) {
- super(player, TREE_TYPE_INV_NAME, getTreeWidths(), new TreeTypeMenu(player, false), autoLoad);
- }
-
- /**
- * Get a list of all tree widths
- */
- private static List getTreeWidths() {
- List treeTypes = new ArrayList<>();
-
- treeTypes.add(new Item(XMaterial.LIME_CONCRETE.parseItem()).setDisplayName("Any").build());
-
- for (TreeWidth treeWidth : TreeWidth.values())
- treeTypes.add(Item.create(XMaterial.PAPER.parseMaterial(), StringUtils.capitalize(treeWidth.getName())));
-
- return treeTypes;
- }
-
- @Override
- protected void setItemClickEventsAsync() {
- super.setItemClickEventsAsync();
-
- // Set click event for next item
- if (canProceed())
- getMenu().getSlot(NEXT_ITEM_SLOT).setClickHandler((clickPlayer, clickInformation) -> {
- Settings settings = GeneratorModule.getInstance().getRoad().getPlayerSettings().get(clickPlayer.getUniqueId());
-
- if (!(settings instanceof RoadSettings))
- return;
-
- RoadSettings roadSettings = (RoadSettings) settings;
- roadSettings.setValue(RoadFlag.ROAD_MATERIAL, Item.createStringFromItemList(selectedMaterials));
-
- clickPlayer.closeInventory();
- clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
-
- //new SidewalkColorMenu(clickPlayer);
- });
- }
-}
diff --git a/src/main/java/net/buildtheearth/modules/generator/menu/GeneratorMenu.java b/src/main/java/net/buildtheearth/modules/generator/menu/GeneratorMenu.java
deleted file mode 100644
index a41d33f8..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/menu/GeneratorMenu.java
+++ /dev/null
@@ -1,300 +0,0 @@
-package net.buildtheearth.modules.generator.menu;
-
-import com.cryptomorin.xseries.XMaterial;
-import net.buildtheearth.modules.common.CommonModule;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.modules.generator.model.GeneratorCollections;
-import net.buildtheearth.modules.generator.components.field.Field;
-import net.buildtheearth.modules.generator.components.field.FieldSettings;
-import net.buildtheearth.modules.generator.components.field.menu.CropTypeMenu;
-import net.buildtheearth.modules.generator.components.house.House;
-import net.buildtheearth.modules.generator.components.house.HouseSettings;
-import net.buildtheearth.modules.generator.components.house.RoofType;
-import net.buildtheearth.modules.generator.components.house.menu.WallColorMenu;
-import net.buildtheearth.modules.generator.components.rail.Rail;
-import net.buildtheearth.modules.generator.components.rail.RailSettings;
-import net.buildtheearth.modules.generator.components.road.Road;
-import net.buildtheearth.modules.generator.components.road.RoadSettings;
-import net.buildtheearth.modules.generator.components.road.menu.RoadColorMenu;
-import net.buildtheearth.modules.generator.components.tree.Tree;
-import net.buildtheearth.modules.generator.components.tree.TreeSettings;
-import net.buildtheearth.modules.generator.components.tree.menu.TreeTypeMenu;
-import net.buildtheearth.modules.generator.model.GeneratorType;
-import net.buildtheearth.utils.Item;
-import net.buildtheearth.utils.ListUtil;
-import net.buildtheearth.utils.MenuItems;
-import net.buildtheearth.utils.menus.AbstractMenu;
-import org.bukkit.ChatColor;
-import org.bukkit.Sound;
-import org.bukkit.SoundCategory;
-import org.bukkit.SoundGroup;
-import org.bukkit.entity.Player;
-import org.bukkit.event.inventory.ClickType;
-import org.bukkit.inventory.ItemStack;
-import org.ipvp.canvas.mask.BinaryMask;
-import org.ipvp.canvas.mask.Mask;
-import java.util.ArrayList;
-
-public class GeneratorMenu extends AbstractMenu {
-
- public static final String GENERATOR_INV_NAME = "What do you want to generate?";
-
- public static final int HOUSE_ITEM_SLOT = 9;
-
- public static final int ROAD_ITEM_SLOT = 11;
-
- public static final int RAILWAY_ITEM_SLOT = 13;
-
- public static final int TREE_ITEM_SLOT = 15;
-
- public static int FIELD_ITEM_SLOT = 17;
-
-
- public GeneratorMenu(Player player, boolean autoLoad) {
- super(3, GENERATOR_INV_NAME, player, autoLoad);
- }
-
- @Override
- protected void setPreviewItems() {
- // HOUSE ITEM
- ArrayList houseLore = ListUtil.createList("",
- "§eDescription:",
- "Generate basic building shells",
- "with multiple floors, windows and roofs",
- "",
- "§eFeatures:",
- "- " + RoofType.values().length + " Roof Types",
- "- Custom Wall, Base and Roof Color",
- "- Custom Floor and Window Sizes",
- "",
- "§8Left-click to generate",
- "§8Right-click for Tutorial");
-
- ItemStack houseItem = Item.create(XMaterial.BIRCH_DOOR.parseMaterial(), "§cGenerate House", houseLore);
-
- // Set navigator item
- getMenu().getSlot(HOUSE_ITEM_SLOT).setItem(houseItem);
-
-
- // ROAD ITEM
- ArrayList roadLore = ListUtil.createList("",
- "§eDescription:",
- "Generate roads and highways",
- "with multiple lanes and sidewalks",
- "",
- "§eFeatures:",
- "- Custom Road Width and Color",
- "- Custom Sidewalk Width and Color",
- "- Custom Lane Count",
- "",
- "§8Left-click to generate",
- "§8Right-click for Tutorial");
-
-
- ItemStack roadItem = new Item(XMaterial.SMOOTH_STONE_SLAB.parseItem()).setDisplayName("§bGenerate Road").setLore(roadLore).build();
-
- // Set navigator item
- getMenu().getSlot(ROAD_ITEM_SLOT).setItem(roadItem);
-
-
- // RAILWAY ITEM
- ArrayList railwayLore = ListUtil.createList("",
- "§eDescription:",
- "Generate railways with multiple tracks",
- "and many different designs",
- "",
- "§eFeatures:",
- "- Custom Railway Width and Color (TODO)",
- "- Custom Track Count (TODO)",
- "",
- "§8Left-click to generate",
- "§8Right-click for Tutorial");
-
- ItemStack railwayItem = Item.create(XMaterial.RAIL.parseMaterial(), "§9Generate Railway", railwayLore);
-
- // Set navigator item
- getMenu().getSlot(RAILWAY_ITEM_SLOT).setItem(railwayItem);
-
-
- if (!CommonModule.getInstance().getDependencyComponent().isSchematicBrushEnabled()) {
- // TREE ITEM
- ArrayList treeLore = ListUtil.createList("", "§cPlugin §eSchematicBrush §cis not installed", "§cTree Generator is disabled", "", "§8Leftclick for Installation Instructions");
-
- ItemStack treeItem = Item.create(XMaterial.OAK_SAPLING.parseMaterial(), "§aGenerate Tree & Forest §c(DISABLED)", treeLore);
-
- // Set navigator item
- getMenu().getSlot(TREE_ITEM_SLOT).setItem(treeItem);
- }else if(GeneratorCollections.checkIfGeneratorCollectionsIsInstalled(getMenuPlayer())){
- // TREE ITEM
- ArrayList treeLore = ListUtil.createList("", "§cThe §eTree Pack " + Tree.TREE_PACK_VERSION + " §cis not installed", "§cTree Generator is disabled", "", "§8Leftclick for Installation Instructions");
-
- ItemStack treeItem = Item.create(XMaterial.OAK_SAPLING.parseMaterial(), "§aGenerate Tree & Forest §c(DISABLED)", treeLore);
-
- // Set navigator item
- getMenu().getSlot(TREE_ITEM_SLOT).setItem(treeItem);
- }else{
- // TREE ITEM
- ArrayList treeLore = ListUtil.createList("",
- "§eDescription:",
- "Generate trees from a set of",
- "hundreds of different types",
- "",
- "§eFeatures:",
- "- Custom Tree Type",
- "",
- "§8Left-click to generate",
- "§8Right-click for Tutorial");
-
- ItemStack treeItem = Item.create(XMaterial.OAK_SAPLING.parseMaterial(), "§aGenerate Tree & Forest", treeLore);
-
- // Set navigator item
- getMenu().getSlot(TREE_ITEM_SLOT).setItem(treeItem);
- }
-
-
- // FIELD ITEM
- ArrayList fieldLore = ListUtil.createList("",
- "§eDescription:",
- "Generate fields with different",
- "crops and plants",
- "",
- "§eFeatures:",
- "- Custom Crop Type",
- "- Custom Crop Size",
- "",
- "§8Left-click to generate",
- "§8Right-click for Tutorial");
-
- ItemStack fieldItem = Item.create(XMaterial.WHEAT.parseMaterial(), "§6Generate Field", fieldLore);
-
- // Set navigator item
- getMenu().getSlot(FIELD_ITEM_SLOT).setItem(fieldItem);
-
-
- super.setPreviewItems();
- }
-
- @Override
- protected void setMenuItemsAsync() {}
-
- @Override
- protected void setItemClickEventsAsync() {
- // Set click event for house item
- getMenu().getSlot(HOUSE_ITEM_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
- if(clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, GeneratorType.HOUSE);
- return;
- }
-
- House house = GeneratorModule.getInstance().getHouse();
- house.getPlayerSettings().put(clickPlayer.getUniqueId(), new HouseSettings(clickPlayer));
-
- if(!house.checkForPlayer(clickPlayer))
- return;
-
- clickPlayer.closeInventory();
- clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
- new WallColorMenu(clickPlayer, true);
- }));
-
- // Set click event for road item
- getMenu().getSlot(ROAD_ITEM_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
- if(clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, GeneratorType.ROAD);
- return;
- }
-
- Road road = GeneratorModule.getInstance().getRoad();
- road.getPlayerSettings().put(clickPlayer.getUniqueId(), new RoadSettings(clickPlayer));
-
- if(!road.checkForPlayer(clickPlayer))
- return;
-
- clickPlayer.closeInventory();
- clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
- new RoadColorMenu(clickPlayer, true);
- }));
-
- // Set click event for railway item
- getMenu().getSlot(RAILWAY_ITEM_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
- if(clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, GeneratorType.RAILWAY);
- return;
- }
-
- Rail rail = GeneratorModule.getInstance().getRail();
- rail.getPlayerSettings().put(clickPlayer.getUniqueId(), new RailSettings(clickPlayer));
-
- if(!rail.checkForPlayer(clickPlayer))
- return;
-
- clickPlayer.closeInventory();
- clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
-
- GeneratorModule.getInstance().getRail().generate(clickPlayer);
- }));
-
- // Set click event for tree item
- getMenu().getSlot(TREE_ITEM_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
- if(clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, GeneratorType.TREE);
- return;
- }
-
- Tree tree = GeneratorModule.getInstance().getTree();
- tree.getPlayerSettings().put(clickPlayer.getUniqueId(), new TreeSettings(clickPlayer));
-
- if(!tree.checkForPlayer(clickPlayer))
- return;
-
- clickPlayer.closeInventory();
- clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
- new TreeTypeMenu(clickPlayer, true);
- }));
-
- // Set click event for field item
- getMenu().getSlot(FIELD_ITEM_SLOT).setClickHandler(((clickPlayer, clickInformation) -> {
- if(clickInformation.getClickType().equals(ClickType.RIGHT)) {
- sendMoreInformation(clickPlayer, GeneratorType.FIELD);
- return;
- }
-
- Field field = GeneratorModule.getInstance().getField();
- field.getPlayerSettings().put(clickPlayer.getUniqueId(), new FieldSettings(clickPlayer));
-
- if(!field.checkForPlayer(clickPlayer))
- return;
-
- clickPlayer.closeInventory();
- clickPlayer.playSound(clickPlayer.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F);
- new CropTypeMenu(clickPlayer, true);
- }));
- }
-
- private void sendMoreInformation(Player clickPlayer, GeneratorType generator) {
- switch (generator) {
- case FIELD:
- clickPlayer.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Field-Command");
- break;
- case HOUSE:
- clickPlayer.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/House-Command");
- break;
- case RAILWAY:
- clickPlayer.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Rail-Command");
- break;
- case ROAD:
- clickPlayer.sendMessage(ChatColor.RED + "https://github.com/BuildTheEarth/BuildTeamTools/wiki/Road-Command");
- break;
- }
- }
-
- @Override
- protected Mask getMask() {
- return BinaryMask.builder(getMenu())
- .item(MenuItems.ITEM_BACKGROUND)
- .pattern("111111111")
- .pattern("010101010")
- .pattern("111111111")
- .build();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/net/buildtheearth/modules/generator/model/Flag.java b/src/main/java/net/buildtheearth/modules/generator/model/Flag.java
deleted file mode 100644
index 156873e1..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/model/Flag.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package net.buildtheearth.modules.generator.model;
-
-import lombok.Getter;
-import net.buildtheearth.modules.generator.components.field.FieldFlag;
-import net.buildtheearth.modules.generator.components.house.HouseFlag;
-import net.buildtheearth.modules.generator.components.rail.RailFlag;
-import net.buildtheearth.modules.generator.components.road.RoadFlag;
-import net.buildtheearth.modules.generator.components.tree.TreeFlag;
-
-public interface Flag {
-
- String getFlag();
-
- FlagType getFlagType();
-
- /** @return the flag by the given string and generator type */
- static Flag byString(GeneratorType generatorType, String flag) {
- switch (generatorType) {
- case HOUSE:
- return HouseFlag.byString(flag);
- case ROAD:
- return RoadFlag.byString(flag);
- case TREE:
- return TreeFlag.byString(flag);
- case RAILWAY:
- return RailFlag.byString(flag);
- case FIELD:
- return FieldFlag.byString(flag);
- }
- return null;
- }
-}
diff --git a/src/main/java/net/buildtheearth/modules/generator/model/GeneratorType.java b/src/main/java/net/buildtheearth/modules/generator/model/GeneratorType.java
deleted file mode 100644
index 0321ca98..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/model/GeneratorType.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package net.buildtheearth.modules.generator.model;
-
-import lombok.Getter;
-
-public enum GeneratorType {
-
- HOUSE("House"),
- ROAD("Road"),
- RAILWAY("Railway"),
- TREE("Tree"),
- FIELD("Field");
-
- @Getter
- private final String name;
-
- GeneratorType(String name) {
- this.name = name;
- }
-
-}
diff --git a/src/main/java/net/buildtheearth/modules/generator/utils/GeneratorUtils.java b/src/main/java/net/buildtheearth/modules/generator/utils/GeneratorUtils.java
deleted file mode 100644
index 992ece36..00000000
--- a/src/main/java/net/buildtheearth/modules/generator/utils/GeneratorUtils.java
+++ /dev/null
@@ -1,1772 +0,0 @@
-package net.buildtheearth.modules.generator.utils;
-
-import clipper2.Clipper;
-import clipper2.core.Path64;
-import clipper2.core.Paths64;
-import clipper2.core.Point64;
-import clipper2.offset.EndType;
-import clipper2.offset.JoinType;
-import com.cryptomorin.xseries.XMaterial;
-import com.fastasyncworldedit.core.limit.FaweLimit;
-import com.sk89q.worldedit.*;
-import com.sk89q.worldedit.bukkit.BukkitAdapter;
-import com.sk89q.worldedit.extension.factory.MaskFactory;
-import com.sk89q.worldedit.extension.input.InputParseException;
-import com.sk89q.worldedit.extension.input.ParserContext;
-import com.sk89q.worldedit.extension.platform.Actor;
-import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
-import com.sk89q.worldedit.extent.inventory.BlockBag;
-import com.sk89q.worldedit.function.mask.BlockMask;
-import com.sk89q.worldedit.function.mask.Mask;
-import com.sk89q.worldedit.function.operation.Operations;
-import com.sk89q.worldedit.function.pattern.ClipboardPattern;
-import com.sk89q.worldedit.function.pattern.Pattern;
-import com.sk89q.worldedit.function.pattern.RandomPattern;
-import com.sk89q.worldedit.math.BlockVector2;
-import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.math.transform.AffineTransform;
-import com.sk89q.worldedit.regions.*;
-import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
-import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
-import com.sk89q.worldedit.session.ClipboardHolder;
-import com.sk89q.worldedit.session.SessionManager;
-import com.sk89q.worldedit.world.block.BlockState;
-import com.sk89q.worldedit.world.block.BlockType;
-import com.sk89q.worldedit.world.block.BlockTypes;
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.modules.common.CommonModule;
-import net.buildtheearth.modules.generator.GeneratorModule;
-import net.buildtheearth.utils.ChatHelper;
-import net.buildtheearth.utils.MenuItems;
-import org.apache.commons.lang3.StringUtils;
-import org.bukkit.Sound;
-import org.bukkit.World;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.util.Vector;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-
-/** This class contains static utility methods for the generator module.
- * The following dependencies are needed for this class to work:
- *
- * - WorldEdit
- * - FastAsyncWorldEdit
- * - XSeries
- * - Clipper
- * - ChatHelper (internal)
- *
- *
- * The functions are categorized into the following sections:
- *
- *
Setup Functions:
- * These functions are plugin specific functions that need to be changed when copying the class to another plugin.
- *
- *
Script Helper Functions:
- *
• {@link #convertArgsToFlags(String[])}
- *
• {@link #convertToFlagAndValue(String, Player)}
- *
• {@link #getBlockState(XMaterial)}
- *
- *
WorldEdit Helper Functions:
- *
• {@link #getWorldEditSchematicsFolderPath()}
- *
- *
WorldEdit Region Functions:
- *
• {@link #getSelectionPointsFromRegion(Region)}
- *
• {@link #getMinMaxPoints(Region)}
- *
• {@link #getMaxHeight(Block[][][], Material...)}
- *
• {@link #getMaxHeight(Block[][][], int, int, Material...)}
- *
• {@link #containsBlock(Block[][][], XMaterial)}
- *
• {@link #containsBlock(Block[][][], XMaterial, int)}
- *
• {@link #getWorldEditSelection(Player)}
- *
• {@link #restoreSelection(Player, RegionSelector)}
- *
• {@link #createCuboidSelection(Player, Vector, Vector)}
- *
• {@link #createPolySelection(Player, List, Block[][][])}
- *
• {@link #createPolySelection(Player, List, int, int)}
- *
- *
WorldEdit Operation Functions:
- *
• {@link #prepareScriptSession(LocalSession, Actor, Player, com.sk89q.worldedit.world.World, int, boolean, boolean, boolean)}
- *
• {@link #analyzeRegion(Player, World)}
- *
• {@link #replaceBlocksWithMasks(LocalSession, Actor, com.sk89q.worldedit.world.World, List, BlockState, BlockState[], int)}
- *
• {@link #replaceBlocksWithSchematic(LocalSession, Actor, com.sk89q.worldedit.world.World, BlockState[], String)}
- *
• {@link #replaceBlocks(LocalSession, Actor, com.sk89q.worldedit.world.World, BlockState[], BlockState[])}
- *
• {@link #drawSplineWithMasks(LocalSession, Actor, com.sk89q.worldedit.world.World, Block[][][], List, List, BlockState[], boolean, double, double, double, double, double, boolean, boolean)}
- *
• {@link #drawCurveWithMasks(LocalSession, Actor, com.sk89q.worldedit.world.World, Block[][][], List, List, BlockState[], boolean)}
- *
• {@link #drawPolyLineWithMasks(LocalSession, Actor, com.sk89q.worldedit.world.World, Block[][][], List, List, BlockState[], boolean, boolean)}
- *
• {@link #drawLineWithMasks(LocalSession, Actor, com.sk89q.worldedit.world.World, Block[][][], List, Vector, Vector, BlockState[], boolean)}
- *
• {@link #pasteSchematicWithMasks(LocalSession, Actor, com.sk89q.worldedit.world.World, Block[][][], List, String, Location, double)}
- *
• {@link #pasteSchematic(LocalSession, Actor, com.sk89q.worldedit.world.World, Block[][][], String, Location, double)}
- *
• {@link #expandSelection(LocalSession, Vector)}
- *
• {@link #clearHistory(LocalSession)}
- *
• {@link #undo(LocalSession, Player, Actor, int)}
- *
• {@link #redo(LocalSession, Player, Actor, int)}
- *
• {@link #setGmask(LocalSession, String)}
- *
• {@link #saveEditSession(EditSession, LocalSession, Actor)}
- *
- *
Vector Helper Functions:
- *
• {@link #adjustHeight(List, Block[][][])}
- *
• {@link #populatePoints(List, int)}
- *
• {@link #reducePoints(List, int, int)}
- *
• {@link #extendPolyLine(List)}
- *
• {@link #shortenPolyLine(List, int)}
- *
• {@link #getClosestVector(List, Vector)}
- *
• {@link #getXYZ(Vector, Block[][][])}
- *
• {@link #getXYZWithVerticalOffset(Vector, Block[][][], int)}
- *
• {@link #convertVectorListToPath64(List, Vector)}
- *
• {@link #convertPathsToVectorList(Paths64, Vector, int, int)}
- *
• {@link #shiftPoints(List, double, boolean)}
- *
• {@link #shiftPointsAll(List, double)}
- *
• {@link #getMinHeight(List)}
- *
• {@link #getMaxHeight(List)}
- *
- *
Preparation Check Functions:
- *
• {@link #checkIfSchematicBrushIsInstalled(Player)}
- *
• {@link #checkForNoWorldEditSelection(Player)}
- *
• {@link #checkForBrickOutline(Block[][][], Player)}
- *
• {@link #checkForWoolBlock(Block[][][], Player)}
- *
- * @version 1.5
- * @author MineFact
- */
-public class GeneratorUtils {
-
-
- /*=============================================**
-
- SETUP FUNCTIONS
-
- **=============================================*/
-
- /** Get the plugin instance. */
- private static Plugin getPlugin(){
- return BuildTeamTools.getInstance();
- }
-
- /** Checks if the plugin "FastAsyncWorldEdit" is enabled. */
- private static boolean isFastAsyncWorldEditEnabled(){
- return CommonModule.getInstance().getDependencyComponent().isFastAsyncWorldEditEnabled();
- }
-
- /** Checks if only the plugin "WorldEdit" is enabled and not "FastAsyncWorldEdit". */
- private static boolean isLegacyWorldEditEnabled(){
- return CommonModule.getInstance().getDependencyComponent().isLegacyWorldEdit();
- }
-
- /** Checks if the plugin "SchematicBrush" is enabled. */
- private static boolean isSchematicBrushEnabled(){
- return CommonModule.getInstance().getDependencyComponent().isSchematicBrushEnabled();
- }
-
- /** Checks if the server version is 1.12. */
- private static boolean isServerVersion1_12(){
- return CommonModule.getInstance().getVersionComponent().is_1_12();
- }
-
- /** Get the ignored materials. */
- private static Material[] getIgnoredMaterials(){
- return MenuItems.getIgnoredMaterials();
- }
-
- private static void sendWikiLink(Player p){
- sendWikiLink(p);
- }
-
-
-
-
-
- /*=============================================**
-
- SCRIPT HELPER FUNCTIONS
-
- **=============================================*/
-
- /**
- * Converts a String[] of arguments to a String[] of flags.
- *
- * @param args The arguments to be converted.
- * @return The converted flags.
- */
- public static String[] convertArgsToFlags(String[] args) {
- String argsString = " " + StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " ");
- String[] argsArray = argsString.split(" -");
-
- return Arrays.copyOfRange(argsArray, 1, argsArray.length);
- }
-
- /** Converts a string with all flags and values to a string array with the flag name and the flag value.
- *
- * @param flagAndValue The string with all flags and values. Example is a command like /gen house -w 10 -h 10
- * @param p The player who should receive an error message if the flag value is invalid.
- * @return The string array with the flag name and the flag value.
- */
- public static String[] convertToFlagAndValue(String flagAndValue, Player p){
- String[] values = flagAndValue.split(" ");
- String flagName = values[0];
- String flagValue;
-
- try {
- flagValue = StringUtils.join(Arrays.copyOfRange(values, 1, values.length), " ");
- } catch (ArrayIndexOutOfBoundsException e) {
- p.sendMessage("§cInvalid flag value: -" + flagName + "§n§c ???");
- return null;
- }
-
- return new String[]{flagName, flagValue};
- }
-
- /**
- * Returns the blockState of a given XMaterial.
- *
- * @param xMaterial The XMaterial to get the blockState from
- * @return The blockState of the XMaterial
- */
- public static BlockState getBlockState(XMaterial xMaterial){
- if(xMaterial == null)
- return null;
-
- BlockType blockType = BlockTypes.get(xMaterial.getId() + "");
-
- if(blockType == null && xMaterial.parseMaterial() != null)
- blockType = BlockTypes.get(xMaterial.parseMaterial().getKey().asString());
-
- if(blockType == null)
- throw new IllegalArgumentException("Invalid block type: " + xMaterial.parseMaterial().name());
-
- return blockType.getDefaultState();
- }
- public static BlockState[] getBlockState(XMaterial[] xMaterial){
- if(xMaterial == null)
- return null;
-
- BlockState[] blockStates = new BlockState[xMaterial.length];
-
- for(int i = 0; i < xMaterial.length; i++)
- blockStates[i] = getBlockState(xMaterial[i]);
-
- return blockStates;
- }
-
-
-
- /*=============================================**
-
- WORLDEDIT HELPER FUNCTIONS
-
- **=============================================*/
-
-
- /**
- * Returns the path to the WorldEdit schematics folder.
- *
- * @return The path to the WorldEdit schematics folder
- */
- public static String getWorldEditSchematicsFolderPath(){
- String worldEditFolder = "WorldEdit";
-
- if(isFastAsyncWorldEditEnabled())
- worldEditFolder = "FastAsyncWorldEdit";
-
- return getPlugin().getDataFolder().getAbsolutePath() + "/../" + worldEditFolder + "/schematics";
- }
-
-
-
-
-
- /*=============================================**
-
- WORLDEDIT REGION FUNCTIONS
-
- **=============================================*/
-
-
-
- /**
- * Returns the WorldEdit selection Vector from a player no matter which type of selection the player made.
- *
- * @param region The WorldEdit region to get the selection from
- * @return A list of vectors representing the selection
- */
- public static List getSelectionPointsFromRegion(Region region) {
- List points = new ArrayList<>();
-
- if (region instanceof Polygonal2DRegion) {
- Polygonal2DRegion polyRegion = (Polygonal2DRegion) region;
- ChatHelper.logDebug("Polygonal2DRegion found");
- // In latest FAWE, the points are stored as BlockVector2
- // In 1.12 WorldEdit, the points are stored as BlockVector2D
- // Both classes have the same methods, so we can use reflection to get the methods
- for (Object blockVectorObj : polyRegion.getPoints()) {
- ChatHelper.logDebug("BlockVector2:" + blockVectorObj);
- try {
- Class> blockVectorClass = blockVectorObj.getClass();
- Method getXMethod = blockVectorClass.getMethod("getBlockX");
- Method getZMethod = blockVectorClass.getMethod("getBlockZ");
-
- int x = (Integer) getXMethod.invoke(blockVectorObj);
- int z = (Integer) getZMethod.invoke(blockVectorObj);
-
- points.add(new Vector(x, 0, z));
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
- e.printStackTrace();
- }
- }
-
- } else if (region instanceof ConvexPolyhedralRegion) {
- ConvexPolyhedralRegion convexRegion = (ConvexPolyhedralRegion) region;
-
- // In latest FAWE, the points are stored as BlockVector2
- // In 1.12 WorldEdit, the points are stored as BlockVector2D
- // Both classes have the same methods, so we can use reflection to get the methods
- for (Object blockVectorObj : convexRegion.getVertices()) {
- try {
- Class> blockVectorClass = blockVectorObj.getClass();
- Method getXMethod = blockVectorClass.getMethod("getBlockX");
- Method getYMethod = blockVectorClass.getMethod("getBlockY");
- Method getZMethod = blockVectorClass.getMethod("getBlockZ");
-
- int x = (Integer) getXMethod.invoke(blockVectorObj);
- int y = (Integer) getYMethod.invoke(blockVectorObj);
- int z = (Integer) getZMethod.invoke(blockVectorObj);
-
- points.add(new Vector(x, y, z));
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
- e.printStackTrace();
- }
- }
-
- }else if (region instanceof CuboidRegion) {
- CuboidRegion cuboidRegion = (CuboidRegion) region;
-
- try {
- Class> regionClass = cuboidRegion.getClass();
- Method getPos1Method = regionClass.getMethod("getPos1");
- Method getPos2Method = regionClass.getMethod("getPos2");
-
- Class> vectorClass = getPos1Method.getReturnType();
-
- Method getXMethod = vectorClass.getMethod("getBlockX");
- Method getYMethod = vectorClass.getMethod("getBlockY");
- Method getZMethod = vectorClass.getMethod("getBlockZ");
-
- Object pos1 = getPos1Method.invoke(region);
- Object pos2 = getPos2Method.invoke(region);
-
- int x1 = (Integer) getXMethod.invoke(pos1);
- int y1 = (Integer) getYMethod.invoke(pos1);
- int z1 = (Integer) getZMethod.invoke(pos1);
-
- int x2 = (Integer) getXMethod.invoke(pos2);
- int y2 = (Integer) getYMethod.invoke(pos2);
- int z2 = (Integer) getZMethod.invoke(pos2);
-
- points.add(new Vector(x1, y1, z1));
- points.add(new Vector(x2, y2, z2));
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
- e.printStackTrace();
- }
- } else
- return null;
-
- return points;
- }
-
- /**
- * Returns the minimum and maximum points of a region as a Vector array.
- *
- * @param region The region to get the minimum and maximum points from
- * @return A Vector array with the minimum vector at index 0 and the maximum vector at index 1
- */
- public static Vector[] getMinMaxPoints(Region region){
- Vector[] minMax = new Vector[2];
-
- try{
- Class> regionClass = region.getClass();
- Method getMinimumPointMethod = regionClass.getMethod("getMinimumPoint");
- Method getMaximumPointMethod = regionClass.getMethod("getMaximumPoint");
-
- Class> vectorClass = getMinimumPointMethod.getReturnType();
-
- Method getXMethod = vectorClass.getMethod("getBlockX");
- Method getYMethod = vectorClass.getMethod("getBlockY");
- Method getZMethod = vectorClass.getMethod("getBlockZ");
-
- Object minPoint = getMinimumPointMethod.invoke(region);
- Object maxPoint = getMaximumPointMethod.invoke(region);
-
- int minX = (Integer) getXMethod.invoke(minPoint);
- int minY = (Integer) getYMethod.invoke(minPoint);
- int minZ = (Integer) getZMethod.invoke(minPoint);
-
- int maxX = (Integer) getXMethod.invoke(maxPoint);
- int maxY = (Integer) getYMethod.invoke(maxPoint);
- int maxZ = (Integer) getZMethod.invoke(maxPoint);
-
- minMax[0] = new Vector(minX, minY, minZ);
- minMax[1] = new Vector(maxX, maxY, maxZ);
-
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
- e.printStackTrace();
- }
-
- return minMax;
- }
-
- /**
- * Checks the maximum height of a polygon region
- *
- * @param blocks List of blocks in polygon region
- * @return Maximum height of polygon region
- */
- public static int getMaxHeight(Block[][][] blocks, Material... ignoreMaterials){
- int maxHeight = 0;
- List ignoreMaterialsList = Arrays.asList(ignoreMaterials);
-
- for (Block[][] block2D : blocks)
- for (Block[] block1D : block2D)
- for (Block block : block1D)
- if (block != null && !ignoreMaterialsList.contains(block.getType()) && block.getType().isSolid() && !block.isLiquid() && block.getY() > maxHeight)
- maxHeight = block.getY();
-
- return maxHeight;
- }
-
- /**
- * Checks the max height of a polygon region given a certain x and z coordinate
- *
- * @param blocks List of blocks in polygon region
- * @return Maximum height of polygon region
- */
- public static int getMaxHeight(Block[][][] blocks, int x, int z, Material... ignoreMaterials){
- int maxHeight = 0;
- List ignoreMaterialsList = Arrays.asList(ignoreMaterials);
-
- for (Block[][] block2D : blocks)
- for (Block[] block1D : block2D)
- for (Block block : block1D)
- if (block != null && block.getX() == x && block.getZ() == z && block.getY() > maxHeight && !ignoreMaterialsList.contains(block.getType()) && block.getType().isSolid() && !block.isLiquid())
- maxHeight = block.getY();
-
- return maxHeight;
- }
-
- /**
- * Checks if polygon region contains a block of a certain type
- *
- * @param blocks List of blocks in polygon region
- * @param xMaterial Material to check for (e.g. XMaterial.WALL_SIGN)
- * @return true if polygon region contains the block, false otherwise
- */
- public static boolean containsBlock(Block[][][] blocks, XMaterial xMaterial){
- return containsBlock(blocks, xMaterial, 1);
- }
-
- /**
- * Checks if polygon region contains a minimum amount of blocks of a certain type
- * @param blocks List of blocks in polygon region
- * @param xMaterial Material to check for (e.g. XMaterial.WALL_SIGN)
- * @param requiredAmount The minimum amount required to return true
- * @return true if polygon region contains the required amount of the block, false otherwise
- */
- public static boolean containsBlock(Block[][][] blocks, XMaterial xMaterial, int requiredAmount){
- int amountFound = 0;
- for (Block[][] block2D : blocks)
- for (Block[] block1D : block2D)
- for (Block block : block1D)
- if (isServerVersion1_12()) {
- if (block != null && block.getType() == xMaterial.parseMaterial() && block.getData() == xMaterial.getData())
- amountFound++;
- }else {
- if (block != null && block.getType() == xMaterial.parseMaterial())
- amountFound++;
- }
-
- return amountFound >= requiredAmount;
- }
-
- /**
- * Returns the current WorldEdit selection of a player.
- *
- * @param p The player whose selection should be returned.
- * @return The current WorldEdit selection of the player.
- */
- public static Region getWorldEditSelection(Player p){
- try {
- Actor actor = BukkitAdapter.adapt(p);
- SessionManager sessionManager = WorldEdit.getInstance().getSessionManager();
- com.sk89q.worldedit.world.World world = sessionManager.get(actor).getSelectionWorld();
-
- return sessionManager.get(actor).getSelection(world);
- } catch (NullPointerException | IncompleteRegionException ex) {
- return null;
- }
- }
-
- /**
- * Returns the WorldEdit selection of a player.
- *
- * @param p The player to get the selection from
- * @param regionSelector The region selector to get the selection from
- */
- public static void restoreSelection(Player p, RegionSelector regionSelector){
- Actor actor = BukkitAdapter.adapt(p);
- SessionManager sessionManager = WorldEdit.getInstance().getSessionManager();
- com.sk89q.worldedit.world.World world = sessionManager.get(actor).getSelectionWorld();
-
- sessionManager.get(actor).setRegionSelector(world, regionSelector);
-
- ChatHelper.logDebug("Restored selection");
- }
-
- /**
- * Creates a Cuboid WorldEdit selection from a list of points and execute it right away.
- *
- * @param p The player to create the selection for
- * @param vector1 Position 1
- * @param vector2 Position 2
- */
- public static void createCuboidSelection(Player p, Vector vector1, Vector vector2){
- Actor actor = BukkitAdapter.adapt(p);
- SessionManager sessionManager = WorldEdit.getInstance().getSessionManager();
- com.sk89q.worldedit.world.World world = sessionManager.get(actor).getSelectionWorld();
-
- sessionManager.get(actor).setRegionSelector(world,
- new CuboidRegionSelector(world,
- BlockVector3.at(vector1.getBlockX(), vector1.getBlockY(), vector1.getBlockZ()),
- BlockVector3.at(vector2.getBlockX(), vector2.getBlockY(), vector2.getBlockZ())
- )
- );
-
- ChatHelper.logDebug("Created cuboid selection");
- }
-
-
- /**
- * Creates a Polygon WorldEdit selection from a list of points and execute it right away.
- * This functions determines the current surface height of each vector directly.
- *
- * @param p The player to create the selection for
- * @param points The list of points to create the selection from
- */
- public static void createPolySelection(Player p, List points, Block[][][] blocks){
- int minY = Integer.MAX_VALUE;
- int maxY = Integer.MIN_VALUE;
-
- for(Vector vector : points) {
- int y = getMaxHeight(blocks, vector.getBlockX(), vector.getBlockZ(), getIgnoredMaterials());
-
- minY = Math.min(minY, y);
- maxY = Math.max(maxY, y);
- }
-
- createPolySelection(p, points, minY, maxY);
- }
-
- /**
- * Creates a Polygon WorldEdit selection from a list of points and execute it right away.
- * This functions determines the current surface height of each vector directly.
- *
- * @param p The player to create the selection for
- * @param points The list of points to create the selection from
- * @param minY The minimum Y value of the selection
- * @param maxY The maximum Y value of the selection
- */
- public static void createPolySelection(Player p, List points, int minY, int maxY) {
- Actor actor = BukkitAdapter.adapt(p);
- SessionManager sessionManager = WorldEdit.getInstance().getSessionManager();
- com.sk89q.worldedit.world.World world = sessionManager.get(actor).getSelectionWorld();
-
- List blockVector2List = new ArrayList<>();
- for (Vector vector : points){
- blockVector2List.add(BlockVector2.at(vector.getBlockX(), vector.getBlockZ()));
- ChatHelper.logDebug("Added point: " + vector);
- }
-
- sessionManager.get(actor).setRegionSelector(world,
- new Polygonal2DRegionSelector(world, blockVector2List, minY, maxY)
- );
-
- ChatHelper.logDebug("Created polygonal selection with " + points.size() + " points. minY: " + minY + " maxY: " + maxY);
- }
-
-
-
-
-
-
-
- /*=============================================**
-
- WORLDEDIT OPERATION FUNCTIONS
-
- **=============================================*/
-
-
-
- /**
- * Prepares a script session by expanding the selection, removing non-solid blocks and ignored materials.
- * The blocks of the region are also analyzed and returned.
- *
- * @param localSession The local session of the actor
- * @param actor The actor who should perform the operation
- * @param player The player who should receive an error message if the flag value is invalid
- * @param world The world in which the region is located
- * @param expandSelection The amount of blocks to expand the selection
- * @param readBlocks Whether the blocks of the region should be read and returned
- * @param removeNonSolidBlocks Whether non-solid blocks should be removed
- * @param removeIgnoredMaterials Whether ignored materials should be removed
- * @return A three-dimensional array of all blocks in the region
- */
- public static Block[][][] prepareScriptSession(LocalSession localSession, Actor actor, Player player, com.sk89q.worldedit.world.World world, int expandSelection, boolean readBlocks, boolean removeNonSolidBlocks, boolean removeIgnoredMaterials){
- if(expandSelection > 0) {
- expandSelection(localSession, new Vector(0, expandSelection, 0));
- expandSelection(localSession, new Vector(0, -expandSelection, 0));
- }
-
- BlockType air = BlockTypes.AIR;
-
- if(air == null)
- return null;
-
- if(removeNonSolidBlocks)
- replaceBlocksWithMasks(localSession, actor, world, Collections.singletonList("!#solid"), null, new BlockState[]{air.getDefaultState()}, 1)
- .join();
-
- if(removeIgnoredMaterials) {
- Material[] materials = getIgnoredMaterials();
- for (Material material : materials) {
- BlockType blockType = BlockTypes.get(material.getKey().asString());
-
- if (blockType == null)
- continue;
-
- List blockStates = blockType.getAllStates();
- BlockState[] blockStatesArray = blockStates.toArray(new BlockState[0]);
- replaceBlocks(localSession, actor, world, blockStatesArray, new BlockState[]{air.getDefaultState()})
- .join();
- }
- }
-
- Block[][][] regionBlocks = null;
-
- if(readBlocks)
- regionBlocks = analyzeRegion(player, player.getWorld());
-
- return regionBlocks;
- }
-
-
-
- /** Analyzes a region and returns a three-dimensional array of all blocks in the region.
- * The size of the array is defined by the width, height and length of the region from WorldEdit of the player.
- * By saving the blocks in an array, the generation can be done much faster later once the region blocks need to be inspected.
- *
- * @param p The player whose selection should be analyzed.
- * @param world The world in which the region is located.
- * @return A three-dimensional array of all blocks in the region.
- */
- public static Block[][][] analyzeRegion(Player p, World world) {
- // Get WorldEdit selection of player
- Region region = getWorldEditSelection(p);
-
- if(region == null)
- return null;
-
- Block[][][] blocks = new Block[region.getWidth()][region.getHeight()][region.getLength()];
-
- try {
- Class> regionClass = region.getClass();
-
- // Reflectively access the minimum and maximum points
- Method getMinimumPoint = regionClass.getMethod("getMinimumPoint");
- Method getMaximumPoint = regionClass.getMethod("getMaximumPoint");
- Method contains;
-
- if(isLegacyWorldEditEnabled())
- contains = regionClass.getMethod("contains", Class.forName("com.sk89q.worldedit.Vector"));
- else
- contains = regionClass.getMethod("contains", com.sk89q.worldedit.math.BlockVector3.class);
-
- Object minPoint = getMinimumPoint.invoke(region);
- Object maxPoint = getMaximumPoint.invoke(region);
-
- Class> vectorClass = minPoint.getClass();
-
- // Assume getBlockX/Y/Z methods exist in both Vector and BlockVector3
- Method getBlockX = vectorClass.getMethod("getBlockX");
- Method getBlockY = vectorClass.getMethod("getBlockY");
- Method getBlockZ = vectorClass.getMethod("getBlockZ");
-
- int minX = (Integer) getBlockX.invoke(minPoint);
- int minY = (Integer) getBlockY.invoke(minPoint);
- int minZ = (Integer) getBlockZ.invoke(minPoint);
- int maxX = (Integer) getBlockX.invoke(maxPoint);
- int maxY = (Integer) getBlockY.invoke(maxPoint);
- int maxZ = (Integer) getBlockZ.invoke(maxPoint);
-
- for (int i = minX; i <= maxX; i++)
- for (int j = minY; j <= maxY; j++)
- for (int k = minZ; k <= maxZ; k++) {
- // Dynamically create vector instance to use in contains method
- Object vectorInstance;
-
- // First, try using BlockVector3.at(int, int, int) - common in FAWE and newer WorldEdit
- try {
- Class> blockVector3Class = Class.forName("com.sk89q.worldedit.math.BlockVector3");
- Method atMethod = blockVector3Class.getMethod("at", int.class, int.class, int.class);
- vectorInstance = atMethod.invoke(null, i, j, k);
- } catch (ClassNotFoundException | NoSuchMethodException e) {
-
- // If BlockVector3 or at method is not found, fallback to WorldEdit's Vector
- vectorInstance = vectorClass.getConstructor(int.class, int.class, int.class).newInstance(i, j, k);
- }
-
- if(vectorInstance != null) {
- boolean regionContains = (Boolean) contains.invoke(region, vectorInstance);
-
- if (regionContains) {
- Block block = world.getBlockAt(i, j, k);
- blocks[i - minX][j - minY][k - minZ] = block;
- }
- }
- }
-
-
- return blocks;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Replaces all blocks in a region with the given masks and a pattern.
- *
- * @param localSession The local session of the actor
- * @param actor The actor who should perform the operation
- * @param weWorld The WorldEdit world in which the region is located
- * @param masks The masks to use
- * @param from The block to replace
- * @param to The blocks to replace with
- * @param iterations The number of iterations to perform
- *
- * @return A CompletableFuture that completes when the operation is finished
- */
- public static CompletableFuture replaceBlocksWithMasks(LocalSession localSession, Actor actor, com.sk89q.worldedit.world.World weWorld, List masks, BlockState from, BlockState[] to, int iterations) {
- if(to == null || to.length == 0)
- throw new IllegalArgumentException("BlockState[] to is empty");
-
- CompletableFuture future = new CompletableFuture<>();
- Thread thread = new Thread(() -> {
- for (int i = 0; i < iterations; i++) {
- try (EditSession editSession = WorldEdit.getInstance().newEditSession(weWorld)) {
-
- Region region = localSession.getSelection();
-
- ParserContext parserContext = new ParserContext();
- parserContext.setActor(actor);
- parserContext.setWorld(weWorld);
- parserContext.setSession(localSession);
- parserContext.setExtent(editSession);
-
- for (String maskString : masks) {
- ChatHelper.logDebug("Replacing blocks with expression mask: " + maskString.replace("%", "'PCT'") + " from " + from + " to " + Arrays.toString(to) + " for " + iterations + " iterations");
-
- Mask mask = new MaskFactory(WorldEdit.getInstance()).parseFromInput(maskString, parserContext);
-
- if (from != null) {
- BlockMask blockMask = new BlockMask(weWorld, from.toBaseBlock());
- editSession.setMask(blockMask);
- }
-
- Pattern pattern;
-
- if (to.length == 1)
- pattern = to[0];
- else {
- RandomPattern randomPattern = new RandomPattern();
- double chance = 100.0 / to.length;
-
- for (BlockState blockState : to)
- randomPattern.add(blockState, chance);
-
- pattern = randomPattern;
- }
-
-
- editSession.replaceBlocks(region, mask, pattern);
-
- saveEditSession(editSession, localSession, actor);
- }
- } catch (IncompleteRegionException | MaxChangedBlocksException | InputParseException e) {
- future.completeExceptionally(new RuntimeException(e));
- }
- }
-
- future.complete(null);
- });
-
- thread.start();
- return future;
- }
-
-
- /**
- * Replaces all blocks in a region with a schematic pattern.
- *
- * @param weWorld The WorldEdit world in which the region is located
- * @param localSession The local session of the actor
- * @param from The block to replace
- * @param schematicPath The path of the schematic to replace with
- *
- * @return A CompletableFuture that completes when the operation is finished
- */
- public static CompletableFuture replaceBlocksWithSchematic(LocalSession localSession, Actor actor, com.sk89q.worldedit.world.World weWorld, BlockState[] from, String schematicPath) {
- CompletableFuture future = new CompletableFuture<>();
- Thread thread = new Thread(() -> {
- ChatHelper.logDebug("Replacing blocks from " + Arrays.toString(from) + " to " + schematicPath);
-
- try (EditSession editSession = WorldEdit.getInstance().newEditSession(weWorld)) {
- Region region = localSession.getSelection();
-
- File schematicFile = new File(GeneratorUtils.getWorldEditSchematicsFolderPath() + schematicPath);
-
- ClipboardFormat format = ClipboardFormats.findByFile(schematicFile);
- ClipboardReader reader;
-
- if (format == null)
- return;
-
- try {
- reader = format.getReader(Files.newInputStream(schematicFile.toPath()));
- Clipboard clipboard = reader.read();
-
- Pattern pattern = new ClipboardPattern(clipboard);
-
- if(from != null) {
- BlockMask blockMask = new BlockMask(weWorld).add(from);
- editSession.replaceBlocks(region, blockMask, pattern);
- }else
- editSession.setBlocks(region, pattern);
- } catch (IOException e) {
- e.printStackTrace();
- return;
- }
-
- saveEditSession(editSession, localSession, actor);
- } catch (IncompleteRegionException | MaxChangedBlocksException e) {
- future.completeExceptionally(new RuntimeException(e));
- }
-
- future.complete(null);
- });
- thread.start();
- return future;
- }
-
-
- /**
- * Replaces all blocks in a region with a given block.
- *
- * @param weWorld The WorldEdit world in which the region is located
- * @param localSession The local session of the actor
- * @param from The block to replace
- * @param to The block to replace with
- *
- * @return A CompletableFuture that completes when the operation is finished
- */
- public static CompletableFuture replaceBlocks(LocalSession localSession, Actor actor, com.sk89q.worldedit.world.World weWorld, BlockState[] from, BlockState[] to) {
- if(to.length == 0)
- throw new IllegalArgumentException("BlockState[] to is empty");
-
- CompletableFuture future = new CompletableFuture<>();
- Thread thread = new Thread(() -> {
- ChatHelper.logDebug("Replacing blocks from " + Arrays.toString(from) + " to " + Arrays.toString(to));
-
- try (EditSession editSession = WorldEdit.getInstance().newEditSession(weWorld)) {
- Region region = localSession.getSelection();
- Pattern pattern;
-
- if(to.length == 1)
- pattern = to[0];
- else{
- RandomPattern randomPattern = new RandomPattern();
- double chance = 100.0 / to.length;
-
- for(BlockState blockState : to)
- randomPattern.add(blockState, chance);
-
- pattern = randomPattern;
- }
-
- if(from != null) {
- BlockMask blockMask = new BlockMask(weWorld).add(from);
- editSession.replaceBlocks(region, blockMask, pattern);
- }else
- editSession.setBlocks(region, pattern);
-
-
- saveEditSession(editSession, localSession, actor);
- } catch (IncompleteRegionException | MaxChangedBlocksException e) {
- future.completeExceptionally(new RuntimeException(e));
- }
-
- future.complete(null);
- });
- thread.start();
- return future;
- }
-
-
- /**
- * Draws a spline in a region with the given masks and a pattern.
- *
- * @param localSession The local session of the actor
- * @param actor The actor who should perform the operation
- * @param weWorld The WorldEdit world in which the region is located
- * @param regionBlocks The blocks of the region
- * @param masks The masks to use. If no mask should be used, pass an empty list.
- * @param points The points of the curve
- * @param blocks The blocks to use for the curve
- * @param tension The tension of the curve - Kochanek–Bartels Spline
- * @param bias The bias of the curve - Kochanek–Bartels Spline
- * @param continuity The continuity of the curve - Kochanek–Bartels Spline
- * @param quality The quality of the curve. The higher the quality, the more points the curve will have.
- * @param radius The radius of the curve. The higher the radius the thicker the curve will be.
- * @param filled Whether the curve should be filled or not.
- * @param matchElevation Whether the elevation of the points should be matched to the region
- */
- public static CompletableFuture drawSplineWithMasks(LocalSession localSession, Actor actor, com.sk89q.worldedit.world.World weWorld, Block[][][] regionBlocks, List masks, List points, BlockState[] blocks,
- boolean matchElevation, double tension, double bias, double continuity, double quality, double radius, boolean filled, boolean connectLineEnds) {
- if(blocks == null || blocks.length == 0)
- throw new IllegalArgumentException("BlockState[] to is empty");
-
- // If no mask is provided, add an empty mask
- if(masks.size() == 0) {
- masks = new ArrayList<>();
- masks.add("");
- }
-
- List finalMasks = masks;
- CompletableFuture future = new CompletableFuture<>();
- Thread thread = new Thread(() -> {
-
- try (EditSession editSession = WorldEdit.getInstance().newEditSession(weWorld)) {
-
- ParserContext parserContext = new ParserContext();
- parserContext.setActor(actor);
- parserContext.setWorld(weWorld);
- parserContext.setSession(localSession);
- parserContext.setExtent(editSession);
-
- for (String maskString : finalMasks) {
- ChatHelper.logDebug("Drawing spline with expression mask: " + maskString.replace("%", "'PCT'") + " with " + Arrays.toString(blocks));
-
- // Set the mask
- if (!maskString.isEmpty()) {
- Mask mask = new MaskFactory(WorldEdit.getInstance()).parseFromInput(maskString, parserContext);
- editSession.setMask(mask);
- }
-
- // Set the pattern
- Pattern pattern;
-
- if (blocks.length == 1)
- pattern = blocks[0];
- else {
- RandomPattern randomPattern = new RandomPattern();
- double chance = 100.0 / blocks.length;
-
- for (BlockState blockState : blocks)
- randomPattern.add(blockState, chance);
-
- pattern = randomPattern;
- }
-
- // Set the block vectors
- List blockVector3s = new ArrayList<>();
- for (Vector point : points) {
- if (matchElevation)
- point = getXYZ(point, regionBlocks);
-
- blockVector3s.add(BlockVector3.at(point.getBlockX(), point.getBlockY(), point.getBlockZ()));
- }
-
- editSession.drawSpline(pattern, blockVector3s, tension, bias, continuity, quality, radius, filled);
-
- if (connectLineEnds && blockVector3s.size() > 1)
- editSession.drawLine(pattern, blockVector3s.get(0), blockVector3s.get(blockVector3s.size() - 1), radius, true);
-
- saveEditSession(editSession, localSession, actor);
- }
- } catch (IncompleteRegionException | MaxChangedBlocksException | InputParseException e) {
- throw new RuntimeException(e);
- }
-
- future.complete(null);
- });
-
- thread.start();
- return future;
- }
-
- public static CompletableFuture drawCurveWithMasks(LocalSession localSession, Actor actor, com.sk89q.worldedit.world.World weWorld, Block[][][] regionBlocks, List masks, List points, BlockState[] blocks, boolean matchElevation){
- return drawSplineWithMasks(localSession, actor, weWorld, regionBlocks, masks, points, blocks, matchElevation, 0, 0, 0, 10, 0, true, false);
- }
-
- public static CompletableFuture drawPolyLineWithMasks(LocalSession localSession, Actor actor, com.sk89q.worldedit.world.World weWorld, Block[][][] regionBlocks, List masks, List points, BlockState[] blocks, boolean matchElevation, boolean connectLineEnds){
- return drawSplineWithMasks(localSession, actor, weWorld, regionBlocks, masks, points, blocks, matchElevation, 1, 0, -1, 10, 0, true, connectLineEnds);
- }
-
-
-
-
- /**
- * Draws a Line in a region with the given masks and a pattern.
- *
- * @param localSession The local session of the actor
- * @param actor The actor who should perform the operation
- * @param weWorld The WorldEdit world in which the region is located
- * @param regionBlocks The blocks of the region
- * @param masks The masks to use. If no mask should be used, pass an empty list.
- * @param point1 The first point of the curve
- * @param point2 The second point of the curve
- * @param blocks The blocks to use for the curve
- * @param matchElevation Whether the elevation of the points should be matched to the region
- */
- public static CompletableFuture drawLineWithMasks(LocalSession localSession, Actor actor, com.sk89q.worldedit.world.World weWorld, Block[][][] regionBlocks, List masks, Vector point1, Vector point2, BlockState[] blocks, boolean matchElevation) {
- if(blocks == null || blocks.length == 0)
- throw new IllegalArgumentException("BlockState[] to is empty");
-
- // If no mask is provided, add an empty mask
- if(masks.size() == 0) {
- masks = new ArrayList<>();
- masks.add("");
- }
-
- CompletableFuture future = new CompletableFuture<>();
- List finalMasks = masks;
- Thread thread = new Thread(() -> {
- try (EditSession editSession = WorldEdit.getInstance().newEditSession(weWorld)) {
-
- ParserContext parserContext = new ParserContext();
- parserContext.setActor(actor);
- parserContext.setWorld(weWorld);
- parserContext.setSession(localSession);
- parserContext.setExtent(editSession);
-
- for (String maskString : finalMasks) {
- ChatHelper.logDebug("Drawing line with expression mask: " + maskString.replace("%", "'PCT'") + " with " + Arrays.toString(blocks) + " from " + point1 + " to " + point2);
-
- // Set the mask
- if(!maskString.isEmpty()) {
- Mask mask = new MaskFactory(WorldEdit.getInstance()).parseFromInput(maskString, parserContext);
- editSession.setMask(mask);
- }
-
- // Set the pattern
- Pattern pattern;
-
- if(blocks.length == 1)
- pattern = blocks[0];
- else{
- RandomPattern randomPattern = new RandomPattern();
- double chance = 100.0 / blocks.length;
-
- for(BlockState blockState : blocks)
- randomPattern.add(blockState, chance);
-
- pattern = randomPattern;
- }
-
- Vector newPoint1 = point1;
- Vector newPoint2 = point2;
-
- // Adjust the points to the elevation of the region if matchElevation is true
- if(matchElevation){
- newPoint1 = getXYZ(point1, regionBlocks);
- newPoint2 = getXYZ(point2, regionBlocks);
- }
-
- // Set the block vectors
- BlockVector3 point1BlockVector3 = BlockVector3.at(newPoint1.getBlockX(), newPoint1.getBlockY(), newPoint1.getBlockZ());
- BlockVector3 point2BlockVector3 = BlockVector3.at(newPoint2.getBlockX(), newPoint2.getBlockY(), newPoint2.getBlockZ());
-
- editSession.drawLine(pattern, point1BlockVector3, point2BlockVector3, 0, true);
-
- saveEditSession(editSession, localSession, actor);
- }
- } catch(IncompleteRegionException | MaxChangedBlocksException | InputParseException e){
- throw new RuntimeException(e);
- }
-
- future.complete(null);
- });
-
- thread.start();
- return future;
- }
-
-
- /**
- * Pastes a schematic at a given location.
- *
- * @param localSession The local session of the actor
- * @param weWorld The WorldEdit world in which the region is located
- * @param blocks The blocks to paste
- * @param masks The masks to use
- * @param schematicPath The path to the schematic
- * @param loc The location to paste the schematic
- * @param rotation The rotation of the schematic
- */
- public static CompletableFuture pasteSchematicWithMasks(LocalSession localSession, Actor actor, com.sk89q.worldedit.world.World weWorld, Block[][][] blocks, List masks, String schematicPath, Location loc, double rotation) {
- int offsetY = 1;
-
- // If no mask is provided, add an empty mask
- if (masks.size() == 0) {
- masks = new ArrayList<>();
- masks.add("");
- }
-
- int maxHeight = loc.getBlockY();
-
- if(blocks != null)
- maxHeight = GeneratorUtils.getMaxHeight(blocks, loc.getBlockX(), loc.getBlockZ(), getIgnoredMaterials());
- if(maxHeight == 0)
- maxHeight = loc.getBlockY();
-
- CompletableFuture future = new CompletableFuture<>();
- int finalMaxHeight = maxHeight;
- final List finalMasks = masks;
- Thread thread = new Thread(() -> {
- try (EditSession editSession = WorldEdit.getInstance().newEditSession(weWorld)) {
- File schematicFile = new File(getWorldEditSchematicsFolderPath() + schematicPath);
-
- ClipboardFormat format = ClipboardFormats.findByFile(schematicFile);
- ClipboardReader reader;
-
- if (format == null)
- return;
-
- try {
- reader = format.getReader(Files.newInputStream(schematicFile.toPath()));
- Clipboard clipboard = reader.read();
-
- AffineTransform transform = new AffineTransform();
- transform = transform.rotateY(rotation);
-
- ClipboardHolder holder = new ClipboardHolder(clipboard);
- holder.setTransform(transform);
-
- ParserContext parserContext = new ParserContext();
- parserContext.setActor(actor);
- parserContext.setWorld(weWorld);
- parserContext.setSession(localSession);
- parserContext.setExtent(editSession);
-
- for (String maskString : finalMasks) {
- // Set the mask
- Mask mask = null;
- if(!maskString.isEmpty())
- mask = new MaskFactory(WorldEdit.getInstance()).parseFromInput(maskString, parserContext);
-
- com.sk89q.worldedit.function.operation.Operation op = holder
- .createPaste(editSession)
- .to(BlockVector3.at(loc.getBlockX(), finalMaxHeight + offsetY, loc.getBlockZ()))
- .ignoreAirBlocks(true)
- .maskSource(mask)
- .build();
- Operations.complete(op);
- }
- } catch (IOException | WorldEditException e) {
- throw new RuntimeException(e);
- }
-
- saveEditSession(editSession, localSession, actor);
-
- ChatHelper.logDebug("Pasted schematic: " + schematicPath + " at " + loc + " with rotation " + rotation);
- }
-
- future.complete(null);
- });
-
- thread.start();
- return future;
- }
-
- public static CompletableFuture pasteSchematic(LocalSession localSession, Actor actor, com.sk89q.worldedit.world.World weWorld, Block[][][] blocks, String schematicPath, Location loc, double rotation){
- return pasteSchematicWithMasks(localSession, actor, weWorld, blocks, new ArrayList<>(), schematicPath, loc, rotation);
- }
-
-
- /**
- * Expands the WorldEdit selection by a given vector.
- *
- * @param localSession The local session of the actor
- * @param vector The vector to expand the selection by
- */
- public static void expandSelection(LocalSession localSession, Vector vector){
- BlockVector3 blockVector3 = BlockVector3.at(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
-
- try {
- localSession.getSelection().expand(blockVector3);
- } catch (IncompleteRegionException | RegionOperationException e) {
- throw new RuntimeException(e);
- }
-
- ChatHelper.logDebug("Expanded selection by: " + vector);
- }
-
-
- /**
- * Clears the history of a LocalSession.
- * @param session The local session to clear the history of
- */
- public static void clearHistory(LocalSession session){
- session.clearHistory();
- ChatHelper.logDebug("Cleared history");
- }
-
- /**
- * Undoes the last action of a LocalSession.
- * @param session The local session to undo the last action of
- * @param player The player who created the structure
- * @param amount The amount of actions to undo
- */
- public static void undo(LocalSession session, Player player, Actor actor, int amount){
- com.sk89q.worldedit.entity.Player wePlayer = BukkitAdapter.adapt(player);
-
- for(int i = 0; i < amount; i++) {
- BlockBag blockBag = session.getBlockBag(wePlayer);
- EditSession undoSession = session.undo(blockBag, wePlayer);
-
- if (undoSession != null)
- WorldEdit.getInstance().flushBlockBag(actor, undoSession);
- else
- break;
- }
- }
-
- /**
- * Redoes the last action of a LocalSession.
- * @param session The local session to redo the last action of
- * @param player The player who created the structure
- * @param amount The amount of actions to redo
- */
- public static void redo(LocalSession session, Player player, Actor actor, int amount){
- com.sk89q.worldedit.entity.Player wePlayer = BukkitAdapter.adapt(player);
-
- for(int i = 0; i < amount; i++) {
- BlockBag blockBag = session.getBlockBag(wePlayer);
- EditSession redoSession = session.redo(blockBag, wePlayer);
-
- if (redoSession != null)
- WorldEdit.getInstance().flushBlockBag(actor, redoSession);
- else
- break;
- }
- }
-
-
-
- /**
- * Sets the gmask of a LocalSession.
- *
- * @param session The local session to set the gmask of
- * @param mask The mask to set. If the mask is null or empty, the gmask will be disabled.
- */
- public static void setGmask(LocalSession session, String mask){
- if(mask == null || mask.isEmpty()) {
- session.setMask(null);
- ChatHelper.logDebug("Disabled gmask");
- return;
- }
-
- try {
- ParserContext parserContext = new ParserContext();
- parserContext.setExtent(session.getSelectionWorld());
-
- Mask newMask = WorldEdit.getInstance().getMaskFactory().parseFromInput(mask,parserContext);
- session.setMask(newMask);
- } catch (InputParseException e) {
- throw new RuntimeException(e);
- }
-
- ChatHelper.logDebug("Set gmask to: " + mask);
- }
-
-
-
-
- /**
- * Commits and saves an edit session.
- *
- * @param editSession The edit session to commit
- * @param localSession The local session to save the edit session to
- */
- public static void saveEditSession(EditSession editSession, LocalSession localSession, Actor actor){
- editSession.commit();
- editSession.flushQueue();
-
- if(isFastAsyncWorldEditEnabled())
- localSession.remember(actor, localSession.getSelectionWorld(), editSession.getChangeSet(), FaweLimit.MAX);
-
- editSession.close();
- }
-
-
-
-
-
-
-
- /*=============================================**
-
- VECTOR HELPER FUNCTIONS
-
- **=============================================*/
-
-
-
- /**
- * Adjusts the height of a list of vectors so that they are on the surface of the terrain.
- *
- * @param points List of vectors to adjust
- * @param blocks List of blocks in polygon region
- */
- public static void adjustHeight(List points, Block[][][] blocks){
- for (Vector point : points)
- point.setY(getMaxHeight(blocks, point.getBlockX(), point.getBlockZ(), getIgnoredMaterials()));
- }
-
- /** As long as two neighboring vectors are further than a given distance of blocks apart, add a new vector in between them
- *
- * @param points The points to populate
- * @param distance The distance between the points
- * @return The populated points
- */
- public static List populatePoints(List points, int distance){
- List result = new ArrayList<>();
-
- // Go through all points
- boolean found = true;
- while(found){
- found = false;
-
- // Go through all vectors
- for (int i = 0; i < points.size() - 1; i++) {
-
- // Get the two neighboring vectors
- Vector p1 = points.get(i).clone();
- Vector p2 = points.get(i+1).clone();
-
- //ChatHelper.logDebug("p1: " + p1 + " p2: " + p2 + " distance: " + distance);
-
- // Add the first point
- result.add(p1);
-
- // If the distance between the two points is greater than the given distance, add a new point in between them
- if(p1.distance(p2) > distance){
- Vector v1 = p2.clone().subtract(p1);
- Vector v2 = v1.clone().multiply(0.5);
- Vector v3 = p1.clone().add(v2);
-
- // Add the new point
- result.add(v3);
- found = true;
- //ChatHelper.logDebug("Adding new point in between: " + v3);
- }
- }
-
- result.add(points.get(points.size()-1));
- points = result;
- result = new ArrayList<>();
- }
-
- return points;
- }
-
- /** As long as two neighboring vectors are closer than a given distance of blocks apart, remove the second point. The distances switch between distance1 and distance2
- *
- * @param points The points to reduce
- * @return The reduced points
- */
- public static List reducePoints(List points, int distance1, int distance2){
- points = new ArrayList<>(points);
-
- // Go through all points
- boolean found = true;
- while(found){
- found = false;
- for(int i = 0; i < points.size()-1; i++){
- Vector p1 = points.get(i);
- Vector p2 = points.get(i+1);
-
- int distance = distance1;
- // Switch between distance1 and distance2
- if(i%2 == 0)
- distance = distance2;
-
- // If the distance between the two points is less than the given distance, remove the second point
- if(p1.distance(p2) < distance){
- points.remove(p2);
- found = true;
- break;
- }
- }
- }
-
- return points;
- }
-
- /** Extends a polyline by taking the first two points and the last two points of the polyline and extending them
- *
- * @param vectors The polyline to extend
- * @return The extended polyline
- */
- public static List extendPolyLine(List vectors){
- List result = new ArrayList<>();
-
- // Get the first two points
- Vector p1 = vectors.get(0);
- Vector p2 = vectors.get(1);
-
- // Get the last two points
- Vector p3 = vectors.get(vectors.size()-2);
- Vector p4 = vectors.get(vectors.size()-1);
-
- // Get the vectors between the points
- Vector v1 = p1.clone().subtract(p2);
- Vector v2 = p4.clone().subtract(p3);
-
- result.add(p1.clone().add(v1));
- result.addAll(vectors);
- result.add(p4.clone().add(v2));
-
- return result;
- }
-
- /** Shortens a polyline by taking the first two points and the last two points of the polyline and shortening them
- *
- * @param vectors The polyline to shorten
- * @return The shortened polyline
- */
- public static List shortenPolyLine(List vectors, int distance){
- List result = new ArrayList<>();
-
- if(vectors.size() < 4)
- return vectors;
-
- // Get the first two points
- Vector p1 = vectors.get(0);
- Vector p2 = vectors.get(1);
-
- // Get the last two points
- Vector p3 = vectors.get(vectors.size()-2);
- Vector p4 = vectors.get(vectors.size()-1);
-
- // Get the vectors between the points
- Vector v1 = p2.clone().subtract(p1);
- Vector v2 = p3.clone().subtract(p4);
-
- // Shorten the vectors
- v1 = v1.clone().normalize().multiply(distance);
- v2 = v2.clone().normalize().multiply(distance);
-
- // Remove the first and last points
- vectors.remove(0);
- vectors.remove(vectors.size() - 1);
-
- // Add the shortened vectors
- result.add(p1.clone().add(v1));
- result.addAll(vectors);
- result.add(p4.clone().add(v2));
-
- return result;
- }
-
- /** Returns the closest vector from a list of vectors to a reference vector
- *
- * @param vectors List of vectors to search through
- * @param reference Reference vector to compare to
- * @return Closest vector to the reference vector
- */
- public static Vector getClosestVector(List vectors, Vector reference){
- Vector closestVector = null;
- double closestDistance = Double.MAX_VALUE;
-
- for(Vector vector : vectors){
- double distance = vector.distance(reference);
- if(distance < closestDistance){
- closestVector = vector;
- closestDistance = distance;
- }
- }
-
- if(closestVector == null)
- return null;
-
- return closestVector.clone();
- }
-
- /**
- * Returns the given vector with the height of the point matching the surface of the terrain.
- *
- * @param vector The vector to get the height from
- * @param blocks The dataset to get the height from
- * @return The vector with the height matching the surface of the terrain
- */
- private static Vector getXYZ(Vector vector, Block[][][] blocks){
- int maxHeight = vector.getBlockY();
-
- if(blocks != null)
- maxHeight = getMaxHeight(blocks, vector.getBlockX(), vector.getBlockZ(), getIgnoredMaterials());
- if(maxHeight == 0)
- maxHeight = vector.getBlockY();
-
- return vector.setY(maxHeight);
- }
-
- /**
- * Returns a XYZ String with the height of the point matching the surface of the terrain.
- *
- * @param vector The vector to get the XYZ String from
- * @param blocks The dataset to get the height from
- * @return The XYZ String
- */
- public static String getXYZWithVerticalOffset(Vector vector, Block[][][] blocks, int offset){
- int maxHeight = vector.getBlockY();
-
- if(blocks != null)
- maxHeight = getMaxHeight(blocks, vector.getBlockX(), vector.getBlockZ(), getIgnoredMaterials()) + offset;
- if(maxHeight == 0)
- maxHeight = vector.getBlockY();
-
- return vector.getBlockX() + "," + maxHeight + "," + vector.getBlockZ();
- }
-
- private static Path64 convertVectorListToPath64(List vectors, Vector reference){
- List points = new ArrayList<>();
- for(Vector vector : vectors)
- points.add(new Point64(vector.getBlockX() - reference.getBlockX(), vector.getBlockZ() - reference.getBlockZ()));
-
- return new Path64(points);
- }
-
- private static List> convertPathsToVectorList(Paths64 pathsD, Vector reference, int minHeight, int maxHeight){
- List> vectors = new ArrayList<>();
-
- for(Path64 path : new ArrayList<>(pathsD)) {
- List vectorList = new ArrayList<>();
-
- for(Point64 point : new ArrayList<>(path))
- vectorList.add(new Vector(point.x + reference.getX(), minHeight, point.y + reference.getZ()));
-
- Vector vector = vectorList.get(vectorList.size() - 1).setY(maxHeight);
- vectorList.set(vectorList.size() - 1, vector);
-
- vectors.add(vectorList);
- }
-
- return vectors;
- }
-
- /**
- * Shifts the points in a polyline by a given amount.
- * Sometimes during shifting there are multiple paths created.
- * For example, if you have a polyline that intersects itself, there is an inner and outer path.
- * This method can either return all the paths or just the longest one.
- *
- * @see #shiftPointsAll(List, double)
- *
- * @param vectors The polyline to shift
- * @param shift The amount to shift the points by
- * @param useLongestPathOnly Whether to only return the longest path
- * @return The shifted polyline
- */
- public static List shiftPoints(List vectors, double shift, boolean useLongestPathOnly) {
- List> resultVectors = shiftPointsAll(vectors, shift);
-
- // If we only want the longest path, find it and return it
- if(useLongestPathOnly){
- int longestPathIndex = 0;
- int longestPathLength = 0;
- for(int i = 0; i < resultVectors.size(); i++){
- if(resultVectors.get(i).size() > longestPathLength){
- longestPathIndex = i;
- longestPathLength = resultVectors.get(i).size();
- }
- }
-
- return resultVectors.get(longestPathIndex);
-
- // Otherwise, return all paths combined into one
- }else{
- List result = new ArrayList<>();
- for(List vectorList : resultVectors)
- result.addAll(vectorList);
-
- return result;
- }
- }
-
- /**
- * Shifts the points in a polyline by a given amount.
- * Sometimes during shifting there are multiple paths created.
- * For example, if you have a polyline that intersects itself, there is an inner and outer path.
- * This method returns a list of all the paths.
- *
- * @see #shiftPoints(List, double, boolean)
- *
- * @param vectors The polyline to shift
- * @param shift The amount to shift the points by
- * @return The shifted polyline
- */
- public static List> shiftPointsAll(List vectors, double shift) {
- Vector reference = vectors.get(0);
- int minHeight = getMinHeight(vectors);
- int maxHeight = getMaxHeight(vectors);
- Paths64 paths = new Paths64();
- paths.add(convertVectorListToPath64(vectors, reference));
- Paths64 inflatedPath = Clipper.InflatePaths(paths, shift, JoinType.Round, EndType.Butt, 2);
-
- return convertPathsToVectorList(inflatedPath, reference, minHeight, maxHeight);
- }
-
- /**
- * Gets the minimum height of a list of vectors
- *
- * @param vectors The list of vectors to get the minimum height of
- * @return The minimum height
- */
- public static int getMinHeight(List vectors){
- int minHeight = Integer.MAX_VALUE;
- for(Vector vector : vectors)
- minHeight = Math.min(minHeight, vector.getBlockY());
-
- return minHeight;
- }
-
- /**
- * Gets the maximum height of a list of vectors
- *
- * @param vectors The list of vectors to get the maximum height of
- * @return The maximum height
- */
- private static int getMaxHeight(List vectors){
- int maxHeight = Integer.MIN_VALUE;
- for(Vector vector : vectors)
- maxHeight = Math.max(maxHeight, vector.getBlockY());
-
- return maxHeight;
- }
-
-
-
-
-
- /*=============================================**
-
- PREPARATION CHECK FUNCTIONS
-
- **=============================================*/
-
-
-
- /**
- * Checks if Schematic Brush is installed and sends the player a message if it isn't.
- *
- * @param p The player to check for
- * @return Whether Schematic Brush is installed
- */
- public static boolean checkIfSchematicBrushIsInstalled(Player p){
- // Check if WorldEdit is enabled
- if (!isSchematicBrushEnabled()) {
- p.sendMessage("§cPlease install Schematic Brush to use this tool. You can ask the server administrator to install it.");
- sendWikiLink(p);
- return false;
- }
- return true;
- }
-
-
- /**
- * Checks if the player has a WorldEdit selection and sends them a message if they don't.
- *
- * @param p The player to check for
- * @return Whether the player has a WorldEdit selection
- */
- public static boolean checkForNoWorldEditSelection(Player p){
- // Get WorldEdit selection of player
- Region polyRegion = getWorldEditSelection(p);
-
- if(polyRegion != null)
- return false;
-
- p.sendMessage("§cPlease make a WorldEdit Selection first.");
- p.closeInventory();
- p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
- return true;
- }
-
-
- /**
- * Checks if the player has a brick block in their selection and sends them a message if they don't.
- *
- * @param p The player to check for
- * @return Whether the player has a brick block in their selection
- */
- public static boolean checkForBrickOutline(Block[][][] blocks, Player p){
- if(!containsBlock(blocks, XMaterial.BRICKS)){
- p.sendMessage("§cPlease make a selection around an outline.");
- p.closeInventory();
- p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
- sendWikiLink(p);
-
- return false;
- }
-
- return true;
- }
-
- /**
- * Checks if the player has a yellow wool block in their selection and sends them a message if they don't.
- *
- * @param p The player to check for
- * @return Whether the player has a yellow wool block in their selection
- */
- public static boolean checkForWoolBlock(Block[][][] blocks, Player p){
- if(!containsBlock(blocks, XMaterial.YELLOW_WOOL)){
- p.sendMessage("§cPlease place a yellow wool block inside the outline.");
- p.closeInventory();
- p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
- sendWikiLink(p);
-
- ItemStack yellowWool = XMaterial.YELLOW_WOOL.parseItem();
- if(!p.getInventory().contains(yellowWool)) {
- p.getInventory().setItem(4, yellowWool);
- p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0F, 1.0F);
- }
-
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/net/buildtheearth/modules/navigation/NavigationModule.java b/src/main/java/net/buildtheearth/modules/navigation/NavigationModule.java
deleted file mode 100644
index e903e0da..00000000
--- a/src/main/java/net/buildtheearth/modules/navigation/NavigationModule.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package net.buildtheearth.modules.navigation;
-
-import lombok.Getter;
-import net.buildtheearth.modules.Module;
-import net.buildtheearth.modules.navigation.components.navigator.NavigatorComponent;
-import net.buildtheearth.modules.navigation.components.navigator.commands.BuildteamCommand;
-import net.buildtheearth.modules.navigation.components.navigator.commands.NavigatorCommand;
-import net.buildtheearth.modules.navigation.components.navigator.listeners.NavigatorJoinListener;
-import net.buildtheearth.modules.navigation.components.navigator.listeners.NavigatorOpenListener;
-import net.buildtheearth.modules.navigation.components.tpll.TpllComponent;
-import net.buildtheearth.modules.navigation.components.tpll.listeners.TpllJoinListener;
-import net.buildtheearth.modules.navigation.components.tpll.listeners.TpllListener;
-import net.buildtheearth.modules.navigation.components.warps.WarpsComponent;
-import net.buildtheearth.modules.navigation.components.warps.commands.WarpCommand;
-import net.buildtheearth.modules.navigation.components.warps.commands.WarpsBtCommand;
-import net.buildtheearth.modules.navigation.components.warps.listeners.WarpJoinListener;
-import net.buildtheearth.modules.network.NetworkModule;
-
-/**
- * Manages all things related to universal tpll
- */
-public class NavigationModule extends Module {
-
-
- @Getter
- private WarpsComponent warpsComponent;
- @Getter
- private NavigatorComponent navigatorComponent;
- @Getter
- private TpllComponent tpllComponent;
-
-
- private static NavigationModule instance = null;
-
- public NavigationModule() {
- super("Navigation", NetworkModule.getInstance());
- }
-
- public static NavigationModule getInstance() {
- return instance == null ? instance = new NavigationModule() : instance;
- }
-
-
- @Override
- public void enable() {
- if(NetworkModule.getInstance().getBuildTeam() == null) {
- shutdown("The Network Module failed to load the Build Team.");
- return;
- }
-
- warpsComponent = new WarpsComponent();
- navigatorComponent = new NavigatorComponent();
- tpllComponent = new TpllComponent();
-
- super.enable();
- }
-
- @Override
- public void registerCommands() {
- registerCommand("warp", new WarpCommand());
- registerCommand("navigator", new NavigatorCommand());
- registerCommand("buildteam", new BuildteamCommand());
- registerCommand("warpsbt", new WarpsBtCommand());
- }
-
- @Override
- public void registerListeners() {
- super.registerListeners(
- new TpllJoinListener(),
- new TpllListener(),
- new WarpJoinListener(),
- new NavigatorJoinListener(),
- new NavigatorOpenListener()
- );
- }
-}
diff --git a/src/main/java/net/buildtheearth/utils/ChatHelper.java b/src/main/java/net/buildtheearth/utils/ChatHelper.java
deleted file mode 100644
index db250e57..00000000
--- a/src/main/java/net/buildtheearth/utils/ChatHelper.java
+++ /dev/null
@@ -1,165 +0,0 @@
-package net.buildtheearth.utils;
-
-import net.buildtheearth.BuildTeamTools;
-import net.buildtheearth.utils.io.ConfigPaths;
-import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.TextComponent;
-import net.kyori.adventure.text.format.NamedTextColor;
-import net.kyori.adventure.text.format.TextDecoration;
-import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import javax.annotation.Nullable;
-import java.util.Arrays;
-import java.util.logging.Level;
-
-public class ChatHelper {
-
- public static TextComponent PREFIX_COMPONENT = LegacyComponentSerializer.legacyAmpersand().deserialize(BuildTeamTools.PREFIX);
-
- public static boolean DEBUG;
-
- static {
- BuildTeamTools.getInstance().getConfig();
- DEBUG = BuildTeamTools.getInstance().getConfig().getBoolean(ConfigPaths.DEBUG, false);
- }
-
-
- // ------------------ LOGGING ------------------
-
- public static void logError(String errorMessage, Object... objects) {
- Bukkit.getLogger().log(Level.INFO, ChatHelper.getErrorString(errorMessage, objects));
- }
-
- public static void logError(String errorMessage, Exception e, Object... objects) {
- BuildTeamTools.getInstance().getComponentLogger().error(ChatHelper.getErrorComponent(errorMessage, objects), e);
- }
-
- public static void log(String string, Object... objects) {
- Bukkit.getConsoleSender().sendMessage( getConsoleString(string, objects));
- }
-
- public static void logDebug(String string, Object... objects) {
- if(DEBUG || BuildTeamTools.getInstance().isDebug())
- Bukkit.getLogger().log(Level.INFO, getConsoleString(string, objects));
- }
-
- public static String getConsoleString(String string, Object... objects) {
- return BuildTeamTools.CONSOLE_PREFIX + String.format(string, objects);
- }
-
-
-
- // ------------------ STANDARD TEXT (Gray & Yellow) ------------------
-
- public static Component getStandardComponent(boolean containsPrefix, String string, Object... objects) {
- Component component = LegacyComponentSerializer.legacyAmpersand().deserialize(
- String.format(string.replaceAll("%s", "&e%s&7"), objects)
- ).color(NamedTextColor.GRAY);
-
- return containsPrefix ? PREFIX_COMPONENT.append(component) : component;
- }
-
- public static String getStandardString(boolean containsPrefix, String string, Object... objects) {
- return convertComponentToLegacyString(getStandardComponent(containsPrefix, string, objects));
- }
-
- public static String getStandardString(String string, Object... objects) {
- return getStandardString(true, string, objects);
- }
-
- public static void sendStandardMessage(Player player, String string, Object... objects) {
- player.sendMessage(getStandardComponent(true, string, objects));
- }
-
- public static void sendStandardMessage(Player player, boolean containsPrefix, String string, Object... objects) {
- player.sendMessage(getStandardComponent(containsPrefix, string, objects));
- }
-
-
- // ------------------ SUCCESS TEXT (Gray & Green Text) ------------------
-
- public static Component getSuccessComponent(String string, Object... objects) {
- return PREFIX_COMPONENT.append(
- LegacyComponentSerializer.legacyAmpersand().deserialize(
- String.format(string.replaceAll("%s", "&a%s&7"), objects)
- ).color(NamedTextColor.GRAY)
- );
- }
-
- public static void sendSuccessfulMessage(Player player, String string, Object... objects) {
- player.sendMessage(getSuccessComponent(string, objects));
- }
-
-
-
- // ------------------ ERROR TEXT (Red & Yellow Text) ------------------
-
- public static Component getErrorComponent(String string, Object... objects) {
- return LegacyComponentSerializer.legacyAmpersand().deserialize(
- String.format(string.replaceAll("%s", "&e%s&c"), objects)
- ).color(NamedTextColor.RED);
- }
-
- public static String getErrorString(String string, Object... objects) {
- return convertComponentToLegacyString(getErrorComponent(string, objects));
- }
-
- public static void sendErrorMessage(Player player, String string, Object... objects) {
- player.sendMessage(getErrorString(string, objects));
- }
-
-
- // ------------------ COLORIZED TEXT ------------------
-
- public static Component getColorizedComponent(NamedTextColor color, String string, boolean bold) {
- return Component.text(string).color(color).decoration(TextDecoration.BOLD, bold);
- }
-
- public static String getColorizedString(NamedTextColor color, String string, boolean bold) {
- return convertComponentToLegacyString(getColorizedComponent(color, string, bold));
- }
-
-
-
- /** Sends the given message to the given player and the console
- *
- * @param p player to send the message to. If null, the message will only be sent to the console
- * @param message message to send
- * @param logLevel log level to use for the console
- */
- public static void logPlayerAndConsole(@Nullable Player p, String message, Level logLevel){
- if(p != null)
- p.sendMessage(message);
-
- BuildTeamTools.getInstance().getLogger().log(logLevel, message);
- }
-
- public static void sendMessageBox(CommandSender sender, String title, Runnable runnable) {
- sender.sendMessage("");
- sender.sendMessage("§7§m==============§e§l " + title + " §7§m==============");
- sender.sendMessage("");
-
- runnable.run();
-
- int length = org.bukkit.ChatColor.stripColor(title).length();
- char[] array = new char[length];
- Arrays.fill(array, '=');
- String bottom = "==============================" + new String(array);
- sender.sendMessage("");
- sender.sendMessage("§7§m" + bottom);
- }
-
- public static void sendMessageToPlayersNearLocation(Location location, String message, double maxDistance) {
- for (Player player : location.getWorld().getNearbyEntitiesByType(Player.class, location, maxDistance)) {
- player.sendMessage(message);
- }
- }
-
- private static String convertComponentToLegacyString(Component component) {
- return LegacyComponentSerializer.legacyAmpersand().serialize(component).replace("&", "§");
- }
-}
diff --git a/src/main/java/net/buildtheearth/utils/Item.java b/src/main/java/net/buildtheearth/utils/Item.java
deleted file mode 100644
index 69401a13..00000000
--- a/src/main/java/net/buildtheearth/utils/Item.java
+++ /dev/null
@@ -1,527 +0,0 @@
-package net.buildtheearth.utils;
-
-import com.cryptomorin.xseries.XMaterial;
-import com.mojang.authlib.GameProfile;
-import com.mojang.authlib.properties.Property;
-import com.sk89q.worldedit.world.block.BlockType;
-import com.sk89q.worldedit.world.block.BlockTypes;
-import net.buildtheearth.modules.common.CommonModule;
-import org.bukkit.Bukkit;
-import org.bukkit.Color;
-import org.bukkit.Material;
-import org.bukkit.enchantments.Enchantment;
-import org.bukkit.inventory.ItemFlag;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-import org.bukkit.inventory.meta.LeatherArmorMeta;
-import org.bukkit.inventory.meta.SkullMeta;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Base64;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-public class Item {
- public static final Map nonPlayerSkulls = new HashMap<>();
-
- private ItemStack item;
- private Material material;
- private String displayName;
- private int amount = -1;
- private List lore;
- private boolean hideAttributes;
- private boolean hideEnchantments;
- private final List canDestroyItems = new ArrayList<>();
- private final List canPlaceItems = new ArrayList<>();
-
- private final HashMap enchantments = new HashMap<>();
-
- public Item() {}
-
- public Item(Material material) {
- this.material = material;
- }
-
- public Item(ItemStack item) {
- this.item = item;
- }
-
- public Item setType(Material material) {
- this.material = material;
- return this;
- }
-
- public Item setDisplayName(String name) {
- this.displayName = name;
- return this;
- }
-
- public Item setAmount(int amount) {
- this.amount = amount;
- return this;
- }
-
- public Item setLore(List lore) {
- this.lore = lore;
- return this;
- }
-
- public Item addEnchantment(Enchantment enchantment, int level) {
- this.enchantments.put(enchantment, level);
- return this;
- }
-
- public Item hideAttributes(boolean hide) {
- this.hideAttributes = hide;
- return this;
- }
-
- public Item hideEnchantments(boolean enchants) {
- this.hideEnchantments = enchants;
- return this;
- }
-
- public Item addCanDestroyItem(String itemName){
- this.canDestroyItems.add(itemName);
- return this;
- }
-
- public Item addCanPlaceItem(String itemName){
- this.canPlaceItems.add(itemName);
- return this;
- }
-
- public ItemStack build() {
- ItemStack item = XMaterial.BARRIER.parseItem();
-
- if(this.material != null)
- item.setType(material);
-
- if(this.item != null)
- item = this.item.clone();
-
- if(this.amount != -1)
- item.setAmount(this.amount);
- else
- item.setAmount(1);
-
- if (item.getEnchantments().isEmpty())
- for (Map.Entry en : this.enchantments.entrySet())
- item.addUnsafeEnchantment(en.getKey(), en.getValue());
-
-
-
- ItemMeta itemmeta = item.getItemMeta();
-
- if(this.displayName != null)
- itemmeta.setDisplayName(this.displayName);
-
- if(this.lore != null)
- itemmeta.setLore(this.lore);
-
- if (this.hideAttributes)
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- if (this.hideEnchantments)
- itemmeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
-
- /*if(!canDestroyItems.isEmpty()){
- // TODO Marked for removal in 1.20.6, not fixed yet.
- //Set nameSpacedKeySet = new HashSet<>();
- //for(String itemName : canDestroyItems)
- // nameSpacedKeySet.add(NamespacedKey.minecraft(itemName));
- //itemmeta.setDestroyableKeys(nameSpacedKeySet);
- }
-
- if(!canPlaceItems.isEmpty()){
- // TODO Marked for removal in 1.20.6, not fixed yet.
- //Set nameSpacedKeySet = new HashSet<>();
- //for(String itemName : canPlaceItems)
- // nameSpacedKeySet.add(NamespacedKey.minecraft(itemName));
- //itemmeta.setPlaceableKeys(nameSpacedKeySet);
- }*/
-
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static ItemStack create(Material material) {
- return new ItemStack(material);
- }
-
- public static ItemStack create(Material material, int amount) {
- return new ItemStack(material, amount);
- }
-
- public static ItemStack create(Material material, String name) {
- ItemStack item = new ItemStack(material, 1);
- return edit(item, name);
- }
-
- public static ItemStack create(Material material, String name, int amount) {
- ItemStack item = new ItemStack(material, amount);
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @NotNull ItemStack create(Material material, String name, List lore) {
- ItemStack item = new ItemStack(material, 1, (short)0);
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setLore(lore);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @NotNull ItemStack create(Material material, String name, short durability, List lore) {
- ItemStack item = new ItemStack(material, 1, durability);
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setLore(lore);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @NotNull ItemStack create(Material material, String name, int amount, List lore) {
- ItemStack item = new ItemStack(material, amount);
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setLore(lore);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @NotNull ItemStack createLeatherArmor(Material material, String name, Color color, List lore) {
- ItemStack item = new ItemStack(material);
- LeatherArmorMeta itemmeta = (LeatherArmorMeta)item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setLore(lore);
- itemmeta.setColor(color);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @NotNull ItemStack create(Material material, String name, List lore, Enchantment enchnt1, Integer level1) {
- ItemStack item = new ItemStack(material);
- item.addUnsafeEnchantment(enchnt1, level1);
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setLore(lore);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @NotNull ItemStack create(Material material, String name, List lore, Enchantment enchnt1, Integer level1, Enchantment enchnt2, Integer level2) {
- ItemStack item = new ItemStack(material);
- item.addUnsafeEnchantment(enchnt1, level1);
- item.addUnsafeEnchantment(enchnt2, level2);
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setLore(lore);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @NotNull ItemStack create(Material material, String name, List lore, Enchantment enchnt1, Integer level1, Enchantment enchnt2, Integer level2, Enchantment enchnt3, Integer level3) {
- ItemStack item = new ItemStack(material);
- item.addUnsafeEnchantment(enchnt1, level1);
- item.addUnsafeEnchantment(enchnt2, level2);
- item.addUnsafeEnchantment(enchnt3, level3);
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setLore(lore);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @NotNull ItemStack createLeatherArmor(Material material, Color color) {
- ItemStack item = new ItemStack(material);
- LeatherArmorMeta itemmeta = (LeatherArmorMeta)item.getItemMeta();
- itemmeta.setColor(color);
- item.setItemMeta(itemmeta);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- return item;
- }
-
- public static @NotNull ItemStack createLeatherArmor(Material material, String name, Color color, List lore, Enchantment enchnt1, Integer level1) {
- ItemStack item = new ItemStack(material);
- item.addUnsafeEnchantment(enchnt1, level1);
- LeatherArmorMeta itemmeta = (LeatherArmorMeta)item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setLore(lore);
- itemmeta.setColor(color);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @NotNull ItemStack createLeatherArmor(Material material, String name, Color color, List lore, Enchantment enchnt1, Integer level1, Enchantment enchnt2, Integer level2) {
- ItemStack item = new ItemStack(material);
- item.addUnsafeEnchantment(enchnt1, level1);
- item.addUnsafeEnchantment(enchnt2, level2);
- LeatherArmorMeta itemmeta = (LeatherArmorMeta)item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setLore(lore);
- itemmeta.setColor(color);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @NotNull ItemStack createLeatherArmor(Material material, String name, Color color, List lore, Enchantment enchnt1, Integer level1, Enchantment enchnt2, Integer level2, Enchantment enchnt3, Integer level3) {
- ItemStack item = new ItemStack(material);
- item.addUnsafeEnchantment(enchnt1, level1);
- item.addUnsafeEnchantment(enchnt2, level2);
- item.addUnsafeEnchantment(enchnt3, level3);
- LeatherArmorMeta itemmeta = (LeatherArmorMeta)item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setLore(lore);
- itemmeta.setColor(color);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @Nullable ItemStack createPlayerHead(String name, String owner) {
- ItemStack item = XMaterial.PLAYER_HEAD.parseItem();
-
- if(item == null)
- return null;
-
- SkullMeta itemmeta = (SkullMeta)item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setOwner(owner);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @Nullable ItemStack createPlayerHead(String name, String owner, List lore) {
- ItemStack item = XMaterial.PLAYER_HEAD.parseItem();
-
- if(item == null)
- return null;
-
- SkullMeta itemmeta = (SkullMeta)item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.setOwner(owner);
- itemmeta.setLore(lore);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- @Contract("_, _ -> param1")
- public static @NotNull ItemStack edit(@NotNull ItemStack item, Material material) {
- item.setType(material);
- return item;
- }
-
- @Contract("_, _ -> param1")
- public static @NotNull ItemStack edit(@NotNull ItemStack item, int amount) {
- item.setAmount(amount);
- return item;
- }
-
- @Contract("_, _ -> param1")
- public static @NotNull ItemStack edit(@NotNull ItemStack item, String name) {
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- @Contract("_, _, _ -> param1")
- public static @NotNull ItemStack edit(@NotNull ItemStack item, int amount, String name) {
- item.setAmount(amount);
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- @Contract("_, _ -> param1")
- public static @NotNull ItemStack edit(@NotNull ItemStack item, List lore) {
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setLore(lore);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- @Contract("_, _, _, _ -> param1")
- public static @NotNull ItemStack edit(@NotNull ItemStack item, int amount, String name, List lore) {
- item.setAmount(amount);
- ItemMeta itemmeta = item.getItemMeta();
- itemmeta.setDisplayName(name);
- itemmeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- itemmeta.setLore(lore);
- item.setItemMeta(itemmeta);
- return item;
- }
-
- public static @Nullable ItemStack fromUniqueMaterialString(String materialString) {
- Material material = Material.matchMaterial(materialString);
- if(material != null)
- return XMaterial.matchXMaterial(material).parseItem();
-
-
- if(XMaterial.matchXMaterial(materialString).isPresent())
- return XMaterial.matchXMaterial(materialString).get().parseItem();
-
- return null;
- }
-
- public static @NotNull String getUniqueMaterialString(ItemStack item) {
- if(CommonModule.getInstance().getVersionComponent().is_1_12())
- return XMaterial.matchXMaterial(item).getId() + ":" + XMaterial.matchXMaterial(item).getData();
- else
- return item.getType().getKey().asString();
-
- }
-
- public static @NotNull String getUniqueMaterialString(@NotNull XMaterial material) {
- return getUniqueMaterialString(material.parseItem());
- }
-
- public static String getUniqueMaterialString(XMaterial[] materials) {
- if(materials == null || materials.length == 0)
- return null;
-
- StringBuilder s = new StringBuilder(getUniqueMaterialString(materials[0]));
-
- for (int i = 1; i < materials.length; i++)
- s.append(",").append(getUniqueMaterialString(materials[i]));
-
- return s.toString();
- }
-
- public static @Nullable XMaterial convertStringToXMaterial(String materialString) {
- XMaterial material;
-
- if(XMaterial.matchXMaterial(materialString).isPresent())
- material = XMaterial.matchXMaterial(materialString).get();
- else {
- Material mat = Material.matchMaterial(materialString);
-
- if(mat != null)
- material = XMaterial.matchXMaterial(mat);
- else
- return null;
- }
-
- return material;
- }
-
- public static BlockType convertXMaterialToBlockType(XMaterial material) {
- String mat = getUniqueMaterialString(material);
- BlockType bt;
-
- if(mat.contains("minecraft:"))
- bt = BlockTypes.parse(mat);
- else
- bt = BlockTypes.get(mat);
-
- return bt;
- }
-
- public static @NotNull String createStringFromItemList(@NotNull List items) throws IllegalArgumentException {
- StringBuilder s = new StringBuilder(items.getFirst());
-
- for (int i = 1; i < items.size(); i++)
- if(XMaterial.matchXMaterial(items.get(i)).isPresent()) {
- XMaterial xMaterial = XMaterial.matchXMaterial(items.get(i)).get();
-
- s.append(",").append(getUniqueMaterialString(xMaterial.parseItem()));
- }
-
- return s.toString();
- }
-
- public static ItemStack createCustomHeadTextureURL(String url, String name, List lore) {
- byte[] encodedByteData = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
- String encodedData = new String(encodedByteData);
-
- return createCustomHeadBase64(encodedData, name, lore);
- }
-
- public static @Nullable ItemStack createCustomHeadBase64(String base64, String name, List lore) {
- if (nonPlayerSkulls.containsKey(base64 + name + lore))
- return nonPlayerSkulls.get(base64 + name + lore);
-
- ItemStack head = XMaterial.PLAYER_HEAD.parseItem();
-
- if(head == null)
- return null;
-
- SkullMeta meta = (SkullMeta) head.getItemMeta();
- mutateItemMeta(meta, base64);
- meta.setDisplayName(name);
- meta.setLore(lore);
- head.setItemMeta(meta);
-
- nonPlayerSkulls.put(base64 + name + lore, head);
-
- return head;
- }
-
- private static void mutateItemMeta(SkullMeta meta, String b64) {
- GameProfile profile = makeProfile(b64);
-
- // Try Paper API (Minecraft Version 1.20+)
- try {
- Method setPlayerProfile = SkullMeta.class.getMethod("setPlayerProfile", com.destroystokyo.paper.profile.PlayerProfile.class);
- com.destroystokyo.paper.profile.PlayerProfile paperProfile = Bukkit.createProfile(profile.getId(), profile.getName());
- paperProfile.getProperties().add(new com.destroystokyo.paper.profile.ProfileProperty("textures", b64));
- setPlayerProfile.invoke(meta, paperProfile);
- return;
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {}
-
- // Try setProfile(GameProfile) (Minecraft Version 1.15 – 1.19.4)
- try {
- Method metaSetProfileMethod = meta.getClass().getDeclaredMethod("setProfile", GameProfile.class);
- metaSetProfileMethod.setAccessible(true);
- metaSetProfileMethod.invoke(meta, profile);
- return;
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {}
-
- // Try direct profile field (Minecraft Version 1.12 – 1.14)
- try {
- Field metaProfileField = meta.getClass().getDeclaredField("profile");
- metaProfileField.setAccessible(true);
- metaProfileField.set(meta, profile);
- } catch (NoSuchFieldException | IllegalAccessException ignored) {
- System.err.println("Failed to set custom skull texture: unsupported server version or method change.");
- }
- }
-
-
- private static @NotNull GameProfile makeProfile(@NotNull String b64) {
- UUID id = new UUID(
- b64.substring(b64.length() - 20).hashCode(),
- b64.substring(b64.length() - 10).hashCode()
- );
- GameProfile profile = new GameProfile(id, "bte");
- profile.getProperties().put("textures", new Property("textures", b64));
- return profile;
- }
-}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index c813b428..3fc73a47 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -2,15 +2,13 @@
# | BuildTeamTools - by BuildTheEarth
# ----------------------------------------------------------------------------------------------
# | [Github Repo] https://github.com/BuildTheEarth/BuildTeamTools
-# | [Config Documentation] https://github.com/BuildTheEarth/BuildTeamTools/wiki/Configuration
-# | [Contacts - Discord] BuildTheEarth Staff Discord, @minefact
+# | [Config Documentation] https://resources.buildtheearth.net/doc/configuration-tpEHSZ6Zt2#h-general-configuration
+# | [Contacts - Discord] BTE Development Hub, @zoriot
# ----------------------------------------------------------------------------------------------
-language: "EN"
-
# The Build Team API Key used to fetch build team info for display.
# Find the key on the Minecraft Network at "buildtheearth.net". Navigate: Compass > Build Teams > My Teams > Your Team > API-Key.
-# Without this key, some plugin components won`t function. For assistance, see #server-support on the staff discord.
+# Without this key, some plugin components wont function. For assistance, see #server-support on the staff discord.
api-key: 00000000-0000-0000-0000-000000000000
# The main world using the custom BTE Dynmaxion projection
@@ -23,6 +21,5 @@ disabled-modules:
# Enable or disable the debug mode
debug: false
-
# NOTE: Do not change
config-version: 1.4
\ No newline at end of file
diff --git a/src/main/resources/modules/navigation/config.yml b/src/main/resources/modules/navigation/config.yml
index 0eed449b..6bbb5662 100644
--- a/src/main/resources/modules/navigation/config.yml
+++ b/src/main/resources/modules/navigation/config.yml
@@ -4,8 +4,8 @@
# | The navigator module allows the player to navigate through the project
# ----------------------------------------------------------------------------------------------
# | [Github Repo] https://github.com/BuildTheEarth/BuildTeamTools
-# | [Config Documentation] https://github.com/BuildTheEarth/BuildTeamTools/wiki/Configuration
-# | [Contacts - Discord] BuildTheEarth Staff Discord, @minefact
+# | [Config Documentation] https://resources.buildtheearth.net/doc/configuration-tpEHSZ6Zt2#h-navigation
+# | [Contacts - Discord] BTE Development Hub, @zoriot
# ----------------------------------------------------------------------------------------------
# Configures the navigator item in the players hotbar
@@ -48,4 +48,4 @@ warps:
sorting-mode: default
# NOTE: Do not change
-config-version: 1.4
\ No newline at end of file
+config-version: 1.6
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index dece42e8..b7984b01 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,7 +1,8 @@
name: BuildTeamTools
-main: net.buildtheearth.BuildTeamTools
+main: net.buildtheearth.buildteamtools.BuildTeamTools
api-version: 1.13
-version: 0.1.3-alpha
+version: ${version}
+description: ${description}
author: MineFact, frikandelworst, George112n, ELgamer, SirJodelstein, Zoriot
softdepend: [WorldEdit, HeadDatabase, PlotSystem-Terra]
@@ -21,26 +22,15 @@ commands:
warp:
description: Command for managing warps.
usage: /warp
- aliases: [warps]
- warpsbt:
+ aliases: [ warps, wp ]
+ warpbt:
description: Opens the warp menu for the specified BuildTeam
usage: /warpsbt
- aliases: [ wbt ]
+ aliases: [ wbt, wpt, warpsbuildteam, warpsbt ]
kml:
description: kml pasting and parsing
usage: /kml
aliases: [geopoints, geopath, georing, geosurface]
- createplot:
- description: Creates a new plot for the PlotSystem.
- usage: /createplot
- permission: plotsystem.createplot
- pasteplot:
- description: Pastes a plot manually with specific ID
- usage: /pasteplot
- permission: plotsystem.pasteplot
- plotsystemterra:
- description: Sends info about the plugin
- usage: /plotsystemterra
blockpalette:
description: Opens the block palette menu.
usage: /blockpalette [filter|menu|filter ...]