the text gui menus now work even better

This commit is contained in:
sekwah41 2014-04-10 22:45:27 +01:00
parent 7f806a0c55
commit c987143838
3 changed files with 119 additions and 10 deletions

View File

@ -244,8 +244,8 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
sender.sendMessage("");
sender.sendMessage("§c[§7AdvancedPortals§c] Are you sure you would like to remove the portal §e" + args[2] + "§c?");
sender.sendMessage("");
IChatBaseComponent comp = ChatSerializer.a("{text:\" \",extra:[{text:\"§e[Yes]\",clickEvent:{action:run_command,value:\"/portal remove " + args[2] + "\",hoverEvent:{action:show_text,value:\"This is a test\"}}}, " +
"{text:\" \"},{text:\"§e[No]\",clickEvent:{action:run_command,value:\"/portal edit " + args[2] + "\",hoverEvent:{action:show_text,value:\"This is a test\"}}}]}");
IChatBaseComponent comp = ChatSerializer.a("{text:\" \",extra:[{text:\"§e[Yes]\",hoverEvent:{action:show_text,value:\"Confirm removing this portal\"},clickEvent:{action:run_command,value:\"/portal remove " + args[2] + "\"}}, " +
"{text:\" \"},{text:\"§e[No]\",hoverEvent:{action:show_text,value:\"Cancel removing this portal\"},clickEvent:{action:run_command,value:\"/portal edit " + args[2] + "\"}}]}");
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
sender.sendMessage("");
@ -350,17 +350,29 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
player.sendMessage("§a[§eAdvancedPortals§a] Help page: (insert bitly link)!");
}
else if(args[0].toLowerCase().equals("show")){
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())){
player.sendMessage("§a[§eAdvancedPortals§a] Your currently selected area has been shown, it will dissapear shortly!");
Selection.Show(player, this.plugin);
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Portals.yml");
if(args.length > 1){
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if(posX != null){
Selection.Show(player, this.plugin, args[1]);
}
else{
player.sendMessage("§c[§7AdvancedPortals§c] The points you have selected need to be in the same world!");
sender.sendMessage("§c[§7AdvancedPortals§c] No portal by that name exists!");
}
}
else{
player.sendMessage("§c[§7AdvancedPortals§c] You need to have both points selected!");
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())){
player.sendMessage("§a[§eAdvancedPortals§a] Your currently selected area has been shown, it will dissapear shortly!");
Selection.Show(player, this.plugin);
}
else{
player.sendMessage("§c[§7AdvancedPortals§c] The points you have selected need to be in the same world!");
}
}
else{
player.sendMessage("§c[§7AdvancedPortals§c] You need to have both points selected!");
}
}
}
else if(args[0].toLowerCase().equals("help")) {
@ -412,11 +424,12 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
else{
sender.sendMessage(" §ctriggerBlock§e: null");
}
sender.sendMessage(" ");
sender.sendMessage("");
Player player = (Player)sender;
IChatBaseComponent comp = ChatSerializer.a("{text:\"§aFunctions§e: \",extra:[{text:\"§eRemove\",clickEvent:{action:run_command,value:\"/portal gui remove " + portalName + "\",hoverEvent:{action:show_text,value:\"This is a test\"}}}]}");
IChatBaseComponent comp = ChatSerializer.a("{text:\"§aFunctions§e: \",extra:[{text:\"§eRemove\",hoverEvent:{action:show_text,value:\"Remove the selected portal\"},clickEvent:{action:run_command,value:\"/portal gui remove " + portalName + "\"}}"
+ ",{text:\" \"},{text:\"§eShow\",hoverEvent:{action:show_text,value:\"Show the selected portal\"},clickEvent:{action:run_command,value:\"/portal show " + portalName + "\"}}]}");
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
sender.sendMessage("");

View File

@ -13,6 +13,7 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class DestinationCommand implements CommandExecutor, TabCompleter {
@ -50,6 +51,22 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
sender.sendMessage("§c[§7AdvancedPortals§c] You do not have permission to create portals so you cannot give yourself a §ePortal Region Selector§c!");
}
}
else if(args[0].toLowerCase().equals("remove")) {
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Destinations.yml");
if(args.length > 1){
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if(posX != null){
Destination.remove(args[1]);
sender.sendMessage("§c[§7AdvancedPortals§c] The portal §e" + args[1] + "§c has been removed!");
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] No portal by that name exists!");
}
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] You need to state the name of the destination you wish to remove!");
}
}
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] You need to type something after /" + command + "\n"

View File

@ -33,6 +33,85 @@ public class Selection {
metadata = (byte) config.getConfig().getInt("ShowSelectionBlockData");
}
@SuppressWarnings("deprecation")
public static void Show(final Player player, final AdvancedPortalsPlugin plugin, String portalName) {
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Portals.yml");
int LowX = portalConfig.getConfig().getInt(portalName + ".pos2.X");
int LowY = portalConfig.getConfig().getInt(portalName + ".pos2.Y");
int LowZ = portalConfig.getConfig().getInt(portalName + ".pos2.Z");
int HighX = portalConfig.getConfig().getInt(portalName + ".pos1.X");
int HighY = portalConfig.getConfig().getInt(portalName + ".pos1.Y");
int HighZ = portalConfig.getConfig().getInt(portalName + ".pos1.Z");
final Location pos1 = new Location(player.getWorld(), LowX, LowY, LowZ);
final Location pos2 = new Location(player.getWorld(), HighX, HighY, HighZ);
/*
* There are alot of for loops at the moment, when i find an easier way to do these other that a load of if statements
* then i will change it, but for now its the best way i can think of for doing this.
*/
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
player.sendBlockChange(loc, blockType, metadata);
}
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
player.sendBlockChange(loc, blockType, metadata);
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), LowX, LowY, z);
player.sendBlockChange(loc, blockType, metadata);
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), HighX, LowY, z);
player.sendBlockChange(loc, blockType, metadata);
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
player.sendBlockChange(loc, blockType, metadata);
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
player.sendBlockChange(loc, blockType, metadata);
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
player.sendBlockChange(loc, blockType, metadata);
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
player.sendBlockChange(loc, blockType, metadata);
}
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
player.sendBlockChange(loc, blockType, metadata);
}
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
player.sendBlockChange(loc, blockType, metadata);
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), LowX, HighY, z);
player.sendBlockChange(loc, blockType, metadata);
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), HighX, HighY, z);
player.sendBlockChange(loc, blockType, metadata);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
Selection.Hide(player, plugin, pos1, pos2);
}
}, timeout * 20);
}
@SuppressWarnings("deprecation")
public static void Show(final Player player, final AdvancedPortalsPlugin plugin) {