default tab completion + plot chat for merged plots

This commit is contained in:
Jesse Boyd 2016-03-28 22:52:22 +11:00
parent b6bdb02fa2
commit dcd1a50a0c
4 changed files with 30 additions and 5 deletions

View File

@ -542,7 +542,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (area == null || (!area.PLOT_CHAT && !plr.getAttribute("chat"))) { if (area == null || (!area.PLOT_CHAT && !plr.getAttribute("chat"))) {
return; return;
} }
Plot plot = area.getPlotAbs(loc); Plot plot = area.getPlot(loc);
if (plot == null) { if (plot == null) {
return; return;
} }
@ -559,10 +559,13 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
String spy = event.getFormat(); String spy = event.getFormat();
spy = String.format(spy, sender, message); spy = String.format(spy, sender, message);
pp.sendMessage(spy); pp.sendMessage(spy);
} else if (plot.equals(pp.getCurrentPlot())) { } else {
Plot current = pp.getCurrentPlot();
if (current != null && current.getBasePlot(false).equals(plot)) {
recipients.add(((BukkitPlayer) pp).player); recipients.add(((BukkitPlayer) pp).player);
} }
} }
}
String full = format.replaceAll("%plot_id%", id.x + ";" + id.y).replaceAll("%sender%", sender).replaceAll("%msg%", message); String full = format.replaceAll("%plot_id%", id.x + ";" + id.y).replaceAll("%sender%", sender).replaceAll("%msg%", message);
full = ChatColor.translateAlternateColorCodes('&', full); full = ChatColor.translateAlternateColorCodes('&', full);
// format = format.replaceAll("%plot_id%", id.x + ";" + id.y).replaceAll("%sender%", "%s").replaceAll("%msg%", "%s"); // format = format.replaceAll("%plot_id%", id.x + ";" + id.y).replaceAll("%sender%", "%s").replaceAll("%msg%", "%s");

View File

@ -71,6 +71,6 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
for (Object o : objects) { for (Object o : objects) {
result.add(o.toString()); result.add(o.toString());
} }
return result; return result.size() == 0 ? null : result;
} }
} }

View File

@ -394,6 +394,28 @@ public abstract class Command {
return cmd; return cmd;
} }
public Command getCommand(Class clazz) {
for (Command cmd : allCommands) {
if (cmd.getClass() == clazz) {
return cmd;
}
}
return null;
}
public Command getCommandById(String id) {
Command exact = staticCommands.get(id);
if (exact != null) {
return exact;
}
for (Command cmd : allCommands) {
if (cmd.getId().equals(id)) {
return cmd;
}
}
return null;
}
public boolean canExecute(PlotPlayer player, boolean message) { public boolean canExecute(PlotPlayer player, boolean message) {
if (!required.allows(player)) { if (!required.allows(player)) {
if (message) { if (message) {

View File

@ -55,7 +55,7 @@ public class SpongeCommand implements CommandCallable {
for (Object o : objects) { for (Object o : objects) {
result.add(o.toString()); result.add(o.toString());
} }
return result; return result.size() == 0 ? null : result;
} }
@Override @Override