Alot of changed and got the portals working

This commit is contained in:
sekwah41 2013-12-15 22:36:07 +00:00
parent 0c1282ef13
commit 2e592c070b
12 changed files with 472 additions and 60 deletions

View File

@ -14,6 +14,12 @@ AxeItemId: IRON_AXE
# Will be implemented so you can give yourself the portal block and build manually with it so its easier to make portals with the portal block.
CanBuildPortalBlock: true
# Defines if portals protect themselves
PortalProtection: true
# How many blocks around the portals will be protected from griefing or destruction
PortalProtectionRadius: 5
# What the default trigger block is for portals if nothing is defined.
DefaultPortalTriggerBlock: PORTAL

View File

@ -2,7 +2,7 @@
# ExamplePortal:
# world: it will be the world name
# triggerblock: LAVA # will only be used if the hastriggerblock is true and can be id or text
# pos1:
# pos1: # dont mess with the data here, if you do it may stop the portal from working.
# X:
# Y:
# Z:

View File

@ -183,10 +183,16 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
else if(args[0].toLowerCase().equals("select")) {
}
else if(args[0].toLowerCase().equals("reload")) {
player.sendMessage("§a[§eAdvancedPortals§a] Reloaded values!");
Listeners.reloadValues(plugin);
Portal.loadPortals();
else if(args[0].toLowerCase().equals("remove")) {
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Portals.yml");
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if(posX != null){
Portal.remove(args[1]);
sender.sendMessage("§a[§eAdvancedPortals§a] Portal removed!");
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] No portal by that name exists!");
}
}
else if(args[0].toLowerCase().equals("bukkitpage")) {
player.sendMessage("§a[§eAdvancedPortals§a] Bukkit page: (insert bitly link)!");
@ -234,7 +240,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", "reload", "select", "selector"
autoComplete.addAll(Arrays.asList("create", "portal", "portalblock", "select", "selector"
, "show", "variables", "wand", "remove", "rename", "help", "bukkitpage", "helppage"));
}
else if(args[0].toLowerCase().equals("create")){

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import org.bukkit.plugin.java.JavaPlugin;
import com.sekwah.advancedportals.DataCollector.DataCollector;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.metrics.Metrics;
import com.sekwah.advancedportals.portalcontrolls.Portal;
@ -31,6 +32,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
new Portal(this);
new Destination(this);
new DataCollector(this);
// These register the commands
new AdvancedPortalsCommand(this);
new DestinationCommand(this);
@ -40,6 +43,7 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
new Listeners(this);
new FlowStopper(this);
new PortalProtect(this);
new PortalPlacer(this);
Selection.LoadData(this);

View File

@ -0,0 +1,84 @@
package com.sekwah.advancedportals.DataCollector;
import java.io.IOException;
import java.util.logging.Level;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.metrics.Metrics;
import com.sekwah.advancedportals.metrics.Metrics.Graph;
public class DataCollector {
private static AdvancedPortalsPlugin plugin;
public DataCollector(AdvancedPortalsPlugin plugin) {
DataCollector.plugin = plugin;
}
/**
*
* This is currently being tested as it doesn't fully work at the moment.
*
*/
public static void playerWarped() {
try {
Metrics metrics = new Metrics(plugin);
Graph TotalWarps = metrics.createGraph("Total Warps");
TotalWarps.addPlotter(new Metrics.Plotter("Internal Warps") {
@Override
public int getValue() {
return 1; // number of warps
}
});
/**TotalWarps.addPlotter(new Metrics.Plotter("Iron Sword") {
// can be used to add more data to the graph, can be in a pie chart or multiple lines on one graph
@Override
public int getValue() {
return 17;
}
});*/
metrics.start();
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Could not submit data", e);
}
}
public static void portalCreated(String triggerName) {
try {
Metrics metrics = new Metrics(plugin);
Graph TotalWarps = metrics.createGraph("Portal Trigger Blocks");
TotalWarps.addPlotter(new Metrics.Plotter(triggerName) {
@Override
public int getValue() {
return 1; // number of portals created
}
});
/**TotalWarps.addPlotter(new Metrics.Plotter("Iron Sword") {
// can be used to add more data to the graph, can be in a pie chart or multiple lines on one graph
@Override
public int getValue() {
return 17;
}
});*/
metrics.start();
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Could not submit data", e);
}
}
}

View File

@ -34,7 +34,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
String posX = config.getConfig().getString(args[1].toLowerCase() + ".pos.X");
if(posX == null){
sender.sendMessage("§c[§7AdvancedPortals§c] You have created a new destination called " + args[1] + "!");
sender.sendMessage("§a[§eAdvancedPortals§a] You have created a new destination called " + args[1] + "!");
Player player = sender.getServer().getPlayer(sender.getName());
Destination.create(player.getLocation(), args[1]);
}

View File

@ -7,6 +7,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class FlowStopper implements Listener {
@SuppressWarnings("unused")
@ -27,22 +29,41 @@ public class FlowStopper implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.HIGH)
public void onBlockFromTo(BlockFromToEvent event) {
// when checking positions check the block and the to block
Block blockTo = event.getToBlock();
Block block = event.getBlock();
if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER
|| blockTo.getType() == Material.WATER || blockTo.getType() == Material.STATIONARY_WATER) {
Object[] portals = Portal.Portals;
int portalId = 0;
for(Object portal : portals){
if(Portal.worldName[portalId].equals(block.getWorld().getName())){
event.setCancelled(true);
if((Portal.pos1[portalId].getX() + 3D) >= block.getX() && (Portal.pos1[portalId].getY() + 3D) >= block.getY() && (Portal.pos1[portalId].getZ() + 3D) >= block.getZ()){
}
else if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA
|| blockTo.getType() == Material.LAVA || blockTo.getType() == Material.STATIONARY_LAVA) {
if((Portal.pos2[portalId].getX() - 3D) <= block.getX() && (Portal.pos2[portalId].getY() - 3D) <= block.getY() && (Portal.pos2[portalId].getZ() - 3D) <= block.getZ()){
event.setCancelled(true);
event.setCancelled(true);
}
}
}
if(Portal.worldName[portalId].equals(blockTo.getWorld().getName())){
if((Portal.pos1[portalId].getX() + 3D) >= blockTo.getX() && (Portal.pos1[portalId].getY() + 3D) >= blockTo.getY() && (Portal.pos1[portalId].getZ() + 3D) >= blockTo.getZ()){
if((Portal.pos2[portalId].getX() - 3D) <= blockTo.getX() && (Portal.pos2[portalId].getY() - 3D) <= blockTo.getY() && (Portal.pos2[portalId].getZ() - 3D) <= blockTo.getZ()){
event.setCancelled(true);
}
}
}
portalId++;
}
}

