mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-24 06:06:45 +01:00
Forgot to merge... Bleh...
This commit is contained in:
parent
1e6ae5c467
commit
c60bd3bbc8
File diff suppressed because it is too large
Load Diff
@ -1,37 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) IntellectualCrafters - 2014.
|
* Copyright (c) IntellectualCrafters - 2014.
|
||||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||||
*
|
*
|
||||||
* >> File = Auto.java
|
* >> File = Auto.java
|
||||||
* >> Generated by: Citymonstret at 2014-08-09 01:40
|
* >> Generated by: Citymonstret at 2014-08-09 01:40
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
import com.intellectualcrafters.plot.PlotHelper;
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.PlotId;
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class Auto extends SubCommand {
|
public class Auto extends SubCommand {
|
||||||
|
|
||||||
public Auto() {
|
public Auto() {
|
||||||
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING);
|
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO auto claim a mega plot!!!!!!!!!!!!
|
// TODO auto claim a mega plot!!!!!!!!!!!!
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Player plr, String... args) {
|
public boolean execute(Player plr, String... args) {
|
||||||
World world;
|
World world;
|
||||||
|
int size_x = 1;
|
||||||
|
int size_z = 1;
|
||||||
if (PlotMain.getPlotWorlds().length == 1) {
|
if (PlotMain.getPlotWorlds().length == 1) {
|
||||||
world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]);
|
world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]);
|
||||||
} else {
|
} else {
|
||||||
@ -41,7 +36,6 @@ public class Auto extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (PlotMain.hasPermission(plr, "plots.auto.mega")) {
|
if (PlotMain.hasPermission(plr, "plots.auto.mega")) {
|
||||||
@ -50,7 +44,7 @@ public class Auto extends SubCommand {
|
|||||||
size_x = Integer.parseInt(split[0]);
|
size_x = Integer.parseInt(split[0]);
|
||||||
size_z = Integer.parseInt(split[1]);
|
size_z = Integer.parseInt(split[1]);
|
||||||
if (size_x < 1 || size_z < 1) {
|
if (size_x < 1 || size_z < 1) {
|
||||||
PlayerFunctions.sendMessage(plr, "&cError: size<=0");
|
PlayerFunctions.sendMessage(plr, "&cError: size<=0");
|
||||||
}
|
}
|
||||||
if (size_x > 4 || size_z > 4) {
|
if (size_x > 4 || size_z > 4) {
|
||||||
PlayerFunctions.sendMessage(plr, "&cError: size>4");
|
PlayerFunctions.sendMessage(plr, "&cError: size>4");
|
||||||
@ -91,38 +85,6 @@ public class Auto extends SubCommand {
|
|||||||
x = q;
|
x = q;
|
||||||
z = q;
|
z = q;
|
||||||
}
|
}
|
||||||
while (!br) {
|
|
||||||
id = new PlotId(x, z);
|
|
||||||
if (PlotHelper.getPlot(world, id).owner == null) {
|
|
||||||
Plot plot = PlotHelper.getPlot(world, id);
|
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(plot.getWorld());
|
|
||||||
if(PlotMain.useEconomy && plotworld.USE_ECONOMY) {
|
|
||||||
double cost = plotworld.PLOT_PRICE;
|
|
||||||
if(cost > 0d) {
|
|
||||||
Economy economy = PlotMain.economy;
|
|
||||||
if(economy.getBalance(plr) < cost) {
|
|
||||||
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
economy.withdrawPlayer(plr, cost);
|
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String schematic;
|
|
||||||
if(args.length > 0 && !(schematic = args[0]).equals("")) {
|
|
||||||
if(plotworld.SCHEMATIC_CLAIM_SPECIFY) {
|
|
||||||
if(!plotworld.SCHEMATICS.contains(schematic.toLowerCase())) {
|
|
||||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boolean result = Claim.claimPlot(plr, plot, true);
|
|
||||||
br = !result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -130,9 +92,7 @@ public class Auto extends SubCommand {
|
|||||||
PlotId start = new PlotId(x, z);
|
PlotId start = new PlotId(x, z);
|
||||||
PlotId end = new PlotId(x+size_x-1, z+size_z-1);
|
PlotId end = new PlotId(x+size_x-1, z+size_z-1);
|
||||||
if (isUnowned(world, start, end)) {
|
if (isUnowned(world, start, end)) {
|
||||||
|
|
||||||
// TODO claim event
|
// TODO claim event
|
||||||
|
|
||||||
for (int i = start.x; i <= end.x; i++) {
|
for (int i = start.x; i <= end.x; i++) {
|
||||||
for (int j = start.y; j <= end.y; j++) {
|
for (int j = start.y; j <= end.y; j++) {
|
||||||
Plot plot = PlotHelper.getPlot(world, new PlotId(i,j));
|
Plot plot = PlotHelper.getPlot(world, new PlotId(i,j));
|
||||||
@ -170,4 +130,4 @@ public class Auto extends SubCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,60 +38,64 @@ import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Set extends SubCommand {
|
public class Set extends SubCommand{
|
||||||
|
|
||||||
public Set() {
|
public Set() {
|
||||||
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS);
|
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] values = new String[] {
|
||||||
|
"biome", "wall", "wall_filling", "floor", "alias", "home", "rain", "flag"
|
||||||
|
};
|
||||||
|
public static String[] aliases = new String[] {
|
||||||
|
"b", "w", "wf", "f", "a", "h", "r", "fl"
|
||||||
|
};
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public boolean execute(Player plr, String ... args) {
|
||||||
|
if(!PlayerFunctions.isInPlot(plr)) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
|
||||||
public static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "rain", "flag" };
|
if(!plot.hasRights(plr) && !plr.hasPermission("plots.admin")) {
|
||||||
public static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "r", "fl" };
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
|
return false;
|
||||||
@SuppressWarnings("deprecation")
|
}
|
||||||
@Override
|
if(args.length < 1) {
|
||||||
public boolean execute(Player plr, String... args) {
|
StringBuilder builder = new StringBuilder();
|
||||||
if (!PlayerFunctions.isInPlot(plr)) {
|
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
builder.append(getArgumentList(values));
|
||||||
return false;
|
PlayerFunctions.sendMessage(plr, builder.toString());
|
||||||
}
|
return true;
|
||||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
}
|
||||||
|
|
||||||
if (!plot.hasRights(plr) && !plr.hasPermission("plots.admin")) {
|
for(int i = 0; i < aliases.length; i++) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
if(aliases[i].equalsIgnoreCase(args[0])) {
|
||||||
return false;
|
args[0] = values[i];
|
||||||
}
|
break;
|
||||||
if (args.length < 1) {
|
}
|
||||||
StringBuilder builder = new StringBuilder();
|
}
|
||||||
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
|
||||||
builder.append(getArgumentList(values));
|
|
||||||
PlayerFunctions.sendMessage(plr, builder.toString());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < aliases.length; i++) {
|
|
||||||
if (aliases[i].equalsIgnoreCase(args[0])) {
|
|
||||||
args[0] = values[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: Implement option */
|
/* TODO: Implement option */
|
||||||
boolean advanced_permissions = false;
|
boolean advanced_permissions = false;
|
||||||
if (advanced_permissions) {
|
if(advanced_permissions) {
|
||||||
if (!plr.hasPermission("plots.set." + args[0].toLowerCase())) {
|
if(!plr.hasPermission("plots.set." + args[0].toLowerCase())) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("flag")) {
|
if(args[0].equalsIgnoreCase("flag")) {
|
||||||
if (args.length < 2) {
|
if(args.length < 2) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", StringUtils.join(FlagManager.getFlags(), "&c, &6")));
|
PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", StringUtils.join(PlotMain.getFlags(),"&c, &6")));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (FlagManager.getFlag(args[1])==null) {
|
if (!PlotMain.isRegisteredFlag(args[1])) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -99,35 +103,34 @@ public class Set extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length == 2) {
|
if (args.length==2) {
|
||||||
if (plot.settings.getFlag(args[1].toLowerCase()) == null) {
|
if (plot.settings.getFlag(args[1].toLowerCase())==null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Flag flag = plot.settings.getFlag(args[1].toLowerCase());
|
Flag flag = plot.settings.getFlag(args[1].toLowerCase());
|
||||||
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag, plot);
|
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag,plot);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if(event.isCancelled()) {
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
java.util.Set<Flag> newflags = plot.settings.getFlags();
|
java.util.Set<Flag> newflags = plot.settings.getFlags();
|
||||||
Flag oldFlag = plot.settings.getFlag(args[1].toLowerCase());
|
Flag oldFlag = plot.settings.getFlag(args[1].toLowerCase());
|
||||||
if (oldFlag != null) {
|
if (oldFlag!=null)
|
||||||
newflags.remove(oldFlag);
|
newflags.remove(oldFlag);
|
||||||
}
|
|
||||||
plot.settings.setFlags(newflags.toArray(new Flag[0]));
|
plot.settings.setFlags(newflags.toArray(new Flag[0]));
|
||||||
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
|
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length)," ");
|
||||||
Flag flag = new Flag(new AbstractFlag(args[1]), value);
|
Flag flag = new Flag(args[1], value);
|
||||||
PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot);
|
PlotFlagAddEvent event = new PlotFlagAddEvent(flag,plot);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if(event.isCancelled()) {
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return false;
|
return false;
|
||||||
@ -136,48 +139,44 @@ public class Set extends SubCommand {
|
|||||||
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0]));
|
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0]));
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
}
|
||||||
PlayerFunctions.sendMessage(plr, "&c" + e.getMessage());
|
catch (Exception e) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&c"+e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("rain")) {
|
if(args[0].equalsIgnoreCase("rain")) {
|
||||||
if (args.length < 2) {
|
if(args.length < 2) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NEED_ON_OFF);
|
PlayerFunctions.sendMessage(plr, C.NEED_ON_OFF);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String word = args[1];
|
String word = args[1];
|
||||||
if (!word.equalsIgnoreCase("on") && !word.equalsIgnoreCase("off")) {
|
if(!word.equalsIgnoreCase("on") && !word.equalsIgnoreCase("off")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NEED_ON_OFF);
|
PlayerFunctions.sendMessage(plr, C.NEED_ON_OFF);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean b = word.equalsIgnoreCase("on");
|
boolean b = word.equalsIgnoreCase("on");
|
||||||
DBFunc.setWeather(plr.getWorld().getName(), plot, b);
|
DBFunc.setWeather(plr.getWorld().getName(), plot, b);
|
||||||
PlayerFunctions.sendMessage(plr, C.SETTING_UPDATED);
|
PlayerFunctions.sendMessage(plr, C.SETTING_UPDATED);
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for(Player p : Bukkit.getOnlinePlayers()) {
|
||||||
if (PlayerFunctions.getCurrentPlot(plr).id == plot.id) {
|
if(PlayerFunctions.getCurrentPlot(plr).id == plot.id) {
|
||||||
if (b) {
|
if(b) p.setPlayerWeather(WeatherType.DOWNFALL);
|
||||||
p.setPlayerWeather(WeatherType.DOWNFALL);
|
else p.resetPlayerWeather();
|
||||||
} else {
|
|
||||||
p.resetPlayerWeather();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("home")) {
|
if(args[0].equalsIgnoreCase("home")) {
|
||||||
if (args.length < 2) {
|
if(args.length < 2) {
|
||||||
PlayerFunctions.sendMessage(plr, C.MISSING_POSITION);
|
PlayerFunctions.sendMessage(plr, C.MISSING_POSITION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotHomePosition position = null;
|
PlotHomePosition position = null;
|
||||||
for (PlotHomePosition p : PlotHomePosition.values()) {
|
for(PlotHomePosition p : PlotHomePosition.values()) {
|
||||||
if (p.isMatching(args[1])) {
|
if(p.isMatching(args[1])) position = p;
|
||||||
position = p;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (position == null) {
|
if(position == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_POSITION);
|
PlayerFunctions.sendMessage(plr, C.INVALID_POSITION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -186,14 +185,14 @@ public class Set extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("alias")) {
|
if(args[0].equalsIgnoreCase("alias")) {
|
||||||
if (args.length < 2) {
|
if(args.length < 2) {
|
||||||
PlayerFunctions.sendMessage(plr, C.MISSING_ALIAS);
|
PlayerFunctions.sendMessage(plr, C.MISSING_ALIAS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String alias = args[1];
|
String alias = args[1];
|
||||||
for (Plot p : PlotMain.getPlots()) {
|
for(Plot p : PlotMain.getPlots()) {
|
||||||
if (p.settings.getAlias().equalsIgnoreCase(alias)) {
|
if(p.settings.getAlias().equalsIgnoreCase(alias)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -202,162 +201,162 @@ public class Set extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
|
PlayerFunctions.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("biome")) {
|
if(args[0].equalsIgnoreCase("biome")) {
|
||||||
if (args.length < 2) {
|
if(args.length < 2) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NEED_BIOME);
|
PlayerFunctions.sendMessage(plr, C.NEED_BIOME);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Biome biome = null;
|
Biome biome = null;
|
||||||
for (Biome b : Biome.values()) {
|
for(Biome b : Biome.values()) {
|
||||||
if (b.toString().equalsIgnoreCase(args[1])) {
|
if(b.toString().equalsIgnoreCase(args[1])) {
|
||||||
biome = b;
|
biome = b;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (biome == null) {
|
if(biome == null) {
|
||||||
PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values())));
|
PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values())));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PlotHelper.setBiome(plr.getWorld(), plot, biome);
|
PlotHelper.setBiome(plr.getWorld(), plot, biome);
|
||||||
PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase());
|
PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("wall")) {
|
if(args[0].equalsIgnoreCase("wall")) {
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||||
if (plotworld == null) {
|
if (plotworld==null) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(args.length < 2) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Material material = null;
|
||||||
|
for(Material m : plotworld.BLOCKS) {
|
||||||
|
if(m.toString().equalsIgnoreCase(args[1])) {
|
||||||
|
material = m;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(material == null) {
|
||||||
|
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
byte data = 0;
|
||||||
|
|
||||||
|
if(args.length > 2) {
|
||||||
|
try {
|
||||||
|
data = (byte) Integer.parseInt(args[2]);
|
||||||
|
} catch(Exception e) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerFunctions.sendMessage(plr, C.GENERATING_WALL);
|
||||||
|
PlotHelper.adjustWall(plr.getWorld(), plot, (short)material.getId(), data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(args[0].equalsIgnoreCase("floor")) {
|
||||||
|
if(args.length < 2) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||||
|
if (plotworld==null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length < 2) {
|
//
|
||||||
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
@SuppressWarnings("unchecked")
|
||||||
return true;
|
ArrayList<Material> materials = (ArrayList<Material>) plotworld.BLOCKS.clone();
|
||||||
}
|
materials.add(Material.AIR);
|
||||||
Material material = null;
|
//
|
||||||
for (Material m : PlotWorld.BLOCKS) {
|
String[] strings = args[1].split(",");
|
||||||
if (m.toString().equalsIgnoreCase(args[1])) {
|
//
|
||||||
material = m;
|
Material[] material = new Material[strings.length];
|
||||||
break;
|
byte[] data = new byte[strings.length];
|
||||||
}
|
//
|
||||||
}
|
int index = 0;
|
||||||
if (material == null) {
|
//
|
||||||
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
|
byte b = (byte) 0;
|
||||||
return true;
|
Material m = null;
|
||||||
}
|
//
|
||||||
byte data = 0;
|
for(String s : strings) {
|
||||||
|
s = s.replaceAll(",", "");
|
||||||
if (args.length > 2) {
|
String[] ss = s.split(";");
|
||||||
try {
|
ss[0] = ss[0].replaceAll(";", "");
|
||||||
data = (byte) Integer.parseInt(args[2]);
|
for(Material ma : materials) {
|
||||||
} catch (Exception e) {
|
if(ma.toString().equalsIgnoreCase(ss[0])) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
m = ma;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
if(m == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.GENERATING_WALL);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK);
|
||||||
PlotHelper.adjustWall(plr.getWorld(), plot, (short) material.getId(), data);
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
if(ss.length == 1) {
|
||||||
if (args[0].equalsIgnoreCase("floor")) {
|
data[index] = (byte) 0;
|
||||||
if (args.length < 2) {
|
material[index] = m;
|
||||||
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
} else {
|
||||||
return true;
|
try {
|
||||||
}
|
b = (byte) Integer.parseInt(ss[1]);
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
} catch(Exception e) {
|
||||||
if (plotworld == null) {
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
data[index] = b;
|
||||||
|
material[index] = m;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
PlotHelper.setFloor(plr, plot, material, data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(args[0].equalsIgnoreCase("wall_filling")) {
|
||||||
|
if(args.length < 2) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||||
|
if (plotworld==null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//
|
Material material = null;
|
||||||
@SuppressWarnings("unchecked")
|
for(Material m : plotworld.BLOCKS) {
|
||||||
ArrayList<Material> materials = (ArrayList<Material>) PlotWorld.BLOCKS.clone();
|
if(m.toString().equalsIgnoreCase(args[1])) {
|
||||||
materials.add(Material.AIR);
|
material = m;
|
||||||
//
|
break;
|
||||||
String[] strings = args[1].split(",");
|
}
|
||||||
//
|
}
|
||||||
Material[] material = new Material[strings.length];
|
if(material == null) {
|
||||||
byte[] data = new byte[strings.length];
|
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
|
||||||
//
|
return true;
|
||||||
int index = 0;
|
}
|
||||||
//
|
byte data = 0;
|
||||||
byte b = (byte) 0;
|
|
||||||
Material m = null;
|
if(args.length > 2) {
|
||||||
//
|
try {
|
||||||
for (String s : strings) {
|
data = (byte) Integer.parseInt(args[2]);
|
||||||
s = s.replaceAll(",", "");
|
} catch(Exception e) {
|
||||||
String[] ss = s.split(";");
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
||||||
ss[0] = ss[0].replaceAll(";", "");
|
return true;
|
||||||
for (Material ma : materials) {
|
}
|
||||||
if (ma.toString().equalsIgnoreCase(ss[0])) {
|
}
|
||||||
m = ma;
|
PlotHelper.adjustWallFilling(plr, plr.getWorld(), plot, (short)material.getId(), data);
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
if (m == null) {
|
PlayerFunctions.sendMessage(plr, "Not a valid option. Use {TODO: Insert list.}");
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK);
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
if (ss.length == 1) {
|
private String getMaterial(Material m) {
|
||||||
data[index] = (byte) 0;
|
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", m.toString().toLowerCase()));
|
||||||
material[index] = m;
|
}
|
||||||
} else {
|
|
||||||
try {
|
private String getBiome(Biome b) {
|
||||||
b = (byte) Integer.parseInt(ss[1]);
|
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", b.toString().toLowerCase()));
|
||||||
} catch (Exception e) {
|
}
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
data[index] = b;
|
|
||||||
material[index] = m;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
PlotHelper.setFloor(plr, plot, material, data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("wall_filling")) {
|
|
||||||
if (args.length < 2) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
|
||||||
if (plotworld == null) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = null;
|
|
||||||
for (Material m : PlotWorld.BLOCKS) {
|
|
||||||
if (m.toString().equalsIgnoreCase(args[1])) {
|
|
||||||
material = m;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (material == null) {
|
|
||||||
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
byte data = 0;
|
|
||||||
|
|
||||||
if (args.length > 2) {
|
|
||||||
try {
|
|
||||||
data = (byte) Integer.parseInt(args[2]);
|
|
||||||
} catch (Exception e) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlotHelper.adjustWallFilling(plr, plr.getWorld(), plot, (short) material.getId(), data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PlayerFunctions.sendMessage(plr, "Not a valid option. Use {TODO: Insert list.}");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getMaterial(Material m) {
|
|
||||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", m.toString().toLowerCase()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getBiome(Biome b) {
|
|
||||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", b.toString().toLowerCase()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getString(String s) {
|
private String getString(String s) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
|
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
|
||||||
@ -365,28 +364,29 @@ public class Set extends SubCommand {
|
|||||||
|
|
||||||
private String getArgumentList(String[] strings) {
|
private String getArgumentList(String[] strings) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (String s : strings) {
|
for(String s : strings) {
|
||||||
builder.append(getString(s));
|
builder.append(getString(s));
|
||||||
}
|
}
|
||||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
return builder.toString().substring(1, builder.toString().length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getBiomeList(List<Biome> biomes) {
|
private String getBiomeList(List<Biome> biomes) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
||||||
for (Biome b : biomes) {
|
for(Biome b : biomes) {
|
||||||
builder.append(getBiome(b));
|
builder.append(getBiome(b));
|
||||||
}
|
}
|
||||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
return builder.toString().substring(1,builder.toString().length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getBlockList(List<Material> blocks) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
||||||
|
for(Material b : blocks) {
|
||||||
|
builder.append(getMaterial(b));
|
||||||
|
}
|
||||||
|
return builder.toString().substring(1,builder.toString().length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
private String getBlockList(List<Material> blocks) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
|
||||||
for (Material b : blocks) {
|
|
||||||
builder.append(getMaterial(b));
|
|
||||||
}
|
|
||||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user