fixed the godo and warp command, updated some messages and started the

list command
This commit is contained in:
sekwah41 2014-04-12 22:10:12 +01:00
parent 7c00efb011
commit 5509ec8d96
3 changed files with 81 additions and 9 deletions

View File

@ -77,7 +77,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
PlayerInventory inventory = player.getInventory();
ItemStack portalBlock = new ItemStack(Material.PORTAL);
inventory.addItem(portalBlock);
sender.sendMessage("§a[§eAdvancedPortals§a] You have been given a §ePortal Block§a!");

View File

@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -60,26 +61,73 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
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!");
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!");
sender.sendMessage("§c[§7AdvancedPortals§c] You need to state the name of the destination you wish to remove.");
}
}
else if(args[0].toLowerCase().equals("goto")) {
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Destinations.yml");
else if(args[0].toLowerCase().equals("goto") || args[0].toLowerCase().equals("warp")) {
if(args.length > 1){
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if(posX != null){
System.out.println(args[1]);
ConfigAccessor configDesti = new ConfigAccessor(plugin, "Destinations.yml");
if(configDesti.getConfig().getString(args[1] + ".world") != null){
Destination.warp(sender, args[1]);
sender.sendMessage("§a[§eAdvancedPortals§a] You have been warped to §e" + args[1] + "§a.");
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] No portal by that name exists!");
sender.sendMessage("§c[§7AdvancedPortals§c] No destination by that name exists.");
}
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] You need to state the name of the destination you wish to teleport to!");
sender.sendMessage("§c[§7AdvancedPortals§c] You need to state the name of the destination you wish to teleport to.");
}
}
else if(args[0].toLowerCase().equals("list")) {
List<String> destiList = Destination.destiList();
if(destiList.size() >= 1){
if(args.length > 1){
try
{
int page = Integer.parseInt(args[1]);
if(page * 5 >= destiList.size() - 5){ // add this if statement so that the user cant select a list page higher than the max
if((int) destiList.size() / 5 == destiList.size()){
}
}
sender.sendMessage("§a[§eAdvancedPortals§a] Showing destinations page 1 of 1");
for(int i = (page - 1) * 5; i < page * 5; i++){
if(i > destiList.size()){
break;
}
sender.sendMessage(" §e" + destiList.get(i));
}
return true;
}
catch(Exception e)
{
}
}
sender.sendMessage("§a[§eAdvancedPortals§a] Showing destinations page 1 of 1");
for(int i = 0; i < 5; i++){
if(i > destiList.size()){
break;
}
sender.sendMessage(" §e" + destiList.get(i));
}
sender.sendMessage("§a[§eAdvancedPortals§a] Showing destinations page 1 of 1");
for(int i = 0; i < 5; i++){
if(i > destiList.size()){
break;
}
sender.sendMessage(" §e" + destiList.get(i));
}
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] There are currently no defined destinations.");
}
}
}

View File

@ -1,10 +1,17 @@
package com.sekwah.advancedportals.destinations;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -174,4 +181,21 @@ public class Destination {
return warp(player, name, true);
}
public static List<String> destiList(){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
LinkedList<String> destiList = new LinkedList<String>();
Set<String> destiSet = config.getConfig().getKeys(false);
if(destiSet.size() > 0){;
for(Object desti: destiSet.toArray()){
destiSet.add(desti.toString());
}
}
Collections.sort(destiList);
return destiList;
}
}