Fixed chests and made more classes!
This commit is contained in:
@@ -23,7 +23,14 @@ public class ChatListener implements Listener {
|
||||
double radius = plugin.config.getDouble("ChatClose_Radius");
|
||||
List<Entity> near = p.getNearbyEntities(radius, radius, radius);
|
||||
event.setCancelled(true);
|
||||
if(near.size()== 0){
|
||||
if(!(near.size()== 0)){
|
||||
for(Entity e:near){
|
||||
if(e instanceof Player){
|
||||
p.sendMessage(msg);
|
||||
((Player) e).sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}else if(near.size()== 0){
|
||||
p.sendMessage(msg);
|
||||
p.sendMessage(ChatColor.YELLOW + "No one near!");
|
||||
}else if(!(near.size()== 0)){
|
||||
@@ -33,12 +40,6 @@ public class ChatListener implements Listener {
|
||||
p.sendMessage(ChatColor.YELLOW + "No one near!");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(Entity e:near){
|
||||
if(e instanceof Player){
|
||||
((Player) e).sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
plugin.getServer().broadcastMessage(msg);
|
||||
|
@@ -2,6 +2,7 @@ package me.Travja.HungerArena;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
@@ -21,8 +22,6 @@ public class Chests implements Listener {
|
||||
public void ChestSaves(PlayerInteractEvent event){
|
||||
Block block = event.getClickedBlock();
|
||||
Player p = event.getPlayer();
|
||||
//currently crashes the server when refilling....
|
||||
//Kinda glitchy through all here...
|
||||
if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){
|
||||
if(block.getState() instanceof Chest){
|
||||
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
|
||||
@@ -48,6 +47,7 @@ public class Chests implements Listener {
|
||||
plugin.getConfig().set("StorageXYZ", list2);
|
||||
plugin.getConfig().options().copyDefaults(true);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.GREEN + "Chest Stored!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
24
src/me/Travja/HungerArena/CommandBlock.java
Normal file
24
src/me/Travja/HungerArena/CommandBlock.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package me.Travja.HungerArena;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
public class CommandBlock implements Listener {
|
||||
public Main plugin;
|
||||
public CommandBlock(Main m) {
|
||||
this.plugin = m;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void CatchCommand(PlayerCommandPreprocessEvent event){
|
||||
String cmd = event.getMessage();
|
||||
Player p = event.getPlayer();
|
||||
if(!cmd.contains("/ha") && plugin.Playing.contains(p)){
|
||||
event.setCancelled(true);
|
||||
p.sendMessage(ChatColor.RED + "You are only allowed to use /ha commands!");
|
||||
}
|
||||
}
|
||||
}
|
@@ -64,6 +64,9 @@ public class DeathListener implements Listener{
|
||||
}
|
||||
for(Player spectator:plugin.Watching){
|
||||
spectator.setAllowFlight(false);
|
||||
for(Player online:plugin.getServer().getOnlinePlayers()){
|
||||
online.showPlayer(spectator);
|
||||
}
|
||||
}
|
||||
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
|
||||
plugin.Dead.clear();
|
||||
@@ -95,6 +98,9 @@ public class DeathListener implements Listener{
|
||||
}
|
||||
for(Player spectator:plugin.Watching){
|
||||
spectator.setAllowFlight(false);
|
||||
for(Player online:plugin.getServer().getOnlinePlayers()){
|
||||
online.showPlayer(spectator);
|
||||
}
|
||||
}
|
||||
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
|
||||
plugin.Dead.clear();
|
||||
@@ -123,6 +129,9 @@ public class DeathListener implements Listener{
|
||||
}
|
||||
for(Player spectator:plugin.Watching){
|
||||
spectator.setAllowFlight(false);
|
||||
for(Player online:plugin.getServer().getOnlinePlayers()){
|
||||
online.showPlayer(spectator);
|
||||
}
|
||||
}
|
||||
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
|
||||
plugin.Dead.clear();
|
||||
@@ -135,9 +144,5 @@ public class DeathListener implements Listener{
|
||||
}
|
||||
}
|
||||
}
|
||||
if(plugin.Watching.contains(p)){
|
||||
for(Player online:plugin.getServer().getOnlinePlayers())
|
||||
online.showPlayer(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,9 @@ public class JoinAndQuitListener implements Listener {
|
||||
public void onPlayerJoin(PlayerJoinEvent event){
|
||||
Player p = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
for(Player spectator:plugin.Watching){
|
||||
p.hidePlayer(spectator);
|
||||
}
|
||||
if(plugin.Out.contains(p)){
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
|
@@ -56,7 +56,10 @@ public class Main extends JavaPlugin{
|
||||
public Listener Chests = new Chests(this);
|
||||
public Listener PvP = new PvP(this);
|
||||
public Listener Blocks = new Blocks(this);
|
||||
public Listener CommandBlock = new CommandBlock(this);
|
||||
public CommandExecutor HaCommands = new HaCommands(this);
|
||||
public CommandExecutor SponsorCommands = new SponsorCommands(this);
|
||||
public CommandExecutor SpawnsCommand = new SpawnsCommand(this);
|
||||
public boolean canjoin;
|
||||
public boolean exists;
|
||||
public FileConfiguration config;
|
||||
@@ -76,7 +79,10 @@ public class Main extends JavaPlugin{
|
||||
getServer().getPluginManager().registerEvents(Chests, this);
|
||||
getServer().getPluginManager().registerEvents(PvP, this);
|
||||
getServer().getPluginManager().registerEvents(Blocks, this);
|
||||
getServer().getPluginManager().registerEvents(CommandBlock, this);
|
||||
getCommand("Ha").setExecutor(HaCommands);
|
||||
getCommand("Sponsor").setExecutor(SponsorCommands);
|
||||
getCommand("Startpoint").setExecutor(SpawnsCommand);
|
||||
Reward = new ItemStack(config.getInt("Reward.ID"), config.getInt("Reward.Amount"));
|
||||
Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount"));
|
||||
}
|
||||
@@ -84,12 +90,10 @@ public class Main extends JavaPlugin{
|
||||
log = this.getLogger();
|
||||
log.info("HungerArena has been Disabled");
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
|
||||
/*public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
|
||||
Player p = (Player) sender;
|
||||
String pname = p.getName();
|
||||
/*if(cmd.getName().equalsIgnoreCase("Sponsor")){
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(cmd.getName().equalsIgnoreCase("Sponsor")){
|
||||
if(!Playing.contains(p)){
|
||||
if(args.length== 0){
|
||||
p.sendMessage(ChatColor.RED + "You didn't specify a tribute!");
|
||||
@@ -102,12 +106,12 @@ public class Main extends JavaPlugin{
|
||||
p.sendMessage(ChatColor.RED + "You didn't specify an amount!");
|
||||
}
|
||||
if(args.length== 3){
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(args[1].equalsIgnoreCase("57") || args[1].equalsIgnoreCase("7")){
|
||||
p.sendMessage(ChatColor.RED + "You can't sponsor that item!");
|
||||
}else{
|
||||
int ID = Integer.parseInt(args[1]);
|
||||
int Amount = Integer.parseInt(args[2]);
|
||||
Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount")*Amount);
|
||||
ItemStack sponsoritem = new ItemStack(ID, Amount);
|
||||
if(p.getInventory().contains(Cost)){
|
||||
if(!Playing.contains(target)){
|
||||
@@ -782,7 +786,7 @@ public class Main extends JavaPlugin{
|
||||
p.sendMessage(ChatColor.RED + "You don't have permission!");
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
if(cmd.getName().equalsIgnoreCase("StartPoint")){
|
||||
if(p.hasPermission("HungerArena.StartPoint")){
|
||||
if(args[0].equalsIgnoreCase("1")){
|
||||
@@ -1008,7 +1012,7 @@ public class Main extends JavaPlugin{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/*class DeadListener implements Listener{
|
||||
class DeadListener implements Listener{
|
||||
public Main plugin;
|
||||
public DeadListener(Main m){
|
||||
this.plugin = m;
|
||||
@@ -1363,5 +1367,5 @@ public class Main extends JavaPlugin{
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}*/
|
||||
}
|
||||
|
243
src/me/Travja/HungerArena/SpawnsCommand.java
Normal file
243
src/me/Travja/HungerArena/SpawnsCommand.java
Normal file
@@ -0,0 +1,243 @@
|
||||
package me.Travja.HungerArena;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SpawnsCommand implements CommandExecutor {
|
||||
public Main plugin;
|
||||
public SpawnsCommand(Main m) {
|
||||
this.plugin = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
Player p = (Player) sender;
|
||||
if(cmd.getName().equalsIgnoreCase("StartPoint")){
|
||||
if(p.hasPermission("HungerArena.StartPoint")){
|
||||
if(args[0].equalsIgnoreCase("1")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_one_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute one!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("2")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_two_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute two!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("3")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_three_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute three!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("4")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_four_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute four!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("5")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_five_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute five!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("6")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_six_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute six!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("7")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_seven_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute seven!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("8")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_eight_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eight!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("9")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_nine_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute nine!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("10")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_ten_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute ten!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("11")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_eleven_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eleven!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("12")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_twelve_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twelve!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("13")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_thirteen_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute thirteen!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("14")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_fourteen_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute fourteen!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("15")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_fifteen_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute fifteen!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("16")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_sixteen_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute sixteen!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("17")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_seventeen_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute seventeen!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("18")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_eighteen_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eighteen!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("19")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_nineteen_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute nineteen!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("20")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_twenty_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twenty!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("21")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_twentyone_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyone!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("22")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_twentytwo_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentytwo!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("23")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_twentythree_spawn", x + "," + y + "," + z + "," + w);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentythree!");
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("24")){
|
||||
double x = p.getLocation().getX();
|
||||
double y = p.getLocation().getY();
|
||||
double z = p.getLocation().getZ();
|
||||
String w = p.getWorld().getName();
|
||||
plugin.config.set("Tribute_twentyfour_spawn", x + "," + y + "," + z + "," + w);
|
||||
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!");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@@ -112,4 +113,13 @@ public class SpectatorListener implements Listener {
|
||||
System.out.println(p.getName() + " quit while spectating!");
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void MobNerf(EntityTargetEvent event){
|
||||
Entity target = event.getTarget();
|
||||
if(target instanceof Player){
|
||||
if(plugin.Watching.contains(target)){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
66
src/me/Travja/HungerArena/SponsorCommands.java
Normal file
66
src/me/Travja/HungerArena/SponsorCommands.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package me.Travja.HungerArena;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class SponsorCommands implements CommandExecutor {
|
||||
public Main plugin;
|
||||
public SponsorCommands(Main m) {
|
||||
this.plugin = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
Player p = (Player) sender;
|
||||
String pname = p.getName();
|
||||
if(cmd.getName().equalsIgnoreCase("Sponsor")){
|
||||
if(!plugin.Playing.contains(p)){
|
||||
if(args.length== 0){
|
||||
p.sendMessage(ChatColor.RED + "You didn't specify a tribute!");
|
||||
return false;
|
||||
}
|
||||
if(args.length== 1){
|
||||
p.sendMessage(ChatColor.RED + "You didn't specify an item!");
|
||||
}
|
||||
if(args.length== 2){
|
||||
p.sendMessage(ChatColor.RED + "You didn't specify an amount!");
|
||||
}
|
||||
if(args.length== 3){
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(args[1].equalsIgnoreCase("57") || args[1].equalsIgnoreCase("7")){
|
||||
p.sendMessage(ChatColor.RED + "You can't sponsor that item!");
|
||||
}else{
|
||||
int ID = Integer.parseInt(args[1]);
|
||||
int Amount = Integer.parseInt(args[2]);
|
||||
ItemStack sponsoritem = new ItemStack(ID, Amount);
|
||||
if(p.getInventory().contains(plugin.Cost)){
|
||||
if(!plugin.Playing.contains(target)){
|
||||
p.sendMessage(ChatColor.RED + "That person isn't playing!");
|
||||
}else{
|
||||
if(args[0].equalsIgnoreCase(pname)){
|
||||
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
|
||||
}else{
|
||||
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
|
||||
target.getInventory().addItem(sponsoritem);
|
||||
p.sendMessage("You have sponsored " + target.getName() + "!");
|
||||
p.getInventory().removeItem(plugin.Cost);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(ChatColor.RED + "You are playing, you can't sponsor yourself!");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user