Added a custom item to be used as the axe along with a few other edits

This commit is contained in:
sekwah41 2013-12-08 19:59:55 +00:00
parent 5b3259feac
commit 3e8305a85f
6 changed files with 44 additions and 40 deletions

View File

@ -5,9 +5,13 @@
# 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
# This must be a placeable block or it will not work and may even crash
ShowSelectionBlockID: WOOL
ShowSelectionBlockData: 14

View File

@ -2,6 +2,8 @@ package com.sekwah.advancedportals;
import java.util.Arrays;
import net.minecraft.server.v1_7_R1.Item;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -33,10 +35,23 @@ public class AdvancedPortalsCommand implements CommandExecutor {
if(sender.hasPermission("AdvancedPortals.CreatePortal")){
PlayerInventory inventory = player.getInventory();
ItemStack regionselector = new ItemStack(Material.IRON_AXE);
String ItemID = config.getConfig().getString("AxeItemId");
Material WandMaterial;
try
{
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
}
catch(Exception e)
{
WandMaterial = Material.getMaterial(ItemID);
}
ItemStack regionselector = new ItemStack(WandMaterial);
ItemMeta selectorname = regionselector.getItemMeta();
selectorname.setDisplayName("§ePortal Region Selector");
selectorname.setLore(Arrays.asList("§rThis iron axe with has the power to help"
selectorname.setLore(Arrays.asList("§rThis wand with has the power to help"
, "§r create portals bistowed upon it!"));
regionselector.setItemMeta(selectorname);

View File

@ -16,8 +16,6 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
ConfigAccessor config = new ConfigAccessor(this, "Config.yml");
config.saveDefaultConfig();
// Loads the current portal data
new Portals(this);
// Loads the portal and destination editors
new Portal(this);

View File

@ -10,6 +10,8 @@ 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 Listeners implements Listener {
private final AdvancedPortalsPlugin plugin;
@ -17,6 +19,8 @@ public class Listeners implements Listener {
// 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 UseOnlyServerAxe = false;
private Material WandMaterial;
public Listeners(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
@ -24,13 +28,27 @@ public class Listeners implements Listener {
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
this.UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
String ItemID = config.getConfig().getString("AxeItemId");
try
{
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
}
catch(Exception e)
{
WandMaterial = Material.getMaterial(ItemID);
}
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onMoveEvent(PlayerMoveEvent event) {
// will check if the player is in the portal or not.
ConfigAccessor portalsconfig = new ConfigAccessor(plugin, "Portals.yml");
Object[] portals = Portal.Portals;
for(Object portal : portals){
System.out.println(portal.toString());
}
}
@ -45,7 +63,7 @@ public class Listeners implements Listener {
// 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() == Material.IRON_AXE.getId()) {
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) {

View File

@ -1,32 +0,0 @@
package com.sekwah.advancedportals;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class Portals {
private final AdvancedPortalsPlugin plugin;
private List<String> portals;
public Portals(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
this.loadPortalData();
}
public void loadPortalData(){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
List<String> portals = config.getConfig().getStringList("portals");
if(portals.size() > 0){
}
else{
plugin.getLogger().log(Level.INFO, "There are currently no portals!");
}
}
}

View File

@ -14,10 +14,11 @@ public class Portal {
private static AdvancedPortalsPlugin plugin;
private static Object[] Portals;
public static Object[] Portals;
public Portal(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
this.loadPortals();
}
/**
@ -29,7 +30,7 @@ public class Portal {
*
*/
public static void load(){
public static void loadPortals(){
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
Set<String> PortalSet = config.getConfig().getKeys(false);