mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-29 05:55:19 +01:00
Updated the portal code and added the destination manipulators
This commit is contained in:
parent
448b38b5b1
commit
b0d593f27e
@ -118,7 +118,6 @@ public class AdvancedPortalsCommand implements CommandExecutor {
|
|||||||
World world = org.bukkit.Bukkit.getWorld(player.getMetadata("Pos1World").get(0).asString());
|
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 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());
|
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){
|
if(hasTriggerBlock){
|
||||||
@ -136,10 +135,10 @@ public class AdvancedPortalsCommand implements CommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
if(!hasTriggerBlock || triggerBlockId == null){
|
if(!hasTriggerBlock || triggerBlockId == null){
|
||||||
Portal.create(player, pos1, pos2, "portalname");
|
Portal.create(pos1, pos2, "portalname");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Portal.create(player, pos1, pos2, "portalname");
|
Portal.create(pos1, pos2, "portalname", triggerBlockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add code to save the portal to the portal config and reload the portals
|
// add code to save the portal to the portal config and reload the portals
|
||||||
|
@ -27,7 +27,7 @@ public class DestinationCommand implements CommandExecutor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
sender.sendMessage("§c[§7AdvancedPortals§c] A destination by that name already exists!!");
|
sender.sendMessage("§c[§7AdvancedPortals§c] A destination by that name already exists!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -15,7 +15,7 @@ public class Destination {
|
|||||||
Destination.plugin = plugin;
|
Destination.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create(Player creator, Location location, String name){
|
public void create(Location location, String name){
|
||||||
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||||
|
|
||||||
config.getConfig().set(name + ".world", location.getWorld().getName());
|
config.getConfig().set(name + ".world", location.getWorld().getName());
|
||||||
@ -24,20 +24,44 @@ public class Destination {
|
|||||||
config.getConfig().set(name + ".pos.Y", location.getY());
|
config.getConfig().set(name + ".pos.Y", location.getY());
|
||||||
config.getConfig().set(name + ".pos.Z", location.getZ());
|
config.getConfig().set(name + ".pos.Z", location.getZ());
|
||||||
|
|
||||||
config.getConfig().set(name + ".creator", creator.getName());
|
config.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void move(Location location, String name){
|
||||||
|
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||||
|
|
||||||
|
config.getConfig().set(name + ".world", location.getWorld().getName());
|
||||||
|
|
||||||
|
config.getConfig().set(name + ".pos.X", location.getX());
|
||||||
|
config.getConfig().set(name + ".pos.Y", location.getY());
|
||||||
|
config.getConfig().set(name + ".pos.Z", location.getZ());
|
||||||
|
|
||||||
config.saveConfig();
|
config.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(Player creator, Location location, String name){
|
public void rename(String oldName, String newName){
|
||||||
|
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||||
|
|
||||||
|
config.getConfig().set(newName + ".world", config.getConfig().getString(oldName + ".world"));
|
||||||
|
|
||||||
|
config.getConfig().set(newName + ".pos.X", config.getConfig().getInt(oldName + ".pos.X"));
|
||||||
|
config.getConfig().set(newName + ".pos.Y", config.getConfig().getInt(oldName + ".pos.Y"));
|
||||||
|
config.getConfig().set(newName + ".pos.Z", config.getConfig().getInt(oldName + ".pos.Z"));
|
||||||
|
|
||||||
|
this.remove(oldName);
|
||||||
|
|
||||||
|
config.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rename(Player creator, String oldName, String newName){
|
public void remove(String name){
|
||||||
|
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||||
|
|
||||||
}
|
config.getConfig().set(name + ".world", null);
|
||||||
|
|
||||||
public void remove(Player player, String name){
|
config.getConfig().set(name + ".pos.X", null);
|
||||||
|
config.getConfig().set(name + ".pos.Y", null);
|
||||||
|
config.getConfig().set(name + ".pos.Z", null);
|
||||||
|
|
||||||
|
config.saveConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,13 +47,13 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void create(Player creator, Material triggerBlockId, Location pos1, Location pos2 , String name) {
|
public static void create(Location pos1, Location pos2 , String name, Material triggerBlockId) {
|
||||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||||
|
|
||||||
config.getConfig().set(name + ".world", pos1.getWorld().getName());
|
config.getConfig().set(name + ".world", pos1.getWorld().getName());
|
||||||
config.getConfig().set(name + ".hastriggerblock", true);
|
config.getConfig().set(name + ".hastriggerblock", true);
|
||||||
|
|
||||||
config.getConfig().set(name + ".triggerblock", triggerBlockId.getId());
|
config.getConfig().set(name + ".triggerblock", triggerBlockId.toString());
|
||||||
|
|
||||||
config.getConfig().set(name + ".pos1.X", pos1.getX());
|
config.getConfig().set(name + ".pos1.X", pos1.getX());
|
||||||
config.getConfig().set(name + ".pos1.Y", pos1.getY());
|
config.getConfig().set(name + ".pos1.Y", pos1.getY());
|
||||||
@ -63,14 +63,12 @@ public class Portal {
|
|||||||
config.getConfig().set(name + ".pos2.Y", pos2.getY());
|
config.getConfig().set(name + ".pos2.Y", pos2.getY());
|
||||||
config.getConfig().set(name + ".pos2.Z", pos2.getZ());
|
config.getConfig().set(name + ".pos2.Z", pos2.getZ());
|
||||||
|
|
||||||
config.getConfig().set(name + ".creator", creator.getName());
|
|
||||||
|
|
||||||
config.saveConfig();
|
config.saveConfig();
|
||||||
|
|
||||||
loadPortals();
|
loadPortals();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void create(Player creator, Location pos1, Location pos2, String name) { // add stuff for destination names or coordinates
|
public static void create(Location pos1, Location pos2, String name) { // add stuff for destination names or coordinates
|
||||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||||
|
|
||||||
config.getConfig().set(name + ".world", pos1.getWorld().getName());
|
config.getConfig().set(name + ".world", pos1.getWorld().getName());
|
||||||
@ -84,12 +82,10 @@ public class Portal {
|
|||||||
config.getConfig().set(name + ".pos2.Y", pos2.getY());
|
config.getConfig().set(name + ".pos2.Y", pos2.getY());
|
||||||
config.getConfig().set(name + ".pos2.Z", pos2.getZ());
|
config.getConfig().set(name + ".pos2.Z", pos2.getZ());
|
||||||
|
|
||||||
config.getConfig().set(name + ".creator", creator.getName());
|
|
||||||
|
|
||||||
loadPortals();
|
loadPortals();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void redefine(Player creator, Location pos1, Location pos2, String name){
|
public static void redefine(Location pos1, Location pos2, String name){
|
||||||
|
|
||||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||||
|
|
||||||
@ -107,7 +103,7 @@ public class Portal {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove(Player creator, String name){
|
public static void remove(String name){
|
||||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||||
|
|
||||||
config.getConfig().set(name + ".world", null);
|
config.getConfig().set(name + ".world", null);
|
||||||
@ -121,8 +117,6 @@ public class Portal {
|
|||||||
config.getConfig().set(name + ".pos2.Y", null);
|
config.getConfig().set(name + ".pos2.Y", null);
|
||||||
config.getConfig().set(name + ".pos2.Z", null);
|
config.getConfig().set(name + ".pos2.Z", null);
|
||||||
|
|
||||||
config.getConfig().set(name + ".creator", null);
|
|
||||||
|
|
||||||
config.saveConfig();
|
config.saveConfig();
|
||||||
|
|
||||||
loadPortals();
|
loadPortals();
|
||||||
|
Loading…
Reference in New Issue
Block a user