mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Changes
ratings api misc-cap other tweakes
This commit is contained in:
parent
2e79f3d0f8
commit
95feaed870
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>3.2.15</version>
|
<version>3.2.16</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -1607,7 +1607,7 @@ public class PS {
|
|||||||
"no-worldedit", "redstone", "keep");
|
"no-worldedit", "redstone", "keep");
|
||||||
final List<String> intervalFlags = Arrays.asList("feed", "heal");
|
final List<String> intervalFlags = Arrays.asList("feed", "heal");
|
||||||
final List<String> stringFlags = Arrays.asList("greeting", "farewell");
|
final List<String> stringFlags = Arrays.asList("greeting", "farewell");
|
||||||
final List<String> intFlags = Arrays.asList("entity-cap", "mob-cap", "animal-cap", "hostile-cap", "vehicle-cap", "music");
|
final List<String> intFlags = Arrays.asList("misc-cap", "entity-cap", "mob-cap", "animal-cap", "hostile-cap", "vehicle-cap", "music");
|
||||||
for (final String flag : stringFlags) {
|
for (final String flag : stringFlags) {
|
||||||
FlagManager.addFlag(new AbstractFlag(flag));
|
FlagManager.addFlag(new AbstractFlag(flag));
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,8 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
|||||||
createCommand(new RegenAllRoads());
|
createCommand(new RegenAllRoads());
|
||||||
createCommand(new Claim());
|
createCommand(new Claim());
|
||||||
createCommand(new Auto());
|
createCommand(new Auto());
|
||||||
createCommand(new Home());
|
|
||||||
createCommand(new Visit());
|
createCommand(new Visit());
|
||||||
|
createCommand(new Home());
|
||||||
createCommand(new TP());
|
createCommand(new TP());
|
||||||
createCommand(new Set());
|
createCommand(new Set());
|
||||||
createCommand(new Toggle());
|
createCommand(new Toggle());
|
||||||
@ -171,47 +171,6 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
|||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
//// public static List<String> helpMenu(final PlotPlayer player, final CommandCategory category, int page) {
|
|
||||||
// List<Command<PlotPlayer>> commands;
|
|
||||||
// // commands = getCommands(category, player);
|
|
||||||
// // final int totalPages = ((int) Math.ceil(12 * (commands.size()) /
|
|
||||||
// // 100));
|
|
||||||
// final int perPage = 5;
|
|
||||||
// // final int totalPages = (commands.size() / perPage) + (commands.size() % perPage == 0 ? 0 : 1);
|
|
||||||
// // if (page > totalPages) {
|
|
||||||
// // page = totalPages;
|
|
||||||
// // }
|
|
||||||
// int max = (page * perPage) + perPage;
|
|
||||||
// // if (max > commands.size()) {
|
|
||||||
// // max = commands.size();
|
|
||||||
// // }
|
|
||||||
// final List<String> help = new ArrayList<>();
|
|
||||||
// help.add(C.HELP_HEADER.s());
|
|
||||||
// // HELP_PAGE_HEADER("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"),
|
|
||||||
// // help.add(C.HELP_PAGE_HEADER.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages)).replace("%dis%", "" + perPage).replace("%total%", "" + commands.size()));
|
|
||||||
// Command cmd;
|
|
||||||
// // HELP_CATEGORY("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"),
|
|
||||||
// // help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages)).replace("%dis%", "" + perPage).replace("%total%", "" + commands.size()));
|
|
||||||
// // Command<PlotPlayer> cmd;
|
|
||||||
// final int start = page * perPage;
|
|
||||||
// for (int x = start; x < max; x++) {
|
|
||||||
// // cmd = commands.get(x);
|
|
||||||
// String s = C.HELP_ITEM.s();
|
|
||||||
// if (cmd.getAliases().size() > 0) {
|
|
||||||
// s = s.replace("%alias%", StringMan.join(cmd.getAliases(), "|"));
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// s = s.replace("%alias%", "");
|
|
||||||
// }
|
|
||||||
// s = s.replace("%usage%", cmd.getUsage().contains("plot") ? cmd.getUsage() : "/plot " + cmd.getUsage()).replace("%cmd%", cmd.getCommand()).replace("%desc%", cmd.getDescription()).replace("[]", "");
|
|
||||||
// help.add(s);
|
|
||||||
// }
|
|
||||||
// if (help.size() < 2) {
|
|
||||||
// help.add(C.NO_COMMANDS.s());
|
|
||||||
// }
|
|
||||||
// return help;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
public static void displayHelp(final PlotPlayer player, String cat, int page, final String label) {
|
public static void displayHelp(final PlotPlayer player, String cat, int page, final String label) {
|
||||||
CommandCategory catEnum = null;
|
CommandCategory catEnum = null;
|
||||||
if (cat != null) {
|
if (cat != null) {
|
||||||
@ -322,6 +281,11 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
String perm = cmd.getPermission();
|
String perm = cmd.getPermission();
|
||||||
HashSet<String> desc = new HashSet<String>();
|
HashSet<String> desc = new HashSet<String>();
|
||||||
|
for (String alias : cmd.getAliases()) {
|
||||||
|
if (alias.startsWith(args[0])) {
|
||||||
|
count += 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (String word : cmd.getDescription().split(" ")) {
|
for (String word : cmd.getDescription().split(" ")) {
|
||||||
desc.add(word);
|
desc.add(word);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class Rate extends SubCommand {
|
|||||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (args[0].equalsIgnoreCase("next")) {
|
if (args[0].equalsIgnoreCase("next")) {
|
||||||
final ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlots());
|
final ArrayList<Plot> plots = new ArrayList<>(PS.get().getBasePlots());
|
||||||
Collections.sort(plots, new Comparator<Plot>() {
|
Collections.sort(plots, new Comparator<Plot>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Plot p1, final Plot p2) {
|
public int compare(final Plot p1, final Plot p2) {
|
||||||
@ -96,7 +96,7 @@ public class Rate extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,9 @@ import java.util.Collection;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.PS.SortType;
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
@ -45,7 +43,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
|||||||
command = "visit",
|
command = "visit",
|
||||||
permission = "plots.visit",
|
permission = "plots.visit",
|
||||||
description = "Visit someones plot",
|
description = "Visit someones plot",
|
||||||
usage = "/plot visit <player|alias|world|id> [#]",
|
usage = "/plot visit [player|alias|world|id] [#]",
|
||||||
aliases = { "v" },
|
aliases = { "v" },
|
||||||
requiredType = RequiredType.NONE,
|
requiredType = RequiredType.NONE,
|
||||||
category = CommandCategory.TELEPORT)
|
category = CommandCategory.TELEPORT)
|
||||||
|
@ -46,7 +46,13 @@ import com.intellectualcrafters.plot.util.StringMan;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
@CommandDeclaration(command = "list", aliases = { "l" }, description = "List plots", permission = "plots.list", category = CommandCategory.INFO)
|
@CommandDeclaration(
|
||||||
|
command = "list",
|
||||||
|
aliases = { "l" },
|
||||||
|
description = "List plots",
|
||||||
|
permission = "plots.list",
|
||||||
|
category = CommandCategory.INFO,
|
||||||
|
usage = "/plot list <forsale|mine|shared|world|top|all|unowned|unknown|player|world|done> [#]")
|
||||||
public class list extends SubCommand {
|
public class list extends SubCommand {
|
||||||
|
|
||||||
private String[] getArgumentList(final PlotPlayer player) {
|
private String[] getArgumentList(final PlotPlayer player) {
|
||||||
|
@ -84,6 +84,18 @@ public interface AbstractDB {
|
|||||||
*/
|
*/
|
||||||
void delete(final Plot plot);
|
void delete(final Plot plot);
|
||||||
|
|
||||||
|
void deleteSettings(Plot plot);
|
||||||
|
|
||||||
|
void deleteHelpers(Plot plot);
|
||||||
|
|
||||||
|
void deleteTrusted(Plot plot);
|
||||||
|
|
||||||
|
void deleteDenied(Plot plot);
|
||||||
|
|
||||||
|
void deleteComments(Plot plot);
|
||||||
|
|
||||||
|
void deleteRatings(Plot plot);
|
||||||
|
|
||||||
void delete(final PlotCluster cluster);
|
void delete(final PlotCluster cluster);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,8 +40,8 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
|||||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DB Functions
|
* Database Functions
|
||||||
*
|
* - These functions do not update the local plot objects and only make changes to the DB
|
||||||
*/
|
*/
|
||||||
public class DBFunc {
|
public class DBFunc {
|
||||||
/**
|
/**
|
||||||
@ -154,6 +154,76 @@ public class DBFunc {
|
|||||||
plot.temp = -1;
|
plot.temp = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the ratings for a plot
|
||||||
|
* @param plot
|
||||||
|
*/
|
||||||
|
public static void deleteRatings(final Plot plot) {
|
||||||
|
if (plot.temp == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dbManager.deleteRatings(plot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the trusted list for a plot
|
||||||
|
* @param plot
|
||||||
|
*/
|
||||||
|
public static void deleteTrusted(final Plot plot) {
|
||||||
|
if (plot.temp == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dbManager.deleteHelpers(plot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the members list for a plot
|
||||||
|
* @param plot
|
||||||
|
*/
|
||||||
|
public static void deleteMembers(final Plot plot) {
|
||||||
|
if (plot.temp == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dbManager.deleteTrusted(plot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the denied list for a plot
|
||||||
|
* @param plot
|
||||||
|
*/
|
||||||
|
public static void deleteDenied(final Plot plot) {
|
||||||
|
if (plot.temp == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dbManager.deleteDenied(plot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the comments in a plot
|
||||||
|
* @param plot
|
||||||
|
*/
|
||||||
|
public static void deleteComments(final Plot plot) {
|
||||||
|
if (plot.temp == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dbManager.deleteComments(plot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deleting settings will
|
||||||
|
* 1) Delete any settings (flags and such) associated with the plot
|
||||||
|
* 2) Prevent any local changes to the plot from saving properly to the db
|
||||||
|
*
|
||||||
|
* This shouldn't ever be needed
|
||||||
|
* @param plot
|
||||||
|
*/
|
||||||
|
public static void deleteSettings(final Plot plot) {
|
||||||
|
if (plot.temp == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dbManager.deleteSettings(plot);
|
||||||
|
}
|
||||||
|
|
||||||
public static void delete(final PlotCluster toDelete) {
|
public static void delete(final PlotCluster toDelete) {
|
||||||
dbManager.delete(toDelete);
|
dbManager.delete(toDelete);
|
||||||
}
|
}
|
||||||
|
@ -1191,14 +1191,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
stmt.close();
|
stmt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a plot
|
|
||||||
*
|
|
||||||
* @param plot
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(final Plot plot) {
|
public void deleteSettings(final Plot plot) {
|
||||||
PS.get().removePlot(plot.world, plot.id, false);
|
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_settings") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_settings") {
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {
|
public void set(final PreparedStatement stmt) throws SQLException {
|
||||||
@ -1210,6 +1204,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_settings` WHERE `plot_plot_id` = ?");
|
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_settings` WHERE `plot_plot_id` = ?");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteHelpers(final Plot plot) {
|
||||||
|
if (plot.getTrusted().size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_helpers") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_helpers") {
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {
|
public void set(final PreparedStatement stmt) throws SQLException {
|
||||||
@ -1221,6 +1222,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_helpers` WHERE `plot_plot_id` = ?");
|
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_helpers` WHERE `plot_plot_id` = ?");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteTrusted(final Plot plot) {
|
||||||
|
if (plot.getMembers().size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_trusted") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_trusted") {
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {
|
public void set(final PreparedStatement stmt) throws SQLException {
|
||||||
@ -1232,6 +1240,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_trusted` WHERE `plot_plot_id` = ?");
|
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_trusted` WHERE `plot_plot_id` = ?");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDenied(final Plot plot) {
|
||||||
|
if (plot.getDenied().size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_denied") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_denied") {
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {
|
public void set(final PreparedStatement stmt) throws SQLException {
|
||||||
@ -1243,6 +1258,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_denied` WHERE `plot_plot_id` = ?");
|
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_denied` WHERE `plot_plot_id` = ?");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteComments(final Plot plot) {
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_comments") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_comments") {
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {
|
public void set(final PreparedStatement stmt) throws SQLException {
|
||||||
@ -1255,6 +1274,40 @@ public class SQLManager implements AbstractDB {
|
|||||||
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ?");
|
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ?");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteRatings(final Plot plot) {
|
||||||
|
if (Settings.CACHE_RATINGS && plot.getSettings().getRatings().size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addPlotTask(plot, new UniqueStatement("delete_plot_ratings") {
|
||||||
|
@Override
|
||||||
|
public void set(final PreparedStatement stmt) throws SQLException {
|
||||||
|
stmt.setInt(1, getId(plot));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PreparedStatement get() throws SQLException {
|
||||||
|
return connection.prepareStatement("DELETE FROM `" + prefix + "plot_rating` WHERE `plot_plot_id` = ?");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a plot
|
||||||
|
*
|
||||||
|
* @param plot
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void delete(final Plot plot) {
|
||||||
|
PS.get().removePlot(plot.world, plot.id, false);
|
||||||
|
deleteSettings(plot);
|
||||||
|
deleteDenied(plot);
|
||||||
|
deleteHelpers(plot);
|
||||||
|
deleteTrusted(plot);
|
||||||
|
deleteComments(plot);
|
||||||
|
deleteRatings(plot);
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot") {
|
addPlotTask(plot, new UniqueStatement("delete_plot") {
|
||||||
@Override
|
@Override
|
||||||
public void set(final PreparedStatement stmt) throws SQLException {
|
public void set(final PreparedStatement stmt) throws SQLException {
|
||||||
|
@ -721,24 +721,55 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public double getAverageRating() {
|
public double getAverageRating() {
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
final Collection<Rating> ratings = getRatings().values();
|
final Collection<Rating> ratings = getBasePlot(false).getRatings().values();
|
||||||
for (final Rating rating : ratings) {
|
for (final Rating rating : ratings) {
|
||||||
sum += rating.getAverageRating();
|
sum += rating.getAverageRating();
|
||||||
}
|
}
|
||||||
return (sum / ratings.size());
|
return (sum / ratings.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a rating for a user<br>
|
||||||
|
* - If the user has already rated, the following will return false
|
||||||
|
* @param uuid
|
||||||
|
* @param rating
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean addRating(UUID uuid, Rating rating) {
|
||||||
|
Plot base = getBasePlot(false);
|
||||||
|
PlotSettings baseSettings = base.getSettings();
|
||||||
|
if (baseSettings.getRatings().containsKey(uuid)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
baseSettings.getRatings().put(uuid, rating.getAggregate());
|
||||||
|
DBFunc.setRating(base, uuid, temp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the ratings for this plot
|
||||||
|
*/
|
||||||
|
public void clearRatings() {
|
||||||
|
Plot base = getBasePlot(false);
|
||||||
|
PlotSettings baseSettings = base.getSettings();
|
||||||
|
if (baseSettings.ratings != null && baseSettings.ratings.size() > 0) {
|
||||||
|
DBFunc.deleteRatings(base);
|
||||||
|
baseSettings.ratings = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ratings associated with a plot<br>
|
* Get the ratings associated with a plot<br>
|
||||||
* - The rating object may contain multiple categories
|
* - The rating object may contain multiple categories
|
||||||
* @return Map of user who rated to the rating
|
* @return Map of user who rated to the rating
|
||||||
*/
|
*/
|
||||||
public HashMap<UUID, Rating> getRatings() {
|
public HashMap<UUID, Rating> getRatings() {
|
||||||
|
Plot base = getBasePlot(false);
|
||||||
final HashMap<UUID, Rating> map = new HashMap<UUID, Rating>();
|
final HashMap<UUID, Rating> map = new HashMap<UUID, Rating>();
|
||||||
if (getSettings().ratings == null) {
|
if (base.getSettings().ratings == null) {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
for (final Entry<UUID, Integer> entry : getSettings().ratings.entrySet()) {
|
for (final Entry<UUID, Integer> entry : base.getSettings().ratings.entrySet()) {
|
||||||
map.put(entry.getKey(), new Rating(entry.getValue()));
|
map.put(entry.getKey(), new Rating(entry.getValue()));
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
@ -980,6 +1011,13 @@ public class Plot {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public boolean removeDenied(final UUID uuid) {
|
public boolean removeDenied(final UUID uuid) {
|
||||||
|
if (uuid == DBFunc.everyone) {
|
||||||
|
boolean result = false;
|
||||||
|
for (UUID other : getDenied()) {
|
||||||
|
result = result || PlotHandler.removeDenied(this, other);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
return PlotHandler.removeDenied(this, uuid);
|
return PlotHandler.removeDenied(this, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -989,6 +1027,13 @@ public class Plot {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public boolean removeTrusted(final UUID uuid) {
|
public boolean removeTrusted(final UUID uuid) {
|
||||||
|
if (uuid == DBFunc.everyone) {
|
||||||
|
boolean result = false;
|
||||||
|
for (UUID other : getTrusted()) {
|
||||||
|
result = result || PlotHandler.removeTrusted(this, other);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
return PlotHandler.removeTrusted(this, uuid);
|
return PlotHandler.removeTrusted(this, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -998,6 +1043,13 @@ public class Plot {
|
|||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public boolean removeMember(final UUID uuid) {
|
public boolean removeMember(final UUID uuid) {
|
||||||
|
if (uuid == DBFunc.everyone) {
|
||||||
|
boolean result = false;
|
||||||
|
for (UUID other : getMembers()) {
|
||||||
|
result = result || PlotHandler.removeMember(this, other);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
return PlotHandler.removeMember(this, uuid);
|
return PlotHandler.removeMember(this, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.object;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
@ -30,35 +31,48 @@ import com.intellectualcrafters.plot.flag.FlagManager;
|
|||||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plot settings
|
* Generic settings class
|
||||||
*
|
* - Does not keep a reference to a parent class
|
||||||
|
* - Direct changes here will not occur in the db (Use the parent plot object for that)
|
||||||
*/
|
*/
|
||||||
public class PlotSettings {
|
public class PlotSettings {
|
||||||
/**
|
/**
|
||||||
* merged plots
|
* merged plots
|
||||||
|
* @deprecated Raw access
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean[] merged = new boolean[] { false, false, false, false };
|
public boolean[] merged = new boolean[] { false, false, false, false };
|
||||||
/**
|
/**
|
||||||
* plot alias
|
* plot alias
|
||||||
|
* @deprecated Raw access
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String alias = "";
|
public String alias = "";
|
||||||
/**
|
/**
|
||||||
* Comments
|
* Comments
|
||||||
|
* @deprecated Raw access
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public List<PlotComment> comments = null;
|
public List<PlotComment> comments = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ratings for a plot
|
* The ratings for a plot
|
||||||
|
* @deprecated Raw access
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public HashMap<UUID, Integer> ratings;
|
public HashMap<UUID, Integer> ratings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags
|
* Flags
|
||||||
|
* @deprecated Raw access
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public HashMap<String, Flag> flags;
|
public HashMap<String, Flag> flags;
|
||||||
/**
|
/**
|
||||||
* Home Position
|
* Home Position
|
||||||
|
* @deprecated Raw access
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
private BlockLoc position;
|
private BlockLoc position;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,6 +110,10 @@ public class PlotSettings {
|
|||||||
this.merged = merged;
|
this.merged = merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<UUID, Integer> getRatings() {
|
||||||
|
return ratings == null ? new HashMap<UUID, Integer>() : ratings;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean setMerged(final int direction, final boolean merged) {
|
public boolean setMerged(final int direction, final boolean merged) {
|
||||||
if (this.merged[direction] != merged) {
|
if (this.merged[direction] != merged) {
|
||||||
this.merged[direction] = merged;
|
this.merged[direction] = merged;
|
||||||
|
@ -524,6 +524,7 @@ public class MainUtil {
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
plot.clearRatings();
|
||||||
if (createSign) {
|
if (createSign) {
|
||||||
plot.removeSign();
|
plot.removeSign();
|
||||||
}
|
}
|
||||||
@ -1010,6 +1011,8 @@ public class MainUtil {
|
|||||||
greaterPlot = tmp;
|
greaterPlot = tmp;
|
||||||
}
|
}
|
||||||
if (!lesserPlot.getMerged(2)) {
|
if (!lesserPlot.getMerged(2)) {
|
||||||
|
lesserPlot.clearRatings();
|
||||||
|
greaterPlot.clearRatings();
|
||||||
lesserPlot.setMerged(2, true);
|
lesserPlot.setMerged(2, true);
|
||||||
greaterPlot.setMerged(0, true);
|
greaterPlot.setMerged(0, true);
|
||||||
mergeData(lesserPlot, greaterPlot);
|
mergeData(lesserPlot, greaterPlot);
|
||||||
@ -1032,6 +1035,8 @@ public class MainUtil {
|
|||||||
greaterPlot = tmp;
|
greaterPlot = tmp;
|
||||||
}
|
}
|
||||||
if (!lesserPlot.getMerged(1)) {
|
if (!lesserPlot.getMerged(1)) {
|
||||||
|
lesserPlot.clearRatings();
|
||||||
|
greaterPlot.clearRatings();
|
||||||
lesserPlot.setMerged(1, true);
|
lesserPlot.setMerged(1, true);
|
||||||
greaterPlot.setMerged(3, true);
|
greaterPlot.setMerged(3, true);
|
||||||
mergeData(lesserPlot, greaterPlot);
|
mergeData(lesserPlot, greaterPlot);
|
||||||
@ -1379,7 +1384,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int[] countEntities(Plot plot) {
|
public static int[] countEntities(Plot plot) {
|
||||||
int[] count = new int[5];
|
int[] count = new int[6];
|
||||||
for (Plot current : getConnectedPlots(plot)) {
|
for (Plot current : getConnectedPlots(plot)) {
|
||||||
int[] result = ChunkManager.manager.countEntities(current);
|
int[] result = ChunkManager.manager.countEntities(current);
|
||||||
count[0] += result[0];
|
count[0] += result[0];
|
||||||
@ -1387,6 +1392,7 @@ public class MainUtil {
|
|||||||
count[2] += result[2];
|
count[2] += result[2];
|
||||||
count[3] += result[3];
|
count[3] += result[3];
|
||||||
count[4] += result[4];
|
count[4] += result[4];
|
||||||
|
count[5] += result[5];
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.projectiles.BlockProjectileSource;
|
import org.bukkit.projectiles.BlockProjectileSource;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import org.spongepowered.api.entity.living.animal.Animal;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
@ -1304,76 +1305,154 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
lastRadius = event.getRadius() + 1;
|
lastRadius = event.getRadius() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkEntity(final Entity entity, final Plot plot) {
|
public boolean checkEntity(Plot plot, String... flags) {
|
||||||
if ((plot != null) && (plot.owner != null)) {
|
int[] mobs = null;
|
||||||
final Flag entityFlag = FlagManager.getPlotFlagRaw(plot, "entity-cap");
|
for (String flag : flags) {
|
||||||
int[] mobs = null;
|
int i;
|
||||||
if (entityFlag != null) {
|
switch (flag) {
|
||||||
final int cap = ((Integer) entityFlag.getValue());
|
case "entity-cap":
|
||||||
if (cap == 0) {
|
i = 0;
|
||||||
return true;
|
break;
|
||||||
}
|
case "mob-cap":
|
||||||
mobs = MainUtil.countEntities(plot);
|
i = 3;
|
||||||
if (mobs[0] >= cap) {
|
break;
|
||||||
return true;
|
case "hostile-cap":
|
||||||
|
i = 2;
|
||||||
|
break;
|
||||||
|
case "animal-cap":
|
||||||
|
i = 1;
|
||||||
|
break;
|
||||||
|
case "vehicle-cap":
|
||||||
|
i = 4;
|
||||||
|
break;
|
||||||
|
case "misc-cap":
|
||||||
|
i = 5;
|
||||||
|
break;
|
||||||
|
default: {
|
||||||
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity instanceof Creature) {
|
final Flag plotFlag = FlagManager.getPlotFlagRaw(plot, flag);
|
||||||
final Flag mobFlag = FlagManager.getPlotFlagRaw(plot, "mob-cap");
|
if (plotFlag == null) {
|
||||||
if (mobFlag != null) {
|
continue;
|
||||||
final int cap = ((Integer) mobFlag.getValue());
|
}
|
||||||
if (cap == 0) {
|
if (mobs == null) {
|
||||||
return true;
|
mobs = MainUtil.countEntities(plot);
|
||||||
}
|
}
|
||||||
if (mobs == null) {
|
if (mobs[i] >= ((Integer) plotFlag.getValue())) {
|
||||||
mobs = MainUtil.countEntities(plot);
|
return true;
|
||||||
}
|
}
|
||||||
if (mobs[3] >= cap) {
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkEntity(final Entity entity, final Plot plot) {
|
||||||
|
if ((plot != null) && (plot.owner != null)) {
|
||||||
|
switch (entity.getType()) {
|
||||||
|
case PLAYER: {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (entity instanceof Animals) {
|
case SMALL_FIREBALL:
|
||||||
final Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap");
|
case FIREBALL:
|
||||||
if (animalFlag != null) {
|
case DROPPED_ITEM:
|
||||||
final int cap = ((Integer) animalFlag.getValue());
|
case EGG:
|
||||||
if (cap == 0) {
|
case THROWN_EXP_BOTTLE:
|
||||||
return true;
|
case SPLASH_POTION:
|
||||||
}
|
case SNOWBALL:
|
||||||
if (mobs == null) {
|
case ENDER_PEARL:
|
||||||
mobs = MainUtil.countEntities(plot);
|
case ARROW: {
|
||||||
}
|
// projectile
|
||||||
if (mobs[1] >= cap) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (entity instanceof Monster) {
|
|
||||||
final Flag monsterFlag = FlagManager.getPlotFlagRaw(plot, "hostile-cap");
|
|
||||||
if (monsterFlag != null) {
|
|
||||||
final int cap = ((Integer) monsterFlag.getValue());
|
|
||||||
if (cap == 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (mobs == null) {
|
|
||||||
mobs = MainUtil.countEntities(plot);
|
|
||||||
}
|
|
||||||
if (mobs[2] >= cap) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (entity instanceof Vehicle) {
|
case PRIMED_TNT:
|
||||||
final Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap");
|
case FALLING_BLOCK: {
|
||||||
if (vehicleFlag != null) {
|
// Block entities
|
||||||
final int cap = ((Integer) vehicleFlag.getValue());
|
}
|
||||||
if (cap == 0) {
|
case ENDER_CRYSTAL:
|
||||||
return true;
|
case COMPLEX_PART:
|
||||||
}
|
case FISHING_HOOK:
|
||||||
if (mobs == null) {
|
case ENDER_SIGNAL:
|
||||||
mobs = MainUtil.countEntities(plot);
|
case EXPERIENCE_ORB:
|
||||||
}
|
case LEASH_HITCH:
|
||||||
if (mobs[4] >= cap) {
|
case FIREWORK:
|
||||||
return true;
|
case WEATHER:
|
||||||
|
case LIGHTNING:
|
||||||
|
case WITHER_SKULL:
|
||||||
|
case UNKNOWN: {
|
||||||
|
// non moving / unremovable
|
||||||
|
return checkEntity(plot, "entity-cap");
|
||||||
|
}
|
||||||
|
case ITEM_FRAME:
|
||||||
|
case PAINTING:
|
||||||
|
case ARMOR_STAND: {
|
||||||
|
return checkEntity(plot, "entity-cap", "misc-cap");
|
||||||
|
// misc
|
||||||
|
}
|
||||||
|
case MINECART:
|
||||||
|
case MINECART_CHEST:
|
||||||
|
case MINECART_COMMAND:
|
||||||
|
case MINECART_FURNACE:
|
||||||
|
case MINECART_HOPPER:
|
||||||
|
case MINECART_MOB_SPAWNER:
|
||||||
|
case MINECART_TNT:
|
||||||
|
case BOAT: {
|
||||||
|
return checkEntity(plot, "entity-cap", "vehicle-cap");
|
||||||
|
}
|
||||||
|
case RABBIT:
|
||||||
|
case SHEEP:
|
||||||
|
case MUSHROOM_COW:
|
||||||
|
case OCELOT:
|
||||||
|
case PIG:
|
||||||
|
case HORSE:
|
||||||
|
case SQUID:
|
||||||
|
case VILLAGER:
|
||||||
|
case IRON_GOLEM:
|
||||||
|
case WOLF:
|
||||||
|
case CHICKEN:
|
||||||
|
case COW:
|
||||||
|
case SNOWMAN:
|
||||||
|
case BAT: {
|
||||||
|
// animal
|
||||||
|
return checkEntity(plot, "entity-cap", "mob-cap", "animal-cap");
|
||||||
|
}
|
||||||
|
case BLAZE:
|
||||||
|
case CAVE_SPIDER:
|
||||||
|
case CREEPER:
|
||||||
|
case ENDERMAN:
|
||||||
|
case ENDERMITE:
|
||||||
|
case ENDER_DRAGON:
|
||||||
|
case GHAST:
|
||||||
|
case GIANT:
|
||||||
|
case GUARDIAN:
|
||||||
|
case MAGMA_CUBE:
|
||||||
|
case PIG_ZOMBIE:
|
||||||
|
case SILVERFISH:
|
||||||
|
case SKELETON:
|
||||||
|
case SLIME:
|
||||||
|
case SPIDER:
|
||||||
|
case WITCH:
|
||||||
|
case WITHER:
|
||||||
|
case ZOMBIE: {
|
||||||
|
// monster
|
||||||
|
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
String[] types;
|
||||||
|
if (entity instanceof LivingEntity) {
|
||||||
|
if (entity instanceof Animal) {
|
||||||
|
types = new String[] { "entity-cap", "mob-cap", "animal-cap" };
|
||||||
|
} else if (entity instanceof Monster) {
|
||||||
|
types = new String[] { "entity-cap", "mob-cap", "hostile-cap" };
|
||||||
|
} else {
|
||||||
|
types = new String[] { "entity-cap", "mob-cap" };
|
||||||
|
}
|
||||||
|
} else if (entity instanceof Vehicle) {
|
||||||
|
types = new String[] { "entity-cap", "vehicle-cap" };
|
||||||
|
} else if (entity instanceof Hanging) {
|
||||||
|
types = new String[] { "entity-cap", "misc-cap" };
|
||||||
|
} else {
|
||||||
|
types = new String[] { "entity-cap" };
|
||||||
}
|
}
|
||||||
|
return checkEntity(plot, types);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ import org.bukkit.entity.Creature;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Vehicle;
|
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -946,7 +945,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] countEntities(final Plot plot) {
|
public int[] countEntities(final Plot plot) {
|
||||||
final int[] count = new int[5];
|
final int[] count = new int[6];
|
||||||
final World world = BukkitUtil.getWorld(plot.world);
|
final World world = BukkitUtil.getWorld(plot.world);
|
||||||
|
|
||||||
final Location bot = MainUtil.getPlotBottomLocAbs(plot.world, plot.id);
|
final Location bot = MainUtil.getPlotBottomLocAbs(plot.world, plot.id);
|
||||||
@ -977,9 +976,6 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
|
|
||||||
if (doWhole) {
|
if (doWhole) {
|
||||||
for (final Entity entity : entities) {
|
for (final Entity entity : entities) {
|
||||||
if (!((entity instanceof Creature) || (entity instanceof Vehicle))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final org.bukkit.Location loc = entity.getLocation();
|
final org.bukkit.Location loc = entity.getLocation();
|
||||||
final Chunk chunk = loc.getChunk();
|
final Chunk chunk = loc.getChunk();
|
||||||
if (chunks.contains(chunk)) {
|
if (chunks.contains(chunk)) {
|
||||||
@ -1001,9 +997,6 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
final int Z = chunk.getX();
|
final int Z = chunk.getX();
|
||||||
final Entity[] ents = chunk.getEntities();
|
final Entity[] ents = chunk.getEntities();
|
||||||
for (final Entity entity : ents) {
|
for (final Entity entity : ents) {
|
||||||
if (!((entity instanceof Creature) || (entity instanceof Vehicle))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ((X == bx) || (X == tx) || (Z == bz) || (Z == tz)) {
|
if ((X == bx) || (X == tx) || (Z == bz) || (Z == tz)) {
|
||||||
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
|
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
|
||||||
if (plot.id.equals(id)) {
|
if (plot.id.equals(id)) {
|
||||||
@ -1020,15 +1013,110 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
|
|
||||||
private void count(final int[] count, final Entity entity) {
|
private void count(final int[] count, final Entity entity) {
|
||||||
count[0]++;
|
count[0]++;
|
||||||
if (entity instanceof Creature) {
|
switch (entity.getType()) {
|
||||||
count[3]++;
|
case PLAYER: {
|
||||||
if (entity instanceof Animals) {
|
// not valid
|
||||||
count[1]++;
|
}
|
||||||
} else {
|
case SMALL_FIREBALL:
|
||||||
count[2]++;
|
case FIREBALL:
|
||||||
|
case DROPPED_ITEM:
|
||||||
|
case EGG:
|
||||||
|
case THROWN_EXP_BOTTLE:
|
||||||
|
case SPLASH_POTION:
|
||||||
|
case SNOWBALL:
|
||||||
|
case ENDER_PEARL:
|
||||||
|
case ARROW: {
|
||||||
|
// projectile
|
||||||
|
}
|
||||||
|
case PRIMED_TNT:
|
||||||
|
case FALLING_BLOCK: {
|
||||||
|
// Block entities
|
||||||
|
}
|
||||||
|
case ENDER_CRYSTAL:
|
||||||
|
case COMPLEX_PART:
|
||||||
|
case FISHING_HOOK:
|
||||||
|
case ENDER_SIGNAL:
|
||||||
|
case EXPERIENCE_ORB:
|
||||||
|
case LEASH_HITCH:
|
||||||
|
case FIREWORK:
|
||||||
|
case WEATHER:
|
||||||
|
case LIGHTNING:
|
||||||
|
case WITHER_SKULL:
|
||||||
|
case UNKNOWN: {
|
||||||
|
// non moving / unremovable
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ITEM_FRAME:
|
||||||
|
case PAINTING:
|
||||||
|
case ARMOR_STAND: {
|
||||||
|
count[5]++;
|
||||||
|
// misc
|
||||||
|
}
|
||||||
|
case MINECART:
|
||||||
|
case MINECART_CHEST:
|
||||||
|
case MINECART_COMMAND:
|
||||||
|
case MINECART_FURNACE:
|
||||||
|
case MINECART_HOPPER:
|
||||||
|
case MINECART_MOB_SPAWNER:
|
||||||
|
case MINECART_TNT:
|
||||||
|
case BOAT: {
|
||||||
|
count[4]++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RABBIT:
|
||||||
|
case SHEEP:
|
||||||
|
case MUSHROOM_COW:
|
||||||
|
case OCELOT:
|
||||||
|
case PIG:
|
||||||
|
case HORSE:
|
||||||
|
case SQUID:
|
||||||
|
case VILLAGER:
|
||||||
|
case IRON_GOLEM:
|
||||||
|
case WOLF:
|
||||||
|
case CHICKEN:
|
||||||
|
case COW:
|
||||||
|
case SNOWMAN:
|
||||||
|
case BAT: {
|
||||||
|
// animal
|
||||||
|
count[3]++;
|
||||||
|
count[1]++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BLAZE:
|
||||||
|
case CAVE_SPIDER:
|
||||||
|
case CREEPER:
|
||||||
|
case ENDERMAN:
|
||||||
|
case ENDERMITE:
|
||||||
|
case ENDER_DRAGON:
|
||||||
|
case GHAST:
|
||||||
|
case GIANT:
|
||||||
|
case GUARDIAN:
|
||||||
|
case MAGMA_CUBE:
|
||||||
|
case PIG_ZOMBIE:
|
||||||
|
case SILVERFISH:
|
||||||
|
case SKELETON:
|
||||||
|
case SLIME:
|
||||||
|
case SPIDER:
|
||||||
|
case WITCH:
|
||||||
|
case WITHER:
|
||||||
|
case ZOMBIE: {
|
||||||
|
// monster
|
||||||
|
count[3]++;
|
||||||
|
count[2]++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
if (entity instanceof Creature) {
|
||||||
|
count[3]++;
|
||||||
|
if (entity instanceof Animals) {
|
||||||
|
count[1]++;
|
||||||
|
} else {
|
||||||
|
count[2]++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
count[4]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
count[4]++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,31 +78,26 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (strings.length > 1) {
|
if (strings.length > 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!command.getLabel().equalsIgnoreCase("plots")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final Set<String> tabOptions = new HashSet<>();
|
final Set<String> tabOptions = new HashSet<>();
|
||||||
final ArrayList<Command<PlotPlayer>> commands = MainCommand.getInstance().getCommands();
|
|
||||||
final String best = new StringComparison(strings[0], commands).getBestMatch();
|
|
||||||
tabOptions.add(best);
|
|
||||||
final String arg = strings[0].toLowerCase();
|
final String arg = strings[0].toLowerCase();
|
||||||
|
ArrayList<String> labels = new ArrayList<>();
|
||||||
for (final Command<PlotPlayer> cmd : MainCommand.getInstance().getCommands()) {
|
for (final Command<PlotPlayer> cmd : MainCommand.getInstance().getCommands()) {
|
||||||
final String label = cmd.getCommand();
|
final String label = cmd.getCommand();
|
||||||
if (!label.equalsIgnoreCase(best)) {
|
HashSet<String> aliases = new HashSet<>(cmd.getAliases());
|
||||||
if (label.startsWith(arg)) {
|
aliases.add(label);
|
||||||
|
for (String alias : aliases) {
|
||||||
|
labels.add(alias);
|
||||||
|
if (alias.startsWith(arg)) {
|
||||||
if (Permissions.hasPermission(player, cmd.getPermission())) {
|
if (Permissions.hasPermission(player, cmd.getPermission())) {
|
||||||
tabOptions.add(cmd.getCommand());
|
tabOptions.add(label);
|
||||||
} else if (cmd.getAliases().size() > 0) {
|
} else {
|
||||||
for (final String alias : cmd.getAliases()) {
|
break;
|
||||||
if (alias.startsWith(arg)) {
|
|
||||||
tabOptions.add(label);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
String best = new StringComparison<>(arg, labels).getBestMatch();
|
||||||
|
tabOptions.add(best);
|
||||||
if (tabOptions.size() > 0) {
|
if (tabOptions.size() > 0) {
|
||||||
return new ArrayList<>(tabOptions);
|
return new ArrayList<>(tabOptions);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class SpongeChunkManager extends ChunkManager {
|
|||||||
final int bz = pos1.getZ();
|
final int bz = pos1.getZ();
|
||||||
final int tx = pos2.getX();
|
final int tx = pos2.getX();
|
||||||
final int tz = pos2.getZ();
|
final int tz = pos2.getZ();
|
||||||
final int[] count = new int[5];
|
final int[] count = new int[6];
|
||||||
world.getEntities(new Predicate<Entity>() {
|
world.getEntities(new Predicate<Entity>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(final Entity entity) {
|
public boolean test(final Entity entity) {
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user