Fixed an issue with spam re-triggering on portal events

This commit is contained in:
Sekwah 2020-11-28 17:07:24 +00:00
parent 9a2ff28ab9
commit 9279be58aa
No known key found for this signature in database
GPG Key ID: C3BE2E6C861A461A
7 changed files with 41 additions and 33 deletions

View File

@ -6,6 +6,8 @@ public class ConfigHelper {
public static String CONFIG_VERSION = "ConfigVersion";
public static String COMMAND_LOGS = "CommandLogs";
public static String DISABLE_GATEWAY_BEAM = "DisableGatewayBeam";
private FileConfiguration config;
@ -20,10 +22,14 @@ public class ConfigHelper {
public void update() {
String configVersion = config.getString("ConfigVersion");
// Added in 0.5.4
if(configVersion == null || configVersion.equals("0.5.3")) {
if(configVersion == null || configVersion.equals("true") || configVersion.equals("0.5.3")) {
config.set(ConfigHelper.CONFIG_VERSION, "0.5.4");
config.set(ConfigHelper.CONFIG_VERSION, true);
config.set(ConfigHelper.DISABLE_GATEWAY_BEAM, true);
update();
} else if(configVersion.equals("0.5.4")) {
config.set(ConfigHelper.CONFIG_VERSION, "0.5.11");
config.set(ConfigHelper.COMMAND_LOGS, true);
}
}
}

View File

@ -23,7 +23,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
@ -126,13 +125,11 @@ public class Listeners implements Listener {
public void checkTriggerLocations(Player player, boolean useDelayed, Location... locations) {
for (AdvancedPortal portal : Portal.portals) {
boolean removeInPortal = true;
boolean delayed = portal.isDelayed();
for (Location loc : locations) {
if (delayed == useDelayed) {
for (Location loc : locations) {
if (delayed ? Portal.locationInPortal(portal, loc, 1)
: Portal.locationInPortalTrigger(portal, loc)) {
removeInPortal = false;
if (portal.getTriggers().contains(Material.NETHER_PORTAL)) {
if (player.getGameMode().equals(GameMode.CREATIVE)) {
player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true));
@ -156,8 +153,6 @@ public class Listeners implements Listener {
return;
}
}
}
if(removeInPortal) {
portal.inPortal.remove(player.getUniqueId());
}
}
@ -236,7 +231,9 @@ public class Listeners implements Listener {
player.removeMetadata("lavaWarped", plugin);
player.setFireTicks(0);
}
};
}
;
class RemoveWarpData implements Runnable {

View File

@ -43,9 +43,8 @@ public class PortalPlacer implements Listener {
if(name == null) return;
if (name.equals("\u00A75Portal Block Placer")){
event.getBlockPlaced().setType(Material.NETHER_PORTAL);
}
else if (name.equals("\u00A78End Portal Block Placer")){
event.getBlock().setType(Material.NETHER_PORTAL);
} else if (name.equals("\u00A78End Portal Block Placer")){
event.getBlockPlaced().setType(Material.END_PORTAL);
}
else if (name.equals("\u00A78Gateway Block Placer")){

View File

@ -6,6 +6,7 @@ import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.bukkit.PluginMessages;
import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg;
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
import com.sekwah.advancedportals.bukkit.config.ConfigHelper;
import com.sekwah.advancedportals.bukkit.destinations.Destination;
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
import com.sekwah.advancedportals.bungee.BungeeMessages;
@ -37,6 +38,7 @@ public class Portal {
private static int portalProtectionRadius;
private static boolean blockSpectatorMode;
private static int joinCooldownDelay;
private static boolean commandLog;
private static Random random = new Random();
public Portal(AdvancedPortalsPlugin plugin) {
@ -53,6 +55,8 @@ public class Portal {
this.joinCooldownDelay = config.getConfig().getInt("PortalCooldown", 5);
this.commandLog = config.getConfig().getBoolean(ConfigHelper.COMMAND_LOGS, true);
Portal.plugin = plugin;
Portal.loadPortals();
}
@ -550,10 +554,9 @@ public class Portal {
do {
// (?i) makes the search case insensitive
command = command.replaceAll("@player", player.getName());
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
if(commandLog) plugin.getLogger().log(Level.INFO, "Portal command: " + command);
if (command.startsWith("#") && plugin.getSettings().enabledCommandLevel("c")) {
command = command.substring(1);
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
try {
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
} catch (Exception e) {

View File

@ -1,4 +1,4 @@
main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.5.10
version: 0.5.11
author: sekwah41

View File

@ -3,7 +3,7 @@
# To set this file back to its default state just delete it and reload the server or restart it!
# Will update whenever there is a config update from an older version so may not be the latest plugin version
ConfigVersion: 0.5.4
ConfigVersion: 0.5.10
# Set to true if you want the normal axes to work normally but the ones gived with /portals selector or wand will still work though
# It can be usefull if people with permission want to use an iron axe on a survival server
@ -85,3 +85,6 @@ DisableGatewayBeam: true
# b enable bungee command portals
#
CommandLevels: opcb
# Should the commands being triggered log in the console? (If you have an active server it may cause a bit of spam)
CommandLogs: true

View File

@ -1,6 +1,6 @@
main: com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.5.10
version: 0.5.11
author: sekwah41
description: An advanced portals plugin for bukkit.
api-version: 1.13