Code cleanup
This commit is contained in:
parent
3f0774d9fc
commit
93cb07806e
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -23,7 +20,7 @@ public class Greenhouses extends Addon {
|
|||
private GreenhouseManager manager;
|
||||
private Settings settings;
|
||||
private RecipeManager recipes;
|
||||
private List<World> activeWorlds = new ArrayList<>();
|
||||
private final List<World> activeWorlds = new ArrayList<>();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see world.bentobox.bentobox.api.addons.Addon#onEnable()
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.data;
|
||||
|
||||
import world.bentobox.bentobox.database.objects.adapters.AdapterInterface;
|
||||
|
@ -11,7 +8,7 @@ import world.bentobox.greenhouses.managers.RecipeManager;
|
|||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class BiomeRecipeSerializer implements AdapterInterface<BiomeRecipe, String> {
|
||||
class BiomeRecipeSerializer implements AdapterInterface<BiomeRecipe, String> {
|
||||
|
||||
@Override
|
||||
public BiomeRecipe deserialize(Object object) {
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.data;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.data;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
@ -11,7 +8,7 @@ import world.bentobox.bentobox.database.objects.adapters.AdapterInterface;
|
|||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class RectangleSerializer implements AdapterInterface<Rectangle, String> {
|
||||
class RectangleSerializer implements AdapterInterface<Rectangle, String> {
|
||||
|
||||
@Override
|
||||
public Rectangle deserialize(Object object) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import world.bentobox.greenhouses.data.Greenhouse;
|
|||
import world.bentobox.greenhouses.managers.GreenhouseManager.GreenhouseResult;
|
||||
|
||||
public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
||||
private Greenhouses plugin;
|
||||
private final Greenhouses addon;
|
||||
private Biome type;
|
||||
private Material icon; // Biome icon for control panel
|
||||
private int priority;
|
||||
|
@ -34,17 +34,17 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
|
||||
// Content requirements
|
||||
// Material, Type, Qty. There can be more than one type of material required
|
||||
private Map<Material, Integer> requiredBlocks = new HashMap<>();
|
||||
private final Map<Material, Integer> requiredBlocks = new HashMap<>();
|
||||
// Plants
|
||||
private TreeMap<Double, GreenhousePlant> plantTree = new TreeMap<>();
|
||||
private final TreeMap<Double, GreenhousePlant> plantTree = new TreeMap<>();
|
||||
|
||||
// Mobs
|
||||
// Entity Type, Material to Spawn on, Probability
|
||||
private TreeMap<Double, GreenhouseMob> mobTree = new TreeMap<>();
|
||||
private final TreeMap<Double, GreenhouseMob> mobTree = new TreeMap<>();
|
||||
|
||||
// Conversions
|
||||
// Original Material, Original Type, New Material, New Type, Probability
|
||||
private Map<Material, GreenhouseBlockConversions> conversionBlocks = new HashMap<>();
|
||||
private final Map<Material, GreenhouseBlockConversions> conversionBlocks = new HashMap<>();
|
||||
|
||||
private int mobLimit;
|
||||
private int waterCoverage;
|
||||
|
@ -52,18 +52,17 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
private int lavaCoverage;
|
||||
|
||||
private String permission = "";
|
||||
private Random random = new Random();
|
||||
private final Random random = new Random();
|
||||
private Map<Material, Integer> missingBlocks;
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @param priority
|
||||
* @param type - biome
|
||||
* @param priority - priority (higher is better)
|
||||
*/
|
||||
public BiomeRecipe(Greenhouses addon, Biome type, int priority) {
|
||||
this.plugin = addon;
|
||||
this.addon = addon;
|
||||
this.type = type;
|
||||
this.priority = priority;
|
||||
//addon.logger(3,"" + type.toString() + " priority " + priority);
|
||||
mobLimit = 9; // Default
|
||||
}
|
||||
|
||||
|
@ -76,17 +75,17 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
public void addConvBlocks(Material oldMaterial, Material newMaterial, double convChance, Material localMaterial) {
|
||||
double probability = Math.min(convChance/100 , 1D);
|
||||
conversionBlocks.put(oldMaterial, new GreenhouseBlockConversions(oldMaterial, newMaterial, probability, localMaterial));
|
||||
//plugin.logger(1," " + convChance + "% chance for " + Util.prettifyText(oldMaterial.toString()) + " to convert to " + Util.prettifyText(newMaterial.toString()));
|
||||
addon.log(" " + convChance + "% chance for " + Util.prettifyText(oldMaterial.toString()) + " to convert to " + Util.prettifyText(newMaterial.toString()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mobType
|
||||
* @param mobProbability
|
||||
* @param mobSpawnOn
|
||||
* @param mobType - entity type
|
||||
* @param mobProbability - reltive probability
|
||||
* @param mobSpawnOn - material to spawn on
|
||||
*/
|
||||
public void addMobs(EntityType mobType, int mobProbability, Material mobSpawnOn) {
|
||||
//plugin.logger(1," " + mobProbability + "% chance for " + Util.prettifyText(mobType.toString()) + " to spawn on " + Util.prettifyText(mobSpawnOn.toString())+ ".");
|
||||
addon.log(" " + mobProbability + "% chance for " + Util.prettifyText(mobType.toString()) + " to spawn on " + Util.prettifyText(mobSpawnOn.toString())+ ".");
|
||||
double probability = ((double)mobProbability/100);
|
||||
double lastProb = mobTree.isEmpty() ? 0D : mobTree.lastKey();
|
||||
// Add up all the probabilities in the list so far
|
||||
|
@ -94,7 +93,7 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
// Add to probability tree
|
||||
mobTree.put(lastProb + probability, new GreenhouseMob(mobType, mobSpawnOn));
|
||||
} else {
|
||||
plugin.logError("Mob chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + mobType.toString());
|
||||
addon.logError("Mob chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + mobType.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,18 +112,18 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
// Add to probability tree
|
||||
plantTree.put(lastProb + probability, new GreenhousePlant(plantMaterial, plantGrowOn));
|
||||
} else {
|
||||
plugin.logError("Plant chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + plantMaterial.toString());
|
||||
addon.logError("Plant chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + plantMaterial.toString());
|
||||
}
|
||||
//plugin.logger(1," " + plantProbability + "% chance for " + Util.prettifyText(plantMaterial.toString()) + " to grow on " + Util.prettifyText(plantGrowOn.toString()));
|
||||
addon.log(" " + plantProbability + "% chance for " + Util.prettifyText(plantMaterial.toString()) + " to grow on " + Util.prettifyText(plantGrowOn.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param blockMaterial
|
||||
* @param blockQty
|
||||
* @param blockMaterial - block material
|
||||
* @param blockQty - number of blocks required
|
||||
*/
|
||||
public void addReqBlocks(Material blockMaterial, int blockQty) {
|
||||
requiredBlocks.put(blockMaterial, blockQty);
|
||||
//plugin.logger(1," " + blockMaterial + " x " + blockQty);
|
||||
addon.log(" " + blockMaterial + " x " + blockQty);
|
||||
}
|
||||
|
||||
// Check required blocks
|
||||
|
@ -156,9 +155,6 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
|| en.getKey().equals(Material.PACKED_ICE))
|
||||
.mapToInt(Map.Entry::getValue).sum();
|
||||
double iceRatio = (double)ice/(double)area * 100;
|
||||
//plugin.logger(3,"water req=" + waterCoverage + " lava req=" + lavaCoverage + " ice req="+iceCoverage);
|
||||
//plugin.logger(3,"waterRatio=" + waterRatio + " lavaRatio=" + lavaRatio + " iceRatio="+iceRatio);
|
||||
|
||||
|
||||
// Check required ratios - a zero means none of these are allowed, e.g.desert has no water
|
||||
if (waterCoverage == 0 && waterRatio > 0) {
|
||||
|
@ -187,10 +183,10 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param b
|
||||
* Check if block should be converted
|
||||
* @param b - block to check
|
||||
*/
|
||||
public void convertBlock(Block b) {
|
||||
//plugin.logger(3,"try to convert block");
|
||||
GreenhouseBlockConversions bc = conversionBlocks.get(b.getType());
|
||||
if (bc == null || random.nextDouble() > bc.getProbability()) {
|
||||
return;
|
||||
|
@ -198,7 +194,6 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
// Check if the block is in the right area, up, down, n,s,e,w
|
||||
if (ADJ_BLOCKS.stream().map(b::getRelative).map(Block::getType).anyMatch(m -> bc.getLocalMaterial() == null || m == bc.getLocalMaterial())) {
|
||||
// Convert!
|
||||
//plugin.logger(3,"Convert block");
|
||||
b.setType(bc.getNewMaterial());
|
||||
}
|
||||
}
|
||||
|
@ -269,7 +264,7 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
/**
|
||||
* @return the priority
|
||||
*/
|
||||
public int getPriority() {
|
||||
private int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
|
@ -286,7 +281,7 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
// Check if the spawn on block matches, if it exists
|
||||
.filter(m -> m.getMobSpawnOn().map(b.getRelative(BlockFace.DOWN).getType()::equals).orElse(true))
|
||||
// If spawn occurs, return true
|
||||
.map(m -> b.getWorld().spawnEntity(b.getLocation(), m.getMobType()) == null ? false : true).orElse(false);
|
||||
.map(m -> b.getWorld().spawnEntity(b.getLocation(), m.getMobType()) != null).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -338,21 +333,21 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param set the friendly name
|
||||
* @param friendlyName - set the friendly name
|
||||
*/
|
||||
public void setFriendlyName(String friendlyName) {
|
||||
this.friendlyName = friendlyName;
|
||||
}
|
||||
/**
|
||||
* @param icecoverage the icecoverage to set
|
||||
* @param iceCoverage the ice coverage to set
|
||||
*/
|
||||
public void setIcecoverage(int icecoverage) {
|
||||
if (icecoverage == 0) {
|
||||
//plugin.logger(1," No Ice Allowed");
|
||||
} else if (icecoverage > 0) {
|
||||
//plugin.logger(1," Ice > " + icecoverage + "%");
|
||||
public void setIcecoverage(int iceCoverage) {
|
||||
if (iceCoverage == 0) {
|
||||
addon.log(" No Ice Allowed");
|
||||
} else if (iceCoverage > 0) {
|
||||
addon.log(" Ice > " + iceCoverage + "%");
|
||||
}
|
||||
this.iceCoverage = icecoverage;
|
||||
this.iceCoverage = iceCoverage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,15 +358,15 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param lavaCoverage the lavaCoverage to set
|
||||
* @param lavaCoverage the lava coverage to set
|
||||
*/
|
||||
public void setLavacoverage(int lavacoverage) {
|
||||
if (lavacoverage == 0) {
|
||||
//plugin.logger(1," No Lava Allowed");
|
||||
} else if (lavacoverage > 0) {
|
||||
//plugin.logger(1," Lava > " + lavacoverage + "%");
|
||||
public void setLavacoverage(int lavaCoverage) {
|
||||
if (lavaCoverage == 0) {
|
||||
addon.log(" No Lava Allowed");
|
||||
} else if (lavaCoverage > 0) {
|
||||
addon.log(" Lava > " + lavaCoverage + "%");
|
||||
}
|
||||
this.lavaCoverage = lavacoverage;
|
||||
this.lavaCoverage = lavaCoverage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -410,15 +405,15 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param waterCoverage the waterCoverage to set
|
||||
* @param waterCoverage the water coverage to set
|
||||
*/
|
||||
public void setWatercoverage(int watercoverage) {
|
||||
if (watercoverage == 0) {
|
||||
//plugin.logger(1," No Water Allowed");
|
||||
} else if (watercoverage > 0) {
|
||||
//plugin.logger(1," Water > " + watercoverage + "%");
|
||||
public void setWatercoverage(int waterCoverage) {
|
||||
if (waterCoverage == 0) {
|
||||
addon.log(" No Water Allowed");
|
||||
} else if (waterCoverage > 0) {
|
||||
addon.log(" Water > " + waterCoverage + "%");
|
||||
}
|
||||
this.waterCoverage = watercoverage;
|
||||
this.waterCoverage = waterCoverage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@ package world.bentobox.greenhouses.greenhouse;
|
|||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class GreenhouseBlockConversions {
|
||||
class GreenhouseBlockConversions {
|
||||
private final Material oldMaterial;
|
||||
private final Material newMaterial;
|
||||
private final double probability;
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Optional;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class GreenhouseMob {
|
||||
class GreenhouseMob {
|
||||
private final EntityType mobType;
|
||||
private final Material mobSpawnOn;
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.Optional;
|
|||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class GreenhousePlant {
|
||||
class GreenhousePlant {
|
||||
private final Material plantMaterial;
|
||||
private final Material plantGrownOn;
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,7 @@ public class Roof {
|
|||
private int maxX;
|
||||
private int minZ;
|
||||
private int maxZ;
|
||||
private int height;
|
||||
private final int height;
|
||||
private boolean roofFound;
|
||||
public final static List<Material> ROOFBLOCKS = Arrays.stream(Material.values())
|
||||
.filter(Material::isBlock) // Blocks only, no items
|
||||
|
@ -33,7 +33,7 @@ public class Roof {
|
|||
.collect(Collectors.toList());
|
||||
/**
|
||||
* Finds a roof from a starting location under the roof and characterizes it
|
||||
* @param loc
|
||||
* @param loc - starting location
|
||||
*/
|
||||
public Roof(Location loc) {
|
||||
this.location = loc;
|
||||
|
@ -42,8 +42,7 @@ public class Roof {
|
|||
// Try just going up - this covers every case except if the player is standing under a hole
|
||||
roofFound = false;
|
||||
// This does a ever-growing check around the player to find a roof block. It is possible for the player
|
||||
// to be outside the greenhouse in this situation, so a check is done later to mkae sure the player is inside
|
||||
//if (!roofFound) {
|
||||
// to be outside the greenhouse in this situation, so a check is done later to make sure the player is inside
|
||||
int roofY = loc.getBlockY();
|
||||
// If the roof was not found start going around in circles until something is found
|
||||
// Expand in ever increasing squares around location until a wall block is found
|
||||
|
@ -88,16 +87,12 @@ public class Roof {
|
|||
minZ = loc.getBlockZ();
|
||||
maxZ = loc.getBlockZ();
|
||||
expandCoords(loc);
|
||||
int minx = minX;
|
||||
int maxx = maxX;
|
||||
int minz = minZ;
|
||||
int maxz = maxZ;
|
||||
int minx;
|
||||
int maxx;
|
||||
int minz;
|
||||
int maxz;
|
||||
// Now we have some idea of the mins and maxes, check each block and see if it goes further
|
||||
do {
|
||||
//plugin.logger(3, "Roof minx=" + minx);
|
||||
//plugin.logger(3, "Roof maxx=" + maxx);
|
||||
//plugin.logger(3, "Roof minz=" + minz);
|
||||
//plugin.logger(3, "Roof maxz=" + maxz);
|
||||
minx = minX;
|
||||
maxx = maxX;
|
||||
minz = minZ;
|
||||
|
@ -117,7 +112,7 @@ public class Roof {
|
|||
/**
|
||||
* This takes any location and tries to go as far as possible in NWSE directions finding contiguous roof blocks
|
||||
* up to 100 in any direction
|
||||
* @param height
|
||||
* @param height - location to start search
|
||||
*/
|
||||
private void expandCoords(Location height) {
|
||||
Location maxx = height.clone();
|
||||
|
|
|
@ -15,41 +15,24 @@ public class Walls {
|
|||
private int minZ;
|
||||
private int maxZ;
|
||||
private int floor;
|
||||
private boolean useRoofMaxX;
|
||||
private boolean useRoofMinX;
|
||||
private boolean useRoofMaxZ;
|
||||
private boolean useRoofMinZ;
|
||||
|
||||
public final static List<Material> WALL_BLOCKS = Arrays.stream(Material.values())
|
||||
.filter(Material::isBlock) // Blocks only, no items
|
||||
.filter(m -> !m.name().contains("TRAPDOOR")) // No trapdoors
|
||||
.filter(m -> !m.name().contains("TRAPDOOR")) // No trap doors
|
||||
.filter(m -> m.name().contains("DOOR") // All doors
|
||||
|| m.name().contains("GLASS") // All glass blocks
|
||||
|| m.equals(Material.HOPPER) // Hoppers
|
||||
|| m.equals(Material.GLOWSTONE)) // Glowstone
|
||||
.collect(Collectors.toList());
|
||||
|
||||
public final static List<BlockFace> ORDINALS = Arrays.asList(BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST);
|
||||
|
||||
public Walls(Roof roof) {
|
||||
// The player is under the roof
|
||||
// Assume the player is inside the greenhouse they are trying to create
|
||||
Location loc = roof.getLocation();
|
||||
World world = roof.getLocation().getWorld();
|
||||
// Find the floor - defined as the last y under the roof where there are no wall blocks
|
||||
int wallBlockCount = 0;
|
||||
int y = roof.getHeight();
|
||||
do {
|
||||
wallBlockCount = 0;
|
||||
for (int x = roof.getMinX(); x <= roof.getMaxX(); x++) {
|
||||
for (int z = roof.getMinZ(); z <= roof.getMaxZ(); z++) {
|
||||
if (WALL_BLOCKS.contains(world.getBlockAt(x, y, z).getType())) {
|
||||
wallBlockCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} while( y-- > 0 && wallBlockCount > 0);
|
||||
floor = y + 1;
|
||||
//addon.logger(3,"#1 Floor found at " + floor);
|
||||
floor = getFloorY(world, roof.getHeight(), roof.getMinX(), roof.getMaxX(), roof.getMinZ(), roof.getMaxZ());
|
||||
// Now start with the player's x and z location
|
||||
int radiusMinX = 0;
|
||||
int radiusMaxX = 0;
|
||||
|
@ -69,14 +52,14 @@ public class Walls {
|
|||
maxX = loc.getBlockX() + radiusMaxX;
|
||||
minZ = loc.getBlockZ() - radiusMinZ;
|
||||
maxZ = loc.getBlockZ() + radiusMaxZ;
|
||||
y = roof.getHeight() - 1;
|
||||
int y;
|
||||
for (y = roof.getHeight() - 1; y > floor; y--) {
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
// Only look around outside edge
|
||||
if (!((x > minX && x < maxX) && (z > minZ && z < maxZ))) {
|
||||
// Look at block faces
|
||||
for (BlockFace bf: BlockFace.values()) {
|
||||
for (BlockFace bf: ORDINALS) {
|
||||
switch (bf) {
|
||||
case EAST:
|
||||
// positive x
|
||||
|
@ -142,7 +125,12 @@ public class Walls {
|
|||
minZ--;
|
||||
maxZ++;
|
||||
// Find the floor again, only looking within the walls
|
||||
y = roof.getHeight();
|
||||
floor = getFloorY(world, roof.getHeight(), minX, maxX, minZ,maxZ);
|
||||
}
|
||||
|
||||
private int getFloorY(World world, int y, int minX, int maxX, int minZ, int maxZ) {
|
||||
// Find the floor - defined as the last y under the roof where there are no wall blocks
|
||||
int wallBlockCount;
|
||||
do {
|
||||
wallBlockCount = 0;
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
|
@ -154,7 +142,8 @@ public class Walls {
|
|||
}
|
||||
|
||||
} while( y-- > 0 && wallBlockCount > 0);
|
||||
floor = y + 1;
|
||||
return y + 1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,36 +170,6 @@ public class Walls {
|
|||
public int getMaxZ() {
|
||||
return maxZ;
|
||||
}
|
||||
/**
|
||||
* @return the useRoofMaxX
|
||||
*/
|
||||
public boolean useRoofMaxX() {
|
||||
return useRoofMaxX;
|
||||
}
|
||||
/**
|
||||
* @return the useRoofMinX
|
||||
*/
|
||||
public boolean useRoofMinX() {
|
||||
return useRoofMinX;
|
||||
}
|
||||
/**
|
||||
* @return the useRoofMaxZ
|
||||
*/
|
||||
public boolean useRoofMaxZ() {
|
||||
return useRoofMaxZ;
|
||||
}
|
||||
/**
|
||||
* @return the useRoofMinZ
|
||||
*/
|
||||
public boolean useRoofMinZ() {
|
||||
return useRoofMinZ;
|
||||
}
|
||||
/**
|
||||
* @return the wallBlocks
|
||||
*/
|
||||
public List<Material> getWallBlocks() {
|
||||
return WALL_BLOCKS;
|
||||
}
|
||||
|
||||
public int getArea() {
|
||||
// Get interior area
|
||||
|
|
|
@ -35,7 +35,7 @@ public class GreenhouseEvents implements Listener {
|
|||
|
||||
/**
|
||||
* Permits water to be placed in the Nether if in a greenhouse and in an acceptable biome
|
||||
* @param event
|
||||
* @param e - event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
|
||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||
|
@ -62,7 +62,7 @@ public class GreenhouseEvents implements Listener {
|
|||
if (plugin.getManager().getMap().getGreenhouse(e.getBlock().getLocation()).isPresent()) {
|
||||
e.setCancelled(true);
|
||||
e.getBlock().setType(Material.WATER);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,10 +98,9 @@ public class GreenhouseEvents implements Listener {
|
|||
user.sendRawMessage("Leaving " + from.get().getBiomeRecipe().getFriendlyName() + " greenhouse");
|
||||
return;
|
||||
}
|
||||
if (!from.isPresent() && to.isPresent()) {
|
||||
if (!from.isPresent()) {
|
||||
// Entering
|
||||
user.sendRawMessage("Entering " + to.get().getBiomeRecipe().getFriendlyName() + " greenhouse");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -118,7 +117,7 @@ public class GreenhouseEvents implements Listener {
|
|||
|
||||
/**
|
||||
* Checks is broken blocks cause the greenhouse to fail
|
||||
* @param e
|
||||
* @param e - event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled=true)
|
||||
public void onBlockBreak(final BlockBreakEvent e) {
|
||||
|
@ -139,7 +138,7 @@ public class GreenhouseEvents implements Listener {
|
|||
|
||||
/**
|
||||
* Prevents placing of blocks above the greenhouses
|
||||
* @param e
|
||||
* @param e - event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled=true)
|
||||
public void onPlayerBlockPlace(final BlockPlaceEvent e) {
|
||||
|
@ -160,7 +159,7 @@ public class GreenhouseEvents implements Listener {
|
|||
|
||||
/**
|
||||
* Check to see if anyone is sneaking a block over a greenhouse by using a piston
|
||||
* @param e
|
||||
* @param e - event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled=true)
|
||||
public void onPistonPush(final BlockPistonExtendEvent e) {
|
||||
|
|
|
@ -28,7 +28,7 @@ import world.bentobox.greenhouses.data.Greenhouse;
|
|||
*/
|
||||
public class SnowTracker implements Listener {
|
||||
private final Greenhouses addon;
|
||||
private Map<World, BukkitTask> snowTasks;
|
||||
private final Map<World, BukkitTask> snowTasks;
|
||||
|
||||
public SnowTracker(Greenhouses addon) {
|
||||
this.addon = addon;
|
||||
|
@ -87,7 +87,7 @@ public class SnowTracker implements Listener {
|
|||
getAirBlocks(g);
|
||||
}
|
||||
|
||||
private List<Block> getAirBlocks(Greenhouse gh) {
|
||||
private void getAirBlocks(Greenhouse gh) {
|
||||
List<Block> waterBlocks = new ArrayList<>();
|
||||
List<Block> result = new ArrayList<>();
|
||||
for (int x = (int)gh.getFootprint().getMinX() + 1; x < (int)gh.getFootprint().getMaxX(); x++) {
|
||||
|
@ -117,6 +117,5 @@ public class SnowTracker implements Listener {
|
|||
if (maxSize > 0) {
|
||||
waterBlocks.stream().limit(maxSize).filter(b -> Math.random() < addon.getSettings().getSnowDensity()).forEach(b -> b.setType(Material.ICE));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -21,10 +21,10 @@ import world.bentobox.greenhouses.data.Greenhouse;
|
|||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class EcoSystemManager {
|
||||
class EcoSystemManager {
|
||||
|
||||
private Greenhouses addon;
|
||||
private GreenhouseManager g;
|
||||
private final Greenhouses addon;
|
||||
private final GreenhouseManager g;
|
||||
private BukkitTask plantTask;
|
||||
private BukkitTask mobTask;
|
||||
private BukkitTask blockTask;
|
||||
|
@ -76,7 +76,7 @@ public class EcoSystemManager {
|
|||
}
|
||||
|
||||
private void convertBlocks(Greenhouse gh) {
|
||||
getAvailableBlocks(gh).stream().forEach(gh.getBiomeRecipe()::convertBlock);
|
||||
getAvailableBlocks(gh).forEach(gh.getBiomeRecipe()::convertBlock);
|
||||
}
|
||||
|
||||
private void verify(Greenhouse gh) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import world.bentobox.greenhouses.managers.GreenhouseManager.GreenhouseResult;
|
|||
public class GreenhouseFinder {
|
||||
|
||||
private Greenhouse gh;
|
||||
private Set<Location> redGlass = new HashSet<Location>();
|
||||
private final Set<Location> redGlass = new HashSet<>();
|
||||
|
||||
|
||||
public Set<GreenhouseResult> find(Location location) {
|
||||
|
@ -56,9 +56,9 @@ public class GreenhouseFinder {
|
|||
// The y height where other blocks were found
|
||||
// If this is the bottom layer, the player has most likely uneven walls
|
||||
int otherBlockLayer = -1;
|
||||
int wallBlockCount = 0;
|
||||
int wallBlockCount;
|
||||
|
||||
int y = 0;
|
||||
int y;
|
||||
for (y = world.getMaxHeight() - 1; y >= walls.getFloor(); y--) {
|
||||
int doorCount = 0;
|
||||
int hopperCount = 0;
|
||||
|
@ -123,7 +123,6 @@ public class GreenhouseFinder {
|
|||
// This is the floor
|
||||
break;
|
||||
} else {
|
||||
wallBlockCount = 0;
|
||||
wallDoors += doorCount;
|
||||
ghHopper += hopperCount;
|
||||
if (airHole) {
|
||||
|
|
|
@ -49,10 +49,10 @@ public class GreenhouseManager implements Listener {
|
|||
FAIL_NO_RECIPE_FOUND
|
||||
}
|
||||
|
||||
private Greenhouses addon;
|
||||
private final Greenhouses addon;
|
||||
// Greenhouses
|
||||
private GreenhouseMap map;
|
||||
private Database<Greenhouse> handler;
|
||||
private final GreenhouseMap map;
|
||||
private final Database<Greenhouse> handler;
|
||||
|
||||
public GreenhouseManager(Greenhouses addon) {
|
||||
this.addon = addon;
|
||||
|
@ -78,7 +78,7 @@ public class GreenhouseManager implements Listener {
|
|||
/**
|
||||
* Load all known greenhouses
|
||||
*/
|
||||
public void loadGreenhouses() {
|
||||
private void loadGreenhouses() {
|
||||
addon.log("Loading greenhouses...");
|
||||
handler.loadObjects().forEach(g -> {
|
||||
GreenhouseResult result = map.addGreenhouse(g);
|
||||
|
@ -109,7 +109,7 @@ public class GreenhouseManager implements Listener {
|
|||
|
||||
/**
|
||||
* Removes the greenhouse from the world and resets biomes
|
||||
* @param g
|
||||
* @param g - greenhouse
|
||||
*/
|
||||
public void removeGreenhouse(Greenhouse g) {
|
||||
map.removeGreenhouse(g);
|
||||
|
@ -141,12 +141,11 @@ public class GreenhouseManager implements Listener {
|
|||
/**
|
||||
* Checks that a greenhouse meets specs and makes it
|
||||
* If type is stated then only this specific type will be checked
|
||||
* @param user
|
||||
* @param greenhouseRecipe
|
||||
* @return
|
||||
* @param location - location to start search from
|
||||
* @param greenhouseRecipe - recipe requested, or null for a best-effort search
|
||||
* @return - greenhouse result {@link GhResult}
|
||||
*/
|
||||
public GhResult tryToMakeGreenhouse(Location location, BiomeRecipe greenhouseRecipe) {
|
||||
addon.log("Player location is " + location.getBlockX() + " " + location.getBlockY() + " " + location.getBlockZ());
|
||||
GreenhouseFinder finder = new GreenhouseFinder();
|
||||
Set<GreenhouseResult> resultSet = finder.find(location);
|
||||
if (!resultSet.isEmpty()) {
|
||||
|
@ -211,7 +210,7 @@ public class GreenhouseManager implements Listener {
|
|||
/**
|
||||
* @param results the results to set
|
||||
*/
|
||||
public GhResult setResults(Set<GreenhouseResult> results) {
|
||||
GhResult setResults(Set<GreenhouseResult> results) {
|
||||
this.results = results;
|
||||
return this;
|
||||
}
|
||||
|
@ -219,7 +218,7 @@ public class GreenhouseManager implements Listener {
|
|||
/**
|
||||
* @param finder the finder to set
|
||||
*/
|
||||
public GhResult setFinder(GreenhouseFinder finder) {
|
||||
GhResult setFinder(GreenhouseFinder finder) {
|
||||
this.finder = finder;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ import world.bentobox.greenhouses.managers.GreenhouseManager.GreenhouseResult;
|
|||
|
||||
public class GreenhouseMap {
|
||||
|
||||
private Greenhouses addon;
|
||||
private Map<Island, List<Greenhouse>> greenhouses = new HashMap<>();
|
||||
private final Greenhouses addon;
|
||||
private final Map<Island, List<Greenhouse>> greenhouses = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @param addon - addon
|
||||
|
@ -58,9 +58,7 @@ public class GreenhouseMap {
|
|||
|
||||
private Optional<Greenhouse> getXZGreenhouse(Location location) {
|
||||
return addon.getIslands().getIslandAt(location)
|
||||
.filter(i -> greenhouses.containsKey(i))
|
||||
.map(i -> greenhouses.get(i).stream().filter(g -> g.contains(location)).findFirst())
|
||||
.orElse(Optional.empty());
|
||||
.filter(greenhouses::containsKey).flatMap(i -> greenhouses.get(i).stream().filter(g -> g.contains(location)).findFirst());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,8 +22,8 @@ import world.bentobox.greenhouses.greenhouse.BiomeRecipe;
|
|||
public class RecipeManager {
|
||||
|
||||
private static final int MAXIMUM_INVENTORY_SIZE = 49;
|
||||
private Greenhouses addon;
|
||||
private static List<BiomeRecipe> biomeRecipes = new ArrayList<>();
|
||||
private final Greenhouses addon;
|
||||
private static final List<BiomeRecipe> biomeRecipes = new ArrayList<>();
|
||||
|
||||
public RecipeManager(Greenhouses addon) {
|
||||
this.addon = addon;
|
||||
|
@ -47,11 +47,11 @@ public class RecipeManager {
|
|||
|
||||
/**
|
||||
* Loads all the biome recipes from the file biomes.yml.
|
||||
* @throws InvalidConfigurationException
|
||||
* @throws IOException
|
||||
* @throws FileNotFoundException
|
||||
* @throws InvalidConfigurationException - bad YAML
|
||||
* @throws IOException - io exception
|
||||
* @throws FileNotFoundException - no file found
|
||||
*/
|
||||
public void loadBiomeRecipes() throws FileNotFoundException, IOException, InvalidConfigurationException {
|
||||
private void loadBiomeRecipes() throws FileNotFoundException, IOException, InvalidConfigurationException {
|
||||
biomeRecipes.clear();
|
||||
YamlConfiguration biomes = new YamlConfiguration();
|
||||
File biomeFile = new File(addon.getDataFolder(), "biomes.yml");
|
||||
|
@ -70,7 +70,7 @@ public class RecipeManager {
|
|||
for (String type: biomeSection.getValues(false).keySet()) {
|
||||
try {
|
||||
ConfigurationSection biomeRecipe = biomeSection.getConfigurationSection(type);
|
||||
Biome thisBiome = null;
|
||||
Biome thisBiome;
|
||||
if (biomeRecipe.contains("biome")) {
|
||||
// Try and get the biome via the biome setting
|
||||
thisBiome = Biome.valueOf(biomeRecipe.getString("biome").toUpperCase());
|
||||
|
@ -78,80 +78,72 @@ public class RecipeManager {
|
|||
// Old style, where type was the biome name
|
||||
thisBiome = Biome.valueOf(type);
|
||||
}
|
||||
if (thisBiome != null) {
|
||||
int priority = biomeRecipe.getInt("priority", 0);
|
||||
BiomeRecipe b = new BiomeRecipe(addon, thisBiome,priority);
|
||||
// Set the name
|
||||
b.setName(type);
|
||||
// Set the permission
|
||||
b.setPermission(biomeRecipe.getString("permission",""));
|
||||
// Set the icon
|
||||
b.setIcon(Material.valueOf(biomeRecipe.getString("icon", "SAPLING")));
|
||||
b.setFriendlyName(ChatColor.translateAlternateColorCodes('&', biomeRecipe.getString("friendlyname", Util.prettifyText(type))));
|
||||
// A value of zero on these means that there must be NO coverage, e.g., desert. If the value is not present, then the default is -1
|
||||
b.setWatercoverage(biomeRecipe.getInt("watercoverage",-1));
|
||||
b.setLavacoverage(biomeRecipe.getInt("lavacoverage",-1));
|
||||
b.setIcecoverage(biomeRecipe.getInt("icecoverage",-1));
|
||||
b.setMobLimit(biomeRecipe.getInt("moblimit", 9));
|
||||
// Set the needed blocks
|
||||
ConfigurationSection reqContents = biomeRecipe.getConfigurationSection("contents");
|
||||
if (reqContents != null) {
|
||||
for (String rq : reqContents.getKeys(false)) {
|
||||
Material mat = Material.valueOf(rq.toUpperCase());
|
||||
if (mat != null) {
|
||||
b.addReqBlocks(mat, reqContents.getInt(rq));
|
||||
} else {
|
||||
addon.logError("Could not parse required block " + rq);
|
||||
}
|
||||
int priority = biomeRecipe.getInt("priority", 0);
|
||||
BiomeRecipe b = new BiomeRecipe(addon, thisBiome,priority);
|
||||
// Set the name
|
||||
b.setName(type);
|
||||
// Set the permission
|
||||
b.setPermission(biomeRecipe.getString("permission",""));
|
||||
// Set the icon
|
||||
b.setIcon(Material.valueOf(biomeRecipe.getString("icon", "SAPLING")));
|
||||
b.setFriendlyName(ChatColor.translateAlternateColorCodes('&', biomeRecipe.getString("friendlyname", Util.prettifyText(type))));
|
||||
// A value of zero on these means that there must be NO coverage, e.g., desert. If the value is not present, then the default is -1
|
||||
b.setWatercoverage(biomeRecipe.getInt("watercoverage",-1));
|
||||
b.setLavacoverage(biomeRecipe.getInt("lavacoverage",-1));
|
||||
b.setIcecoverage(biomeRecipe.getInt("icecoverage",-1));
|
||||
b.setMobLimit(biomeRecipe.getInt("moblimit", 9));
|
||||
// Set the needed blocks
|
||||
ConfigurationSection reqContents = biomeRecipe.getConfigurationSection("contents");
|
||||
if (reqContents != null) {
|
||||
for (String rq : reqContents.getKeys(false)) {
|
||||
try {
|
||||
b.addReqBlocks(Material.valueOf(rq.toUpperCase()), reqContents.getInt(rq));
|
||||
} catch(Exception e) {
|
||||
addon.logError("Could not parse required block " + rq);
|
||||
}
|
||||
}
|
||||
// Load plants
|
||||
// # Plant Material: Probability in %:Block Material on what they grow
|
||||
ConfigurationSection temp = biomes.getConfigurationSection("biomes." + type + ".plants");
|
||||
if (temp != null) {
|
||||
HashMap<String,Object> plants = (HashMap<String,Object>)temp.getValues(false);
|
||||
if (plants != null) {
|
||||
for (String s: plants.keySet()) {
|
||||
//logger(1, "Plant = " + s);
|
||||
Material plantMaterial = Material.valueOf(s);
|
||||
|
||||
//logger(1, "Plant = " + plantMaterial);
|
||||
String[] split = ((String)plants.get(s)).split(":");
|
||||
//logger(1, "Split length = " + split.length);
|
||||
int plantProbability = Integer.valueOf(split[0]);
|
||||
Material plantGrowOn = Material.valueOf(split[1]);
|
||||
|
||||
b.addPlants(plantMaterial, plantProbability, plantGrowOn);
|
||||
}
|
||||
}
|
||||
// Load plants
|
||||
// # Plant Material: Probability in %:Block Material on what they grow
|
||||
ConfigurationSection temp = biomes.getConfigurationSection("biomes." + type + ".plants");
|
||||
if (temp != null) {
|
||||
HashMap<String,Object> plants = (HashMap<String,Object>)temp.getValues(false);
|
||||
if (plants != null) {
|
||||
for (String s: plants.keySet()) {
|
||||
Material plantMaterial = Material.valueOf(s);
|
||||
String[] split = ((String)plants.get(s)).split(":");
|
||||
int plantProbability = Integer.valueOf(split[0]);
|
||||
Material plantGrowOn = Material.valueOf(split[1]);
|
||||
b.addPlants(plantMaterial, plantProbability, plantGrowOn);
|
||||
}
|
||||
}
|
||||
// Load mobs!
|
||||
// Mob EntityType: Probability:Spawn on Material
|
||||
temp = biomes.getConfigurationSection("biomes." + type + ".mobs");
|
||||
if (temp != null) {
|
||||
HashMap<String,Object> mobs = (HashMap<String,Object>)temp.getValues(false);
|
||||
if (mobs != null) {
|
||||
for (String s: mobs.keySet()) {
|
||||
EntityType mobType = EntityType.valueOf(s);
|
||||
}
|
||||
// Load mobs!
|
||||
// Mob EntityType: Probability:Spawn on Material
|
||||
temp = biomes.getConfigurationSection("biomes." + type + ".mobs");
|
||||
if (temp != null) {
|
||||
HashMap<String,Object> mobs = (HashMap<String,Object>)temp.getValues(false);
|
||||
if (mobs != null) {
|
||||
for (String s: mobs.keySet()) {
|
||||
try {
|
||||
EntityType mobType = EntityType.valueOf(s.toUpperCase());
|
||||
String[] split = ((String)mobs.get(s)).split(":");
|
||||
int mobProbability = Integer.valueOf(split[0]);
|
||||
Material mobSpawnOn = Material.valueOf(split[1]);
|
||||
b.addMobs(mobType, mobProbability, mobSpawnOn);
|
||||
} catch (Exception e) {
|
||||
addon.logError("Could not parse " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Load block conversions
|
||||
ConfigurationSection conversionSec = biomeSection.getConfigurationSection(type + ".conversions");
|
||||
if (conversionSec != null) {
|
||||
for (String oldMat : conversionSec.getKeys(false)) {
|
||||
Material oldMaterial = Material.valueOf(oldMat);
|
||||
if (oldMaterial == null) {
|
||||
addon.logError("Could not parse " + oldMat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Load block conversions
|
||||
ConfigurationSection conversionSec = biomeSection.getConfigurationSection(type + ".conversions");
|
||||
if (conversionSec != null) {
|
||||
for (String oldMat : conversionSec.getKeys(false)) {
|
||||
try {
|
||||
Material oldMaterial = Material.valueOf(oldMat.toUpperCase());
|
||||
String conversions = conversionSec.getString(oldMat);
|
||||
|
||||
//logger(3,"conversions = '" + conversions + "'");
|
||||
if (!conversions.isEmpty()) {
|
||||
String[] split = conversions.split(":");
|
||||
int convChance = Integer.valueOf(split[0]);
|
||||
|
@ -159,26 +151,26 @@ public class RecipeManager {
|
|||
Material localMaterial = Material.valueOf(split[2]);
|
||||
b.addConvBlocks(oldMaterial, newMaterial, convChance, localMaterial);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
addon.logError("Could not parse " + oldMat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Add the recipe to the list
|
||||
biomeRecipes.add(b);
|
||||
}
|
||||
// Add the recipe to the list
|
||||
biomeRecipes.add(b);
|
||||
} catch (Exception e) {
|
||||
//logger(1,"Problem loading biome recipe - skipping!");
|
||||
String validBiomes = "";
|
||||
addon.logError("Problem loading biome recipe - skipping! " + e.getMessage());
|
||||
StringBuilder validBiomes = new StringBuilder();
|
||||
for (Biome biome : Biome.values()) {
|
||||
validBiomes = validBiomes + " " + biome.name();
|
||||
validBiomes.append(" ").append(biome.name());
|
||||
}
|
||||
//logger(1,"Valid biomes are " + validBiomes);
|
||||
e.printStackTrace();
|
||||
addon.logError("Valid biomes are " + validBiomes);
|
||||
}
|
||||
|
||||
// Check maximum number
|
||||
if (biomeRecipes.size() == MAXIMUM_INVENTORY_SIZE) {
|
||||
addon.logWarning("Cannot load any more biome recipies - limit is 49!");
|
||||
addon.logWarning("Cannot load any more biome recipies - limit is " + MAXIMUM_INVENTORY_SIZE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
* @author ben
|
||||
* All the text strings in the game sent to players
|
||||
*/
|
||||
public class Locale {
|
||||
class Locale {
|
||||
|
||||
public static String generalnotavailable;
|
||||
public static String generalgreenhouses;
|
||||
|
@ -43,7 +43,7 @@ public class Locale {
|
|||
public static String messagesremovedmessage;
|
||||
public static String messagesecolost;
|
||||
public static String infotitle;
|
||||
public static List<String> infoinstructions = new ArrayList<String>();
|
||||
public static List<String> infoinstructions = new ArrayList<>();
|
||||
public static String infoinfo;
|
||||
public static String infonone;
|
||||
public static String recipehint;
|
||||
|
|
|
@ -10,7 +10,7 @@ import world.bentobox.greenhouses.Greenhouses;
|
|||
* This class handles commands for admins
|
||||
*
|
||||
*/
|
||||
public class AdminCmd extends CompositeCommand {
|
||||
class AdminCmd extends CompositeCommand {
|
||||
|
||||
public AdminCmd(Greenhouses greenhouses) {
|
||||
super(greenhouses, "gadmin");
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.ui.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,16 +9,13 @@ import world.bentobox.bentobox.api.user.User;
|
|||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class GreenhousesAdminInfoCommand extends CompositeCommand {
|
||||
class GreenhousesAdminInfoCommand extends CompositeCommand {
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param label
|
||||
* @param aliases
|
||||
* @param parent - parent user command, e.g, /island
|
||||
*/
|
||||
public GreenhousesAdminInfoCommand(CompositeCommand parent) {
|
||||
super(parent, "info");
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.ui.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,12 +9,10 @@ import world.bentobox.bentobox.api.user.User;
|
|||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class GreenhousesAdminReloadCommand extends CompositeCommand {
|
||||
class GreenhousesAdminReloadCommand extends CompositeCommand {
|
||||
|
||||
/**
|
||||
* @param addon
|
||||
* @param label
|
||||
* @param aliases
|
||||
* @param parent - parent command
|
||||
*/
|
||||
public GreenhousesAdminReloadCommand(CompositeCommand parent) {
|
||||
super(parent, "reload");
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.ui.user;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,12 +9,10 @@ import world.bentobox.bentobox.api.user.User;
|
|||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class InfoCommand extends CompositeCommand {
|
||||
class InfoCommand extends CompositeCommand {
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param label
|
||||
* @param aliases
|
||||
* @param parent - parent command
|
||||
*/
|
||||
public InfoCommand(CompositeCommand parent) {
|
||||
super(parent, "make");
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.ui.user;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,12 +9,10 @@ import world.bentobox.bentobox.api.user.User;
|
|||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class ListCommand extends CompositeCommand {
|
||||
class ListCommand extends CompositeCommand {
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param label
|
||||
* @param aliases
|
||||
* @param parent - parent command
|
||||
*/
|
||||
public ListCommand(CompositeCommand parent) {
|
||||
super(parent, "list");
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.ui.user;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -20,12 +17,10 @@ import world.bentobox.greenhouses.managers.GreenhouseManager.GreenhouseResult;
|
|||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class MakeCommand extends CompositeCommand {
|
||||
class MakeCommand extends CompositeCommand {
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param label
|
||||
* @param aliases
|
||||
* @param parent - parent command
|
||||
*/
|
||||
public MakeCommand(CompositeCommand parent) {
|
||||
super(parent, "make");
|
||||
|
@ -65,14 +60,8 @@ public class MakeCommand extends CompositeCommand {
|
|||
result.getResults().forEach(r -> sendErrorMessage(user, r));
|
||||
if (!result.getFinder().getRedGlass().isEmpty()) {
|
||||
// Show red glass
|
||||
result.getFinder().getRedGlass().forEach(rg -> {
|
||||
user.getPlayer().sendBlockChange(rg, Material.RED_STAINED_GLASS.createBlockData());
|
||||
});
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> {
|
||||
result.getFinder().getRedGlass().forEach(rg -> {
|
||||
user.getPlayer().sendBlockChange(rg, rg.getBlock().getBlockData());
|
||||
});
|
||||
}, 120L);
|
||||
result.getFinder().getRedGlass().forEach(rg -> user.getPlayer().sendBlockChange(rg, Material.RED_STAINED_GLASS.createBlockData()));
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> result.getFinder().getRedGlass().forEach(rg -> user.getPlayer().sendBlockChange(rg, rg.getBlock().getBlockData())), 120L);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.ui.user;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,12 +9,10 @@ import world.bentobox.bentobox.api.user.User;
|
|||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class RecipeCommand extends CompositeCommand {
|
||||
class RecipeCommand extends CompositeCommand {
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param label
|
||||
* @param aliases
|
||||
* @param parent - parent command
|
||||
*/
|
||||
public RecipeCommand(CompositeCommand parent) {
|
||||
super(parent, "make");
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.ui.user;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,12 +9,10 @@ import world.bentobox.bentobox.api.user.User;
|
|||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class RemoveCommand extends CompositeCommand {
|
||||
class RemoveCommand extends CompositeCommand {
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param label
|
||||
* @param aliases
|
||||
* @param parent - parent command
|
||||
*/
|
||||
public RemoveCommand(CompositeCommand parent) {
|
||||
super(parent, "make");
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.greenhouses.ui.user;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -16,10 +13,8 @@ import world.bentobox.greenhouses.Greenhouses;
|
|||
public class UserCommand extends CompositeCommand {
|
||||
|
||||
/**
|
||||
* @param gh
|
||||
* @param parent
|
||||
* @param label
|
||||
* @param aliases
|
||||
* @param gh - addon
|
||||
* @param parent - parent command
|
||||
*/
|
||||
public UserCommand(Greenhouses gh, CompositeCommand parent) {
|
||||
super(gh, parent, "greenhouse", "gh");
|
||||
|
|
Loading…
Reference in New Issue