mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-27 19:24:43 +02:00
* Added Fly Flag
* Moved stuff away from the actual listener class * Ability to delete plot on player ban
This commit is contained in:
@ -61,7 +61,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
|
||||
@EventHandler
|
||||
public void onChangeWorld(PlayerChangedWorldEvent event) {
|
||||
if (isPlotWorld(event.getFrom()) && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) {
|
||||
/*if (isPlotWorld(event.getFrom()) && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) {
|
||||
event.getPlayer().setResourcePack("");
|
||||
}
|
||||
else {
|
||||
@ -88,46 +88,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
return;
|
||||
}
|
||||
plotEntry(player, plot);
|
||||
}
|
||||
else
|
||||
if (leftPlot(event.getFrom(), event.getTo())) {
|
||||
} else if (leftPlot(event.getFrom(), event.getTo())) {
|
||||
Plot plot = getCurrentPlot(event.getFrom());
|
||||
plotExit(player, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// Gotta catch 'em all.
|
||||
}
|
||||
public static void PlayerMove(PlayerMoveEvent event) {
|
||||
try {
|
||||
Player player = event.getPlayer();
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
if ((from.getBlockX() != to.getBlockX()) || (from.getBlockZ() != to.getBlockZ())) {
|
||||
if (!isPlotWorld(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
if (enteredPlot(from, to)) {
|
||||
Plot plot = getCurrentPlot(event.getTo());
|
||||
boolean admin = player.hasPermission("plots.admin");
|
||||
if (plot.deny_entry(player) && !admin) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
plotEntry(player, plot);
|
||||
}
|
||||
else
|
||||
if (leftPlot(event.getFrom(), event.getTo())) {
|
||||
Plot plot = getCurrentPlot(event.getFrom());
|
||||
plotExit(player, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Gotta catch 'em all.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler(
|
||||
priority = EventPriority.HIGHEST)
|
||||
|
@ -16,37 +16,37 @@ import java.util.UUID;
|
||||
*/
|
||||
public class PlotListener {
|
||||
|
||||
public void textures(Player p) {
|
||||
public static void textures(Player p) {
|
||||
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld())) {
|
||||
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInPlot(Player player) {
|
||||
public static boolean isInPlot(Player player) {
|
||||
return PlayerFunctions.isInPlot(player);
|
||||
}
|
||||
|
||||
public Plot getPlot(Player player) {
|
||||
public static Plot getPlot(Player player) {
|
||||
return PlayerFunctions.getCurrentPlot(player);
|
||||
}
|
||||
|
||||
public boolean isPlotWorld(World world) {
|
||||
public static boolean isPlotWorld(World world) {
|
||||
return PlotMain.isPlotWorld(world);
|
||||
}
|
||||
|
||||
public PlotWorld getPlotWorld(World world) {
|
||||
public static PlotWorld getPlotWorld(World world) {
|
||||
return PlotMain.getWorldSettings(world);
|
||||
}
|
||||
|
||||
public String getName(UUID uuid) {
|
||||
public static String getName(UUID uuid) {
|
||||
return UUIDHandler.getName(uuid);
|
||||
}
|
||||
|
||||
public UUID getUUID(String name) {
|
||||
public static UUID getUUID(String name) {
|
||||
return UUIDHandler.getUUID(name);
|
||||
}
|
||||
|
||||
public boolean enteredPlot(Location l1, Location l2) {
|
||||
public static boolean enteredPlot(Location l1, Location l2) {
|
||||
PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ()));
|
||||
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ()));
|
||||
if (p2 == null) {
|
||||
@ -61,7 +61,7 @@ public class PlotListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean leftPlot(Location l1, Location l2) {
|
||||
public static boolean leftPlot(Location l1, Location l2) {
|
||||
PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ()));
|
||||
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ()));
|
||||
if (p1 == null) {
|
||||
@ -76,7 +76,7 @@ public class PlotListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isPlotWorld(Location l) {
|
||||
public static boolean isPlotWorld(Location l) {
|
||||
return PlotMain.isPlotWorld(l.getWorld());
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public class PlotListener {
|
||||
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld().getName());
|
||||
}
|
||||
|
||||
private WeatherType getWeatherType(String str) {
|
||||
private static WeatherType getWeatherType(String str) {
|
||||
str = str.toLowerCase();
|
||||
if(str.equals("rain")) {
|
||||
return WeatherType.DOWNFALL;
|
||||
@ -105,19 +105,20 @@ public class PlotListener {
|
||||
}
|
||||
}
|
||||
|
||||
private GameMode getGameMode(String str) {
|
||||
if (str.equals("creative")) {
|
||||
return GameMode.CREATIVE;
|
||||
} else if (str.equals("survival")) {
|
||||
return GameMode.SURVIVAL;
|
||||
} else if (str.equals("adventure")) {
|
||||
return GameMode.ADVENTURE;
|
||||
} else {
|
||||
return Bukkit.getDefaultGameMode();
|
||||
private static GameMode getGameMode(String str) {
|
||||
switch (str) {
|
||||
case "creative":
|
||||
return GameMode.CREATIVE;
|
||||
case "survival":
|
||||
return GameMode.SURVIVAL;
|
||||
case "adventure":
|
||||
return GameMode.ADVENTURE;
|
||||
default:
|
||||
return Bukkit.getDefaultGameMode();
|
||||
}
|
||||
}
|
||||
|
||||
public void plotEntry(Player player, Plot plot) {
|
||||
public static void plotEntry(Player player, Plot plot) {
|
||||
if (plot.hasOwner()) {
|
||||
if(plot.settings.getFlag("gamemode") != null) {
|
||||
player.setGameMode(getGameMode(plot.settings.getFlag("gamemode").getValue()));
|
||||
@ -155,7 +156,7 @@ public class PlotListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void plotExit(Player player, Plot plot) {
|
||||
public static void plotExit(Player player, Plot plot) {
|
||||
{
|
||||
PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
||||
Bukkit.getPluginManager().callEvent(callEvent);
|
||||
@ -166,7 +167,7 @@ public class PlotListener {
|
||||
PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage());
|
||||
}
|
||||
|
||||
public boolean getFlagValue(String value) {
|
||||
public static boolean getFlagValue(String value) {
|
||||
return Arrays.asList("true", "on", "enabled", "yes").contains(value.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user