Moving files around

didnt like the Advanced-Portals inside advanced portals folder
This commit is contained in:
sekwah41 2015-01-15 19:56:13 +00:00
parent fee77ff56f
commit 52ced1e3ef
31 changed files with 3018 additions and 3045 deletions

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="C:/Users/Alastair/Documents/NextGenCrafters/Server Plugins/bukkit jars/craftbukkit-1.7.9-R0.2.jar"/>
<classpathentry kind="lib" path="C:/Users/Alastair/Documents/NextGenCrafters/Server Plugins/bukkit jars/spigot-1.7.5-R0.1-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="C:/Users/Alastair/Documents/NextGenCrafters/Server Plugins/bukkit jars/spigot-1.7.2-R0.3-SNAPSHOT.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1 +0,0 @@
/bin

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Advanced Portals</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,67 +1,67 @@
# Advanced Portals Config
# To set this file back to its default state just delete it and reload the server or restart it!
# Set to true if you want the normal axes to work normally but the ones gived with /portals selector or wand will still work though
# It can be usefull if people with permission want to use an iron axe on a survival server
UseOnlyServerMadeAxe: false
# Preferably an item and not a block but it shouldnt matter
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
# This stops all water flowing inside a portal area(can be disabled if something like world edit is handelling the water flow or you dont want it active)
# you want to
StopWaterFlow: true
# This must be a placeable block or it will not work and may even crash
ShowSelectionBlockID: STAINED_GLASS
ShowSelectionBlockData: 14
# WarpEffect
# 0 = disabled(no particles)
# 1 = Eye of ender explode efffect(loads of portal particles)
WarpParticles: 1
# WarpSound generally suggested to keep the same as warpeffect but can usually be used for just the sound and no particle effects
# 0 = disabled(no sound)
# 1 = Enderman Warp Sound
WarpSound: 1
# In case you want to show the bungee attempting warp message
ShowBungeeWarpMessage: false
# This changes how long the show seletion lasts in seconds
ShowSelectionShowDuration: 10
# If a player is riding a entity, warp the entity too?(unless its a bungee portal)
WarpRiddenEntity: true
# Use the default warp messages for portals
PortalWarpMessages: true
# Use plugin name in the warp messages
UseWarpPrefix: true
# If this is true a custom prefix can be used
UseCustomPrefix: false
CustomPrefix: '[Test]'
# Advanced Portals Config
# To set this file back to its default state just delete it and reload the server or restart it!
# Set to true if you want the normal axes to work normally but the ones gived with /portals selector or wand will still work though
# It can be usefull if people with permission want to use an iron axe on a survival server
UseOnlyServerMadeAxe: false
# Preferably an item and not a block but it shouldnt matter
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
# This stops all water flowing inside a portal area(can be disabled if something like world edit is handelling the water flow or you dont want it active)
# you want to
StopWaterFlow: true
# This must be a placeable block or it will not work and may even crash
ShowSelectionBlockID: STAINED_GLASS
ShowSelectionBlockData: 14
# WarpEffect
# 0 = disabled(no particles)
# 1 = Eye of ender explode efffect(loads of portal particles)
WarpParticles: 1
# WarpSound generally suggested to keep the same as warpeffect but can usually be used for just the sound and no particle effects
# 0 = disabled(no sound)
# 1 = Enderman Warp Sound
WarpSound: 1
# In case you want to show the bungee attempting warp message
ShowBungeeWarpMessage: false
# This changes how long the show seletion lasts in seconds
ShowSelectionShowDuration: 10
# If a player is riding a entity, warp the entity too?(unless its a bungee portal)
WarpRiddenEntity: true
# Use the default warp messages for portals
PortalWarpMessages: true
# Use plugin name in the warp messages
UseWarpPrefix: true
# If this is true a custom prefix can be used
UseCustomPrefix: false
CustomPrefix: '[Test]'

View File

@ -1,7 +1,7 @@
# ExampleDestination:
# world: it will be the world name
# pos:
# X:
# Y:
# Z:
# ExampleDestination:
# world: it will be the world name
# pos:
# X:
# Y:
# Z:

View File

@ -1,19 +1,19 @@
# 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: # dont mess with the data here, if you do it may stop the portal from working.
# X:
# Y:
# Z:
# pos2:
# X:
# Y:
# Z:
# destination:
# issetpoint: true # if this was false point name would not be used and the coordinates would be saved here, it just adds more customisation.
# pointname: examplepoint # if issetpoint is false this wont be here and tppos will be.
# tppos:
# X:
# Y:
# Z:
# 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: # dont mess with the data here, if you do it may stop the portal from working.
# X:
# Y:
# Z:
# pos2:
# X:
# Y:
# Z:
# destination:
# issetpoint: true # if this was false point name would not be used and the coordinates would be saved here, it just adds more customisation.
# pointname: examplepoint # if issetpoint is false this wont be here and tppos will be.
# tppos:
# X:
# Y:
# Z:

View File

@ -1,106 +1,106 @@
package com.sekwah.advancedportals;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import org.bukkit.plugin.java.JavaPlugin;
import com.sekwah.advancedportals.DataCollector.DataCollector;
import com.sekwah.advancedportals.compat.NMS;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.metrics.Metrics;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class AdvancedPortalsPlugin extends JavaPlugin {
public NMS nmsAccess;
public void onEnable() {
try {
Metrics metrics = new Metrics(this);
metrics.start();
} catch (IOException e) {
// Failed to submit the stats :-(
}
this.getServer().getConsoleSender().sendMessage("§aAdvanced portals have been sucsessfully enabled!");
String packageName = getServer().getClass().getPackage().getName();
String[] packageSplit = packageName.split("\\.");
String version = packageSplit[packageSplit.length - 1];
try {
Class<?> nmsClass = Class.forName("com.sekwah.advancedportals.compat." + version);
if(NMS.class.isAssignableFrom(nmsClass)){
this.nmsAccess = (NMS) nmsClass.getConstructor().newInstance();
}else
{
System.out.println("Something went wrong, please notify the author and tell them this version v:" + version);
this.setEnabled(false);
}
} catch (ClassNotFoundException e) {
System.out.println("This version of craftbukkit is not yet supported, please notify the author and give them this version v:" + version);
this.setEnabled(false);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
}
new Assets(this);
// Opens a channel that messages bungeeCord
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
// thanks to the new config accessor code the config.saveDefaultConfig(); will now
// only copy the file if it doesnt exist!
ConfigAccessor config = new ConfigAccessor(this, "Config.yml");
config.saveDefaultConfig();
ConfigAccessor portalconfig = new ConfigAccessor(this, "Portals.yml");
portalconfig.saveDefaultConfig();
ConfigAccessor destinationconfig = new ConfigAccessor(this, "Destinations.yml");
destinationconfig.saveDefaultConfig();
// Loads the portal and destination editors
new Portal(this);
new Destination(this);
new DataCollector(this);
// These register the commands
new AdvancedPortalsCommand(this);
new DestinationCommand(this);
new WarpCommand(this);
// These register the listeners
new Listeners(this);
new FlowStopper(this);
new PortalProtect(this);
new PortalPlacer(this);
Selection.LoadData(this);
DataCollector.setupMetrics();
}
public void onDisable() {
this.getServer().getConsoleSender().sendMessage("§cAdvanced portals are being disabled!");
}
}
package com.sekwah.advancedportals;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import org.bukkit.plugin.java.JavaPlugin;
import com.sekwah.advancedportals.DataCollector.DataCollector;
import com.sekwah.advancedportals.compat.NMS;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.metrics.Metrics;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class AdvancedPortalsPlugin extends JavaPlugin {
public NMS nmsAccess;
public void onEnable() {
try {
Metrics metrics = new Metrics(this);
metrics.start();
} catch (IOException e) {
// Failed to submit the stats :-(
}
this.getServer().getConsoleSender().sendMessage("§aAdvanced portals have been sucsessfully enabled!");
String packageName = getServer().getClass().getPackage().getName();
String[] packageSplit = packageName.split("\\.");
String version = packageSplit[packageSplit.length - 1];
try {
Class<?> nmsClass = Class.forName("com.sekwah.advancedportals.compat." + version);
if(NMS.class.isAssignableFrom(nmsClass)){
this.nmsAccess = (NMS) nmsClass.getConstructor().newInstance();
}else
{
System.out.println("Something went wrong, please notify the author and tell them this version v:" + version);
this.setEnabled(false);
}
} catch (ClassNotFoundException e) {
System.out.println("This version of craftbukkit is not yet supported, please notify the author and give them this version v:" + version);
this.setEnabled(false);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
}
new Assets(this);
// Opens a channel that messages bungeeCord
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
// thanks to the new config accessor code the config.saveDefaultConfig(); will now
// only copy the file if it doesnt exist!
ConfigAccessor config = new ConfigAccessor(this, "Config.yml");
config.saveDefaultConfig();
ConfigAccessor portalconfig = new ConfigAccessor(this, "Portals.yml");
portalconfig.saveDefaultConfig();
ConfigAccessor destinationconfig = new ConfigAccessor(this, "Destinations.yml");
destinationconfig.saveDefaultConfig();
// Loads the portal and destination editors
new Portal(this);
new Destination(this);
new DataCollector(this);
// These register the commands
new AdvancedPortalsCommand(this);
new DestinationCommand(this);
new WarpCommand(this);
// These register the listeners
new Listeners(this);
new FlowStopper(this);
new PortalProtect(this);
new PortalPlacer(this);
Selection.LoadData(this);
DataCollector.setupMetrics();
}
public void onDisable() {
this.getServer().getConsoleSender().sendMessage("§cAdvanced portals are being disabled!");
}
}