View File

@ -1,17 +1,20 @@
package com.sekwah.advancedportals;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.event.player.PlayerPortalEvent;
import com.sekwah.advancedportals.DataCollector.DataCollector;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class Listeners implements Listener {
@ -63,13 +66,42 @@ public class Listeners implements Listener {
}
}
@EventHandler
@EventHandler(priority = EventPriority.HIGHEST)
public void onMoveEvent(PlayerMoveEvent event) {
// will check if the player is in the portal or not.
Object[] portals = Portal.Portals;
for(Object portal : portals){
System.out.println("Checking " + portal.toString());
if(Portal.portalsActive){
Player player = event.getPlayer();
Location loc = player.getLocation();
Object[] portals = Portal.Portals;
int portalId = 0;
for(Object portal : portals){
if(Portal.worldName[portalId].equals(player.getWorld().getName())){
if(Portal.triggers[portalId].equals(player.getLocation().getBlock().getType())
|| Portal.triggers[portalId].equals(player.getEyeLocation().getBlock().getType())){
if((Portal.pos1[portalId].getX() + 1D) >= loc.getX() && (Portal.pos1[portalId].getY() + 1D) >= loc.getY() && (Portal.pos1[portalId].getZ() + 1D) >= loc.getZ()){
if(Portal.pos2[portalId].getX() <= loc.getX() && Portal.pos2[portalId].getY() <= loc.getY() && Portal.pos2[portalId].getZ() <= loc.getZ()){
Portal.activate(player, portal.toString());
DataCollector.playerWarped();
final Player finalplayer = event.getPlayer();
if(player.getGameMode().equals(GameMode.CREATIVE)){
player.setMetadata("HasWarped", new FixedMetadataValue(plugin, true));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
finalplayer.removeMetadata("HasWarped", plugin);
}
}, 20);
}
}
}
}
}
portalId++;
}
}
}
@ -77,7 +109,36 @@ public class Listeners implements Listener {
@SuppressWarnings("deprecation")
@EventHandler
public void onPortalEvent(PlayerPortalEvent event) {
// check if the portal is inside the region so it doesnt teleport you to the nether
if(Portal.portalsActive){
Player player = event.getPlayer();
if(player.hasMetadata("HasWarped")){
event.setCancelled(true);
return;
}
Location loc = player.getLocation();
Object[] portals = Portal.Portals;
int portalId = 0;
for(Object portal : portals){
if(Portal.worldName[portalId].equals(player.getWorld().getName())){
if((Portal.pos1[portalId].getX() + 3D) >= loc.getX() && (Portal.pos1[portalId].getY() + 3D) >= loc.getY() && (Portal.pos1[portalId].getZ() + 3D) >= loc.getZ()){
if((Portal.pos2[portalId].getX() - 3D) <= loc.getX() && (Portal.pos2[portalId].getY() - 3D) <= loc.getY() && (Portal.pos2[portalId].getZ() - 3D) <= loc.getZ()){
event.setCancelled(true);
}
}
}
portalId++;
}
}
}
@SuppressWarnings("deprecation")

View File

@ -0,0 +1,117 @@
package com.sekwah.advancedportals;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class PortalProtect implements Listener {
@SuppressWarnings("unused")
private final AdvancedPortalsPlugin plugin;
// The needed config values will be stored so they are easier to access later
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("§eP...
private boolean PortalProtect = true;
private double PortalProtectionRadius = 5D;
public PortalProtect(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
this.PortalProtect = config.getConfig().getBoolean("PortalProtection");
this.PortalProtectionRadius = config.getConfig().getDouble("PortalProtectionRadius");
if(PortalProtect){
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event){
if(!event.getPlayer().hasPermission("advancedportals.build")){
Block block = event.getBlock();
Object[] portals = Portal.Portals;
int portalId = 0;
for(Object portal : portals){
if(Portal.worldName[portalId].equals(block.getWorld().getName())){
if((Portal.pos1[portalId].getX() + PortalProtectionRadius) >= block.getX() && (Portal.pos1[portalId].getY() + PortalProtectionRadius) >= block.getY() && (Portal.pos1[portalId].getZ() + PortalProtectionRadius) >= block.getZ()){
if((Portal.pos2[portalId].getX() - PortalProtectionRadius) <= block.getX() && (Portal.pos2[portalId].getY() - PortalProtectionRadius) <= block.getY() && (Portal.pos2[portalId].getZ() - PortalProtectionRadius) <= block.getZ()){
event.setCancelled(true);
}
}
}
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event){
if(!event.getPlayer().hasPermission("advancedportals.build")){
Block block = event.getBlock();
Object[] portals = Portal.Portals;
int portalId = 0;
for(Object portal : portals){
if(Portal.worldName[portalId].equals(block.getWorld().getName())){
if((Portal.pos1[portalId].getX() + PortalProtectionRadius) >= block.getX() && (Portal.pos1[portalId].getY() + PortalProtectionRadius) >= block.getY() && (Portal.pos1[portalId].getZ() + PortalProtectionRadius) >= block.getZ()){
if((Portal.pos2[portalId].getX() - PortalProtectionRadius) <= block.getX() && (Portal.pos2[portalId].getY() - PortalProtectionRadius) <= block.getY() && (Portal.pos2[portalId].getZ() - PortalProtectionRadius) <= block.getZ()){
event.setCancelled(true);
}
}
}
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onExplosion(EntityExplodeEvent event){
List<Block> blockList = event.blockList();
for (int i = 0; i < blockList.size(); i++) {
Block block = blockList.get(i);
Object[] portals = Portal.Portals;
int portalId = 0;
for(Object portal : portals){ // change for format for(int i = 0; i < portals.length; i++){
if(Portal.worldName[portalId].equals(block.getWorld().getName())){
if((Portal.pos1[portalId].getX() + PortalProtectionRadius) >= block.getX() && (Portal.pos1[portalId].getY() + PortalProtectionRadius) >= block.getY() && (Portal.pos1[portalId].getZ() + PortalProtectionRadius) >= block.getZ()){
if((Portal.pos2[portalId].getX() - PortalProtectionRadius) <= block.getX() && (Portal.pos2[portalId].getY() - PortalProtectionRadius) <= block.getY() && (Portal.pos2[portalId].getZ() - PortalProtectionRadius) <= block.getZ()){
blockList.remove(i);
}
}
}
}
}
}
}

View File

@ -1,6 +1,9 @@
package com.sekwah.advancedportals.destinations;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
@ -21,6 +24,9 @@ public class Destination {
config.getConfig().set(name.toLowerCase() + ".pos.Y", location.getY());
config.getConfig().set(name.toLowerCase() + ".pos.Z", location.getZ());
config.getConfig().set(name.toLowerCase() + ".pos.pitch", location.getPitch());
config.getConfig().set(name.toLowerCase() + ".pos.yaw", location.getYaw());
config.saveConfig();
}
@ -33,17 +39,23 @@ public class Destination {
config.getConfig().set(name.toLowerCase() + ".pos.Y", location.getY());
config.getConfig().set(name.toLowerCase() + ".pos.Z", location.getZ());
config.getConfig().set(name.toLowerCase() + ".pos.pitch", location.getPitch());
config.getConfig().set(name.toLowerCase() + ".pos.yaw", location.getYaw());
config.saveConfig();
}
public static 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.toLowerCase() + ".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"));
config.getConfig().set(newName.toLowerCase() + ".pos.X", config.getConfig().getDouble(oldName + ".pos.X"));
config.getConfig().set(newName.toLowerCase() + ".pos.Y", config.getConfig().getDouble(oldName + ".pos.Y"));
config.getConfig().set(newName.toLowerCase() + ".pos.Z", config.getConfig().getDouble(oldName + ".pos.Z"));
config.getConfig().set(newName.toLowerCase() + ".pos.pitch", config.getConfig().getDouble(oldName + ".pos.pitch"));
config.getConfig().set(newName.toLowerCase() + ".pos.yaw", config.getConfig().getDouble(oldName + ".pos.yaw"));
remove(oldName);
@ -53,12 +65,38 @@ public class Destination {
public static void remove(String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
config.getConfig().set(name + ".world", null);
config.getConfig().set(name.toLowerCase() + ".world", null);
config.getConfig().set(name + ".pos.X", null);
config.getConfig().set(name + ".pos.Y", null);
config.getConfig().set(name + ".pos.Z", null);
config.getConfig().set(name.toLowerCase() + ".pos.X", null);
config.getConfig().set(name.toLowerCase() + ".pos.Y", null);
config.getConfig().set(name.toLowerCase() + ".pos.Z", null);
config.getConfig().set(name.toLowerCase() + ".pos.pitch", null);
config.getConfig().set(name.toLowerCase() + ".pos.yaw", null);
config.getConfig().set(name.toLowerCase() + ".pos", null);
config.getConfig().set(name.toLowerCase(), null);
config.saveConfig();
}
public static void warp(Player player, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
if(config.getConfig().getString(name + ".world") != null){
Location loc = player.getLocation();
loc.setWorld(Bukkit.getWorld(config.getConfig().getString(name + ".world")));
loc.setX(config.getConfig().getDouble(name + ".pos.X"));
loc.setY(config.getConfig().getDouble(name + ".pos.Y"));
loc.setZ(config.getConfig().getDouble(name + ".pos.Z"));
loc.setPitch((float) config.getConfig().getDouble(name + ".pos.pitch"));
loc.setYaw((float) config.getConfig().getDouble(name + ".pos.yaw"));
player.teleport(loc);
}
}
}

View File

@ -2,22 +2,28 @@ package com.sekwah.advancedportals.portalcontrolls;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.DataCollector.DataCollector;
import com.sekwah.advancedportals.destinations.Destination;
public class Portal {
private static AdvancedPortalsPlugin plugin;
public static String[] Portals;
public static boolean portalsActive = true;
public static Object[] Portals;
public static Material[] triggers;
public static World[] world;
public static String[] worldName;
public static Location[] pos1;
@ -41,32 +47,81 @@ public class Portal {
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
Set<String> PortalSet = config.getConfig().getKeys(false);
Portals = (String[]) PortalSet.toArray();
int portalId = 0;
for(String portal: Portals){
portal.toString();
Material blockType;
String BlockID = config.getConfig().getString(portal.toString() + ".triggerblock");
try
{
blockType = Material.getMaterial(Integer.parseInt(BlockID));
}
catch(Exception e)
{
blockType = Material.getMaterial(BlockID);
}
triggers[portalId] = blockType;
world[portalId] = org.bukkit.Bukkit.getWorld(config.getConfig().getString(portal.toString() + ".world"));
pos1[portalId] = new Location(world[portalId], config.getConfig().getInt(portal.toString() + ".pos1.X"), config.getConfig().getInt(portal.toString() + ".pos1.Y"), config.getConfig().getInt(portal.toString() + ".pos1.Z"));
pos2[portalId] = new Location(world[portalId], config.getConfig().getInt(portal.toString() + ".pos2.X"), config.getConfig().getInt(portal.toString() + ".pos2.Y"), config.getConfig().getInt(portal.toString() + ".pos2.Z"));
portalId++;
if(PortalSet.size() > 0){
Portals = PortalSet.toArray();
// allocates the memory for the arrays
worldName = new String[Portals.length];
triggers = new Material[Portals.length];
pos1 = new Location[Portals.length];
pos2 = new Location[Portals.length];
int portalId = 0;
for(Object portal: Portals){
Material blockType;
String BlockID = config.getConfig().getString(portal.toString() + ".triggerblock");
try
{
blockType = Material.getMaterial(Integer.parseInt(BlockID));
}
catch(Exception e)
{
blockType = Material.getMaterial(BlockID);
}
triggers[portalId] = blockType;
worldName[portalId] = config.getConfig().getString(portal.toString() + ".world");
World world = Bukkit.getWorld(config.getConfig().getString(portal.toString() + ".world"));
pos1[portalId] = new Location(world, config.getConfig().getInt(portal.toString() + ".pos1.X"), config.getConfig().getInt(portal.toString() + ".pos1.Y"), config.getConfig().getInt(portal.toString() + ".pos1.Z"));
pos2[portalId] = new Location(world, config.getConfig().getInt(portal.toString() + ".pos2.X"), config.getConfig().getInt(portal.toString() + ".pos2.Y"), config.getConfig().getInt(portal.toString() + ".pos2.Z"));
portalId++;
}
portalsActive = true;
}
else{
portalsActive = false;
}
}
public static void create(Location pos1, Location pos2 , String name, String destination , Material triggerBlockId) {
int LowX = 0;
int LowY = 0;
int LowZ = 0;
int HighX = 0;
int HighY = 0;
int HighZ = 0;
if(pos1.getX() > pos2.getX()){
LowX = (int) pos2.getX();
HighX = (int) pos1.getX();
}
else{
LowX = (int) pos1.getX();
HighX = (int) pos2.getX();
}
if(pos1.getY() > pos2.getY()){
LowY = (int) pos2.getY();
HighY = (int) pos1.getY();
}
else{
LowY = (int) pos1.getY();
HighY = (int) pos2.getY();
}
if(pos1.getZ() > pos2.getZ()){
LowZ = (int) pos2.getZ();
HighZ = (int) pos1.getZ();
}
else{
LowZ = (int) pos1.getZ();
HighZ = (int) pos2.getZ();
}
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
config.getConfig().set(name.toLowerCase() + ".world", pos1.getWorld().getName());
@ -75,16 +130,18 @@ public class Portal {
config.getConfig().set(name.toLowerCase() + ".destination", destination);
config.getConfig().set(name.toLowerCase() + ".pos1.X", pos1.getX());
config.getConfig().set(name.toLowerCase() + ".pos1.Y", pos1.getY());
config.getConfig().set(name.toLowerCase() + ".pos1.Z", pos1.getZ());
config.getConfig().set(name.toLowerCase() + ".pos1.X", HighX);
config.getConfig().set(name.toLowerCase() + ".pos1.Y", HighY);
config.getConfig().set(name.toLowerCase() + ".pos1.Z", HighZ);
config.getConfig().set(name.toLowerCase() + ".pos2.X", pos2.getX());
config.getConfig().set(name.toLowerCase() + ".pos2.Y", pos2.getY());
config.getConfig().set(name.toLowerCase() + ".pos2.Z", pos2.getZ());
config.getConfig().set(name.toLowerCase() + ".pos2.X", LowX);
config.getConfig().set(name.toLowerCase() + ".pos2.Y", LowY);
config.getConfig().set(name.toLowerCase() + ".pos2.Z", LowZ);
config.saveConfig();
DataCollector.portalCreated(triggerBlockId.toString());
loadPortals();
}
@ -134,7 +191,8 @@ public class Portal {
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
config.getConfig().set(name.toLowerCase() + ".world", null);
config.getConfig().set(name.toLowerCase() + ".hastriggerblock", null);
config.getConfig().set(name.toLowerCase() + ".triggerblock", null);
config.getConfig().set(name.toLowerCase() + ".destination", null);
config.getConfig().set(name.toLowerCase() + ".pos1.X", null);
config.getConfig().set(name.toLowerCase() + ".pos1.Y", null);
@ -144,10 +202,23 @@ public class Portal {
config.getConfig().set(name.toLowerCase() + ".pos2.Y", null);
config.getConfig().set(name.toLowerCase() + ".pos2.Z", null);
config.getConfig().set(name.toLowerCase() + ".pos1", null);
config.getConfig().set(name.toLowerCase() + ".pos2", null);
config.getConfig().set(name.toLowerCase(), null);
config.saveConfig();
loadPortals();
}
public static void activate(Player player, String portalName) {
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
Destination.warp(player, config.getConfig().getString(portalName + ".destination"));
}

View File

@ -17,6 +17,10 @@ permissions:
description: Gives access to all portal commands
children:
advancedportals.createportal: true
advancedportals.build: true
advancedportals.createportal:
description: Allows you to create portals
default: op
advancedportals.build:
description: Allows you to build in the portal regions
default: op