Merge branch 'master' of git.etztech.xyz:Etzelia/QoL

master
Etzelia 2018-09-23 17:46:28 -05:00
commit 179b86f2b4
3 changed files with 42 additions and 6 deletions

View File

@ -68,6 +68,11 @@
<artifactId>Essentials</artifactId>
<version>2.14-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
@ -90,6 +95,10 @@
<id>etztech-repo</id>
<url>http://repo.etztech.xyz</url>
</repository>
<repository>
<id>dynmap-repo</id>
<url>http://repo.mikeprimm.com/</url>
</repository>
<repository>
<id>ess-repo</id>
<url>http://repo.ess3.net/content/groups/essentials</url>

View File

@ -11,6 +11,7 @@ import xyz.etztech.qol.commands.*;
import xyz.etztech.qol.listeners.*;
import xyz.etztech.qol.other.LinkCommand;
import xyz.etztech.qol.other.TPSRunnable;
import org.dynmap.DynmapAPI;
import java.util.ArrayList;
import java.util.List;
@ -21,6 +22,7 @@ public class QoL extends JavaPlugin {
private static QoL instance;
private static IEssentials essentials = null;
private static DynmapAPI dynmap = null;
public static FileConfiguration config;
private Logger log = Logger.getLogger( "Minecraft" );
@ -44,6 +46,12 @@ public class QoL extends JavaPlugin {
essentials = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
}
//Dynmap hook
if (Bukkit.getPluginManager().isPluginEnabled("dynmap")) {
log("Hooked into Dynmap.");
dynmap = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap");
}
if( isEnabled() ) {
// Add listeners
@ -243,9 +251,9 @@ public class QoL extends JavaPlugin {
return links;
}
public static IEssentials getEssentials() {
return essentials;
}
public static IEssentials getEssentials() { return essentials; }
public static DynmapAPI getDynmap() { return dynmap; }
private void runTask(final String command) {

View File

@ -13,6 +13,7 @@ import xyz.etztech.core.CoreUtils;
import xyz.etztech.core.web.CoreWeb;
import xyz.etztech.qol.QoL;
import xyz.etztech.qol.other.LinkCommand;
import org.dynmap.DynmapAPI;
import java.util.HashMap;
import java.util.Map;
@ -20,25 +21,43 @@ import java.util.UUID;
public class CommandPreprocessListener implements Listener {
QoL plugin;
private Map<UUID, String> confirmTpMap = new HashMap<>();
private Map<UUID, Boolean> dynmapVisibleStatusMap = new HashMap<>();
public CommandPreprocessListener(QoL plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String command = event.getMessage();
String base = command.split(" ")[0].substring(1).toLowerCase(); // Strip the slash
Player sender = event.getPlayer();
DynmapAPI dynmap = plugin.getDynmap();
// Spec dynmap hide
if (base.equals("spec") && sender.hasPermission("SafeSpectate.spectate") && dynmap != null) {
boolean visibleStatus;
if (sender.getGameMode() != GameMode.SPECTATOR){
dynmapVisibleStatusMap.put(sender.getUniqueId(), dynmap.getPlayerVisbility(sender.getName()));
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")) {
//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).toLowerCase().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 (command.equals(confirmTpMap.get(sender.getUniqueId()))) {
confirmTpMap.remove(sender.getUniqueId());