Merge branch 'master' into portals-rewrite

# Conflicts:
#	src/com/sekwah/advancedportals/listeners/PortalProtect.java
This commit is contained in:
Alastair 2016-11-20 05:04:05 +00:00
commit b94ec07573
7 changed files with 72 additions and 37 deletions

View File

@ -1,6 +1,6 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.0.20
version: 0.0.21
author: sekwah41
description: An advanced portals plugin for bukkit.
commands:
@ -10,7 +10,7 @@ commands:
usage: /<command>
destination:
description: Can be used to access portal destinations.
aliases: [desti, awarp]
aliases: [desti]
usage: /<command>
permissions:
advancedportals.*:

View File

@ -16,7 +16,7 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<version>0.0.20-snapshot</version>
<version>0.0.21-snapshot</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>

View File

@ -65,8 +65,9 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
inventory.addItem(regionselector);
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Region Selector\u00A7a!");
break;
case "portal":
case "portalblock":
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
// Also do this for other blocks such as gateways and end portals just in case they want it.
ItemStack portalBlock = new ItemStack(Material.PORTAL, 1);
inventory.addItem(portalBlock);
@ -75,7 +76,8 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
break;
case "create":
if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString()) && player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString())
&& player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
if (args.length >= 2) { // may make this next piece of code more efficient, maybe check against a list of available variables or something
// TODO change system to use arrays and hashmaps
boolean hasName = false;
@ -210,7 +212,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
}
break;
case "variables" :
sender.sendMessage(PluginMessages.customPrefix + " Currently available variables: name, triggerBlock, destination");
sender.sendMessage(PluginMessages.customPrefix + " \u00A77Variables \u00A7c: \u00A7aname, triggerBlock, destination");
sender.sendMessage("");
sender.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal");
break;
@ -239,8 +241,10 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
sender.sendMessage("");
sender.sendMessage(PluginMessages.customPrefixFail + " Are you sure you would like to remove the portal \u00A7e" + args[2] + "\u00A7c?");
sender.sendMessage("");
plugin.compat.sendRawMessage("{\"text\":\" \",\"extra\":[{\"text\":\"\u00A7e[Yes]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Confirm removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal remove " + args[2] + "\"}}, " +
"{\"text\":\" \"},{\"text\":\"\u00A7e[No]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Cancel removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal edit " + args[2] + "\"}}]}", player);
plugin.compat.sendRawMessage("{\"text\":\" \",\"extra\":[{\"text\":\"\u00A7e[Yes]\",\"hoverEvent\":{\"action\":\"show_text\"," +
"\"value\":\"Confirm removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal remove " + args[2] + "\"}}, " +
"{\"text\":\" \"},{\"text\":\"\u00A7e[No]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Cancel removing this portal\"}" +
",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal edit " + args[2] + "\"}}]}", player);
sender.sendMessage("");
}
}
@ -366,6 +370,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
sender.sendMessage("\u00A76/" + command + " portal \u00A7a- gives you a portal block");
sender.sendMessage("\u00A76/" + command + " select \u00A7a- selects an existing portal");
sender.sendMessage("\u00A76/" + command + " remove \u00A7a- removes a portal");
sender.sendMessage("\u00A76/" + command + " list \u00A7a- lists all the current portals");
sender.sendMessage("\u00A76/" + command + " variables \u00A7a- lists all available tags");
sender.sendMessage("\u00A7e\u00A7m-----------------------------------");
break;
@ -382,7 +387,8 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
player.sendMessage(PluginMessages.customPrefix + " Your currently selected portal has been shown, it will dissapear shortly!");
Selection.Show(player, this.plugin, player.getMetadata("selectedPortal").get(0).asString());
} else if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString()) && player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString())
&& player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
player.sendMessage(PluginMessages.customPrefix + " Your currently selected area has been shown, it will dissapear shortly!");
Selection.Show(player, this.plugin, null);
}
@ -397,15 +403,20 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
Portal.loadPortals();
break;
case "list" :
String message = PluginMessages.customPrefix + " \u00A7c:\u00A7a";
String message = PluginMessages.customPrefix + " \u00A77Portals \u00A7c:\u00A7a";
LinkedList<String> portals = new LinkedList<>();
for (AdvancedPortal portal : Portal.Portals) {
message = message + " " + portal.portalName;
portals.add(portal.portalName);
}
Collections.sort(portals);
for (Object portalName : portals.toArray()) {
message = message + " " + portalName;
}
player.sendMessage(message);
break;
default:
PluginMessages.UnknownCommand(sender, command);
}
}
} else {
PluginMessages.UnknownCommand(sender, command);
}
@ -449,8 +460,10 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
sender.sendMessage("");
sender.sendMessage(PluginMessages.customPrefix + " Editing: \u00A7e" + portalName);
sender.sendMessage(" \u00A7apos1\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos1.X") + ", " + portalConfig.getConfig().getString(portalName + ".pos1.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos1.Z"));
sender.sendMessage(" \u00A7apos2\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos2.X") + ", " + portalConfig.getConfig().getString(portalName + ".pos2.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos2.Z"));
sender.sendMessage(" \u00A7apos1\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos1.X")
+ ", " + portalConfig.getConfig().getString(portalName + ".pos1.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos1.Z"));
sender.sendMessage(" \u00A7apos2\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos2.X")
+ ", " + portalConfig.getConfig().getString(portalName + ".pos2.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos2.Z"));
String destination = portalConfig.getConfig().getString(portalName + ".destination");
if (destination != null) {
@ -485,7 +498,8 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
Player player = (Player) sender;
plugin.compat.sendRawMessage("{\"text\":\"\u00A7aFunctions\u00A7e: \",\"extra\":[{\"text\":\"\u00A7eRemove\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Remove the selected portal\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/portal gui remove " + portalName + "\"}}"
plugin.compat.sendRawMessage("{\"text\":\"\u00A7aFunctions\u00A7e: \"," +
"\"extra\":[{\"text\":\"\u00A7eRemove\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Remove the selected portal\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/portal gui remove " + portalName + "\"}}"
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eShow\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Show the selected portal\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/portal show " + portalName + "\"}}"
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eRename\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Change the name of the portal\"},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/portal rename \"}}"
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eActivate\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Teleport to the set destination\n(same as entering the portal)\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/warp " + destination + "\"}}]}", player);
@ -499,7 +513,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
LinkedList<String> autoComplete = new LinkedList<String>();
if (sender.hasPermission("AdvancedPortals.CreatePortal")) {
if (args.length == 1) {
autoComplete.addAll(Arrays.asList("create", "portal", "portalblock", "select", "selector"
autoComplete.addAll(Arrays.asList("create", "list", "portalblock", "select", "selector"
, "show", "variables", "wand", "remove", "rename", "help", "bukkitpage", "helppage"));
} else if (args[0].toLowerCase().equals("create")) {

View File

@ -86,7 +86,7 @@ public class CraftBukkit {
playerConnection.getClass().getMethod("sendPacket", this.packet).invoke(playerConnection, packet);
} catch (IllegalAccessException |InvocationTargetException | NoSuchMethodException | NoSuchFieldException
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | NoSuchFieldException
| InstantiationException e) {
this.plugin.getLogger().warning("Error creating raw message, something must be wrong with reflection");
e.printStackTrace();

View File

@ -9,10 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
public class DestinationCommand implements CommandExecutor, TabCompleter {
@ -67,22 +64,36 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
break;
case "list":
String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a";
for (String desti : config.getConfig().getKeys(false)) message = message + " " + desti;
List<Object> destiObj = Arrays.asList(config.getConfig().getKeys(false).toArray());
LinkedList<String> destis = new LinkedList<>();
for (Object object : destiObj.toArray()) {
destis.add(object.toString());
}
Collections.sort(destis);
for (Object desti : destis.toArray()) message = message + " " + desti;
sender.sendMessage(message);
break;
case "help":
sender.sendMessage(PluginMessages.customPrefix + " Destination Help Menu");
sender.sendMessage("\u00A7e\u00A7m----------------------------");
sender.sendMessage("\u00A76/" + command + " \u00A7c[name] \u00A7a- teleport to destination");
sender.sendMessage("\u00A76/" + command + " create \u00A7c[name] \u00A7a- create destination at your location");
sender.sendMessage("\u00A76/" + command + " remove \u00A7c[name] \u00A7a- remove destination");
sender.sendMessage("\u00A76/" + command + " warp \u00A7c[name] \u00A7a- teleport to destination");
sender.sendMessage("\u00A76/" + command + " list \u00A7a- list all destinations");
sender.sendMessage("\u00A7e\u00A7m----------------------------");
break;
default:
Destination.warp((Player) sender, args[0]);
case "warp":
if(args.length >= 2){
Destination.warp((Player) sender, args[1]);
}
else{
sender.sendMessage(PluginMessages.customPrefixFail + " You must specify a warp location!");
}
break;
}
default:
PluginMessages.UnknownCommand(sender, command);
break;
}
} else {
PluginMessages.UnknownCommand(sender, command);
}
@ -92,11 +103,13 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
LinkedList<String> autoComplete = new LinkedList<String>();
LinkedList<String> autoComplete = new LinkedList<>();
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
for (String string : config.getConfig().getKeys(false)) {
if (sender.hasPermission("advancedportals.desti.*") | sender.hasPermission("advancedportals.desti." + string))
autoComplete.add(string);
if(args.length > 1 && args[0].equalsIgnoreCase("warp")){
for (String string : config.getConfig().getKeys(false)) {
if (sender.hasPermission("advancedportals.desti.*") | sender.hasPermission("advancedportals.desti." + string))
autoComplete.add(string);
}
}
if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("AdvancedPortals.CreatePortal")) {
if (args.length == 1) {
@ -104,6 +117,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
} else if (args[0].toLowerCase().equals("create")) {
}
}
autoComplete.add("warp");
Collections.sort(autoComplete);
for (Object result : autoComplete.toArray()) {
if (!result.toString().startsWith(args[args.length - 1])) {

View File

@ -0,0 +1,12 @@
package com.sekwah.advancedportals.destinations;
/**
* Created by on 04/08/2016.
*
* TODO load the destinations into memory rather than constantly reading from the yml.
*
* @author sekwah41
*/
public class PortalWarp {
}

View File

@ -25,9 +25,8 @@ public class Listeners implements Listener {
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("\u00A7eP...
private static boolean UseOnlyServerAxe = false;
private static Material WandMaterial;
private static boolean ShowBungeeMessage;
private final AdvancedPortalsPlugin plugin;
private int PortalMessagesDisplay = 2;
@SuppressWarnings("deprecation")
public Listeners(AdvancedPortalsPlugin plugin) {
@ -38,8 +37,6 @@ public class Listeners implements Listener {
String ItemID = config.getConfig().getString("AxeItemId");
PortalMessagesDisplay = config.getConfig().getInt("WarpMessageDisplay");
try {
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
} catch (Exception e) {
@ -55,8 +52,6 @@ public class Listeners implements Listener {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
String ItemID = config.getConfig().getString("AxeItemId");
try {
@ -83,7 +78,7 @@ public class Listeners implements Listener {
Location loc = event.getTo();
Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ());
for (AdvancedPortal portal : Portal.Portals) {
if (Portal.locationInPortalTrigger(portal, loc) | Portal.locationInPortalTrigger(portal, eyeLoc)) {
if (Portal.locationInPortalTrigger(portal, loc) || Portal.locationInPortalTrigger(portal, eyeLoc)) {
if (portal.trigger.equals(Material.PORTAL)) {
if (player.getGameMode().equals(GameMode.CREATIVE)) {
player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true));