Added check in CommandPreprocessListener to hide a user when they go into spec and put them back into the same visibility after they come out of spec.
parent
fef5ab6b5f
commit
18e36727f2
9
pom.xml
9
pom.xml
|
@ -68,6 +68,11 @@
|
||||||
<artifactId>Essentials</artifactId>
|
<artifactId>Essentials</artifactId>
|
||||||
<version>2.14-SNAPSHOT</version>
|
<version>2.14-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>us.dynmap</groupId>
|
||||||
|
<artifactId>dynmap-api</artifactId>
|
||||||
|
<version>1.9.4</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-lang</groupId>
|
<groupId>commons-lang</groupId>
|
||||||
<artifactId>commons-lang</artifactId>
|
<artifactId>commons-lang</artifactId>
|
||||||
|
@ -90,6 +95,10 @@
|
||||||
<id>etztech-repo</id>
|
<id>etztech-repo</id>
|
||||||
<url>http://repo.etztech.xyz</url>
|
<url>http://repo.etztech.xyz</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>dynmap-repo</id>
|
||||||
|
<url>http://repo.mikeprimm.com/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>ess-repo</id>
|
<id>ess-repo</id>
|
||||||
<url>http://repo.ess3.net/content/groups/essentials</url>
|
<url>http://repo.ess3.net/content/groups/essentials</url>
|
||||||
|
|
|
@ -11,6 +11,7 @@ import xyz.etztech.qol.commands.*;
|
||||||
import xyz.etztech.qol.listeners.*;
|
import xyz.etztech.qol.listeners.*;
|
||||||
import xyz.etztech.qol.other.LinkCommand;
|
import xyz.etztech.qol.other.LinkCommand;
|
||||||
import xyz.etztech.qol.other.TPSRunnable;
|
import xyz.etztech.qol.other.TPSRunnable;
|
||||||
|
import org.dynmap.DynmapAPI;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,6 +21,7 @@ public class QoL extends JavaPlugin {
|
||||||
|
|
||||||
private static QoL instance;
|
private static QoL instance;
|
||||||
private static IEssentials essentials = null;
|
private static IEssentials essentials = null;
|
||||||
|
private static DynmapAPI dynmap = null;
|
||||||
|
|
||||||
public static FileConfiguration config;
|
public static FileConfiguration config;
|
||||||
private Logger log = Logger.getLogger( "Minecraft" );
|
private Logger log = Logger.getLogger( "Minecraft" );
|
||||||
|
@ -43,6 +45,12 @@ public class QoL extends JavaPlugin {
|
||||||
essentials = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
|
essentials = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Dynmap hook
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("dynmap")) {
|
||||||
|
log("Hooked into Essentials for TPS alert.");
|
||||||
|
dynmap = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap");
|
||||||
|
}
|
||||||
|
|
||||||
if( isEnabled() ) {
|
if( isEnabled() ) {
|
||||||
|
|
||||||
// Add listeners
|
// Add listeners
|
||||||
|
@ -240,9 +248,9 @@ public class QoL extends JavaPlugin {
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEssentials getEssentials() {
|
public static IEssentials getEssentials() { return essentials; }
|
||||||
return essentials;
|
|
||||||
}
|
public static DynmapAPI getDynmap() { return dynmap; }
|
||||||
|
|
||||||
|
|
||||||
private void runTask(final String command) {
|
private void runTask(final String command) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import xyz.etztech.core.CoreUtils;
|
||||||
import xyz.etztech.core.web.CoreWeb;
|
import xyz.etztech.core.web.CoreWeb;
|
||||||
import xyz.etztech.qol.QoL;
|
import xyz.etztech.qol.QoL;
|
||||||
import xyz.etztech.qol.other.LinkCommand;
|
import xyz.etztech.qol.other.LinkCommand;
|
||||||
|
import org.dynmap.DynmapAPI;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -20,14 +21,19 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class CommandPreprocessListener implements Listener {
|
public class CommandPreprocessListener implements Listener {
|
||||||
|
|
||||||
|
|
||||||
QoL plugin;
|
QoL plugin;
|
||||||
private Map<UUID, String> confirmTpMap = new HashMap<>();
|
private Map<UUID, String> confirmTpMap = new HashMap<>();
|
||||||
|
private Map<UUID, Boolean> dynmapVisibleStatusMap = new HashMap<>();
|
||||||
|
private DynmapAPI dynmap;
|
||||||
|
|
||||||
public CommandPreprocessListener(QoL plugin) {
|
public CommandPreprocessListener(QoL plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
if (plugin.getDynmap() != null) {
|
||||||
|
this.dynmap = plugin.getDynmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
|
@ -36,9 +42,27 @@ public class CommandPreprocessListener implements Listener {
|
||||||
String base = command.split(" ")[0].substring(1).toLowerCase(); // Strip the slash
|
String base = command.split(" ")[0].substring(1).toLowerCase(); // Strip the slash
|
||||||
Player sender = event.getPlayer();
|
Player sender = event.getPlayer();
|
||||||
|
|
||||||
|
// Spec dynmap hide
|
||||||
|
if (base.equals("spec") && this.dynmap != null) {
|
||||||
|
boolean visibleStatus;
|
||||||
|
if (sender.getGameMode() != GameMode.SPECTATOR){
|
||||||
|
dynmapVisibleStatusMap.put(sender.getUniqueId(), dynmap.getPlayerVisbility(sender.getDisplayName()));
|
||||||
|
visibleStatus = false;
|
||||||
|
}
|
||||||
|
else if (dynmapVisibleStatusMap.containsKey(sender.getUniqueId())){
|
||||||
|
visibleStatus = dynmapVisibleStatusMap.remove(sender.getUniqueId());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
visibleStatus = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
dynmap.setPlayerVisiblity(sender.getDisplayName(), visibleStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spec TP confirmation
|
||||||
if (sender.hasPermission("qol.tpconfirm")) {
|
if (sender.hasPermission("qol.tpconfirm")) {
|
||||||
//check if the command is a tp command
|
//check if the command is a tp command
|
||||||
if (noSlash(base).equals("tp") || noSlash(base).startsWith("tele") || noSlash(command).startsWith("lagg tpchunk")) {
|
if (noSlash(base).equals("tp") || noSlash(base).startsWith("tele") || noSlash(command).toLowerCase().startsWith("lagg tpchunk")) {
|
||||||
//If the user is in the confirm tp map, remove them and let the command run
|
//If the user is in the confirm tp map, remove them and let the command run
|
||||||
if (command.equals(confirmTpMap.get(sender.getUniqueId()))) {
|
if (command.equals(confirmTpMap.get(sender.getUniqueId()))) {
|
||||||
confirmTpMap.remove(sender.getUniqueId());
|
confirmTpMap.remove(sender.getUniqueId());
|
||||||
|
@ -81,6 +105,10 @@ public class CommandPreprocessListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (noSlash(base).equals("spec")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Links
|
// Links
|
||||||
for (LinkCommand linkCommand : QoL.getLinks()) {
|
for (LinkCommand linkCommand : QoL.getLinks()) {
|
||||||
if (base.equalsIgnoreCase(linkCommand.getCommand())) {
|
if (base.equalsIgnoreCase(linkCommand.getCommand())) {
|
||||||
|
|
Loading…
Reference in New Issue