Fixed world restrictions

This commit is contained in:
travja 2012-08-25 11:58:12 -06:00
parent 73e7050762
commit 3d90d9afce
9 changed files with 13 additions and 10 deletions

Binary file not shown.

View File

@ -84,7 +84,7 @@ ChatClose_Radius: 10
######################## ########################
Spawn_coords: 100,100,100,world Spawn_coords: 100,100,100,world
# If /ha setspawn has been run # If /ha setspawn has been run
Spawn_set: 'false' Spawns_set: 'false'
Tribute_one_spawn: 100,100,100 Tribute_one_spawn: 100,100,100
Tribute_two_spawn: 100,100,100 Tribute_two_spawn: 100,100,100
Tribute_three_spawn: 100,100,100 Tribute_three_spawn: 100,100,100

View File

@ -25,7 +25,7 @@ public class Chests implements Listener {
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
Player p = event.getPlayer(); Player p = event.getPlayer();
if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){ if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){
if(!plugin.restricted || (plugin.restricted && plugin.config.getStringList("worlds").contains(p.getWorld().toString()))){ if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
if(block.getState() instanceof Chest){ if(block.getState() instanceof Chest){
if(p.hasPermission("HungerArena.Chest.Store")){ if(p.hasPermission("HungerArena.Chest.Store")){
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents(); ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();

View File

@ -35,9 +35,9 @@ public class HaCommands implements CommandExecutor {
final String pname = p.getName(); final String pname = p.getName();
ChatColor c = ChatColor.AQUA; ChatColor c = ChatColor.AQUA;
if(cmd.getName().equalsIgnoreCase("Ha")){ if(cmd.getName().equalsIgnoreCase("Ha")){
if(plugin.restricted && !plugin.config.getStringList("worlds").contains(p.getWorld().toString())){ if(plugin.restricted && !plugin.worlds.contains(p.getWorld().getName())){
p.sendMessage(ChatColor.RED + "That can't be run in this world!"); p.sendMessage(ChatColor.RED + "That can't be run in this world!");
}else if((plugin.restricted && plugin.config.getStringList("worlds").contains(p.getWorld().toString())) || !plugin.restricted){ }else if((plugin.restricted && plugin.worlds.contains(p.getWorld().getName())) || !plugin.restricted){
if(args.length== 0){ if(args.length== 0){
p.sendMessage(ChatColor.GREEN + "[HungerArena] by " + ChatColor.AQUA + "travja!"); p.sendMessage(ChatColor.GREEN + "[HungerArena] by " + ChatColor.AQUA + "travja!");
return false; return false;

View File

@ -2,6 +2,7 @@ package me.Travja.HungerArena;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -22,6 +23,7 @@ public class Main extends JavaPlugin{
public ArrayList<String> Watching = new ArrayList<String>(); public ArrayList<String> Watching = new ArrayList<String>();
public ArrayList<String> NeedConfirm = new ArrayList<String>(); public ArrayList<String> NeedConfirm = new ArrayList<String>();
public HashSet<String> Frozen = new HashSet<String>(); public HashSet<String> Frozen = new HashSet<String>();
public List<String> worlds;
public Listener DeathListener = new DeathListener(this); public Listener DeathListener = new DeathListener(this);
public Listener SpectatorListener = new SpectatorListener(this); public Listener SpectatorListener = new SpectatorListener(this);
public Listener FreezeListener = new FreezeListener(this); public Listener FreezeListener = new FreezeListener(this);
@ -90,9 +92,10 @@ public class Main extends JavaPlugin{
} }
Reward = new ItemStack(config.getInt("Reward.ID"), config.getInt("Reward.Amount")); Reward = new ItemStack(config.getInt("Reward.ID"), config.getInt("Reward.Amount"));
Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount")); Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount"));
if(config.getStringList("worlds").isEmpty()){ worlds = config.getStringList("worlds");
if(worlds.isEmpty()){
restricted = false; restricted = false;
}else if(!config.getStringList("worlds").isEmpty()){ }else if(!worlds.isEmpty()){
restricted = true; restricted = true;
} }
} }

View File

@ -18,8 +18,8 @@ public class SpawnsCommand implements CommandExecutor {
Player p = (Player) sender; Player p = (Player) sender;
if(cmd.getName().equalsIgnoreCase("StartPoint")){ if(cmd.getName().equalsIgnoreCase("StartPoint")){
if(p.hasPermission("HungerArena.StartPoint")){ if(p.hasPermission("HungerArena.StartPoint")){
if(!plugin.restricted || (plugin.restricted && plugin.config.getStringList("worlds").contains(p.getWorld().toString()))){ if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
if(plugin.restricted && !plugin.config.getStringList("worlds").contains(p.getWorld().toString())){ if(plugin.restricted && !plugin.worlds.contains(p.getWorld().toString())){
p.sendMessage(ChatColor.GOLD + "We ran the command, however, this isn't a world you defined in the config..."); p.sendMessage(ChatColor.GOLD + "We ran the command, however, this isn't a world you defined in the config...");
p.sendMessage(ChatColor.GOLD + "If this is the right world, please disregard this message."); p.sendMessage(ChatColor.GOLD + "If this is the right world, please disregard this message.");
} }