mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-29 05:55:19 +01:00
Started making the portal creation commands
This commit is contained in:
parent
06ced651a1
commit
ea1fef37b8
@ -4,7 +4,9 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
import net.minecraft.server.v1_7_R1.Item;
|
import net.minecraft.server.v1_7_R1.Item;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
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;
|
||||||
@ -65,10 +67,89 @@ public class AdvancedPortalsCommand implements CommandExecutor {
|
|||||||
else if(args[0].toLowerCase().equals("create")) {
|
else if(args[0].toLowerCase().equals("create")) {
|
||||||
if(player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")){
|
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("");
|
if(args.length >= 2){
|
||||||
player.sendMessage("§a[§eAdvancedPortals§a] You have created a new portal with the following details:");
|
boolean hasName = false;
|
||||||
boolean hasTriggerBlock = false;
|
boolean hasTriggerBlock = false;
|
||||||
|
boolean hasDestination = false;
|
||||||
|
String destination = null;
|
||||||
|
String portalName = null;
|
||||||
|
String triggerBlock = null;
|
||||||
|
for(int i = 0; i < args.length; i++){
|
||||||
|
if(args[i].toLowerCase().startsWith("name:") && args[i].length() > 5){
|
||||||
|
hasName = true;
|
||||||
|
portalName = args[i].replaceFirst("name:", "");
|
||||||
|
}
|
||||||
|
else if(args[i].toLowerCase().startsWith("name:")) {
|
||||||
|
player.sendMessage("§c[§7AdvancedPortals§c] You must include a name for the portal that isnt nothing!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args[i].toLowerCase().startsWith("destination:") && args[i].length() > 11){
|
||||||
|
hasDestination = true;
|
||||||
|
destination = args[i].replaceFirst("destination:", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13){
|
||||||
|
hasTriggerBlock = true;
|
||||||
|
triggerBlock = args[i].replaceFirst("trigger:", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!hasName){
|
||||||
|
player.sendMessage("§c[§7AdvancedPortals§c] You must include a name for the portal that you are creating in the variables!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage("");
|
||||||
|
player.sendMessage("§a[§eAdvancedPortals§a]§e You have created a new portal with the following details:");
|
||||||
|
player.sendMessage("§aname: §e" + portalName);
|
||||||
|
if(hasDestination){
|
||||||
|
player.sendMessage("§adestination: §e" + destination);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
player.sendMessage("§cdestination: §eN/A (will not work)");
|
||||||
|
}
|
||||||
|
if(hasTriggerBlock){
|
||||||
|
player.sendMessage("§atriggerBlock: §e" + triggerBlock);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
player.sendMessage("§ctriggerBlock: §eN/A");
|
||||||
|
}
|
||||||
|
|
||||||
|
World world = org.bukkit.Bukkit.getWorld(player.getMetadata("Pos1World").get(0).asString());
|
||||||
|
Location pos1 = new Location(world, player.getMetadata("Pos1X").get(0).asInt(), player.getMetadata("Pos1Y").get(0).asInt(), player.getMetadata("Pos1Z").get(0).asInt());
|
||||||
|
Location pos2 = new Location(world, player.getMetadata("Pos2X").get(0).asInt(), player.getMetadata("Pos2Y").get(0).asInt(), player.getMetadata("Pos2Z").get(0).asInt());
|
||||||
|
Portal.create(player, pos1, pos2, "portalname");
|
||||||
|
|
||||||
Material triggerBlockId = Material.getMaterial(0);
|
Material triggerBlockId = Material.getMaterial(0);
|
||||||
|
if(hasTriggerBlock){
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
triggerBlockId = Material.getMaterial(Integer.parseInt(triggerBlock));
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
triggerBlockId = Material.getMaterial(triggerBlock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!hasTriggerBlock || triggerBlockId == null){
|
||||||
|
Portal.create(player, pos1, pos2, "portalname");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Portal.create(player, pos1, pos2, "portalname");
|
||||||
|
}
|
||||||
|
|
||||||
|
// add code to save the portal to the portal config and reload the portals
|
||||||
|
|
||||||
|
player.sendMessage("");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
player.sendMessage("§c[§7AdvancedPortals§c] You need to at least add the name of the portal as a variable, §cType §e/portal variables§c"
|
||||||
|
+ " for a full list of currently available variables and an example command!");
|
||||||
|
}
|
||||||
|
/**Material triggerBlockId = Material.getMaterial(0);
|
||||||
if(hasTriggerBlock){
|
if(hasTriggerBlock){
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -80,7 +161,7 @@ public class AdvancedPortalsCommand implements CommandExecutor {
|
|||||||
triggerBlockId = Material.getMaterial("PORTAL");
|
triggerBlockId = Material.getMaterial("PORTAL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Portal.create(player, null, null, "portalname");
|
Portal.create(player, null, null, "portalname");*/
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
player.sendMessage("§c[§7AdvancedPortals§c] The points you have selected need to be in the same world!");
|
player.sendMessage("§c[§7AdvancedPortals§c] The points you have selected need to be in the same world!");
|
||||||
@ -90,6 +171,11 @@ public class AdvancedPortalsCommand implements CommandExecutor {
|
|||||||
player.sendMessage("§c[§7AdvancedPortals§c] You need to have two points selected to make a portal!");
|
player.sendMessage("§c[§7AdvancedPortals§c] You need to have two points selected to make a portal!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(args[0].toLowerCase().equals("variables")) {
|
||||||
|
player.sendMessage("§a[§eAdvancedPortals§a] Currently available variables: name, triggerBlock, destination");
|
||||||
|
player.sendMessage("");
|
||||||
|
player.sendMessage("§aExample command: §e/portal create name:test triggerId:portal");
|
||||||
|
}
|
||||||
else if(args[0].toLowerCase().equals("select")) {
|
else if(args[0].toLowerCase().equals("select")) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -112,13 +198,17 @@ public class AdvancedPortalsCommand implements CommandExecutor {
|
|||||||
player.sendMessage("§c[§7AdvancedPortals§c] You need to have both points selected!");
|
player.sendMessage("§c[§7AdvancedPortals§c] You need to have both points selected!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(args[0].toLowerCase().equals("help")) {
|
||||||
|
player.sendMessage("§a[§eAdvancedPortals§a] Reloaded values!");
|
||||||
|
Listeners.reloadValues(plugin);
|
||||||
|
Portal.loadPortals();
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
PluginMessages.UnknownCommand(sender, command);
|
PluginMessages.UnknownCommand(sender, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
sender.sendMessage("§c[§7AdvancedPortals§c] You need to type something after /" + command + "\n"
|
PluginMessages.UnknownCommand(sender, command);
|
||||||
+ "if you do not know what you can put or would like some help with the commands please type /" + command + " help");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -8,7 +8,6 @@ public class PluginMessages {
|
|||||||
// easily changed.
|
// easily changed.
|
||||||
|
|
||||||
public static void UnknownCommand(CommandSender sender, String command) {
|
public static void UnknownCommand(CommandSender sender, String command) {
|
||||||
sender.sendMessage(" ");
|
|
||||||
sender.sendMessage("§c[§7AdvancedPortals§c] You need to type something after /" + command + "\n");
|
sender.sendMessage("§c[§7AdvancedPortals§c] You need to type something after /" + command + "\n");
|
||||||
sender.sendMessage("§cIf you do not know what you can put or would like some help with the commands please type §e" + '"' + "§e/" + command + " help" + '"' + "§c\n");
|
sender.sendMessage("§cIf you do not know what you can put or would like some help with the commands please type §e" + '"' + "§e/" + command + " help" + '"' + "§c\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user