Fix plot entry/leave for sponge.

This commit is contained in:
boy0001 2015-09-06 11:53:56 +10:00
parent ea146dcf91
commit 2b3b947143
20 changed files with 102 additions and 95 deletions

View file

@ -146,11 +146,13 @@
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
</dependency>
<!--
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>2.1-SNAPSHOT</version>
</dependency>
-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>

View file

@ -171,10 +171,6 @@ public class PlotPlusListener extends PlotListener implements Listener {
public void onPlotEnter(final PlayerEnterPlotEvent event) {
Player player = event.getPlayer();
final Plot plot = event.getPlot();
Flag greeting = FlagManager.getPlotFlag(plot, "greeting");
if (greeting != null) {
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + greeting.getValueString()));
}
Flag feed = FlagManager.getPlotFlag(plot, "feed");
if (feed != null) {
Integer[] value = (Integer[]) feed.getValue();
@ -185,27 +181,6 @@ public class PlotPlusListener extends PlotListener implements Listener {
Integer[] value = (Integer[]) heal.getValue();
healRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
}
if (FlagManager.isBooleanFlag(plot, "notify-enter", false)) {
final Player trespasser = event.getPlayer();
final PlotPlayer pt = BukkitUtil.getPlayer(trespasser);
if (Permissions.hasPermission(pt, "plots.flag.notify-enter.bypass")) {
return;
}
if (plot.hasOwner()) {
for (UUID owner : PlotHandler.getOwners(plot)) {
final PlotPlayer pp = UUIDHandler.getPlayer(owner);
if (pp == null) {
return;
}
if (pp.getUUID().equals(pt.getUUID())) {
return;
}
if (pp.isOnline()) {
MainUtil.sendMessage(pp, C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString()));
}
}
}
}
}
@EventHandler
@ -223,33 +198,10 @@ public class PlotPlusListener extends PlotListener implements Listener {
if (!plot.hasOwner()) {
return;
}
Flag farewell = FlagManager.getPlotFlag(plot, "farewell");
if (farewell != null) {
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + farewell.getValueString()));
}
final PlotPlayer pl = BukkitUtil.getPlayer(leaver);
String name = leaver.getName();
feedRunnable.remove(name);
healRunnable.remove(name);
if (FlagManager.isBooleanFlag(plot, "notify-leave", false)) {
if (Permissions.hasPermission(pl, "plots.flag.notify-leave.bypass")) {
return;
}
if (plot.hasOwner()) {
for (UUID owner : PlotHandler.getOwners(plot)) {
final PlotPlayer pp = UUIDHandler.getPlayer(owner);
if (pp == null) {
return;
}
if (pp.getUUID().equals(pl.getUUID())) {
return;
}
if (pp.isOnline()) {
MainUtil.sendMessage(pp, C.NOTIFY_LEAVE.s().replace("%player", leaver.getName()).replace("%plot", plot.getId().toString()));
}
}
}
}
}
public static class Interval {

View file

@ -23,6 +23,10 @@ package com.plotsquared.listener;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
@ -31,6 +35,7 @@ import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotHandler;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.AbstractTitle;
@ -42,6 +47,8 @@ import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.BukkitUtil;
/**
* @author Citymonstret
@ -73,11 +80,25 @@ public class PlotListener {
Flag greetingFlag = flags.get("greeting");
if (greetingFlag != null) {
greeting = (String) greetingFlag.getValue();
pp.sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + greeting));
}
else {
greeting = "";
}
if (greeting != null) {
}
Flag enter = flags.get("notify-enter");
if (enter != null && ((Boolean) enter.getValue())) {
if (!Permissions.hasPermission(pp, "plots.flag.notify-enter.bypass")) {
for (UUID uuid : PlotHandler.getOwners(plot)) {
final PlotPlayer owner = UUIDHandler.getPlayer(uuid);
if (owner != null && !owner.getUUID().equals(pp.getUUID())) {
MainUtil.sendMessage(pp, C.NOTIFY_ENTER.s().replace("%player", pp.getName()).replace("%plot", plot.getId().toString()));
}
}
}
}
final Flag gamemodeFlag = flags.get("gamemode");
if (gamemodeFlag != null) {
if (pp.getGamemode() != gamemodeFlag.getValue()) {
@ -188,6 +209,21 @@ public class PlotListener {
}
}
}
Flag farewell = FlagManager.getPlotFlag(plot, "farewell");
if (farewell != null) {
pp.sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + farewell.getValueString()));
}
Flag leave = FlagManager.getPlotFlag(plot, "notify-leave");
if (leave != null && ((Boolean) leave.getValue())) {
if (!Permissions.hasPermission(pp, "plots.flag.notify-enter.bypass")) {
for (UUID uuid : PlotHandler.getOwners(plot)) {
final PlotPlayer owner = UUIDHandler.getPlayer(uuid);
if (owner != null && !owner.getUUID().equals(pp.getUUID())) {
MainUtil.sendMessage(pp, C.NOTIFY_LEAVE.s().replace("%player", pp.getName()).replace("%plot", plot.getId().toString()));
}
}
}
}
if (FlagManager.getPlotFlag(plot, "fly") != null) {
PlotGamemode gamemode = pp.getGamemode();
if (gamemode == PlotGamemode.SURVIVAL || gamemode == PlotGamemode.ADVENTURE) {

View file

@ -20,8 +20,10 @@ import org.spongepowered.api.Server;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.entity.living.player.PlayerChatEvent;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.event.entity.player.PlayerChatEvent;
import org.spongepowered.api.event.state.PreInitializationEvent;
import org.spongepowered.api.event.state.ServerAboutToStartEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.service.profile.GameProfileResolver;

View file

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.object.Plot;

View file

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import com.intellectualcrafters.plot.object.Plot;

View file

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.event.AbstractEvent;
public abstract class PlayerEvent extends AbstractEvent {

View file

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import com.intellectualcrafters.plot.object.Plot;

View file

@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.UUID;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import com.intellectualcrafters.plot.object.Plot;

View file

@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.UUID;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import com.intellectualcrafters.plot.object.Plot;

View file

@ -2,7 +2,7 @@ package com.plotsquared.sponge.events;
import java.util.UUID;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import com.intellectualcrafters.plot.object.Plot;

View file

@ -1,6 +1,6 @@
package com.plotsquared.sponge.events;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.event.Cancellable;
import com.intellectualcrafters.plot.object.Location;

View file

@ -12,13 +12,28 @@ import org.spongepowered.api.entity.living.Ambient;
import org.spongepowered.api.entity.living.Living;
import org.spongepowered.api.entity.living.animal.Animal;
import org.spongepowered.api.entity.living.monster.Monster;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.entity.vehicle.Boat;
import org.spongepowered.api.entity.vehicle.minecart.Minecart;
import org.spongepowered.api.event.entity.living.player.PlayerChatEvent;
import org.spongepowered.api.event.entity.living.player.PlayerConnectionEvent;
import org.spongepowered.api.event.entity.living.player.PlayerJoinEvent;
import org.spongepowered.api.event.entity.living.player.PlayerQuitEvent;
import org.spongepowered.api.event.block.BlockMoveEvent;
import org.spongepowered.api.event.block.BlockRedstoneUpdateEvent;
import org.spongepowered.api.event.block.FloraGrowEvent;
import org.spongepowered.api.event.block.FluidSpreadEvent;
import org.spongepowered.api.event.entity.EntityChangeBlockEvent;
import org.spongepowered.api.event.entity.EntitySpawnEvent;
import org.spongepowered.api.event.entity.EntityTeleportEvent;
import org.spongepowered.api.event.entity.player.PlayerBreakBlockEvent;
import org.spongepowered.api.event.entity.player.PlayerChangeWorldEvent;
import org.spongepowered.api.event.entity.player.PlayerChatEvent;
import org.spongepowered.api.event.entity.player.PlayerInteractBlockEvent;
import org.spongepowered.api.event.entity.player.PlayerJoinEvent;
import org.spongepowered.api.event.entity.player.PlayerMoveEvent;
import org.spongepowered.api.event.entity.player.PlayerPlaceBlockEvent;
import org.spongepowered.api.event.entity.player.PlayerQuitEvent;
import org.spongepowered.api.event.message.CommandEvent;
import org.spongepowered.api.event.network.PlayerConnectionEvent;
import org.spongepowered.api.event.world.ChunkPreGenerateEvent;
import org.spongepowered.api.event.world.WorldOnExplosionEvent;
import org.spongepowered.api.network.PlayerConnection;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.Texts;
@ -711,10 +726,10 @@ public class MainListener {
if (!PlotListener.plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setTo(from);
event.setNewLocation(from);
}
else {
event.setTo(world.getSpawnLocation());
event.setNewLocation(world.getSpawnLocation());
}
return;
}
@ -727,10 +742,10 @@ public class MainListener {
if (!PlotListener.plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setTo(from);
event.setNewLocation(from);
}
else {
event.setTo(world.getSpawnLocation());
event.setNewLocation(world.getSpawnLocation());
}
return;
}
@ -740,13 +755,13 @@ public class MainListener {
if (x2 > border) {
Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(border - 4, pos.getY(), pos.getZ()));
event.setTo(to);
event.setNewLocation(to);
MainUtil.sendMessage(pp, C.BORDER);
}
else if (x2 < -border) {
Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(-border + 4, pos.getY(), pos.getZ()));
event.setTo(to);
event.setNewLocation(to);
MainUtil.sendMessage(pp, C.BORDER);
}
}
@ -778,10 +793,10 @@ public class MainListener {
if (!PlotListener.plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setTo(from);
event.setNewLocation(from);
}
else {
event.setTo(world.getSpawnLocation());
event.setNewLocation(world.getSpawnLocation());
}
return;
}
@ -794,10 +809,10 @@ public class MainListener {
if (!PlotListener.plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setTo(from);
event.setNewLocation(from);
}
else {
event.setTo(world.getSpawnLocation());
event.setNewLocation(world.getSpawnLocation());
}
return;
}
@ -807,13 +822,13 @@ public class MainListener {
if (z2 > border) {
Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(pos.getX(), pos.getY(), border - 4));
event.setTo(to);
event.setNewLocation(to);
MainUtil.sendMessage(pp, C.BORDER);
}
else if (z2 < -border) {
Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(pos.getX(), pos.getY(), -border + 4));
event.setTo(to);
event.setNewLocation(to);
MainUtil.sendMessage(pp, C.BORDER);
}
}
@ -852,10 +867,10 @@ public class MainListener {
if (!PlotListener.plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setTo(from);
event.setNewLocation(from);
}
else {
event.setTo(world.getSpawnLocation());
event.setNewLocation(world.getSpawnLocation());
}
return;
}
@ -868,10 +883,10 @@ public class MainListener {
if (!PlotListener.plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setTo(from);
event.setNewLocation(from);
}
else {
event.setTo(world.getSpawnLocation());
event.setNewLocation(world.getSpawnLocation());
}
return;
}
@ -881,13 +896,13 @@ public class MainListener {
if (x2 > border) {
Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(border - 4, pos.getY(), pos.getZ()));
event.setTo(to);
event.setNewLocation(to);
MainUtil.sendMessage(pp, C.BORDER);
}
else if (x2 < -border) {
Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(-border + 4, pos.getY(), pos.getZ()));
event.setTo(to);
event.setNewLocation(to);
MainUtil.sendMessage(pp, C.BORDER);
}
}
@ -919,10 +934,10 @@ public class MainListener {
if (!PlotListener.plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setTo(from);
event.setNewLocation(from);
}
else {
event.setTo(player.getWorld().getSpawnLocation());
event.setNewLocation(player.getWorld().getSpawnLocation());
}
return;
}
@ -935,10 +950,10 @@ public class MainListener {
if (!PlotListener.plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setTo(from);
event.setNewLocation(from);
}
else {
event.setTo(player.getWorld().getSpawnLocation());
event.setNewLocation(player.getWorld().getSpawnLocation());
}
return;
}
@ -948,13 +963,13 @@ public class MainListener {
if (z2 > border) {
Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(pos.getX(), pos.getY(), border - 4));
event.setTo(to);
event.setNewLocation(to);
MainUtil.sendMessage(pp, C.BORDER);
}
else if (z2 < -border) {
Vector3d pos = to.getPosition();
to = to.setPosition(new Vector3d(pos.getX(), pos.getY(), -border + 4));
event.setTo(to);
event.setNewLocation(to);
MainUtil.sendMessage(pp, C.BORDER);
}
}

View file

@ -7,9 +7,9 @@ import java.util.UUID;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.manipulator.mutable.TargetedLocationData;
import org.spongepowered.api.data.value.mutable.Value;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.living.player.gamemode.GameMode;
import org.spongepowered.api.entity.living.player.gamemode.GameModes;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.entity.player.gamemode.GameMode;
import org.spongepowered.api.entity.player.gamemode.GameModes;
import org.spongepowered.api.text.TextBuilder;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.text.action.HoverAction;

View file

@ -5,7 +5,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.util.command.CommandCallable;

View file

@ -3,7 +3,7 @@ package com.plotsquared.sponge.util;
import java.util.ArrayList;
import java.util.Locale;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.Carrier;

View file

@ -1,7 +1,7 @@
package com.plotsquared.sponge.util;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.extent.Extent;

View file

@ -3,7 +3,7 @@ package com.plotsquared.sponge.uuid;
import java.util.UUID;
import org.spongepowered.api.GameProfile;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.player.Player;
import com.google.common.base.Charsets;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;

Binary file not shown.

Binary file not shown.