View File

@ -1,15 +1,15 @@
package com.sekwah.advancedportals;
public class Assets {
public static int currentWarpParticles = 0;
public static int currentWarpSound = 0;
public Assets(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
currentWarpParticles = config.getConfig().getInt("WarpParticles");
currentWarpSound = config.getConfig().getInt("WarpSound");
}
}
package com.sekwah.advancedportals;
public class Assets {
public static int currentWarpParticles = 0;
public static int currentWarpSound = 0;
public Assets(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
currentWarpParticles = config.getConfig().getInt("WarpParticles");
currentWarpSound = config.getConfig().getInt("WarpSound");
}
}

View File

@ -1,82 +1,82 @@
package com.sekwah.advancedportals;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
public class ConfigAccessor {
private final String fileName;
private final JavaPlugin plugin;
private File configFile;
private FileConfiguration fileConfiguration;
public ConfigAccessor(JavaPlugin plugin, String fileName) {
if (!plugin.isInitialized())
throw new IllegalArgumentException("plugin must be initiaized");
this.plugin = plugin;
this.fileName = fileName;
}
// gets all of the
public void reloadConfig() {
if (configFile == null) {
File dataFolder = plugin.getDataFolder();
if (dataFolder == null)
throw new IllegalStateException();
configFile = new File(dataFolder, fileName);
}
fileConfiguration = YamlConfiguration.loadConfiguration(configFile);
// Look for defaults in the jar
InputStream defConfigStream = plugin.getResource(fileName);
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
fileConfiguration.setDefaults(defConfig);
}
}
public FileConfiguration getConfig() {
if (fileConfiguration == null) {
this.reloadConfig();
}
return fileConfiguration;
}
// Saves all the data to the selected yml file
public void saveConfig() {
if (fileConfiguration == null || configFile == null) {
return;
} else {
try {
getConfig().save(configFile);
} catch (IOException ex) {
plugin.getLogger().log(Level.SEVERE, "Could not save config to " + configFile, ex);
}
}
}
// Saves
/**public void saveDefaultConfig() {
if (!configFile.exists()) {
this.plugin.saveResource(fileName, false);
}
}*/
// New save default config saving code, it checks if the needed config is in the jar file before
// overriding it.
public void saveDefaultConfig() {
if (configFile == null) {
configFile = new File(plugin.getDataFolder(), fileName);
}
if (!configFile.exists()) {
plugin.saveResource(fileName, false);
}
}
package com.sekwah.advancedportals;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
public class ConfigAccessor {
private final String fileName;
private final JavaPlugin plugin;
private File configFile;
private FileConfiguration fileConfiguration;
public ConfigAccessor(JavaPlugin plugin, String fileName) {
if (!plugin.isInitialized())
throw new IllegalArgumentException("plugin must be initiaized");
this.plugin = plugin;
this.fileName = fileName;
}
// gets all of the
public void reloadConfig() {
if (configFile == null) {
File dataFolder = plugin.getDataFolder();
if (dataFolder == null)
throw new IllegalStateException();
configFile = new File(dataFolder, fileName);
}
fileConfiguration = YamlConfiguration.loadConfiguration(configFile);
// Look for defaults in the jar
InputStream defConfigStream = plugin.getResource(fileName);
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
fileConfiguration.setDefaults(defConfig);
}
}
public FileConfiguration getConfig() {
if (fileConfiguration == null) {
this.reloadConfig();
}
return fileConfiguration;
}
// Saves all the data to the selected yml file
public void saveConfig() {
if (fileConfiguration == null || configFile == null) {
return;
} else {
try {
getConfig().save(configFile);
} catch (IOException ex) {
plugin.getLogger().log(Level.SEVERE, "Could not save config to " + configFile, ex);
}
}
}
// Saves
/**public void saveDefaultConfig() {
if (!configFile.exists()) {
this.plugin.saveResource(fileName, false);
}
}*/
// New save default config saving code, it checks if the needed config is in the jar file before
// overriding it.
public void saveDefaultConfig() {
if (configFile == null) {
configFile = new File(plugin.getDataFolder(), fileName);
}
if (!configFile.exists()) {
plugin.saveResource(fileName, false);
}
}
}

View File

@ -1,77 +1,77 @@
package com.sekwah.advancedportals.DataCollector;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
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;
import com.sekwah.advancedportals.portalcontrolls.AdvancedPortal;
import com.sekwah.advancedportals.portalcontrolls.Portal;
import org.bukkit.Material;
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
}
});
metrics.start();
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Could not submit data", e);
}
}*/
public static void setupMetrics() {
try {
Metrics metrics = new Metrics(plugin);
Graph TotalWarps = metrics.createGraph("Portal Trigger Blocks");
/**List<Material> MaterialList = new ArrayList<Material>();
for(AdvancedPortal portal : Portal.Portals){
MaterialList.add(portal.trigger);
}*/
/**TotalWarps.addPlotter(new Metrics.Plotter(triggerName) {
@Override
public int getValue() {
return 1; // number of portals created
}
});*/
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Could not submit data", e);
}
}
}
package com.sekwah.advancedportals.DataCollector;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
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;
import com.sekwah.advancedportals.portalcontrolls.AdvancedPortal;
import com.sekwah.advancedportals.portalcontrolls.Portal;
import org.bukkit.Material;
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
}
});
metrics.start();
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Could not submit data", e);
}
}*/
public static void setupMetrics() {
try {
Metrics metrics = new Metrics(plugin);
Graph TotalWarps = metrics.createGraph("Portal Trigger Blocks");
/**List<Material> MaterialList = new ArrayList<Material>();
for(AdvancedPortal portal : Portal.Portals){
MaterialList.add(portal.trigger);
}*/
/**TotalWarps.addPlotter(new Metrics.Plotter(triggerName) {
@Override
public int getValue() {
return 1; // number of portals created
}
});*/
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Could not submit data", e);
}
}
}

View File

@ -1,162 +1,162 @@
package com.sekwah.advancedportals;
import java.util.Arrays;
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;
import org.bukkit.command.CommandSender;
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 {
private AdvancedPortalsPlugin plugin;
public DestinationCommand(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
plugin.getCommand("destination").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
if(args.length > 0){
if(args[0].toLowerCase().equals("create")){
if(sender.hasPermission("AdvancedPortals.create")){
if(args.length > 1){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
String posX = config.getConfig().getString(args[1].toLowerCase() + ".pos.X");
if(posX == null){
sender.sendMessage("§a[§eAdvancedPortals§a] You have created a new destination called §e" + args[1] + "!");
Player player = sender.getServer().getPlayer(sender.getName());
Destination.create(player.getLocation(), args[1]);
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] A destination by that name already exists!");
}
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] Please state the name of the destination you would like to create!");
}
}
else{
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 if(args[0].toLowerCase().equals("goto") || args[0].toLowerCase().equals("warp")) {
if(args.length > 1){
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 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.");
}
}
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.");
}
}
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] You need to type something after /" + command + ", if you do not know what you can put or would like some help with the commands please type /" + command + " help");
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
LinkedList<String> autoComplete = new LinkedList<String>();
if(sender.hasPermission("AdvancedPortals.CreatePortal")){
if(args.length == 1){
autoComplete.addAll(Arrays.asList("create", "goto", "redefine", "move", "rename", "remove"));
}
else if(args[0].toLowerCase().equals("create")){
}
}
Collections.sort(autoComplete);
for(Object result: autoComplete.toArray()){
if(!result.toString().startsWith(args[args.length - 1])){
autoComplete.remove(result);
}
}
return autoComplete;
}
}
package com.sekwah.advancedportals;
import java.util.Arrays;
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;
import org.bukkit.command.CommandSender;
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 {
private AdvancedPortalsPlugin plugin;
public DestinationCommand(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
plugin.getCommand("destination").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
if(args.length > 0){
if(args[0].toLowerCase().equals("create")){
if(sender.hasPermission("AdvancedPortals.create")){
if(args.length > 1){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
String posX = config.getConfig().getString(args[1].toLowerCase() + ".pos.X");
if(posX == null){
sender.sendMessage("§a[§eAdvancedPortals§a] You have created a new destination called §e" + args[1] + "!");
Player player = sender.getServer().getPlayer(sender.getName());
Destination.create(player.getLocation(), args[1]);
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] A destination by that name already exists!");
}
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] Please state the name of the destination you would like to create!");
}
}
else{
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 if(args[0].toLowerCase().equals("goto") || args[0].toLowerCase().equals("warp")) {
if(args.length > 1){
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 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.");
}
}
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.");
}
}
}
else{
sender.sendMessage("§c[§7AdvancedPortals§c] You need to type something after /" + command + ", if you do not know what you can put or would like some help with the commands please type /" + command + " help");
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
LinkedList<String> autoComplete = new LinkedList<String>();
if(sender.hasPermission("AdvancedPortals.CreatePortal")){
if(args.length == 1){
autoComplete.addAll(Arrays.asList("create", "goto", "redefine", "move", "rename", "remove"));
}
else if(args[0].toLowerCase().equals("create")){
}
}
Collections.sort(autoComplete);
for(Object result: autoComplete.toArray()){
if(!result.toString().startsWith(args[args.length - 1])){
autoComplete.remove(result);
}
}
return autoComplete;
}
}

View File

