Moved the resources so they were output with intellij

This commit is contained in:
Alastair 2016-04-24 17:54:14 +01:00
parent d8872c0fa1
commit 94c02eadb2
4 changed files with 99 additions and 84 deletions

View File

@ -1,6 +1,6 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.0.18
version: 0.0.19
author: sekwah41
description: An advanced portals plugin for bukkit.
commands:

View File

@ -244,16 +244,16 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
}
}
} else if (args[0].toLowerCase().equals("edit")) {
Player player = (Player) sender;
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml");
if (args.length > 1) {
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if (posX != null) {
if (Portal.portalExists(args[1])) {
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
portalEditMenu(sender, portalConfig, args[1]);
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by the name \u00A7e" + args[1] + "\u00A7c exists!");
}
} else {
Player player = (Player) sender;
if (player.hasMetadata("selectedPortal")) {
String portalName = player.getMetadata("selectedPortal").get(0).asString();
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");

View File

@ -38,6 +38,8 @@ public class Listeners implements Listener {
private final AdvancedPortalsPlugin plugin;
private int PortalMessagesDisplay = 2;
private boolean teleportDuringMove = false;
@SuppressWarnings("deprecation")
public Listeners(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
@ -77,11 +79,14 @@ public class Listeners implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onMoveEvent(PlayerMoveEvent event) {
// will check if the player is in the portal or not.
if (!Portal.portalsActive) {
return;
}
teleportDuringMove = false;
Player player = event.getPlayer();
Location fromloc = event.getFrom();
@ -116,15 +121,18 @@ public class Listeners implements Listener {
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ")
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
}
if (warped) {
//event.setFrom(player.getLocation());
//event.setTo(player.getLocation());
//event.setCancelled(true);
} else {
player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
event.setCancelled(true);
//player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
//plugin.getLogger().info(String.valueOf(teleportDuringMove));
if(!teleportDuringMove){
event.setCancelled(true);
}
}
}
if (portal.trigger.equals(Material.PORTAL)) {
@ -146,6 +154,33 @@ public class Listeners implements Listener {
}
@EventHandler(ignoreCancelled = false, priority = EventPriority.LOWEST)
public void onPlayerTeleport(final PlayerTeleportEvent event){
Player player = event.getPlayer();
plugin.getLogger().info(String.valueOf(event.getCause()));
if(event.getCause() != PlayerTeleportEvent.TeleportCause.NETHER_PORTAL && event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL){
teleportDuringMove = true;
}
else{
Location loc = player.getLocation();
Object[] portals = Portal.Portals;
for (AdvancedPortal portal : Portal.Portals) {
if (portal.worldName.equals(player.getWorld().getName())) {
if ((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()) {
if ((portal.pos2.getX()) <= loc.getX() && (portal.pos2.getY()) <= loc.getY() && (portal.pos2.getZ()) <= loc.getZ()) {
event.setCancelled(true);
}
}
}
}
}
}
// These are here because java 7 can only take finals straight into a runnable
class RemoveLavaData implements Runnable{

View File

@ -366,6 +366,45 @@ public class Portal {
return false;
}
boolean showFailMessage = true;
if (portal.getArg("command.1") != null) {
showFailMessage = false;
int commandLine = 1;
String command = portal.getArg("command." + commandLine);//portalData.getConfig().getString(portal.portalName+ ".portalArgs.command." + commandLine);
do {
// (?i) makes the search case insensitive
command = command.replaceAll("@player", player.getName());
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
if (command.startsWith("#")) {
command = command.substring(1);
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
} else if (command.startsWith("!")) {
command = command.substring(1);
boolean wasOp = player.isOp();
try {
player.setOp(true);
player.performCommand(command);
} finally {
player.setOp(wasOp);
}
} else if (command.startsWith("^")) {
command = command.substring(1);
PermissionAttachment permissionAttachment = null;
try {
permissionAttachment = player.addAttachment(plugin, "*", true);
player.performCommand(command);
} finally {
player.removeAttachment(permissionAttachment);
}
} else {
player.performCommand(command);
}
command = portal.getArg("command." + ++commandLine);
} while (command != null);
}
//plugin.getLogger().info(portal.portalName + ":" + portal.destiation);
if (portal.bungee != null) {
if (ShowBungeeMessage) {
player.sendMessage(plugin.customPrefix + "\u00A7a Attempting to warp to \u00A7e" + portal.bungee + "\u00A7a.");
@ -374,86 +413,27 @@ public class Portal {
out.writeUTF("Connect");
out.writeUTF(portal.bungee);
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
return false;
} else {
boolean showFailMessage = true;
if (portal.getArg("command.1") != null) {
showFailMessage = false;
int commandLine = 1;
String command = portal.getArg("command." + commandLine);//portalData.getConfig().getString(portal.portalName+ ".portalArgs.command." + commandLine);
do {
// (?i) makes the search case insensitive
command = command.replaceAll("@player", player.getName());
plugin.getLogger().log(Level.SEVERE, "Portal command: " + command);
if (command.startsWith("#")) {
command = command.substring(1);
plugin.getLogger().log(Level.SEVERE, "Portal command: " + command);
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
} else if (command.startsWith("!")) {
command = command.substring(1);
boolean wasOp = player.isOp();
try {
player.setOp(true);
player.performCommand(command);
} finally {
player.setOp(wasOp);
}
} else if (command.startsWith("^")) {
command = command.substring(1);
PermissionAttachment permissionAttachment = null;
try {
permissionAttachment = player.addAttachment(plugin, "*", true);
player.performCommand(command);
} finally {
player.removeAttachment(permissionAttachment);
}
} else {
player.performCommand(command);
}
command = portal.getArg("command." + ++commandLine);
} while (command != null);
}
//plugin.getLogger().info(portal.portalName + ":" + portal.destiation);
if (portal.destiation != null) {
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
if (configDesti.getConfig().getString(portal.destiation + ".world") != null) {
boolean warped = Destination.warp(player, portal.destiation);
return warped;
} else {
player.sendMessage(plugin.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or that destination listed doesn't exist!");
return false;
}
// Down to bungee to sort out the teleporting but yea theoretically they should warp.
return true;
}
else if (portal.destiation != null) {
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
if (configDesti.getConfig().getString(portal.destiation + ".world") != null) {
boolean warped = Destination.warp(player, portal.destiation);
return warped;
} else {
if (showFailMessage) {
player.sendMessage(plugin.customPrefix + "\u00A7c The portal you are trying to use doesn't have a destination!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or portal doesn't exist!");
}
player.sendMessage(plugin.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or that destination listed doesn't exist!");
return false;
}
/*if(configDesti.getConfig().getString(destiName + ".world") != null){
String permission = portalData.getConfig().getString(portalName + ".portalArgs.permission");
if(permission == null || (permission != null && player.hasPermission(permission)) || player.isOp()){
boolean warped = Destination.warp(player, destiName);
return warped;
}
else{
player.sendMessage(plugin.customPrefix + "\u00A7c You do not have permission to use this portal!");
return false;
}
}
else{
player.sendMessage(plugin.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or that destination listed doesn't exist!");
return false;
}*/
} else {
if (showFailMessage) {
player.sendMessage(plugin.customPrefix + "\u00A7c The portal you are trying to use doesn't have a destination!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or portal doesn't exist!");
}
return false;
}
}