Added a custom item to be used as the axe along with a few other edits
This commit is contained in:
parent
5b3259feac
commit
3e8305a85f
|
@ -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
|
# 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
|
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
|
ShowSelectionBlockID: WOOL
|
||||||
ShowSelectionBlockData: 14
|
ShowSelectionBlockData: 14
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.sekwah.advancedportals;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R1.Item;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
@ -33,10 +35,23 @@ public class AdvancedPortalsCommand implements CommandExecutor {
|
||||||
if(sender.hasPermission("AdvancedPortals.CreatePortal")){
|
if(sender.hasPermission("AdvancedPortals.CreatePortal")){
|
||||||
PlayerInventory inventory = player.getInventory();
|
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();
|
ItemMeta selectorname = regionselector.getItemMeta();
|
||||||
selectorname.setDisplayName("§ePortal Region Selector");
|
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!"));
|
, "§r create portals bistowed upon it!"));
|
||||||
regionselector.setItemMeta(selectorname);
|
regionselector.setItemMeta(selectorname);
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||||
ConfigAccessor config = new ConfigAccessor(this, "Config.yml");
|
ConfigAccessor config = new ConfigAccessor(this, "Config.yml");
|
||||||
config.saveDefaultConfig();
|
config.saveDefaultConfig();
|
||||||
|
|
||||||
// Loads the current portal data
|
|
||||||
new Portals(this);
|
|
||||||
|
|
||||||
// Loads the portal and destination editors
|
// Loads the portal and destination editors
|
||||||
new Portal(this);
|
new Portal(this);
|
||||||
|
|
|
@ -10,6 +10,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.portalcontrolls.Portal;
|
||||||
|
|
||||||
public class Listeners implements Listener {
|
public class Listeners implements Listener {
|
||||||
|
|
||||||
private final AdvancedPortalsPlugin plugin;
|
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
|
// 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...
|
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("§eP...
|
||||||
private boolean UseOnlyServerAxe = false;
|
private boolean UseOnlyServerAxe = false;
|
||||||
|
|
||||||
|
private Material WandMaterial;
|
||||||
|
|
||||||
public Listeners(AdvancedPortalsPlugin plugin) {
|
public Listeners(AdvancedPortalsPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
@ -24,13 +28,27 @@ public class Listeners implements Listener {
|
||||||
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
||||||
this.UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
|
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);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMoveEvent(PlayerMoveEvent event) {
|
public void onMoveEvent(PlayerMoveEvent event) {
|
||||||
// will check if the player is in the portal or not.
|
// 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,
|
// 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
|
// 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.
|
// 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.
|
// 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) {
|
if(event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
|
|
|
@ -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!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,10 +14,11 @@ public class Portal {
|
||||||
|
|
||||||
private static AdvancedPortalsPlugin plugin;
|
private static AdvancedPortalsPlugin plugin;
|
||||||
|
|
||||||
private static Object[] Portals;
|
public static Object[] Portals;
|
||||||
|
|
||||||
public Portal(AdvancedPortalsPlugin plugin) {
|
public Portal(AdvancedPortalsPlugin plugin) {
|
||||||
this.plugin = 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");
|
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||||
Set<String> PortalSet = config.getConfig().getKeys(false);
|
Set<String> PortalSet = config.getConfig().getKeys(false);
|
||||||
|
|
Loading…
Reference in New Issue