mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-25 20:15:58 +01:00
Added extra checks to in portal as well as fix spam trigger on commands
This commit is contained in:
parent
d104da907f
commit
6dd23ddeee
@ -564,7 +564,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
StringBuilder portalCommand = new StringBuilder(args[2]);
|
StringBuilder portalCommand = new StringBuilder(args[2]);
|
||||||
for (int i = 3; i < args.length; i++) {
|
for (int i = 3; i < args.length; i++) {
|
||||||
portalCommand.append(args[i]);
|
portalCommand.append(" ").append(args[i]);
|
||||||
}
|
}
|
||||||
if (Portal.addCommand(portalName, portalCommand.toString())) {
|
if (Portal.addCommand(portalName, portalCommand.toString())) {
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
|
@ -4,6 +4,8 @@ import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
|||||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
||||||
|
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||||
|
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -13,6 +15,7 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Destination {
|
public class Destination {
|
||||||
@ -155,6 +158,16 @@ public class Destination {
|
|||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a."));
|
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Location newLoc = player.getLocation();
|
||||||
|
Location newEyeLoc = player.getEyeLocation();
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
for (AdvancedPortal portal : Portal.portals) {
|
||||||
|
if (!portal.inPortal.contains(uuid) && !portal.isDelayed()
|
||||||
|
&& (Portal.locationInPortalTrigger(portal, newLoc) || Portal.locationInPortalTrigger(portal, newEyeLoc))) {
|
||||||
|
portal.inPortal.add(uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c The destination you are trying to warp to seems to be linked to a world that doesn't exist!");
|
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c The destination you are trying to warp to seems to be linked to a world that doesn't exist!");
|
||||||
|
@ -23,7 +23,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Listeners implements Listener {
|
public class Listeners implements Listener {
|
||||||
|
|
||||||
@ -93,11 +95,19 @@ public class Listeners implements Listener {
|
|||||||
|
|
||||||
Portal.joinCooldown.put(player.getName(), System.currentTimeMillis());
|
Portal.joinCooldown.put(player.getName(), System.currentTimeMillis());
|
||||||
|
|
||||||
String uuid = player.getUniqueId().toString();
|
Location loc = player.getLocation();
|
||||||
|
Location eyeLoc = player.getEyeLocation();
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
for (AdvancedPortal portal : Portal.portals) {
|
||||||
|
if (!portal.inPortal.contains(uuid)
|
||||||
|
&& (Portal.locationInPortalTrigger(portal, loc) || Portal.locationInPortalTrigger(portal, eyeLoc))) {
|
||||||
|
portal.inPortal.add(uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (plugin.PlayerDestiMap.containsKey(uuid)) {
|
if (plugin.PlayerDestiMap.containsKey(uuid.toString())) {
|
||||||
Destination.warp(player, plugin.PlayerDestiMap.get(uuid), false, true);
|
Destination.warp(player, plugin.PlayerDestiMap.get(uuid.toString()), false, true);
|
||||||
plugin.PlayerDestiMap.remove(uuid);
|
plugin.PlayerDestiMap.remove(uuid.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,20 +120,19 @@ public class Listeners implements Listener {
|
|||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
Location loc = event.getTo();
|
checkTriggerLocations(player, false, event.getTo(), player.getEyeLocation());
|
||||||
Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ());
|
|
||||||
|
|
||||||
checkTriggerLocations(player, false, loc, eyeLoc);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkTriggerLocations(Player player, boolean useDelayed, Location... locations) {
|
public void checkTriggerLocations(Player player, boolean useDelayed, Location... locations) {
|
||||||
for (AdvancedPortal portal : Portal.portals) {
|
for (AdvancedPortal portal : Portal.portals) {
|
||||||
boolean delayed = portal.hasArg("delayed") && portal.getArg("delayed").equalsIgnoreCase("true");
|
boolean removeInPortal = true;
|
||||||
|
boolean delayed = portal.isDelayed();
|
||||||
for (Location loc : locations) {
|
for (Location loc : locations) {
|
||||||
if (delayed == useDelayed) {
|
if (delayed == useDelayed) {
|
||||||
if (delayed ? Portal.locationInPortal(portal, loc, 1)
|
if (delayed ? Portal.locationInPortal(portal, loc, 1)
|
||||||
: Portal.locationInPortalTrigger(portal, loc)) {
|
: Portal.locationInPortalTrigger(portal, loc)) {
|
||||||
|
removeInPortal = false;
|
||||||
if (portal.getTriggers().contains(Material.NETHER_PORTAL)) {
|
if (portal.getTriggers().contains(Material.NETHER_PORTAL)) {
|
||||||
if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||||
player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true));
|
player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true));
|
||||||
@ -145,10 +154,12 @@ public class Listeners implements Listener {
|
|||||||
if (!delayed)
|
if (!delayed)
|
||||||
portal.inPortal.add(player.getUniqueId());
|
portal.inPortal.add(player.getUniqueId());
|
||||||
return;
|
return;
|
||||||
} else if (!delayed)
|
}
|
||||||
portal.inPortal.remove(player.getUniqueId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(removeInPortal) {
|
||||||
|
portal.inPortal.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ public class PortalPlacer implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
Block newBlock = block.getWorld().getBlockAt(block.getLocation());
|
||||||
Material material = block.getType();
|
Material material = block.getType();
|
||||||
if (material == Material.NETHER_PORTAL && Portal.inPortalRegion(block.getLocation(), Portal.getPortalProtectionRadius()))
|
if (material == Material.NETHER_PORTAL && Portal.inPortalRegion(block.getLocation(), Portal.getPortalProtectionRadius()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -112,4 +112,8 @@ public class AdvancedPortal {
|
|||||||
public void setBungee(String bungee) {
|
public void setBungee(String bungee) {
|
||||||
this.bungee = bungee;
|
this.bungee = bungee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDelayed() {
|
||||||
|
return this.hasArg("delayed") && this.getArg("delayed").equalsIgnoreCase("true");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,12 +417,19 @@ public class Portal {
|
|||||||
|
|
||||||
String permission = portal.getArg("permission");
|
String permission = portal.getArg("permission");
|
||||||
|
|
||||||
|
boolean noMessage = permission != null && permission.startsWith("nomsg.");
|
||||||
|
if(noMessage) {
|
||||||
|
permission.substring(6);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(permission == null || player.hasPermission(permission) || player.isOp())) {
|
if (!(permission == null || player.hasPermission(permission) || player.isOp())) {
|
||||||
player.sendMessage(
|
if(!noMessage) {
|
||||||
PluginMessages.customPrefixFail + "\u00A7c You do not have permission to use this portal!");
|
player.sendMessage(
|
||||||
failSound(player, portal);
|
PluginMessages.customPrefixFail + "\u00A7c You do not have permission to use this portal!");
|
||||||
if(doKnockback)
|
failSound(player, portal);
|
||||||
throwPlayerBack(player);
|
if(doKnockback)
|
||||||
|
throwPlayerBack(player);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ public class AdvancedPortalsPlugin extends Plugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getProxy().registerChannel(channelName);
|
getProxy().registerChannel(channelName);
|
||||||
|
|
||||||
|
if(channelName != null)
|
||||||
|
|
||||||
getProxy().getPluginManager().registerListener(this, new PluginMessageReceiver(this));
|
getProxy().getPluginManager().registerListener(this, new PluginMessageReceiver(this));
|
||||||
getProxy().getPluginManager().registerListener(this, new EventListener(this));
|
getProxy().getPluginManager().registerListener(this, new EventListener(this));
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin
|
main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin
|
||||||
name: AdvancedPortals
|
name: AdvancedPortals
|
||||||
version: 0.5.9
|
version: 0.5.10
|
||||||
author: sekwah41
|
author: sekwah41
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
main: com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin
|
main: com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin
|
||||||
name: AdvancedPortals
|
name: AdvancedPortals
|
||||||
version: 0.5.9
|
version: 0.5.10
|
||||||
author: sekwah41
|
author: sekwah41
|
||||||
description: An advanced portals plugin for bukkit.
|
description: An advanced portals plugin for bukkit.
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
Loading…
Reference in New Issue
Block a user