Recommend paper just like FAWE. I want to be like the cool kids.

Oh, and fix an issue with `/plot music`. Still broken. Just not
the same kind of broken.
This commit is contained in:
Sauilitired 2018-12-26 15:29:39 +01:00
parent f1378013c1
commit b05316c000
No known key found for this signature in database
GPG Key ID: C0207FF7EA146678
5 changed files with 30 additions and 11 deletions

View File

@ -158,6 +158,15 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
if (Bukkit.getVersion().contains("git-Spigot")) {
// Uses System.out.println because the logger isn't initialized yet
System.out.println("[P2] ====== USE PAPER ======");
System.out.println("[P2] DOWNLOAD: https://papermc.io/downloads");
System.out.println("[P2] GUIDE: https://www.spigotmc.org/threads/21726/");
System.out.println("[P2] - This is only a recommendation");
System.out.println("[P2] ==============================");
}
new PlotSquared(this, "Bukkit");
if (Settings.Enabled_Components.METRICS) {
this.startMetrics();

View File

@ -24,6 +24,7 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Piston;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.*;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -1516,6 +1517,7 @@ import java.util.regex.Pattern;
PlotInventory inventory = pp.getMeta("inventory");
if (inventory != null && event.getRawSlot() == event.getSlot()) {
if (!inventory.onClick(event.getSlot())) {
event.setResult(Event.Result.DENY);
event.setCancelled(true);
inventory.close();
}

View File

@ -314,8 +314,12 @@ import java.util.zip.ZipInputStream;
if (message == null || message.toString().isEmpty()) {
return;
}
if (PlotSquared.get() == null || PlotSquared.get().getLogger() == null) {
System.out.printf("[P2][Info] %s\n", StringMan.getString(message));
} else {
PlotSquared.get().getLogger().log(StringMan.getString(message));
}
}
/**
* Log a message to the IPlotMain logger.
@ -325,7 +329,11 @@ import java.util.zip.ZipInputStream;
*/
public static void debug(@Nullable Object message) {
if (Settings.DEBUG) {
PlotSquared.log(message);
if (PlotSquared.get() == null || PlotSquared.get().getLogger() == null) {
System.out.printf("[P2][Debug] %s\n", StringMan.getString(message));
} else {
PlotSquared.get().getLogger().log(StringMan.getString(message));
}
}
}

View File

@ -128,20 +128,20 @@ public class PlotListener {
Optional<Integer> musicFlag = plot.getFlag(Flags.MUSIC);
if (musicFlag.isPresent()) {
Integer id = musicFlag.get();
if ((id >= 2256 && id <= 2267) || (id == 0)) {
Number id = musicFlag.get();
if ((id.intValue() >= 2256 && id.intValue() <= 2267) || (id.intValue() == 0)) {
Location loc = player.getLocation();
Location lastLoc = player.getMeta("music");
if (lastLoc != null) {
player.playMusic(lastLoc, 0);
if (id == 0) {
if (id.intValue() == 0) {
player.deleteMeta("music");
}
}
if (id != 0) {
if (id.intValue() != 0) {
try {
player.setMeta("music", loc);
player.playMusic(loc, id);
player.playMusic(loc, id.intValue());
} catch (Exception ignored) {
}
}

View File

@ -45,19 +45,19 @@ public class StringMan {
return (String) obj;
}
if (obj.getClass().isArray()) {
String result = "";
StringBuilder result = new StringBuilder();
String prefix = "";
for (int i = 0; i < Array.getLength(obj); i++) {
result += prefix + getString(Array.get(obj, i));
result.append(prefix).append(getString(Array.get(obj, i)));
prefix = ",";
}
return "( " + result + " )";
} else if (obj instanceof Collection<?>) {
String result = "";
StringBuilder result = new StringBuilder();
String prefix = "";
for (Object element : (Collection<?>) obj) {
result += prefix + getString(element);
result.append(prefix).append(getString(element));
prefix = ",";
}
return "[ " + result + " ]";