2: Update code.

This commit is contained in:
YoshiGenius 2012-07-15 19:21:36 +10:00
parent 2445281be8
commit f2d2d634a3
19 changed files with 91 additions and 28 deletions

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import java.util.List;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import java.util.List;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import java.util.List;
@ -74,7 +74,10 @@ public class Chests implements Listener {
plugin.getConfig().options().copyDefaults(true);
plugin.saveConfig();
p.sendMessage("Chest Removed!");
}
} else {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "[HungerArena] That's a storage chest! You don't have permission to break it!");
}
}
}
}

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.*;
import org.bukkit.configuration.file.FileConfiguration;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import java.util.List;
import org.bukkit.Bukkit;
@ -58,7 +58,7 @@ public class HaCommands implements CommandExecutor {
sender.sendMessage(c + "/ha rlist - See who's ready!");
sender.sendMessage(c + "/startpoint [1,2,3,4,etc] - Sets the starting points of tributes!");
sender.sendMessage(ChatColor.GREEN + "----------------------");
return false;
return true;
}else if(args[0].equalsIgnoreCase("List")){
if(p.hasPermission("HungerArena.GameMaker")){
sender.sendMessage(ChatColor.AQUA + "-----People Playing-----");
@ -66,13 +66,16 @@ public class HaCommands implements CommandExecutor {
for(String playernames: plugin.Playing){
Player players = plugin.getServer().getPlayerExact(playernames);
p.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/20");
return true;
}
}else if(plugin.Playing.isEmpty()){
p.sendMessage(ChatColor.GRAY + "No one is playing!");
}
p.sendMessage(ChatColor.AQUA + "----------------------");
return true;
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
return true;
}
}else if(args[0].equalsIgnoreCase("rList")){
if(p.hasPermission("HungerArena.GameMaker")){
@ -86,8 +89,10 @@ public class HaCommands implements CommandExecutor {
p.sendMessage(ChatColor.GRAY + "No one is ready!");
}
p.sendMessage(ChatColor.AQUA + "---------------------");
return true;
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
return true;
}
}else if(args[0].equalsIgnoreCase("SetSpawn")){
if(p.hasPermission("HungerArena.SetSpawn")){
@ -99,26 +104,35 @@ public class HaCommands implements CommandExecutor {
plugin.config.set("Spawns_set", "true");
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn for dead tributes!");
return true;
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
return true;
}
}else if(args[0].equalsIgnoreCase("Join")){
if(p.hasPermission("HungerArena.Join")){
if(plugin.Playing.contains(pname)){
p.sendMessage(ChatColor.RED + "You are already playing!");
return true;
}else if(plugin.Dead.contains(pname) || plugin.Quit.contains(pname)){
p.sendMessage(ChatColor.RED + "You DIED/QUIT! You can't join again!");
return true;
}else if(plugin.Playing.size()== 24){
p.sendMessage(ChatColor.RED + "There are already 24 Tributes!");
return true;
}else if(plugin.canjoin== true){
p.sendMessage(ChatColor.RED + "The game is in progress!");
return true;
}else if(plugin.config.getString("Spawns_set").equalsIgnoreCase("false")){
p.sendMessage(ChatColor.RED + "/ha setspawn hasn't been run!");
return true;
}else if(plugin.NeedConfirm.contains(pname)){
p.sendMessage(ChatColor.RED + "You need to do /ha confirm");
return true;
}else if(plugin.config.getString("Need_Confirm").equalsIgnoreCase("true")){
plugin.NeedConfirm.add(pname);
p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede");
return true;
}else{
plugin.Playing.add(pname);
p.getInventory().clear();
@ -130,9 +144,11 @@ public class HaCommands implements CommandExecutor {
if(plugin.Playing.size()== 24){
p.performCommand("ha warpall");
}
return true;
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
return true;
}
}else if(args[0].equalsIgnoreCase("Confirm")){
if(plugin.NeedConfirm.contains(pname)){
@ -148,26 +164,32 @@ public class HaCommands implements CommandExecutor {
if(plugin.Playing.size()== 24){
p.performCommand("ha warpall");
}
return true;
}
}else if(args[0].equalsIgnoreCase("Ready")){
if(plugin.Playing.contains(pname)){
if(plugin.Ready.contains(pname)){
p.sendMessage(ChatColor.RED + "You're already ready!");
return true;
}else if(plugin.Playing.size()== 1){
p.sendMessage(ChatColor.RED + "You can't be ready when no one else is playing!");
return true;
}else{
plugin.Ready.add(pname);
p.sendMessage(ChatColor.AQUA + "You have marked yourself as READY!");
if(plugin.Playing.size()-4== plugin.Ready.size()){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha warpall");
return true;
}
}
}else if(!plugin.Playing.contains(pname)){
p.sendMessage(ChatColor.RED + "You aren't playing!");
return true;
}
}else if(args[0].equalsIgnoreCase("Leave")){
if(!plugin.Playing.contains(pname)){
p.sendMessage(ChatColor.RED + "You aren't playing!");
return true;
}else if(plugin.canjoin== false){
plugin.Playing.remove(pname);
p.sendMessage(ChatColor.AQUA + "You have left the game!");
@ -181,6 +203,7 @@ public class HaCommands implements CommandExecutor {
if(plugin.Frozen.contains(pname)){
plugin.Frozen.remove(pname);
}
return true;
}else{
plugin.Playing.remove(pname);
plugin.Quit.add(pname);
@ -208,6 +231,7 @@ public class HaCommands implements CommandExecutor {
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
Bukkit.getServer().getPluginManager().callEvent(new PlayerWinGamesEvent(winner));
plugin.Playing.clear();
//Show spectators
String s = plugin.Watching.get(i++);
@ -221,6 +245,7 @@ public class HaCommands implements CommandExecutor {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}
return true;
}
}else if(args[0].equalsIgnoreCase("Watch")){
if(sender.hasPermission("HungerArena.Watch")){
@ -231,10 +256,13 @@ public class HaCommands implements CommandExecutor {
}
p.setAllowFlight(true);
p.sendMessage(ChatColor.AQUA + "You can now spectate!");
return true;
}else if(plugin.canjoin== false){
p.sendMessage(ChatColor.RED + "The game isn't in progress!");
return true;
}else if(plugin.Playing.contains(pname)){
p.sendMessage(ChatColor.RED + "You can't watch while you're playing!");
return true;
}else if(plugin.Watching.contains(pname)){
plugin.Watching.remove(pname);
for(Player online:plugin.getServer().getOnlinePlayers()){
@ -242,12 +270,17 @@ public class HaCommands implements CommandExecutor {
}
p.teleport(Spawn);
p.setAllowFlight(false);
p.sendMessage(ChatColor.AQUA + "You are not spectating anymore");
p.sendMessage(ChatColor.AQUA + "You are not spectating any more");
return true;
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
return true;
}
}else if(args[0].equalsIgnoreCase("Kick")){
if (args.length != 2) {
return false;
}
Player target = plugin.getServer().getPlayer(args[1]);
if(sender.hasPermission("HungerArena.Kick")){
if(plugin.Playing.contains(target.getName())){
@ -272,6 +305,7 @@ public class HaCommands implements CommandExecutor {
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
Bukkit.getServer().getPluginManager().callEvent(new PlayerWinGamesEvent(winner));
plugin.Playing.clear();
if(!plugin.Watching.isEmpty()){
String s = plugin.Watching.get(i++);
@ -863,6 +897,7 @@ public class HaCommands implements CommandExecutor {
winner.getInventory().setHelmet(null);
winner.getInventory().setLeggings(null);
winner.getInventory().addItem(plugin.Reward);
Bukkit.getServer().getPluginManager().callEvent(new PlayerWinGamesEvent(winner));
plugin.Playing.clear();
//Make spectators visible
if(!plugin.Watching.isEmpty()){

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import java.util.ArrayList;
import java.util.HashSet;
@ -65,15 +65,24 @@ public class Main extends JavaPlugin{
getCommand("Startpoint").setExecutor(SpawnsCommand);
if (setupEconomy()) {
log.info(ChatColor.AQUA + "[HungerArena] Found Vault! Hooking in for economy!");
vault = true;
}
if (config.getBoolean("Economy_Support", true)) {
if (config.getDouble("config.version") != 1.3) {
config.set("config.version", 1.3);
config.set("eco.enabled", false);
config.set("eco.reward", 100);
}
if (config.getBoolean("eco.enabled", true)) {
if (vault == true) {
log.info(ChatColor.AQUA + "Economy hook deployed.");
} else {
log.info(ChatColor.RED + "You want economy support... yet you don't have Vault. Sorry, can't give you it.");
}
}
if (config.getBoolean("eco.enabled", false)) {
if (vault == true) {
log.info(ChatColor.GREEN + "We see that you have Vault on your server. To set economy support to true, enable it in the config.");
}
}
Reward = new ItemStack(config.getInt("Reward.ID"), config.getInt("Reward.Amount"));
Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount"));
}
@ -91,6 +100,7 @@ public class Main extends JavaPlugin{
return false;
}
econ = rsp.getProvider();
vault = true;
return econ != null;
}
}

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.ChatColor;
import org.bukkit.Material;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -29,7 +29,17 @@ public class SpectatorListener implements Listener {
}
}
@EventHandler
public void SpectatorInteractions(PlayerInteractEvent event){
public void SpectatorInteractBlock(PlayerInteractEvent event){
Player p = event.getPlayer();
String pname = p.getName();
if(plugin.Watching.contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractEntity(PlayerInteractEntityEvent event){
Player p = event.getPlayer();
String pname = p.getName();
if(plugin.Watching.contains(pname)){

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

View File

@ -1,4 +1,4 @@
package me.Travja.HungerArena;
package me.travja.hungerarena;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -18,6 +18,7 @@ public class WinGamesListener implements Listener {
@EventHandler
public void onWin(PlayerWinGamesEvent evt) {
Player p = evt.getPlayer();
plugin.econ.depositPlayer(p.getName(), plugin.config.getDouble("EcoReward"));
}
}

View File

@ -1,4 +1,7 @@
# default config.yml
#config version for us devs. DONT CHANGE THIS, or it will screw up some things PRETTY badly.
config:
version: 1.3
# Message to display when the games start
Start_Message: '&bLet The Games Begin!'
# If the games should automatically restart at the end
@ -19,7 +22,7 @@ Sponsor_Cost:
Countdown: 'true'
Spawn_coords: 100,100,100,world
# 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
@ -55,9 +58,9 @@ 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.
Economy_Support: 'false'
eco:
enabled: false
reward: 100
# How much money to give the winner.
Economy_Reward:
Amount: 100
# Leave this. :)
Blocks_Destroyed:

View File

@ -1,7 +1,8 @@
name: HungerArena
main: me.Travja.HungerArena.Main
main: me.travja.hungerarena.Main
version: 1.3alpha
description: A lightweight and powerful plugin to help with playing The Hunger Games!
softdepend: [Vault]
commands:
Ha:
description: Base command for HungerArena!