@ -1,72 +1,72 @@
package com.sekwah.advancedportals;
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.BlockFromToEvent;
import com.sekwah.advancedportals.portalcontrolls.AdvancedPortal;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class FlowStopper 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 WaterFlow = true;
public FlowStopper(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
this.WaterFlow = config.getConfig().getBoolean("StopWaterFlow");
if(WaterFlow){
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
}
@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();
AdvancedPortal[] portals = Portal.Portals;
int portalId = 0;
for(Object portal : portals){
if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + 3D) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= block.getZ()){
if((Portal.Portals[portalId].pos2.getX() - 3D) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= block.getZ()){
event.setCancelled(true);
}
}
}
if(Portal.Portals[portalId].worldName.equals(blockTo.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + 3D) >= blockTo.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= blockTo.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= blockTo.getZ()){
if((Portal.Portals[portalId].pos2.getX() - 3D) <= blockTo.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= blockTo.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= blockTo.getZ()){
event.setCancelled(true);
}
}
}
portalId++;
}
}
}
package com.sekwah.advancedportals;
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.BlockFromToEvent;
import com.sekwah.advancedportals.portalcontrolls.AdvancedPortal;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class FlowStopper 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 WaterFlow = true;
public FlowStopper(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
this.WaterFlow = config.getConfig().getBoolean("StopWaterFlow");
if(WaterFlow){
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
}
@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();
AdvancedPortal[] portals = Portal.Portals;
int portalId = 0;
for(Object portal : portals){
if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + 3D) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= block.getZ()){
if((Portal.Portals[portalId].pos2.getX() - 3D) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= block.getZ()){
event.setCancelled(true);
}
}
}
if(Portal.Portals[portalId].worldName.equals(blockTo.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + 3D) >= blockTo.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= blockTo.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= blockTo.getZ()){
if((Portal.Portals[portalId].pos2.getX() - 3D) <= blockTo.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= blockTo.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= blockTo.getZ()){
event.setCancelled(true);
}
}
}
portalId++;
}
}
}

View File

@ -1,265 +1,265 @@
package com.sekwah.advancedportals;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
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.event.player.PlayerPortalEvent;
import org.bukkit.metadata.FixedMetadataValue;
import com.sekwah.advancedportals.DataCollector.DataCollector;
import com.sekwah.advancedportals.events.WarpEvent;
import com.sekwah.advancedportals.portalcontrolls.AdvancedPortal;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class Listeners implements Listener {
private final AdvancedPortalsPlugin plugin;
private boolean DefaultPortalMessages = true;
// 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 static boolean UseOnlyServerAxe = false;
private static Material WandMaterial;
private static boolean ShowBungeeMessage;
@SuppressWarnings("deprecation")
public Listeners(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
String ItemID = config.getConfig().getString("AxeItemId");
DefaultPortalMessages = config.getConfig().getBoolean("PortalWarpMessages");
try
{
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
}
catch(Exception e)
{
WandMaterial = Material.getMaterial(ItemID);
}
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@SuppressWarnings("deprecation")
public static void reloadValues(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
String ItemID = config.getConfig().getString("AxeItemId");
try
{
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
}
catch(Exception e)
{
WandMaterial = Material.getMaterial(ItemID);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onMoveEvent(PlayerMoveEvent event) {
// will check if the player is in the portal or not.
if(Portal.portalsActive){
Player player = event.getPlayer();
Location fromloc = event.getFrom();
Location loc = event.getTo();
Location eyeloc = event.getTo();
//System.out.println(loc.getBlock().getType()); // for debugging, remove or comment out when not needed
eyeloc.setY(eyeloc.getY() + player.getEyeHeight());
AdvancedPortal[] portals = Portal.Portals;
int portalId = 0;
for(AdvancedPortal portal : portals){
if(Portal.Portals[portalId].worldName.equals(loc.getWorld().getName())){
if(Portal.Portals[portalId].trigger.equals(loc.getBlock().getType())
|| Portal.Portals[portalId].trigger.equals(eyeloc.getBlock().getType())){
if((Portal.Portals[portalId].pos1.getX() + 1D) >= loc.getX() && (Portal.Portals[portalId].pos1.getY() + 1D) >= loc.getY() && (Portal.Portals[portalId].pos1.getZ() + 1D) >= loc.getZ()){
if(Portal.Portals[portalId].pos2.getX() <= loc.getX() && Portal.Portals[portalId].pos2.getY() <= loc.getY() && Portal.Portals[portalId].pos2.getZ() <= loc.getZ()){
WarpEvent warpEvent = new WarpEvent(player, portal.portalName);
plugin.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
boolean warped = Portal.activate(player, portal.portalName);
if(DefaultPortalMessages && warped){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
player.sendMessage("");
player.sendMessage("§a[§eAdvancedPortals§a] You have warped to §e" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination") + ".");
player.sendMessage("");
}
if(!warped){
player.teleport(fromloc);
event.setCancelled(true);
}
}
else{
}
if(Portal.Portals[portalId].trigger.equals(Material.PORTAL)){
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);
}
}, 10);
}
}
}
}
}
}
portalId++;
}
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onPortalEvent(PlayerPortalEvent event) {
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.Portals[portalId].worldName.equals(player.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + 1D) >= loc.getX() && (Portal.Portals[portalId].pos1.getY() + 1D) >= loc.getY() && (Portal.Portals[portalId].pos1.getZ() + 1D) >= loc.getZ()){
if((Portal.Portals[portalId].pos2.getX()) <= loc.getX() && (Portal.Portals[portalId].pos2.getY()) <= loc.getY() && (Portal.Portals[portalId].pos2.getZ()) <= loc.getZ()){
event.setCancelled(true);
}
}
}
portalId++;
}
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void oniteminteract(PlayerInteractEvent event) {
// will detect if the player is using an axe so the points of a portal can be set
// also any other detections such as sign interaction or basic block protection
Player player = event.getPlayer();
if(player.hasMetadata("selectingPortal") && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)){
Block block = event.getClickedBlock();
Object[] portals = Portal.Portals;
int portalId = 0;
for(Object portal : portals){
if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + 3D) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= block.getZ()){
if((Portal.Portals[portalId].pos2.getX() - 3D) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= block.getZ()){
player.sendMessage("§a[§eAdvancedPortals§a] You have selected: §e" + Portal.Portals[portalId].portalName);
// TODO add code somewhere so when a portal is removed or changed if someone has it selected it notifies them
// or removed their selections and tells them, maybe not before this update.
player.removeMetadata("selectingPortal", plugin);
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, Portal.Portals[portalId].portalName)); // adds the name to the metadata of the character
event.setCancelled(true);
player.removeMetadata("selectingPortal", plugin);
return;
}
}
}
portalId++;
}
player.sendMessage("§c[§7AdvancedPortals§c] No portal was selected - if you would like to stop selecting please type §e/portal select §cagain!");
event.setCancelled(true);
return;
}
if(player.hasPermission("AdvancedPortals.CreatePortal")){
// UseOnlyServerMadeAxe being set to true makes is so only the axe generated by the server can be used so other iron axes can be used normally,
// by default its false but it is a nice feature in case the user wants to use the axe normally too, such as a admin playing survival or it being used
// as a weapon.
if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("§ePortal Region Selector")) && event.getPlayer().getItemInHand().getTypeId() == WandMaterial.getId()) {
// This checks if the action was a left or right click and if it was directly effecting a block.
if(event.getAction() == Action.LEFT_CLICK_BLOCK) {
Location blockloc = event.getClickedBlock().getLocation();
// stores the selection as metadata on the character so then it isn't saved anywhere, if the player logs out it will
// have to be selected again if the player joins, also it does not affect any other players.
player.setMetadata("Pos1X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
player.setMetadata("Pos1Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
player.setMetadata("Pos1Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
player.setMetadata("Pos1World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
player.sendMessage("§eYou have selected pos1! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY() + " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
// Stops the event so the block is not damaged
event.setCancelled(true);
// Returns the event so no more code is executed(stops unnecessary code being executed)
return;
}
else if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Location blockloc = event.getClickedBlock().getLocation();
player.setMetadata("Pos2X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
player.setMetadata("Pos2Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
player.setMetadata("Pos2Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
player.setMetadata("Pos2World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
player.sendMessage("§eYou have selected pos2! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY() + " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
// Stops the event so the block is not interacted with
event.setCancelled(true);
// Returns the event so no more code is executed(stops unnecessary code being executed)
return;
}
}
}
}
}
package com.sekwah.advancedportals;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
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.event.player.PlayerPortalEvent;
import org.bukkit.metadata.FixedMetadataValue;
import com.sekwah.advancedportals.DataCollector.DataCollector;
import com.sekwah.advancedportals.events.WarpEvent;
import com.sekwah.advancedportals.portalcontrolls.AdvancedPortal;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class Listeners implements Listener {
private final AdvancedPortalsPlugin plugin;
private boolean DefaultPortalMessages = true;
// 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 static boolean UseOnlyServerAxe = false;
private static Material WandMaterial;
private static boolean ShowBungeeMessage;
@SuppressWarnings("deprecation")
public Listeners(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
String ItemID = config.getConfig().getString("AxeItemId");
DefaultPortalMessages = config.getConfig().getBoolean("PortalWarpMessages");
try
{
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
}
catch(Exception e)
{
WandMaterial = Material.getMaterial(ItemID);
}
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@SuppressWarnings("deprecation")
public static void reloadValues(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
String ItemID = config.getConfig().getString("AxeItemId");
try
{
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
}
catch(Exception e)
{
WandMaterial = Material.getMaterial(ItemID);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onMoveEvent(PlayerMoveEvent event) {
// will check if the player is in the portal or not.
if(Portal.portalsActive){
Player player = event.getPlayer();
Location fromloc = event.getFrom();
Location loc = event.getTo();
Location eyeloc = event.getTo();
//System.out.println(loc.getBlock().getType()); // for debugging, remove or comment out when not needed
eyeloc.setY(eyeloc.getY() + player.getEyeHeight());
AdvancedPortal[] portals = Portal.Portals;
int portalId = 0;
for(AdvancedPortal portal : portals){
if(Portal.Portals[portalId].worldName.equals(loc.getWorld().getName())){
if(Portal.Portals[portalId].trigger.equals(loc.getBlock().getType())
|| Portal.Portals[portalId].trigger.equals(eyeloc.getBlock().getType())){
if((Portal.Portals[portalId].pos1.getX() + 1D) >= loc.getX() && (Portal.Portals[portalId].pos1.getY() + 1D) >= loc.getY() && (Portal.Portals[portalId].pos1.getZ() + 1D) >= loc.getZ()){
if(Portal.Portals[portalId].pos2.getX() <= loc.getX() && Portal.Portals[portalId].pos2.getY() <= loc.getY() && Portal.Portals[portalId].pos2.getZ() <= loc.getZ()){
WarpEvent warpEvent = new WarpEvent(player, portal.portalName);
plugin.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
boolean warped = Portal.activate(player, portal.portalName);
if(DefaultPortalMessages && warped){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
player.sendMessage("");
player.sendMessage("§a[§eAdvancedPortals§a] You have warped to §e" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination") + ".");
player.sendMessage("");
}
if(!warped){
player.teleport(fromloc);
event.setCancelled(true);
}
}
else{
}
if(Portal.Portals[portalId].trigger.equals(Material.PORTAL)){
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);
}
}, 10);
}
}
}
}
}
}
portalId++;
}
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onPortalEvent(PlayerPortalEvent event) {
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.Portals[portalId].worldName.equals(player.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + 1D) >= loc.getX() && (Portal.Portals[portalId].pos1.getY() + 1D) >= loc.getY() && (Portal.Portals[portalId].pos1.getZ() + 1D) >= loc.getZ()){
if((Portal.Portals[portalId].pos2.getX()) <= loc.getX() && (Portal.Portals[portalId].pos2.getY()) <= loc.getY() && (Portal.Portals[portalId].pos2.getZ()) <= loc.getZ()){
event.setCancelled(true);
}
}
}
portalId++;
}
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void oniteminteract(PlayerInteractEvent event) {
// will detect if the player is using an axe so the points of a portal can be set
// also any other detections such as sign interaction or basic block protection
Player player = event.getPlayer();
if(player.hasMetadata("selectingPortal") && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)){
Block block = event.getClickedBlock();
Object[] portals = Portal.Portals;
int portalId = 0;
for(Object portal : portals){
if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + 3D) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= block.getZ()){
if((Portal.Portals[portalId].pos2.getX() - 3D) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= block.getZ()){
player.sendMessage("§a[§eAdvancedPortals§a] You have selected: §e" + Portal.Portals[portalId].portalName);
// TODO add code somewhere so when a portal is removed or changed if someone has it selected it notifies them
// or removed their selections and tells them, maybe not before this update.
player.removeMetadata("selectingPortal", plugin);
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, Portal.Portals[portalId].portalName)); // adds the name to the metadata of the character
event.setCancelled(true);
player.removeMetadata("selectingPortal", plugin);
return;
}
}
}
portalId++;
}
player.sendMessage("§c[§7AdvancedPortals§c] No portal was selected - if you would like to stop selecting please type §e/portal select §cagain!");
event.setCancelled(true);
return;
}
if(player.hasPermission("AdvancedPortals.CreatePortal")){
// UseOnlyServerMadeAxe being set to true makes is so only the axe generated by the server can be used so other iron axes can be used normally,
// by default its false but it is a nice feature in case the user wants to use the axe normally too, such as a admin playing survival or it being used
// as a weapon.
if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("§ePortal Region Selector")) && event.getPlayer().getItemInHand().getTypeId() == WandMaterial.getId()) {
// This checks if the action was a left or right click and if it was directly effecting a block.
if(event.getAction() == Action.LEFT_CLICK_BLOCK) {
Location blockloc = event.getClickedBlock().getLocation();
// stores the selection as metadata on the character so then it isn't saved anywhere, if the player logs out it will
// have to be selected again if the player joins, also it does not affect any other players.
player.setMetadata("Pos1X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
player.setMetadata("Pos1Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
player.setMetadata("Pos1Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
player.setMetadata("Pos1World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
player.sendMessage("§eYou have selected pos1! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY() + " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
// Stops the event so the block is not damaged
event.setCancelled(true);
// Returns the event so no more code is executed(stops unnecessary code being executed)
return;
}
else if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Location blockloc = event.getClickedBlock().getLocation();
player.setMetadata("Pos2X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
player.setMetadata("Pos2Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
player.setMetadata("Pos2Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
player.setMetadata("Pos2World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
player.sendMessage("§eYou have selected pos2! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY() + " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
// Stops the event so the block is not interacted with
event.setCancelled(true);
// Returns the event so no more code is executed(stops unnecessary code being executed)
return;
}
}
}
}
}

View File

@ -1,19 +1,19 @@
package com.sekwah.advancedportals;
import org.bukkit.command.CommandSender;
public class PluginMessages {
// This class is so then the common messages in commands or just messages over the commands are the same and can be
// easily changed.
public static void UnknownCommand(CommandSender sender, String command) {
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");
}
public static void NoPermission(CommandSender sender, String command) {
sender.sendMessage("§c[§7AdvancedPortals§c] You do not have permission to perform that command!");
}
}
package com.sekwah.advancedportals;
import org.bukkit.command.CommandSender;
public class PluginMessages {
// This class is so then the common messages in commands or just messages over the commands are the same and can be
// easily changed.
public static void UnknownCommand(CommandSender sender, String command) {
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");
}
public static void NoPermission(CommandSender sender, String command) {
sender.sendMessage("§c[§7AdvancedPortals§c] You do not have permission to perform that command!");
}
}

View File

@ -1,40 +1,40 @@
package com.sekwah.advancedportals;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
public class PortalPlacer 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 PortalPlace = true;
public PortalPlacer(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
this.PortalPlace = config.getConfig().getBoolean("CanBuildPortalBlock");
if(PortalPlace){
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPhysics(BlockPhysicsEvent event) {
Material material = event.getBlock().getType();
if (material == Material.PORTAL)
{
event.getChangedType();
event.setCancelled(true);
}
}
}
package com.sekwah.advancedportals;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
public class PortalPlacer 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 PortalPlace = true;
public PortalPlacer(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
this.PortalPlace = config.getConfig().getBoolean("CanBuildPortalBlock");
if(PortalPlace){
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPhysics(BlockPhysicsEvent event) {
Material material = event.getBlock().getType();
if (material == Material.PORTAL)
{
event.getChangedType();
event.setCancelled(true);
}
}
}

View File

@ -1,118 +1,118 @@
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 {
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.Portals[portalId].worldName.equals(block.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + PortalProtectionRadius) >= block.getZ()){
if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.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.Portals[portalId].worldName.equals(block.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + PortalProtectionRadius) >= block.getZ()){
if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.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.Portals[portalId].worldName.equals(block.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + PortalProtectionRadius) >= block.getZ()){
if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - PortalProtectionRadius) <= block.getZ()){
blockList.remove(i);
i--;
}
}
}
portalId++;
}
}
}
}
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 {
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.Portals[portalId].worldName.equals(block.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + PortalProtectionRadius) >= block.getZ()){
if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.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.Portals[portalId].worldName.equals(block.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + PortalProtectionRadius) >= block.getZ()){
if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.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.Portals[portalId].worldName.equals(block.getWorld().getName())){
if((Portal.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + PortalProtectionRadius) >= block.getZ()){
if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - PortalProtectionRadius) <= block.getZ()){
blockList.remove(i);
i--;
}
}
}
portalId++;
}
}
}
}

