Fixed nocheatplus compatability

This commit is contained in:
Alastair 2015-08-18 00:03:56 +01:00
parent c2b6b58940
commit dc937b28ce
7 changed files with 23 additions and 34 deletions

View File

@ -23,7 +23,7 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
// Failed to submit the stats :-( // Failed to submit the stats :-(
} }
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been sucsessfully enabled!"); this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!");
String packageName = getServer().getClass().getPackage().getName(); String packageName = getServer().getClass().getPackage().getName();
String[] packageSplit = packageName.split("\\."); String[] packageSplit = packageName.split("\\.");
@ -46,10 +46,6 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
e.printStackTrace(); e.printStackTrace();
} }
if(getServer().getPluginManager().getPlugin("NoCheatPlus") != null){
Listeners.noCheatsPlus = true;
}
new Assets(this); new Assets(this);
// Opens a channel that messages bungeeCord // Opens a channel that messages bungeeCord

View File

@ -14,7 +14,7 @@ import java.util.List;
public class DestinationCommand implements CommandExecutor, TabCompleter { public class DestinationCommand implements CommandExecutor, TabCompleter {
private final int PortalMessagesDisplay; public static int PortalMessagesDisplay = 0;
private AdvancedPortalsPlugin plugin; private AdvancedPortalsPlugin plugin;
@ -95,7 +95,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
} }
} }
else{ else{
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to state the name of the destination you wish to teleport to."); sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to state the name of the destination you wish to exemptPlayer to.");
} }
} }
else if(args[0].toLowerCase().equals("list")) { else if(args[0].toLowerCase().equals("list")) {

View File

@ -1,6 +1,5 @@
package com.sekwah.advancedportals; package com.sekwah.advancedportals;
import com.sekwah.advancedportals.compat.NoCheatPlus;
import com.sekwah.advancedportals.events.WarpEvent; import com.sekwah.advancedportals.events.WarpEvent;
import com.sekwah.advancedportals.portals.AdvancedPortal; import com.sekwah.advancedportals.portals.AdvancedPortal;
import com.sekwah.advancedportals.portals.Portal; import com.sekwah.advancedportals.portals.Portal;
@ -22,7 +21,6 @@ import org.bukkit.metadata.FixedMetadataValue;
public class Listeners implements Listener { public class Listeners implements Listener {
public static boolean noCheatsPlus = false;
private final AdvancedPortalsPlugin plugin; private final AdvancedPortalsPlugin plugin;
private int PortalMessagesDisplay = 2; private int PortalMessagesDisplay = 2;
@ -91,7 +89,7 @@ public class Listeners implements Listener {
eyeloc.setY(eyeloc.getY() + player.getEyeHeight()); eyeloc.setY(eyeloc.getY() + player.getEyeHeight());
AdvancedPortal[] portals = Portal.Portals; AdvancedPortal[] portals = Portal.Portals;
for(AdvancedPortal portal : portals){ for(AdvancedPortal portal : portals){
if(portal.worldName.equals(loc.getWorld().getName())){ if(loc.getWorld() != null && portal.worldName.equals(loc.getWorld().getName())){
if(portal.trigger.equals(loc.getBlock().getType()) if(portal.trigger.equals(loc.getBlock().getType())
|| portal.trigger.equals(eyeloc.getBlock().getType())){ || portal.trigger.equals(eyeloc.getBlock().getType())){
if((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()){ if((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()){
@ -99,7 +97,7 @@ public class Listeners implements Listener {
WarpEvent warpEvent = new WarpEvent(player, portal.portalName); WarpEvent warpEvent = new WarpEvent(player, portal.portalName);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(warpEvent);
if (!event.isCancelled()) { if (!event.isCancelled()) {
boolean warped = Portal.activate(player, portal.portalName); boolean warped = Portal.activate(player, portal.portalName);
@ -117,9 +115,9 @@ public class Listeners implements Listener {
} }
if(warped){ if(warped){
if(noCheatsPlus){ //event.setFrom(player.getLocation());
NoCheatPlus.teleport(player); //event.setTo(player.getLocation());
}
//event.setCancelled(true); //event.setCancelled(true);
} }
else{ else{

View File

@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
public class Selection { public class Selection {
public static Material blockType = Material.WOOL; public static Material blockType = Material.STAINED_GLASS;
public static int timeout = 10; public static int timeout = 10;
public static byte metadata = 14; public static byte metadata = 14;

View File

@ -5,6 +5,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -25,10 +26,18 @@ public class WarpCommand implements CommandExecutor, TabCompleter {
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
if(args.length > 0){ if(args.length > 0){
if(Destination.warp(sender, args[0], false)){ if(Destination.warp(sender, args[0], false)){
if(DestinationCommand.PortalMessagesDisplay == 1){
sender.sendMessage(""); sender.sendMessage("");
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + args[0] + "\u00A7a."); sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + args[0].replaceAll("_", " ") + "\u00A7a.");
sender.sendMessage(""); sender.sendMessage("");
} }
else if(DestinationCommand.PortalMessagesDisplay == 2){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
plugin.nmsAccess.sendActionBarMessage("{text:\"\u00A7aYou have warped to \u00A7e" + args[0].replaceAll("_", " ") + "\u00A7a.\"}", (Player) sender);
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ")
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
}
}
else{ else{
sender.sendMessage(""); sender.sendMessage("");
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you tried to warp to does not exist!"); sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you tried to warp to does not exist!");

View File

@ -1,14 +0,0 @@
package com.sekwah.advancedportals.compat;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import org.bukkit.entity.Player;
public class NoCheatPlus {
public static void teleport(Player player) {
MovingData.getData(player).setTeleported(player.getLocation());
// MovingData.getData(player).prepareSetBack(player.getLocation());
//MovingData.getData(player).onSetBack(player.getLocation());
System.out.println("Warp NoCheat");
}
}

View File

@ -369,7 +369,7 @@ public class Portal {
} }
} }
// add code for if the portal doesnt have a destination but a teleport location // add code for if the portal doesnt have a destination but a exemptPlayer location
} }