Started adding the destinations code

This commit is contained in:
sekwah41 2013-12-11 21:38:46 +00:00
parent eef53ec21b
commit 448b38b5b1
6 changed files with 130 additions and 11 deletions

View File

@ -11,8 +11,12 @@ UseOnlyServerMadeAxe: false
# Preferably an item and not a block but it shouldnt matter
AxeItemId: IRON_AXE
# 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: WOOL
ShowSelectionBlockID: STAINED_GLASS
ShowSelectionBlockData: 14

View File

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

View File

@ -20,7 +20,19 @@ public class DestinationCommand implements CommandExecutor {
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){
}
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!");

View File

@ -0,0 +1,67 @@
package com.sekwah.advancedportals;
import java.util.logging.Level;
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.block.BlockFromToEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.metadata.FixedMetadataValue;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class FlowStopper 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 static 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);
}
else{
plugin.getLogger().log(Level.INFO, "Water flow is currently allowed!");
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPhysics(BlockPhysicsEvent event) {
Material material = event.getBlock().getType();
if (material == Material.STATIONARY_WATER)
{
event.setCancelled(true);
}
else if (material == Material.STATIONARY_LAVA){
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockFromTo(BlockFromToEvent event) {
Block block = event.getToBlock();
if (block.getType() == Material.WATER) {
event.setCancelled(true);
}
else if (block.getType() == Material.LAVA) {
event.setCancelled(true);
}
}
}

View File

@ -3,10 +3,30 @@ package com.sekwah.advancedportals.destinations;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class Destination {
private static AdvancedPortalsPlugin plugin;
public Destination(AdvancedPortalsPlugin plugin) {
Destination.plugin = plugin;
}
public void create(Player creator, Location location, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
config.getConfig().set(name + ".world", location.getWorld().getName());
config.getConfig().set(name + ".pos.X", location.getX());
config.getConfig().set(name + ".pos.Y", location.getY());
config.getConfig().set(name + ".pos.Z", location.getZ());
config.getConfig().set(name + ".creator", creator.getName());
config.saveConfig();
}
public void move(Player creator, Location location, String name){

View File

@ -1,6 +1,5 @@
package com.sekwah.advancedportals.portalcontrolls;
import java.util.List;
import java.util.Set;
import org.bukkit.Location;
@ -16,9 +15,13 @@ public class Portal {
public static Object[] Portals;
public static Object[] pos1;
public static Object[] pos2;
public Portal(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
this.loadPortals();
Portal.plugin = plugin;
Portal.loadPortals();
}
/**
@ -36,9 +39,15 @@ public class Portal {
Set<String> PortalSet = config.getConfig().getKeys(false);
Portals = PortalSet.toArray();
for(Object portal: Portals){
portal.toString();
}
}
public static void create(Player player, Material triggerBlockId, Location pos1, Location pos2 , String name) {
@SuppressWarnings("deprecation")
public static void create(Player creator, Material triggerBlockId, Location pos1, Location pos2 , String name) {
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
config.getConfig().set(name + ".world", pos1.getWorld().getName());
@ -54,14 +63,14 @@ public class Portal {
config.getConfig().set(name + ".pos2.Y", pos2.getY());
config.getConfig().set(name + ".pos2.Z", pos2.getZ());
config.getConfig().set(name + ".creator", player.getName());
config.getConfig().set(name + ".creator", creator.getName());
config.saveConfig();
loadPortals();
}
public static void create(Player player, Location pos1, Location pos2, String name) { // add stuff for destination names or coordinates
public static void create(Player creator, Location pos1, Location pos2, String name) { // add stuff for destination names or coordinates
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
config.getConfig().set(name + ".world", pos1.getWorld().getName());
@ -75,12 +84,12 @@ public class Portal {
config.getConfig().set(name + ".pos2.Y", pos2.getY());
config.getConfig().set(name + ".pos2.Z", pos2.getZ());
config.getConfig().set(name + ".creator", player.getName());
config.getConfig().set(name + ".creator", creator.getName());
loadPortals();
}
public static void redefine(Player player, Location pos1, Location pos2, String name){
public static void redefine(Player creator, Location pos1, Location pos2, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
@ -98,7 +107,7 @@ public class Portal {
}
public static void remove(Player player, String name){
public static void remove(Player creator, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
config.getConfig().set(name + ".world", null);