View File

@ -1,280 +1,280 @@
package com.sekwah.advancedportals;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class Selection {
public static Material blockType = Material.WOOL;
public static int timeout = 10;
public static byte metadata = 14;
@SuppressWarnings("deprecation")
public static void LoadData(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
timeout = config.getConfig().getInt("ShowSelectionShowDuration");
String BlockID = config.getConfig().getString("ShowSelectionBlockID");
try
{
blockType = Material.getMaterial(Integer.parseInt(BlockID));
}
catch(Exception e)
{
blockType = Material.getMaterial(BlockID);
}
if(blockType == null){
blockType = Material.STAINED_GLASS;
}
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) {
int LowX = 0;
int LowY = 0;
int LowZ = 0;
int HighX = 0;
int HighY = 0;
int HighZ = 0;
if(player.getMetadata("Pos1X").get(0).asInt() > player.getMetadata("Pos2X").get(0).asInt()){
LowX = player.getMetadata("Pos2X").get(0).asInt();
HighX = player.getMetadata("Pos1X").get(0).asInt();
}
else{
LowX = player.getMetadata("Pos1X").get(0).asInt();
HighX = player.getMetadata("Pos2X").get(0).asInt();
}
if(player.getMetadata("Pos1Y").get(0).asInt() > player.getMetadata("Pos2Y").get(0).asInt()){
LowY = player.getMetadata("Pos2Y").get(0).asInt();
HighY = player.getMetadata("Pos1Y").get(0).asInt();
}
else{
LowY = player.getMetadata("Pos1Y").get(0).asInt();
HighY = player.getMetadata("Pos2Y").get(0).asInt();
}
if(player.getMetadata("Pos1Z").get(0).asInt() > player.getMetadata("Pos2Z").get(0).asInt()){
LowZ = player.getMetadata("Pos2Z").get(0).asInt();
HighZ = player.getMetadata("Pos1Z").get(0).asInt();
}
else{
LowZ = player.getMetadata("Pos1Z").get(0).asInt();
HighZ = player.getMetadata("Pos2Z").get(0).asInt();
}
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")
protected static void Hide(Player player, AdvancedPortalsPlugin plugin, Location pos1, Location pos2) {
int LowX = pos1.getBlockX();
int LowY = pos1.getBlockY();
int LowZ = pos1.getBlockZ();
int HighX = pos2.getBlockX();
int HighY = pos2.getBlockY();
int HighZ = pos2.getBlockZ();
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), LowX, LowY, z);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), HighX, LowY, z);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), LowX, HighY, z);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), HighX, HighY, z);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
}
}
package com.sekwah.advancedportals;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class Selection {
public static Material blockType = Material.WOOL;
public static int timeout = 10;
public static byte metadata = 14;
@SuppressWarnings("deprecation")
public static void LoadData(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
timeout = config.getConfig().getInt("ShowSelectionShowDuration");
String BlockID = config.getConfig().getString("ShowSelectionBlockID");
try
{
blockType = Material.getMaterial(Integer.parseInt(BlockID));
}
catch(Exception e)
{
blockType = Material.getMaterial(BlockID);
}
if(blockType == null){
blockType = Material.STAINED_GLASS;
}
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) {
int LowX = 0;
int LowY = 0;
int LowZ = 0;
int HighX = 0;
int HighY = 0;
int HighZ = 0;
if(player.getMetadata("Pos1X").get(0).asInt() > player.getMetadata("Pos2X").get(0).asInt()){
LowX = player.getMetadata("Pos2X").get(0).asInt();
HighX = player.getMetadata("Pos1X").get(0).asInt();
}
else{
LowX = player.getMetadata("Pos1X").get(0).asInt();
HighX = player.getMetadata("Pos2X").get(0).asInt();
}
if(player.getMetadata("Pos1Y").get(0).asInt() > player.getMetadata("Pos2Y").get(0).asInt()){
LowY = player.getMetadata("Pos2Y").get(0).asInt();
HighY = player.getMetadata("Pos1Y").get(0).asInt();
}
else{
LowY = player.getMetadata("Pos1Y").get(0).asInt();
HighY = player.getMetadata("Pos2Y").get(0).asInt();
}
if(player.getMetadata("Pos1Z").get(0).asInt() > player.getMetadata("Pos2Z").get(0).asInt()){
LowZ = player.getMetadata("Pos2Z").get(0).asInt();
HighZ = player.getMetadata("Pos1Z").get(0).asInt();
}
else{
LowZ = player.getMetadata("Pos1Z").get(0).asInt();
HighZ = player.getMetadata("Pos2Z").get(0).asInt();
}
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")
protected static void Hide(Player player, AdvancedPortalsPlugin plugin, Location pos1, Location pos2) {
int LowX = pos1.getBlockX();
int LowY = pos1.getBlockY();
int LowZ = pos1.getBlockZ();
int HighX = pos2.getBlockX();
int HighY = pos2.getBlockY();
int HighZ = pos2.getBlockZ();
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), LowX, LowY, z);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), HighX, LowY, z);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int y = LowY; y <= HighY; y++){
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int x = LowX; x <= HighX; x++){
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), LowX, HighY, z);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
for(int z = LowZ; z <= HighZ; z++){
Location loc = new Location(player.getWorld(), HighX, HighY, z);
player.sendBlockChange(loc, loc.getBlock().getType(), (byte) loc.getBlock().getData());
}
}
}

