Added world restrictions

This commit is contained in:
travja 2012-08-25 10:09:49 -06:00
parent 368b69f0f2
commit 73e7050762
38 changed files with 1035 additions and 971 deletions

View File

@ -2,7 +2,7 @@
<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.6"/>
<classpathentry kind="lib" path="C:/Users/Travja/Documents/Projects/Vault.jar"/>
<classpathentry kind="lib" path="C:/Users/Travja/Downloads/bukkit-1.3.1-R1.1-20120809.005103-3.jar"/>
<classpathentry kind="lib" path="C:/Users/Travja/Documents/Plugins/Vault.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Binary file not shown.

View File

@ -1,41 +1,90 @@
# default config.yml
#config version for us devs. DONT CHANGE THIS, or it will screw up some things PRETTY badly.
config:
version: 1.3
######################################
######## Game Configuration #########
######################################
# The world(s) that all HA features are restricted to.
# If left blank all worlds will be allowed.
# ie:
# worlds:
# - world
# - world_nether
worlds:
# Message to display when the games start
Start_Message: '&bLet The Games Begin!'
# If the games should automatically restart at the end
Auto_Restart: 'false'
# If it should automatically start the countdown on warping
Auto_Start: 'false'
# If tributes need to type /ha confirm to join
Need_Confirm: 'true'
# Not yet implemented
iConomy_Support: 'false'
# Whether or not the countdown will start upon warping.
Countdown: 'true'
# Whether or not players can break blocks while playing
Protected_Arena: 'true'
# Whether or not players will be frozen when they are teleported to their positions
Frozen_Teleport: 'true'
# If the Tributes will get blown to bits when stepping off the pedestal
Explode_on_Move: 'false'
# Whether or not thunder will sound upon a players death
Cannon_Death: 'true'
######################################
######################################
######################################
################################
###### Rewards/Sponsoring ######
################################
# What the reward for winning is
Reward:
ID: 264
Amount: 10
# True means give money to winner, false means don't.
eco:
enabled: false
reward: 100
# How much money to give the winner.
# What sponsors have to pay to sponsor tributes
Sponsor_Cost:
ID: 264
Amount: 1
# Whether or not the countdown will start upon warping.
Countdown: 'true'
Spawn_coords: 100,100,100,world
################################
################################
################################
#############################
####### Chat Related ########
#############################
# If players will only talk to close players of the whole server
ChatClose: 'true'
ChatClose: 'false'
# How close the players have to be to talk to them
ChatClose_Radius: 10
# Whether or not players can break blocks while playing
Protected_Arena: 'true'
# Whether or not players will be frozen when they are teleported to their positions
Frozen_Teleport: 'true'
# If the Tributes will get blown to bits when stepping off the pedestal
Explode_on_Move: 'false'
# Whether or not thunder will sound upon a players death
Cannon_Death: 'true'
#############################
#############################
#############################
########################
####### Spawns #########
########################
Spawn_coords: 100,100,100,world
# If /ha setspawn has been run
Spawn_set: 'false'
Tribute_one_spawn: 100,100,100
Tribute_two_spawn: 100,100,100
Tribute_three_spawn: 100,100,100
@ -60,12 +109,9 @@ Tribute_twentyone_spawn: 100,100,100
Tribute_twentytwo_spawn: 100,100,100
Tribute_twentythree_spawn: 100,100,100
Tribute_twentyfour_spawn: 100,100,100
# If /ha setspawn has been run
Spawn_set: 'false'
# True means give money to winner, false means don't.
eco:
enabled: false
reward: 100
# How much money to give the winner.
########################
########################
########################
# Leave this. :)
Blocks_Destroyed:

View File

@ -25,6 +25,7 @@ public class Chests implements Listener {
Block block = event.getClickedBlock();
Player p = event.getPlayer();
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(block.getState() instanceof Chest){
if(p.hasPermission("HungerArena.Chest.Store")){
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
@ -57,6 +58,7 @@ public class Chests implements Listener {
}
}
}
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player p = event.getPlayer();

View File

@ -35,6 +35,9 @@ public class HaCommands implements CommandExecutor {
final String pname = p.getName();
ChatColor c = ChatColor.AQUA;
if(cmd.getName().equalsIgnoreCase("Ha")){
if(plugin.restricted && !plugin.config.getStringList("worlds").contains(p.getWorld().toString())){
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){
if(args.length== 0){
p.sendMessage(ChatColor.GREEN + "[HungerArena] by " + ChatColor.AQUA + "travja!");
return false;
@ -791,6 +794,7 @@ public class HaCommands implements CommandExecutor {
p.sendMessage(ChatColor.RED + "Unknown command, type /ha help for a list of commands");
}
}
}
}else if(sender instanceof ConsoleCommandSender){
if(cmd.getName().equalsIgnoreCase("Ha")){
if(args.length== 0){

View File

@ -41,6 +41,7 @@ public class Main extends JavaPlugin{
public CommandExecutor SpawnsCommand = new SpawnsCommand(this);
public boolean canjoin;
public boolean exists;
public boolean restricted;
public FileConfiguration config;
public ItemStack Reward;
public ItemStack Cost;
@ -89,6 +90,11 @@ public class Main extends JavaPlugin{
}
Reward = new ItemStack(config.getInt("Reward.ID"), config.getInt("Reward.Amount"));
Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount"));
if(config.getStringList("worlds").isEmpty()){
restricted = false;
}else if(!config.getStringList("worlds").isEmpty()){
restricted = true;
}
}
public void onDisable(){

View File

@ -18,6 +18,11 @@ public class SpawnsCommand implements CommandExecutor {
Player p = (Player) sender;
if(cmd.getName().equalsIgnoreCase("StartPoint")){
if(p.hasPermission("HungerArena.StartPoint")){
if(!plugin.restricted || (plugin.restricted && plugin.config.getStringList("worlds").contains(p.getWorld().toString()))){
if(plugin.restricted && !plugin.config.getStringList("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 + "If this is the right world, please disregard this message.");
}
Location ploc = p.getLocation().getBlock().getLocation();
if(args[0].equalsIgnoreCase("1")){
double x = ploc.getX();
@ -235,6 +240,7 @@ public class SpawnsCommand implements CommandExecutor {
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyfour!");
}
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}

View File

@ -17,7 +17,7 @@ public class TeleportListener implements Listener {
this.plugin = m;
}
@EventHandler
/*@EventHandler Unwanted right now...
public void onTP(PlayerTeleportEvent evt) {
@SuppressWarnings("unused")
Player p = evt.getPlayer();
@ -32,6 +32,6 @@ public class TeleportListener implements Listener {
return;
}
evt.setCancelled(true);
}
}*/
}