mirror of
https://github.com/BentoBoxWorld/Greenhouses.git
synced 2024-11-25 03:55:29 +01:00
Removed admin commands
This commit is contained in:
parent
0397f8fcfa
commit
01a5548119
@ -13,7 +13,6 @@ import world.bentobox.bentobox.api.flags.Flag.Mode;
|
||||
import world.bentobox.bentobox.api.flags.Flag.Type;
|
||||
import world.bentobox.greenhouses.managers.GreenhouseManager;
|
||||
import world.bentobox.greenhouses.managers.RecipeManager;
|
||||
import world.bentobox.greenhouses.ui.admin.AdminCmd;
|
||||
import world.bentobox.greenhouses.ui.user.UserCommand;
|
||||
|
||||
/**
|
||||
@ -72,7 +71,6 @@ public class Greenhouses extends Addon {
|
||||
.forEach(gm -> {
|
||||
// Register command
|
||||
gm.getPlayerCommand().ifPresent(playerCmd -> new UserCommand(this, playerCmd));
|
||||
gm.getAdminCommand().ifPresent(playerCmd -> new AdminCmd(this, playerCmd));
|
||||
// Log
|
||||
this.log("Hooking into " + gm.getDescription().getName());
|
||||
// Store active world
|
||||
|
@ -55,7 +55,7 @@ public class GreenhouseFinder {
|
||||
// Find the roof
|
||||
Roof roof = new Roof(cache, location);
|
||||
roof.findRoof().thenAccept(found -> {
|
||||
if (!found) {
|
||||
if (Boolean.FALSE.equals(found)) {
|
||||
result.add(GreenhouseResult.FAIL_NO_ROOF);
|
||||
r.complete(result);
|
||||
return;
|
||||
@ -68,7 +68,7 @@ public class GreenhouseFinder {
|
||||
gh.setOriginalBiome(location.getBlock().getBiome());
|
||||
|
||||
// Now check to see if the floor really is the floor and the walls follow the rules
|
||||
checkGreenhouse(cache, gh, roof, walls).thenAccept(c -> {
|
||||
checkGreenhouse(cache, roof, walls).thenAccept(c -> {
|
||||
result.addAll(c);
|
||||
r.complete(result);
|
||||
});
|
||||
@ -86,13 +86,13 @@ public class GreenhouseFinder {
|
||||
* @param walls - walls object
|
||||
* @return future set of Greenhouse Results
|
||||
*/
|
||||
CompletableFuture<Set<GreenhouseResult>> checkGreenhouse(AsyncWorldCache cache, Greenhouse gh2, Roof roof, Walls walls) {
|
||||
CompletableFuture<Set<GreenhouseResult>> checkGreenhouse(AsyncWorldCache cache, Roof roof, Walls walls) {
|
||||
CompletableFuture<Set<GreenhouseResult>> r = new CompletableFuture<>();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(BentoBox.getInstance(), () -> checkGHAsync(r, cache, gh2, roof, walls));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(BentoBox.getInstance(), () -> checkGHAsync(r, cache, roof, walls));
|
||||
return r;
|
||||
}
|
||||
|
||||
private Set<GreenhouseResult> checkGHAsync(CompletableFuture<Set<GreenhouseResult>> r, AsyncWorldCache cache, Greenhouse gh2,
|
||||
private Set<GreenhouseResult> checkGHAsync(CompletableFuture<Set<GreenhouseResult>> r, AsyncWorldCache cache,
|
||||
Roof roof, Walls walls) {
|
||||
Set<GreenhouseResult> result = new HashSet<>();
|
||||
cc = new CounterCheck();
|
||||
|
@ -1,110 +0,0 @@
|
||||
package world.bentobox.greenhouses.ui.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.greenhouses.Greenhouses;
|
||||
|
||||
/**
|
||||
* This class handles commands for admins
|
||||
*
|
||||
*/
|
||||
public class AdminCmd extends CompositeCommand {
|
||||
|
||||
public AdminCmd(Greenhouses greenhouses, CompositeCommand parent) {
|
||||
super(greenhouses, parent, "gadmin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
this.setPermission("greenhouses.admin");
|
||||
this.setOnlyPlayer(false);
|
||||
this.setParametersHelp("greenhouses.admin.parameters");
|
||||
this.setDescription("greenhouses.admin.description");
|
||||
|
||||
//new GreenhousesAdminReloadCommand(this);
|
||||
new GreenhousesAdminInfoCommand(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
case 1:
|
||||
if (split[0].equalsIgnoreCase("reload")) {
|
||||
plugin.reloadConfig();
|
||||
plugin.loadPluginConfig();
|
||||
plugin.loadBiomeRecipes();
|
||||
plugin.ecoTick();
|
||||
sender.sendMessage(ChatColor.YELLOW + Locale.reloadconfigReloaded);
|
||||
return true;
|
||||
} else if (split[0].equalsIgnoreCase("info")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + Locale.admininfoerror);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
Greenhouse greenhouse = players.getInGreenhouse(player);
|
||||
if (greenhouse == null) {
|
||||
sender.sendMessage(ChatColor.RED + Locale.admininfoerror2);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + Locale.infoinfo);
|
||||
sender.sendMessage(ChatColor.GREEN + Locale.generalowner + ":" + greenhouse.getPlayerName());
|
||||
sender.sendMessage(ChatColor.GREEN + Locale.admininfoflags);
|
||||
for (String flag : greenhouse.getFlags().keySet()) {
|
||||
sender.sendMessage(flag + ": " + greenhouse.getFlags().get(flag));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + Locale.errorunknownCommand);
|
||||
return false;
|
||||
}
|
||||
case 2:
|
||||
if (split[0].equalsIgnoreCase("info")) {
|
||||
sender.sendMessage(ChatColor.GREEN + Locale.infoinfo);
|
||||
int index = 0;
|
||||
boolean found = false;
|
||||
for (Greenhouse g : plugin.getGreenhouses()) {
|
||||
if (g.getPlayerName().equalsIgnoreCase(split[1])) {
|
||||
if (!found)
|
||||
sender.sendMessage(ChatColor.GREEN + Locale.generalowner + ":" + g.getPlayerName());
|
||||
found = true;
|
||||
sender.sendMessage("Greenhouse #" + (++index));
|
||||
sender.sendMessage("Biome: " + g.getBiome().name());
|
||||
sender.sendMessage("Recipe: " + g.getBiomeRecipe().getFriendlyName());
|
||||
sender.sendMessage(g.getWorld().getName());
|
||||
sender.sendMessage(g.getPos1().getBlockX() + ", " + g.getPos1().getBlockZ() + " to " + g.getPos2().getBlockX() + ", " + g.getPos2().getBlockZ());
|
||||
sender.sendMessage("Base at " + g.getPos1().getBlockY());
|
||||
sender.sendMessage("Height = " + g.getHeight());
|
||||
sender.sendMessage("Area = " + g.getArea());
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
if (index == 0) {
|
||||
sender.sendMessage("Player has no greenhouses.");
|
||||
} else {
|
||||
Player player = plugin.getServer().getPlayer(split[1]);
|
||||
if (player != null) {
|
||||
sender.sendMessage("Player has " + index + " greenhouses and is allowed to build " + plugin.getMaxGreenhouses(player));
|
||||
} else {
|
||||
sender.sendMessage("Player has " + index + " greenhouses. Player is offline.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Cannot find that player. (May not have logged on recently)");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + Locale.errorunknownCommand);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package world.bentobox.greenhouses.ui.admin;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.greenhouses.Greenhouses;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
class GreenhousesAdminInfoCommand extends CompositeCommand {
|
||||
|
||||
private Greenhouses addon = Greenhouses.getInstance();
|
||||
private static final Set<Material> transparent = new HashSet<>();
|
||||
{
|
||||
transparent.add(Material.AIR);
|
||||
transparent.add(Material.GLASS);
|
||||
}
|
||||
/**
|
||||
* @param parent - parent user command, e.g, /island
|
||||
*/
|
||||
public GreenhousesAdminInfoCommand(CompositeCommand parent) {
|
||||
super(parent, "info");
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see world.bentobox.bentobox.api.commands.BentoBoxCommand#setup()
|
||||
*/
|
||||
@Override
|
||||
public void setup() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see world.bentobox.bentobox.api.commands.BentoBoxCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
Location l = user.getPlayer().getLineOfSight(transparent, 5).get(0).getLocation();
|
||||
addon.getManager().getMap().getGreenhouse(l).ifPresent(gh ->
|
||||
{
|
||||
addon.log("There are " + addon.getManager().getEcoMgr().getAvailableBlocks(gh, false).size());
|
||||
addon.getManager().getEcoMgr().getAvailableBlocks(gh, false).forEach(b -> user.getPlayer().sendBlockChange(b.getLocation(), Material.CYAN_STAINED_GLASS.createBlockData()));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package world.bentobox.greenhouses.ui.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
class GreenhousesAdminReloadCommand extends CompositeCommand {
|
||||
|
||||
/**
|
||||
* @param parent - parent command
|
||||
*/
|
||||
public GreenhousesAdminReloadCommand(CompositeCommand parent) {
|
||||
super(parent, "reload");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see world.bentobox.bentobox.api.commands.BentoBoxCommand#setup()
|
||||
*/
|
||||
@Override
|
||||
public void setup() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see world.bentobox.bentobox.api.commands.BentoBoxCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -100,8 +100,7 @@ public class GreenhouseFinderTest {
|
||||
*/
|
||||
@Test
|
||||
public void testCheckGreenhouse() {
|
||||
Greenhouse gh2 = new Greenhouse(world, walls, ROOF_HEIGHT);
|
||||
gf.checkGreenhouse(cache, gh2, roof, walls).thenAccept(result -> {
|
||||
gf.checkGreenhouse(cache, roof, walls).thenAccept(result -> {
|
||||
assertTrue(result.isEmpty()); // Success
|
||||
assertEquals(441, gf.getWallBlockCount());
|
||||
assertEquals(0, gf.getWallDoors());
|
||||
|
Loading…
Reference in New Issue
Block a user