View File

@ -1,72 +1,72 @@
package com.sekwah.advancedportals;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import com.sekwah.advancedportals.destinations.Destination;
public class WarpCommand implements CommandExecutor, TabCompleter {
private AdvancedPortalsPlugin plugin;
public WarpCommand(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
plugin.getCommand("warp").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
if(args.length > 0){
if(Destination.warp(sender, args[0], false)){
sender.sendMessage("");
sender.sendMessage("§a[§eAdvancedPortals§a] You have been warped to §e" + args[0] + ".");
sender.sendMessage("");
}
else{
sender.sendMessage("");
sender.sendMessage("§c[§7AdvancedPortals§c] The destination you tried to warp to does not exist!");
sender.sendMessage("");
}
}
else{
sender.sendMessage("");
sender.sendMessage("§c[§7AdvancedPortals§c] You need to type a destination after /" + command + "!");
sender.sendMessage("");
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
LinkedList<String> autoComplete = new LinkedList<String>();
if(sender.hasPermission("AdvancedPortals.CreatePortal")){
if(args.length == 1){
autoComplete.addAll(Arrays.asList("create", "goto", "redefine", "move", "rename", "remove"));
}
else if(args[0].toLowerCase().equals("create")){
}
}
Collections.sort(autoComplete);
for(Object result: autoComplete.toArray()){
if(!result.toString().startsWith(args[args.length - 1])){
autoComplete.remove(result);
}
}
return autoComplete;
}
}
package com.sekwah.advancedportals;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import com.sekwah.advancedportals.destinations.Destination;
public class WarpCommand implements CommandExecutor, TabCompleter {
private AdvancedPortalsPlugin plugin;
public WarpCommand(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
plugin.getCommand("warp").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
if(args.length > 0){
if(Destination.warp(sender, args[0], false)){
sender.sendMessage("");
sender.sendMessage("§a[§eAdvancedPortals§a] You have been warped to §e" + args[0] + ".");
sender.sendMessage("");
}
else{
sender.sendMessage("");
sender.sendMessage("§c[§7AdvancedPortals§c] The destination you tried to warp to does not exist!");
sender.sendMessage("");
}
}
else{
sender.sendMessage("");
sender.sendMessage("§c[§7AdvancedPortals§c] You need to type a destination after /" + command + "!");
sender.sendMessage("");
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
LinkedList<String> autoComplete = new LinkedList<String>();
if(sender.hasPermission("AdvancedPortals.CreatePortal")){
if(args.length == 1){
autoComplete.addAll(Arrays.asList("create", "goto", "redefine", "move", "rename", "remove"));
}
else if(args[0].toLowerCase().equals("create")){
}
}
Collections.sort(autoComplete);
for(Object result: autoComplete.toArray()){
if(!result.toString().startsWith(args[args.length - 1])){
autoComplete.remove(result);
}
}
return autoComplete;
}
}

View File

@ -1,9 +1,9 @@
package com.sekwah.advancedportals.compat;
import org.bukkit.entity.Player;
public interface NMS {
public void sendRawMessage(String rawMessage, Player player);
}
package com.sekwah.advancedportals.compat;
import org.bukkit.entity.Player;
public interface NMS {
public void sendRawMessage(String rawMessage, Player player);
}

View File

@ -1,19 +1,19 @@
package com.sekwah.advancedportals.compat;
import net.minecraft.server.v1_7_R1.ChatSerializer;
import net.minecraft.server.v1_7_R1.IChatBaseComponent;
import net.minecraft.server.v1_7_R1.PacketPlayOutChat;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class v1_7_R1 implements NMS {
@Override
public void sendRawMessage(String rawMessage, Player player) {
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
package com.sekwah.advancedportals.compat;
import net.minecraft.server.v1_7_R1.ChatSerializer;
import net.minecraft.server.v1_7_R1.IChatBaseComponent;
import net.minecraft.server.v1_7_R1.PacketPlayOutChat;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class v1_7_R1 implements NMS {
@Override
public void sendRawMessage(String rawMessage, Player player) {
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -1,19 +1,19 @@
package com.sekwah.advancedportals.compat;
import net.minecraft.server.v1_7_R2.ChatSerializer;
import net.minecraft.server.v1_7_R2.IChatBaseComponent;
import net.minecraft.server.v1_7_R2.PacketPlayOutChat;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class v1_7_R2 implements NMS {
@Override
public void sendRawMessage(String rawMessage, Player player) {
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
package com.sekwah.advancedportals.compat;
import net.minecraft.server.v1_7_R2.ChatSerializer;
import net.minecraft.server.v1_7_R2.IChatBaseComponent;
import net.minecraft.server.v1_7_R2.PacketPlayOutChat;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class v1_7_R2 implements NMS {
@Override
public void sendRawMessage(String rawMessage, Player player) {
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -1,19 +1,19 @@
package com.sekwah.advancedportals.compat;
import net.minecraft.server.v1_7_R3.ChatSerializer;
import net.minecraft.server.v1_7_R3.IChatBaseComponent;
import net.minecraft.server.v1_7_R3.PacketPlayOutChat;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class v1_7_R3 implements NMS {
@Override
public void sendRawMessage(String rawMessage, Player player) {
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
package com.sekwah.advancedportals.compat;
import net.minecraft.server.v1_7_R3.ChatSerializer;
import net.minecraft.server.v1_7_R3.IChatBaseComponent;
import net.minecraft.server.v1_7_R3.PacketPlayOutChat;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class v1_7_R3 implements NMS {
@Override
public void sendRawMessage(String rawMessage, Player player) {
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -1,19 +1,19 @@
package com.sekwah.advancedportals.compat;
import net.minecraft.server.v1_7_R4.ChatSerializer;
import net.minecraft.server.v1_7_R4.IChatBaseComponent;
import net.minecraft.server.v1_7_R4.PacketPlayOutChat;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class v1_7_R4 implements NMS {
@Override
public void sendRawMessage(String rawMessage, Player player) {
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
package com.sekwah.advancedportals.compat;
import net.minecraft.server.v1_7_R4.ChatSerializer;
import net.minecraft.server.v1_7_R4.IChatBaseComponent;
import net.minecraft.server.v1_7_R4.PacketPlayOutChat;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class v1_7_R4 implements NMS {
@Override
public void sendRawMessage(String rawMessage, Player player) {
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -1,206 +1,206 @@
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;
import com.mysql.jdbc.Util;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.effects.WarpEffects;
public class Destination {
private static AdvancedPortalsPlugin plugin;
public Destination(AdvancedPortalsPlugin plugin) {
Destination.plugin = plugin;
}
public static void create(Location location, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
config.getConfig().set(name.toLowerCase() + ".world", location.getWorld().getName());
config.getConfig().set(name.toLowerCase() + ".pos.X", location.getX());
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 move(Location location, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
config.getConfig().set(name.toLowerCase() + ".world", location.getWorld().getName());
config.getConfig().set(name.toLowerCase() + ".pos.X", location.getX());
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.toLowerCase() + ".world", config.getConfig().getString(oldName + ".world"));
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);
config.saveConfig();
}
public static void remove(String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
config.getConfig().set(name.toLowerCase() + ".world", 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 boolean warp(Player player, String name, boolean senderror){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
if(config.getConfig().getString(name + ".world") != null){
Location loc = player.getLocation();
if(Bukkit.getWorld(config.getConfig().getString(name + ".world")) != null){
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"));
WarpEffects.activateParticles(player);
WarpEffects.activateSound(player);
Chunk c = loc.getChunk();
Entity riding = player.getVehicle();
if (!c.isLoaded()) c.load();
if(player.getVehicle() != null){
riding.eject();
riding.teleport(loc);
player.teleport(loc);
riding.setPassenger(player);
}
else{
player.teleport(loc);
}
WarpEffects.activateParticles(player);
WarpEffects.activateSound(player);
return true;
}
else{
if(senderror){
player.sendMessage("§c[§7AdvancedPortals§c] The destination you are trying to warp to seems to be linked to a world that doesn't exist!");
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' is linked to the world "
+ config.getConfig().getString(name + ".world") + " which doesnt seem to exist any more!");
}
return false;
}
}
else{
if(senderror){
player.sendMessage("§c[§7AdvancedPortals§c] There has been a problem warping you to the selected destination!");
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' has just had a warp "
+ "attempt and either the data is corrupt or that destination doesn't exist!");
}
return false;
}
}
/**
* Same as other warp but changes sender to player for you.
*
* @param sender
* @param name
* @return
*/
public static boolean warp(Player player, String name) {
return warp(player, name, true);
}
/**
* Same as other warp but changes sender to player for you.
*
* @param sender
* @param name
* @return
*/
public static boolean warp(CommandSender sender, String name, boolean senderror) {
Player player = (Player)sender;
return warp(player, name, senderror);
}
/**
* Same as other warp but changes sender to player for you.
*
* @param sender
* @param name
* @return
*/
public static boolean warp(CommandSender sender, String name) {
Player player = (Player)sender;
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;
}
}
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;
import com.mysql.jdbc.Util;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.effects.WarpEffects;
public class Destination {
private static AdvancedPortalsPlugin plugin;
public Destination(AdvancedPortalsPlugin plugin) {
Destination.plugin = plugin;
}
public static void create(Location location, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
config.getConfig().set(name.toLowerCase() + ".world", location.getWorld().getName());
config.getConfig().set(name.toLowerCase() + ".pos.X", location.getX());
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 move(Location location, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
config.getConfig().set(name.toLowerCase() + ".world", location.getWorld().getName());
config.getConfig().set(name.toLowerCase() + ".pos.X", location.getX());
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.toLowerCase() + ".world", config.getConfig().getString(oldName + ".world"));
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);
config.saveConfig();
}
public static void remove(String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
config.getConfig().set(name.toLowerCase() + ".world", 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 boolean warp(Player player, String name, boolean senderror){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
if(config.getConfig().getString(name + ".world") != null){
Location loc = player.getLocation();
if(Bukkit.getWorld(config.getConfig().getString(name + ".world")) != null){
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"));
WarpEffects.activateParticles(player);
WarpEffects.activateSound(player);
Chunk c = loc.getChunk();
Entity riding = player.getVehicle();
if (!c.isLoaded()) c.load();
if(player.getVehicle() != null){
riding.eject();
riding.teleport(loc);
player.teleport(loc);
riding.setPassenger(player);
}
else{
player.teleport(loc);
}
WarpEffects.activateParticles(player);
WarpEffects.activateSound(player);
return true;
}
else{
if(senderror){
player.sendMessage("§c[§7AdvancedPortals§c] The destination you are trying to warp to seems to be linked to a world that doesn't exist!");
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' is linked to the world "
+ config.getConfig().getString(name + ".world") + " which doesnt seem to exist any more!");
}
return false;
}
}
else{
if(senderror){
player.sendMessage("§c[§7AdvancedPortals§c] There has been a problem warping you to the selected destination!");
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' has just had a warp "
+ "attempt and either the data is corrupt or that destination doesn't exist!");
}
return false;
}
}
/**
* Same as other warp but changes sender to player for you.
*
* @param sender
* @param name
* @return
*/
public static boolean warp(Player player, String name) {
return warp(player, name, true);
}
/**
* Same as other warp but changes sender to player for you.
*
* @param sender
* @param name
* @return
*/
public static boolean warp(CommandSender sender, String name, boolean senderror) {
Player player = (Player)sender;
return warp(player, name, senderror);
}
/**
* Same as other warp but changes sender to player for you.
*
* @param sender
* @param name
* @return
*/
public static boolean warp(CommandSender sender, String name) {
Player player = (Player)sender;
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;
}
}

View File

@ -1,45 +1,45 @@
package com.sekwah.advancedportals.effects;
import org.bukkit.Effect;
import org.bukkit.Instrument;
import org.bukkit.Location;
import org.bukkit.Note;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.Note.Tone;
import org.bukkit.entity.Player;
import com.sekwah.advancedportals.Assets;
public class WarpEffects {
public static void activateParticles(Player player) {
Location loc = player.getLocation();
World world = player.getWorld();
switch (Assets.currentWarpParticles){
case 1:
for(int i = 0; i < 10; i++){
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
}
loc.add(0D, 1D, 0D);
for(int i = 0; i < 10; i++){
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
}
default: break;
}
}
public static void activateSound(Player player) {
Location loc = player.getLocation();
World world = player.getWorld();
switch (Assets.currentWarpParticles){
case 1:
world.playSound(loc, Sound.ENDERMAN_TELEPORT, 1F, 1F);
default: break;
}
}
}
package com.sekwah.advancedportals.effects;
import org.bukkit.Effect;
import org.bukkit.Instrument;
import org.bukkit.Location;
import org.bukkit.Note;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.Note.Tone;
import org.bukkit.entity.Player;
import com.sekwah.advancedportals.Assets;
public class WarpEffects {
public static void activateParticles(Player player) {
Location loc = player.getLocation();
World world = player.getWorld();
switch (Assets.currentWarpParticles){
case 1:
for(int i = 0; i < 10; i++){
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
}
loc.add(0D, 1D, 0D);
for(int i = 0; i < 10; i++){
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
}
default: break;
}
}
public static void activateSound(Player player) {
Location loc = player.getLocation();
World world = player.getWorld();
switch (Assets.currentWarpParticles){
case 1:
world.playSound(loc, Sound.ENDERMAN_TELEPORT, 1F, 1F);
default: break;
}
}
}

View File

@ -1,75 +1,75 @@
package com.sekwah.advancedportals.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Cancellable;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public final class WarpEvent extends Event implements Cancellable {
/**
* Use listeners so you can add new triggers easier and also other plugins can listen for the event
* and add their own triggers
*/
private static final HandlerList handlers = new HandlerList();
private boolean cancelled = false;
private Player player;
private String portalName;
private boolean hasWarped = false;
public WarpEvent(Player player, String portalName) {
this.player = player;
this.portalName = portalName;
}
/**
* Returns if the event has been cancelled
*
* @return cancelled
*/
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
/**
* If the
*
* @param warped
*/
public void setHasWarped(boolean warped){
this.hasWarped = warped;
}
/**
* This will return true if another plugin has warped the player(and set this to true)
*
* @return hasWarped
*/
public boolean getHasWarped(){
return hasWarped;
}
public Player getPlayer(){
return player;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
package com.sekwah.advancedportals.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Cancellable;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public final class WarpEvent extends Event implements Cancellable {
/**
* Use listeners so you can add new triggers easier and also other plugins can listen for the event
* and add their own triggers
*/
private static final HandlerList handlers = new HandlerList();
private boolean cancelled = false;
private Player player;
private String portalName;
private boolean hasWarped = false;
public WarpEvent(Player player, String portalName) {
this.player = player;
this.portalName = portalName;
}
/**
* Returns if the event has been cancelled
*
* @return cancelled
*/
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
/**
* If the
*
* @param warped
*/
public void setHasWarped(boolean warped){
this.hasWarped = warped;
}
/**
* This will return true if another plugin has warped the player(and set this to true)
*
* @return hasWarped
*/
public boolean getHasWarped(){
return hasWarped;
}
public Player getPlayer(){
return player;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -1,21 +1,21 @@
package com.sekwah.advancedportals.portalcontrolls;
import org.bukkit.Location;
import org.bukkit.Material;
public class AdvancedPortal {
public Material trigger = null;
public String worldName = null;
public Location pos1 = null;
public Location pos2 = null;
public String portalName = null;
public String destiation = null; // Could possibly store the destination name to stop the server having to read the config file
public String bungee = null; // Could possibly store the bungee server name to stop the server having to read the config file
}
package com.sekwah.advancedportals.portalcontrolls;
import org.bukkit.Location;
import org.bukkit.Material;
public class AdvancedPortal {
public Material trigger = null;
public String worldName = null;
public Location pos1 = null;
public Location pos2 = null;
public String portalName = null;
public String destiation = null; // Could possibly store the destination name to stop the server having to read the config file
public String bungee = null; // Could possibly store the bungee server name to stop the server having to read the config file
}

View File

@ -1,400 +1,400 @@
package com.sekwah.advancedportals.portalcontrolls;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.DataCollector.DataCollector;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.events.WarpEvent;
public class Portal {
private static AdvancedPortalsPlugin plugin;
public static boolean portalsActive = true;
public static AdvancedPortal[] Portals;
private static boolean ShowBungeeMessage;
public Portal(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
Portal.plugin = plugin;
Portal.loadPortals();
}
/**
* This can be used to move the get keys to different sections
*
* ConfigurationSection section = config.getSection("sectionname");
*
* section.getKeys(false);
*
*/
public static void loadPortals(){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
Set<String> PortalSet = config.getConfig().getKeys(false);
if(PortalSet.size() > 0){
Portals = new AdvancedPortal[PortalSet.toArray().length];
for(int i = 0; i <= PortalSet.toArray().length - 1; i++){
Portals[i] = new AdvancedPortal();
}
int portalId = 0;
for(Object portal: PortalSet.toArray()){
Material blockType = Material.PORTAL;
String BlockID = config.getConfig().getString(portal.toString() + ".triggerblock");
try
{
Integer.parseInt(BlockID);
System.out.println("Block names must be given not IDs");
}
catch(NumberFormatException e)
{
blockType = Material.getMaterial(BlockID);
}
if(blockType == null){
blockType = Material.PORTAL;
}
Portals[portalId].trigger = blockType;
System.out.println("Test: " + portal.toString());
Portals[portalId].portalName = portal.toString();
Portals[portalId].worldName = config.getConfig().getString(portal.toString() + ".world");
World world = Bukkit.getWorld(config.getConfig().getString(portal.toString() + ".world"));
Portals[portalId].pos1 = new Location(world, config.getConfig().getInt(portal.toString() + ".pos1.X"), config.getConfig().getInt(portal.toString() + ".pos1.Y"), config.getConfig().getInt(portal.toString() + ".pos1.Z"));
Portals[portalId].pos2 = 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 String create(Location pos1, Location pos2 , String name, String destination, Material triggerBlock) {
return create(pos1, pos2, name, destination, triggerBlock, null);
}
public static String create(Location pos1, Location pos2 , String name, String destination, Material triggerBlock, String serverName) {
if(!pos1.getWorld().equals(pos2.getWorld())){
plugin.getLogger().log(Level.WARNING, "pos1 and pos2 must be in the same world!");
return "§cPortal creation error, pos1 and pos2 must be in the same world!";
}
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();
}
Location checkpos1 = new Location(pos1.getWorld(), HighX, HighY, HighZ);
Location checkpos2 = new Location(pos2.getWorld(), LowX, LowY, LowZ);
if(checkPortalOverlap(checkpos1, checkpos2)){
plugin.getLogger().log(Level.WARNING, "Portals must not overlap!");
return "§cPortal creation error, portals must not overlap!";
}
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
config.getConfig().set(name + ".world", pos1.getWorld().getName());
config.getConfig().set(name + ".triggerblock", checkMaterial(triggerBlock));
config.getConfig().set(name + ".destination", destination);
config.getConfig().set(name + ".bungee", serverName);
config.getConfig().set(name + ".pos1.X", HighX);
config.getConfig().set(name + ".pos1.Y", HighY);
config.getConfig().set(name + ".pos1.Z", HighZ);
config.getConfig().set(name + ".pos2.X", LowX);
config.getConfig().set(name + ".pos2.Y", LowY);
config.getConfig().set(name + ".pos2.Z", LowZ);
config.saveConfig();
loadPortals();
return "§aPortal creation successful!";
}
// make this actually work!
private static boolean checkPortalOverlap(Location pos1, Location pos2) {
if(portalsActive){
int portalId = 0;
for(@SuppressWarnings("unused") Object portal : Portal.Portals){
if(Portals[portalId].worldName.equals(pos2.getWorld().getName())){ // checks that the cubes arnt overlapping by seeing if all 4 corners are not in side another
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
}
portalId++;
}
}
return false;
}
private static boolean checkOverLapPortal(Location pos1, Location pos2, int posX, int posY, int posZ) {
if(pos1.getX() >= posX && pos1.getY() >= posX && pos1.getZ() >= posZ){
if((pos2.getX()) <= posX && pos2.getY() <= posY && pos2.getZ() <= posZ){
return true;
}
}
return false;
}
private static String checkMaterial(Material triggerBlock) {
if(triggerBlock.equals(Material.WATER)){
return "STATIONARY_WATER";
}
else if(triggerBlock.equals(Material.LAVA)){
return "STATIONARY_LAVA";
}
return triggerBlock.toString();
}
public static String create(Location pos1, Location pos2, String name, String destination) {
return create(pos1, pos2, name, destination,(String) null);
}
@SuppressWarnings("deprecation")
public static String create(Location pos1, Location pos2, String name, String destination, String serverName) { // add stuff for destination names or coordinates
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
Material triggerBlockType;
String BlockID = config.getConfig().getString("DefaultPortalTriggerBlock");
try
{
triggerBlockType = Material.getMaterial(Integer.parseInt(BlockID));
}
catch(Exception e)
{
triggerBlockType = Material.getMaterial(BlockID);
}
if(triggerBlockType == null){
triggerBlockType = Material.PORTAL;
}
// TODO add a for loop which scans through the addArgs and adds them to the config so that the application can use them
String result = create(pos1, pos2, name, destination, triggerBlockType, serverName);
return result;
}
public static void redefine(Location pos1, Location pos2, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
config.getConfig().set(name + ".pos1.X", pos1.getX());
config.getConfig().set(name + ".pos1.Y", pos1.getY());
config.getConfig().set(name + ".pos1.Z", pos1.getZ());
config.getConfig().set(name + ".pos2.X", pos2.getX());
config.getConfig().set(name + ".pos2.Y", pos2.getY());
config.getConfig().set(name + ".pos2.Z", pos2.getZ());
config.saveConfig();
loadPortals();
}
public static void remove(String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
Object[] keys = config.getConfig().getKeys(true).toArray();
for(int i = keys.length - 1; i >= 0; i--){
String key = keys[i].toString();
if(key.startsWith(name + ".")){
config.getConfig().set(key, null);
}
}
config.getConfig().set(name, null);
/**Set<String> keys = config.getConfig().getKeys(true);
for(String key: keys){
if(key.startsWith(name)){
config.getConfig().set(key, null);
}
}*/
/**config.getConfig().set(name + ".world", null);
config.getConfig().set(name + ".triggerblock", null);
config.getConfig().set(name + ".destination", null);
config.getConfig().set(name + ".pos1.X", null);
config.getConfig().set(name + ".pos1.Y", null);
config.getConfig().set(name + ".pos1.Z", null);
config.getConfig().set(name + ".pos2.X", null);
config.getConfig().set(name + ".pos2.Y", null);
config.getConfig().set(name + ".pos2.Z", null);
config.getConfig().set(name + ".pos1", null);
config.getConfig().set(name + ".pos2", null);
config.getConfig().set(name, null);*/
config.saveConfig();
loadPortals();
}
public static boolean portalExists(String portalName){
ConfigAccessor portalconfig = new ConfigAccessor(plugin, "Portals.yml");
String posX = portalconfig.getConfig().getString(portalName + ".pos1.X");
if(posX == null){
return false;
}
else{
return true;
}
}
public static boolean activate(Player player, String portalName) {
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
// add other variables or filter code here, or somehow have a way to register them
if(config.getConfig().getString(portalName + ".bungee") != null){
if(ShowBungeeMessage){
player.sendMessage("§a[§eAdvancedPortals§a] Attempting to warp to §e" + config.getConfig().getString(portalName + ".bungee") + "§a.");
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(config.getConfig().getString(portalName + ".bungee"));
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
return false;
}
else{
if(config.getConfig().getString(portalName + ".destination") != null){
ConfigAccessor configDesti = new ConfigAccessor(plugin, "Destinations.yml");
String destiName = config.getConfig().getString(portalName + ".destination");
if(configDesti.getConfig().getString(destiName + ".world") != null){
boolean warped = Destination.warp(player, destiName);
return warped;
}
else{
player.sendMessage("§c[§7AdvancedPortals§c] The destination you are currently attempting to warp to doesnt exist!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or that destination listed doesn't exist!");
return false;
}
}
else{
player.sendMessage("§c[§7AdvancedPortals§c] The portal you are trying to use doesn't have a destination!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or portal doesn't exist!");
return false;
}
}
// add code for if the portal doesnt have a destination but a teleport location
}
public static void rename(String oldName, String newName){
// set it so it gets all data from one and puts it into another place
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
Set<String> keys = config.getConfig().getKeys(true);
for(String key: keys){
if(key.startsWith(oldName + ".")){
if(config.getConfig().getString(key) != null){
try
{
int intData = Integer.parseInt(config.getConfig().getString(key));
config.getConfig().set(key.replace(oldName + ".", newName + "."), intData);
}
catch(Exception e)
{
config.getConfig().set(key.replace(oldName + ".", newName + "."), config.getConfig().getString(key));
}
}
}
}
config.saveConfig();
remove(oldName);
}
}
package com.sekwah.advancedportals.portalcontrolls;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.DataCollector.DataCollector;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.events.WarpEvent;
public class Portal {
private static AdvancedPortalsPlugin plugin;
public static boolean portalsActive = true;
public static AdvancedPortal[] Portals;
private static boolean ShowBungeeMessage;
public Portal(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
Portal.plugin = plugin;
Portal.loadPortals();
}
/**
* This can be used to move the get keys to different sections
*
* ConfigurationSection section = config.getSection("sectionname");
*
* section.getKeys(false);
*
*/
public static void loadPortals(){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
Set<String> PortalSet = config.getConfig().getKeys(false);
if(PortalSet.size() > 0){
Portals = new AdvancedPortal[PortalSet.toArray().length];
for(int i = 0; i <= PortalSet.toArray().length - 1; i++){
Portals[i] = new AdvancedPortal();
}
int portalId = 0;
for(Object portal: PortalSet.toArray()){
Material blockType = Material.PORTAL;
String BlockID = config.getConfig().getString(portal.toString() + ".triggerblock");
try
{
Integer.parseInt(BlockID);
System.out.println("Block names must be given not IDs");
}
catch(NumberFormatException e)
{
blockType = Material.getMaterial(BlockID);
}
if(blockType == null){
blockType = Material.PORTAL;
}
Portals[portalId].trigger = blockType;
System.out.println("Test: " + portal.toString());
Portals[portalId].portalName = portal.toString();
Portals[portalId].worldName = config.getConfig().getString(portal.toString() + ".world");
World world = Bukkit.getWorld(config.getConfig().getString(portal.toString() + ".world"));
Portals[portalId].pos1 = new Location(world, config.getConfig().getInt(portal.toString() + ".pos1.X"), config.getConfig().getInt(portal.toString() + ".pos1.Y"), config.getConfig().getInt(portal.toString() + ".pos1.Z"));
Portals[portalId].pos2 = 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 String create(Location pos1, Location pos2 , String name, String destination, Material triggerBlock) {
return create(pos1, pos2, name, destination, triggerBlock, null);
}
public static String create(Location pos1, Location pos2 , String name, String destination, Material triggerBlock, String serverName) {
if(!pos1.getWorld().equals(pos2.getWorld())){
plugin.getLogger().log(Level.WARNING, "pos1 and pos2 must be in the same world!");
return "§cPortal creation error, pos1 and pos2 must be in the same world!";
}
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();
}
Location checkpos1 = new Location(pos1.getWorld(), HighX, HighY, HighZ);
Location checkpos2 = new Location(pos2.getWorld(), LowX, LowY, LowZ);
if(checkPortalOverlap(checkpos1, checkpos2)){
plugin.getLogger().log(Level.WARNING, "Portals must not overlap!");
return "§cPortal creation error, portals must not overlap!";
}
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
config.getConfig().set(name + ".world", pos1.getWorld().getName());
config.getConfig().set(name + ".triggerblock", checkMaterial(triggerBlock));
config.getConfig().set(name + ".destination", destination);
config.getConfig().set(name + ".bungee", serverName);
config.getConfig().set(name + ".pos1.X", HighX);
config.getConfig().set(name + ".pos1.Y", HighY);
config.getConfig().set(name + ".pos1.Z", HighZ);
config.getConfig().set(name + ".pos2.X", LowX);
config.getConfig().set(name + ".pos2.Y", LowY);
config.getConfig().set(name + ".pos2.Z", LowZ);
config.saveConfig();
loadPortals();
return "§aPortal creation successful!";
}
// make this actually work!
private static boolean checkPortalOverlap(Location pos1, Location pos2) {
if(portalsActive){
int portalId = 0;
for(@SuppressWarnings("unused") Object portal : Portal.Portals){
if(Portals[portalId].worldName.equals(pos2.getWorld().getName())){ // checks that the cubes arnt overlapping by seeing if all 4 corners are not in side another
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
}
portalId++;
}
}
return false;
}
private static boolean checkOverLapPortal(Location pos1, Location pos2, int posX, int posY, int posZ) {
if(pos1.getX() >= posX && pos1.getY() >= posX && pos1.getZ() >= posZ){
if((pos2.getX()) <= posX && pos2.getY() <= posY && pos2.getZ() <= posZ){
return true;
}
}
return false;
}
private static String checkMaterial(Material triggerBlock) {
if(triggerBlock.equals(Material.WATER)){
return "STATIONARY_WATER";
}
else if(triggerBlock.equals(Material.LAVA)){
return "STATIONARY_LAVA";
}
return triggerBlock.toString();
}
public static String create(Location pos1, Location pos2, String name, String destination) {
return create(pos1, pos2, name, destination,(String) null);
}
@SuppressWarnings("deprecation")
public static String create(Location pos1, Location pos2, String name, String destination, String serverName) { // add stuff for destination names or coordinates
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
Material triggerBlockType;
String BlockID = config.getConfig().getString("DefaultPortalTriggerBlock");
try
{
triggerBlockType = Material.getMaterial(Integer.parseInt(BlockID));
}
catch(Exception e)
{
triggerBlockType = Material.getMaterial(BlockID);
}
if(triggerBlockType == null){
triggerBlockType = Material.PORTAL;
}
// TODO add a for loop which scans through the addArgs and adds them to the config so that the application can use them
String result = create(pos1, pos2, name, destination, triggerBlockType, serverName);
return result;
}
public static void redefine(Location pos1, Location pos2, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
config.getConfig().set(name + ".pos1.X", pos1.getX());
config.getConfig().set(name + ".pos1.Y", pos1.getY());
config.getConfig().set(name + ".pos1.Z", pos1.getZ());
config.getConfig().set(name + ".pos2.X", pos2.getX());
config.getConfig().set(name + ".pos2.Y", pos2.getY());
config.getConfig().set(name + ".pos2.Z", pos2.getZ());
config.saveConfig();
loadPortals();
}
public static void remove(String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
Object[] keys = config.getConfig().getKeys(true).toArray();
for(int i = keys.length - 1; i >= 0; i--){
String key = keys[i].toString();
if(key.startsWith(name + ".")){
config.getConfig().set(key, null);
}
}
config.getConfig().set(name, null);
/**Set<String> keys = config.getConfig().getKeys(true);
for(String key: keys){
if(key.startsWith(name)){
config.getConfig().set(key, null);
}
}*/
/**config.getConfig().set(name + ".world", null);
config.getConfig().set(name + ".triggerblock", null);
config.getConfig().set(name + ".destination", null);
config.getConfig().set(name + ".pos1.X", null);
config.getConfig().set(name + ".pos1.Y", null);
config.getConfig().set(name + ".pos1.Z", null);
config.getConfig().set(name + ".pos2.X", null);
config.getConfig().set(name + ".pos2.Y", null);
config.getConfig().set(name + ".pos2.Z", null);
config.getConfig().set(name + ".pos1", null);
config.getConfig().set(name + ".pos2", null);
config.getConfig().set(name, null);*/
config.saveConfig();
loadPortals();
}
public static boolean portalExists(String portalName){
ConfigAccessor portalconfig = new ConfigAccessor(plugin, "Portals.yml");
String posX = portalconfig.getConfig().getString(portalName + ".pos1.X");
if(posX == null){
return false;
}
else{
return true;
}
}
public static boolean activate(Player player, String portalName) {
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
// add other variables or filter code here, or somehow have a way to register them
if(config.getConfig().getString(portalName + ".bungee") != null){
if(ShowBungeeMessage){
player.sendMessage("§a[§eAdvancedPortals§a] Attempting to warp to §e" + config.getConfig().getString(portalName + ".bungee") + "§a.");
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(config.getConfig().getString(portalName + ".bungee"));
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
return false;
}
else{
if(config.getConfig().getString(portalName + ".destination") != null){
ConfigAccessor configDesti = new ConfigAccessor(plugin, "Destinations.yml");
String destiName = config.getConfig().getString(portalName + ".destination");
if(configDesti.getConfig().getString(destiName + ".world") != null){
boolean warped = Destination.warp(player, destiName);
return warped;
}
else{
player.sendMessage("§c[§7AdvancedPortals§c] The destination you are currently attempting to warp to doesnt exist!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or that destination listed doesn't exist!");
return false;
}
}
else{
player.sendMessage("§c[§7AdvancedPortals§c] The portal you are trying to use doesn't have a destination!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or portal doesn't exist!");
return false;
}
}
// add code for if the portal doesnt have a destination but a teleport location
}
public static void rename(String oldName, String newName){
// set it so it gets all data from one and puts it into another place
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
Set<String> keys = config.getConfig().getKeys(true);
for(String key: keys){
if(key.startsWith(oldName + ".")){
if(config.getConfig().getString(key) != null){
try
{
int intData = Integer.parseInt(config.getConfig().getString(key));
config.getConfig().set(key.replace(oldName + ".", newName + "."), intData);
}
catch(Exception e)
{
config.getConfig().set(key.replace(oldName + ".", newName + "."), config.getConfig().getString(key));
}
}
}
}
config.saveConfig();
remove(oldName);
}
}

View File

@ -1,29 +1,29 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.0.3
author: SEKWAH41
description: An advanced portals plugin for bukkit.
commands:
advancedportals:
description: The main command for the advanced portals
aliases: [portals, aportals, portal]
usage: /<command>
destination:
description: Can be used to access portal destinations.
aliases: [desti]
usage: /<command>
warp:
description: Used to warp to destinations.
usage: /<command>
permissions:
advancedportals.*:
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
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.0.3
author: SEKWAH41
description: An advanced portals plugin for bukkit.
commands:
advancedportals:
description: The main command for the advanced portals
aliases: [portals, aportals, portal]
usage: /<command>
destination:
description: Can be used to access portal destinations.
aliases: [desti]
usage: /<command>
warp:
description: Used to warp to destinations.
usage: /<command>
permissions:
advancedportals.*:
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