@ -6,9 +6,12 @@ import java.util.List;
import org.bukkit.Bukkit ;
import org.bukkit.ChatColor ;
import org.bukkit.Location ;
import org.bukkit.Material ;
import org.bukkit.Sound ;
import org.bukkit.World ;
import org.bukkit.block.Sign ;
import org.bukkit.entity.Arrow ;
import org.bukkit.entity.Item ;
import org.bukkit.entity.Player ;
import org.bukkit.entity.Projectile ;
@ -22,6 +25,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause ;
import org.bukkit.event.entity.EntityShootBowEvent ;
import org.bukkit.event.entity.FoodLevelChangeEvent ;
import org.bukkit.event.entity.ProjectileLaunchEvent ;
import org.bukkit.event.inventory.ClickType ;
import org.bukkit.event.inventory.InventoryClickEvent ;
import org.bukkit.event.inventory.InventoryCloseEvent ;
@ -39,8 +43,12 @@ import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack ;
import org.bukkit.potion.PotionEffect ;
import org.bukkit.potion.PotionEffectType ;
import org.bukkit.projectiles.ProjectileSource ;
import org.bukkit.scheduler.BukkitRunnable ;
import com.google.common.io.ByteArrayDataOutput ;
import com.google.common.io.ByteStreams ;
import cx.sfy.TheBridge.Main ;
import cx.sfy.TheBridge.cosmetics.Cage ;
import cx.sfy.TheBridge.database.PlayerStat ;
@ -67,18 +75,54 @@ public class PlayerListener implements Listener {
this . plugin = plugin ;
}
public void runTask ( ) {
Bukkit . getScheduler ( ) . runTaskTimer ( this . plugin , ( ) - > {
for ( GameDuo gd : plugin . getGm ( ) . getGames ( ) ) {
for ( Location loc : gd . getBuild ( ) ) {
World world = loc . getWorld ( ) ;
if ( world = = null ) {
continue ;
}
for ( Projectile proj : world . getEntitiesByClass ( Projectile . class ) ) {
ProjectileSource p = proj . getShooter ( ) ;
if ( ! ( p instanceof Player ) ) {
continue ;
}
createTrail ( proj . getLocation ( ) ,
plugin . getArm ( ) . getArrowByName ( PlayerStat . getPlayerStat ( ( Player ) p ) . getArrow ( ) ) ) ;
}
}
}
} , 5 , 5 ) ;
}
@EventHandler
public void onShoot ( ProjectileLaunchEvent e ) {
if ( e . getEntity ( ) instanceof Arrow ) {
runTask ( ) ;
}
}
@EventHandler
public void onJoin ( PlayerJoinEvent e ) {
final Player p = e . getPlayer ( ) ;
new PlayerStat ( p ) ;
givePlayerItems ( p ) ;
Utils . setPlayerExperience ( p , PlayerStat . getPlayerStat ( p ) . getXP ( ) ) ;
Utils . setPlayerExperience ( p , PlayerStat . getPlayerStat ( p ) . getXp ( ) ) ;
}
public void createTrail ( Location loc , cx . sfy . TheBridge . cosmetics . Arrow arrow ) {
plugin . getNms ( ) . sendParticle ( loc , arrow ) ;
}
@EventHandler
public void onCommand ( PlayerCommandPreprocessEvent e ) {
if ( plugin . getGM ( ) . getGameByPlayer ( e . getPlayer ( ) ) ! = null
| | plugin . getGM ( ) . getGameFourByPlayer ( e . getPlayer ( ) ) ! = null ) {
if ( plugin . getGm ( ) . getGameByPlayer ( e . getPlayer ( ) ) ! = null
| | plugin . getGm ( ) . getGameFourByPlayer ( e . getPlayer ( ) ) ! = null ) {
final List < String > cmds = plugin . getConfig ( ) . getStringList ( "commands.list" ) ;
if ( e . getMessage ( ) . contains ( "/bridges" ) )
return ;
@ -112,6 +156,16 @@ public class PlayerListener implements Listener {
plugin . getConfig ( ) . getInt ( "items.shop.amount" ) , ( short ) plugin . getConfig ( ) . getInt ( "items.shop.data" ) ,
plugin . getConfig ( ) . getString ( "items.shop.nameItem" ) . replaceAll ( "&" , "§" ) ,
plugin . getConfig ( ) . getString ( "items.shop.loreItem" ) . replaceAll ( "&" , "§" ) ) ;
final ItemStack lobby = ItemBuilder . item ( Material . valueOf ( plugin . getConfig ( ) . getString ( "items.lobby.material" ) ) ,
plugin . getConfig ( ) . getInt ( "items.lobby.amount" ) , ( short ) plugin . getConfig ( ) . getInt ( "items.lobby.data" ) ,
plugin . getConfig ( ) . getString ( "items.lobby.nameItem" ) . replaceAll ( "&" , "§" ) ,
plugin . getConfig ( ) . getString ( "items.lobby.loreItem" ) . replaceAll ( "&" , "§" ) ) ;
final ItemStack archievements = ItemBuilder . item (
Material . valueOf ( plugin . getConfig ( ) . getString ( "items.archievements.material" ) ) ,
plugin . getConfig ( ) . getInt ( "items.archievements.amount" ) ,
( short ) plugin . getConfig ( ) . getInt ( "items.archievements.data" ) ,
plugin . getConfig ( ) . getString ( "items.archievements.nameItem" ) . replaceAll ( "&" , "§" ) ,
plugin . getConfig ( ) . getString ( "items.archievements.loreItem" ) . replaceAll ( "&" , "§" ) ) ;
if ( plugin . getConfig ( ) . getBoolean ( "items.menu.enabled" ) )
p . getInventory ( ) . setItem ( plugin . getConfig ( ) . getInt ( "items.menu.slot" ) , select ) ;
if ( plugin . getConfig ( ) . getBoolean ( "items.random.enabled" ) )
@ -120,6 +174,10 @@ public class PlayerListener implements Listener {
p . getInventory ( ) . setItem ( plugin . getConfig ( ) . getInt ( "items.hotbar.slot" ) , hotbar ) ;
if ( plugin . getConfig ( ) . getBoolean ( "items.shop.enabled" ) )
p . getInventory ( ) . setItem ( plugin . getConfig ( ) . getInt ( "items.shop.slot" ) , shop ) ;
if ( plugin . getConfig ( ) . getBoolean ( "items.lobby.enabled" ) )
p . getInventory ( ) . setItem ( plugin . getConfig ( ) . getInt ( "items.lobby.slot" ) , lobby ) ;
if ( plugin . getConfig ( ) . getBoolean ( "items.archievements.enabled" ) )
p . getInventory ( ) . setItem ( plugin . getConfig ( ) . getInt ( "items.archievements.slot" ) , archievements ) ;
}
@EventHandler
@ -131,11 +189,11 @@ public class PlayerListener implements Listener {
e . getItemDrop ( ) . remove ( ) ;
e . setCancelled ( true ) ;
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
e . setCancelled ( true ) ;
return ;
}
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
e . setCancelled ( true ) ;
return ;
}
@ -179,12 +237,32 @@ public class PlayerListener implements Listener {
if ( item . getItemStack ( ) . equals ( random ) )
e . setCancelled ( true ) ;
}
if ( plugin . getConfig ( ) . getBoolean ( "items.lobby.enabled" ) ) {
final ItemStack random = ItemBuilder . item (
Material . valueOf ( plugin . getConfig ( ) . getString ( "items.lobby.material" ) ) ,
plugin . getConfig ( ) . getInt ( "items.lobby.amount" ) ,
( short ) plugin . getConfig ( ) . getInt ( "items.lobby.data" ) ,
plugin . getConfig ( ) . getString ( "items.lobby.nameItem" ) . replaceAll ( "&" , "§" ) ,
plugin . getConfig ( ) . getString ( "items.lobby.loreItem" ) . replaceAll ( "&" , "§" ) ) ;
if ( item . getItemStack ( ) . equals ( random ) )
e . setCancelled ( true ) ;
}
if ( plugin . getConfig ( ) . getBoolean ( "items.archievements.enabled" ) ) {
final ItemStack random = ItemBuilder . item (
Material . valueOf ( plugin . getConfig ( ) . getString ( "items.archievements.material" ) ) ,
plugin . getConfig ( ) . getInt ( "items.archievements.amount" ) ,
( short ) plugin . getConfig ( ) . getInt ( "items.archievements.data" ) ,
plugin . getConfig ( ) . getString ( "items.archievements.nameItem" ) . replaceAll ( "&" , "§" ) ,
plugin . getConfig ( ) . getString ( "items.archievements.loreItem" ) . replaceAll ( "&" , "§" ) ) ;
if ( item . getItemStack ( ) . equals ( random ) )
e . setCancelled ( true ) ;
}
}
@EventHandler
public void onInteract ( PlayerInteractEvent e ) {
final Player p = e . getPlayer ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
if ( p . getItemInHand ( ) = = null | | p . getItemInHand ( ) . getType ( ) = = Material . AIR )
return ;
final ItemStack item = p . getItemInHand ( ) ;
@ -193,10 +271,10 @@ public class PlayerListener implements Listener {
if ( item . getType ( ) . equals ( Material . PAPER )
& & item . getItemMeta ( ) . getDisplayName ( ) . equals ( plugin . getLang ( ) . get ( "items.teams.nameItem" ) ) ) {
e . setCancelled ( true ) ;
plugin . getTEM ( ) . openTeamNormalMenu ( p ) ;
plugin . getTem ( ) . openTeamNormalMenu ( p ) ;
}
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
if ( p . getItemInHand ( ) = = null | | p . getItemInHand ( ) . getType ( ) = = Material . AIR )
return ;
final ItemStack item = p . getItemInHand ( ) ;
@ -210,18 +288,18 @@ public class PlayerListener implements Listener {
if ( item . getType ( ) . equals ( Material . COMPASS )
& & item . getItemMeta ( ) . getDisplayName ( ) . equals ( plugin . getLang ( ) . get ( "items.spectate.nameItem" ) ) ) {
e . setCancelled ( true ) ;
plugin . getSPM ( ) . openSpectPlayerMenu ( p ) ;
plugin . getSpm ( ) . openSpectPlayerMenu ( p ) ;
}
if ( item . getType ( ) . equals ( Material . PAPER )
& & item . getItemMeta ( ) . getDisplayName ( ) . equals ( plugin . getLang ( ) . get ( "items.teams.nameItem" ) ) ) {
e . setCancelled ( true ) ;
plugin . getTEM ( ) . openTeamFourMenu ( p ) ;
plugin . getTem ( ) . openTeamFourMenu ( p ) ;
}
if ( item . getType ( ) . equals ( Material . REDSTONE_COMPARATOR )
| | item . getType ( ) . equals ( Material . REDSTONE_COMPARATOR_OFF ) & & item . getItemMeta ( ) . getDisplayName ( )
. equals ( plugin . getLang ( ) . get ( "items.config.nameItem" ) ) ) {
e . setCancelled ( true ) ;
plugin . getSOM ( ) . openOptionsMenu ( p ) ;
plugin . getSom ( ) . openOptionsMenu ( p ) ;
}
if ( item . getType ( ) . equals ( Material . BED )
& & item . getItemMeta ( ) . getDisplayName ( ) . equals ( plugin . getLang ( ) . get ( "items.leave.nameItem" ) ) ) {
@ -240,7 +318,7 @@ public class PlayerListener implements Listener {
}
}
}
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
final ItemStack item = p . getItemInHand ( ) ;
if ( item . getType ( ) . equals ( Material . BOW ) )
if ( bow . contains ( p ) ) {
@ -266,7 +344,7 @@ public class PlayerListener implements Listener {
}
}
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) = = null & & plugin . getGM ( ) . getGameByPlayer ( p ) = = null ) {
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) = = null & & plugin . getGm ( ) . getGameByPlayer ( p ) = = null ) {
if ( p . getItemInHand ( ) ! = null & & p . getItemInHand ( ) . getType ( ) ! = Material . AIR ) {
final ItemStack item = p . getItemInHand ( ) ;
if ( item . hasItemMeta ( ) ) {
@ -278,7 +356,7 @@ public class PlayerListener implements Listener {
plugin . getConfig ( ) . getString ( "items.menu.nameItem" ) . replaceAll ( "&" , "§" ) ,
plugin . getConfig ( ) . getString ( "items.menu.loreItem" ) . replaceAll ( "&" , "§" ) ) ;
if ( item . equals ( select ) )
plugin . getGMU ( ) . openSelectTypeMenu ( p ) ;
plugin . getGmu ( ) . openSelectTypeMenu ( p ) ;
}
if ( plugin . getConfig ( ) . getBoolean ( "items.random.enabled" ) )
if ( ! leaving . contains ( p ) ) {
@ -291,7 +369,7 @@ public class PlayerListener implements Listener {
if ( item . equals ( random ) ) {
GameDuo g = null ;
int alto = 0 ;
for ( final GameDuo game : plugin . getGM ( ) . getGames ( ) ) {
for ( final GameDuo game : plugin . getGm ( ) . getGames ( ) ) {
if ( game . isState ( State . FINISH ) | | game . isState ( State . INGAME )
| | game . isState ( State . RESTARTING ) | | game . isState ( State . PREGAME ) )
continue ;
@ -303,7 +381,7 @@ public class PlayerListener implements Listener {
}
}
if ( g ! = null )
plugin . getGM ( ) . addPlayerGame ( p , g ) ;
plugin . getGm ( ) . addPlayerGame ( p , g ) ;
else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.noGames" ) ) ;
}
@ -328,6 +406,38 @@ public class PlayerListener implements Listener {
if ( item . equals ( random ) )
plugin . getShop ( ) . openShopMenu ( p ) ;
}
if ( plugin . getConfig ( ) . getBoolean ( "items.archievements.enabled" ) ) {
final ItemStack random = ItemBuilder . item (
Material . valueOf ( plugin . getConfig ( ) . getString ( "items.archievements.material" ) ) ,
plugin . getConfig ( ) . getInt ( "items.archievements.amount" ) ,
( short ) plugin . getConfig ( ) . getInt ( "items.archievements.data" ) ,
plugin . getConfig ( ) . getString ( "items.archievements.nameItem" ) . replaceAll ( "&" , "§" ) ,
plugin . getConfig ( ) . getString ( "items.archievements.loreItem" ) . replaceAll ( "&" , "§" ) ) ;
if ( item . equals ( random ) )
plugin . getArchimenu ( ) . createArchievementsMenu ( p , 1 ) ;
}
if ( plugin . getConfig ( ) . getBoolean ( "items.lobby.enabled" ) ) {
final ItemStack random = ItemBuilder . item (
Material . valueOf ( plugin . getConfig ( ) . getString ( "items.lobby.material" ) ) ,
plugin . getConfig ( ) . getInt ( "items.lobby.amount" ) ,
( short ) plugin . getConfig ( ) . getInt ( "items.lobby.data" ) ,
plugin . getConfig ( ) . getString ( "items.lobby.nameItem" ) . replaceAll ( "&" , "§" ) ,
plugin . getConfig ( ) . getString ( "items.lobby.loreItem" ) . replaceAll ( "&" , "§" ) ) ;
if ( item . equals ( random ) ) {
ByteArrayDataOutput out = ByteStreams . newDataOutput ( ) ;
out . writeUTF ( "Connect" ) ;
out . writeUTF ( plugin . getConfig ( ) . getString ( "items.lobby.server" ) ) ;
try {
p . sendPluginMessage ( Main . get ( ) , "BungeeCord" , out . toByteArray ( ) ) ;
} catch ( Exception ex ) {
e . setCancelled ( true ) ;
plugin . getServer ( ) . getConsoleSender ( )
. sendMessage ( ChatColor . RED + "Server " + ChatColor . YELLOW
+ plugin . getConfig ( ) . getString ( "items.lobby.server" ) + ChatColor . RED
+ " not found... Please check you config!" ) ;
}
}
}
}
}
if ( e . getAction ( ) . equals ( Action . RIGHT_CLICK_BLOCK ) | | e . getAction ( ) . equals ( Action . LEFT_CLICK_BLOCK ) )
@ -336,27 +446,27 @@ public class PlayerListener implements Listener {
return ;
if ( leaving . contains ( p ) )
return ;
if ( plugin . getSIM ( ) . getSigns ( ) . keySet ( ) . contains ( e . getClickedBlock ( ) . getLocation ( ) ) ) {
final GameNormalSign sign = plugin . getSIM ( ) . getSigns ( ) . get ( e . getClickedBlock ( ) . getLocation ( ) ) ;
final GameDuo game = plugin . getGM ( ) . getGameByName ( sign . getGame ( ) ) ;
if ( plugin . getSim ( ) . getSigns ( ) . keySet ( ) . contains ( e . getClickedBlock ( ) . getLocation ( ) ) ) {
final GameNormalSign sign = plugin . getSim ( ) . getSigns ( ) . get ( e . getClickedBlock ( ) . getLocation ( ) ) ;
final GameDuo game = plugin . getGm ( ) . getGameByName ( sign . getGame ( ) ) ;
if ( game . isState ( State . WAITING ) | | game . isState ( State . STARTING ) ) {
if ( game . getPlayers ( ) > = game . getMax ( ) ) {
p . sendMessage ( plugin . getLang ( ) . get ( "messages.gameFull" ) ) ;
return ;
}
plugin . getGM ( ) . addPlayerGame ( p , game ) ;
plugin . getGm ( ) . addPlayerGame ( p , game ) ;
return ;
} else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.gameAlreadyStart" ) ) ;
} else if ( plugin . getSIM ( ) . getFourSigns ( ) . keySet ( ) . contains ( e . getClickedBlock ( ) . getLocation ( ) ) ) {
final GameFourSign sign = plugin . getSIM ( ) . getFourSigns ( ) . get ( e . getClickedBlock ( ) . getLocation ( ) ) ;
final GameFour game = plugin . getGM ( ) . getGameFourByName ( sign . getGame ( ) ) ;
} else if ( plugin . getSim ( ) . getFourSigns ( ) . keySet ( ) . contains ( e . getClickedBlock ( ) . getLocation ( ) ) ) {
final GameFourSign sign = plugin . getSim ( ) . getFourSigns ( ) . get ( e . getClickedBlock ( ) . getLocation ( ) ) ;
final GameFour game = plugin . getGm ( ) . getGameFourByName ( sign . getGame ( ) ) ;
if ( game . isState ( FState . WAITING ) | | game . isState ( FState . STARTING ) ) {
if ( game . getPlayers ( ) . size ( ) > = game . getMax ( ) ) {
p . sendMessage ( plugin . getLang ( ) . get ( "messages.gameFull" ) ) ;
return ;
}
plugin . getGM ( ) . addPlayerGameFour ( p , game ) ;
plugin . getGm ( ) . addPlayerGameFour ( p , game ) ;
return ;
} else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.gameAlreadyStart" ) ) ;
@ -369,8 +479,8 @@ public class PlayerListener implements Listener {
public void onMove ( PlayerMoveEvent e ) {
boolean wait = false ;
final Player p = e . getPlayer ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( p ) ;
if ( game . isState ( State . WAITING ) | | game . isState ( State . STARTING ) | | game . isState ( State . FINISH ) )
if ( p . getLocation ( ) . getY ( ) < 30 )
p . teleport ( game . getLobby ( ) ) ;
@ -393,8 +503,8 @@ public class PlayerListener implements Listener {
}
return ;
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( p ) ;
if ( game . isState ( FState . WAITING ) | | game . isState ( FState . STARTING ) | | game . isState ( FState . FINISH ) )
if ( p . getLocation ( ) . getY ( ) < 30 )
p . teleport ( game . getLobby ( ) ) ;
@ -445,11 +555,11 @@ public class PlayerListener implements Listener {
public void onFood ( FoodLevelChangeEvent e ) {
if ( e . getEntity ( ) instanceof Player ) {
final Player p = ( Player ) e . getEntity ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
e . setCancelled ( true ) ;
return ;
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
e . setCancelled ( true ) ;
return ;
}
@ -461,8 +571,8 @@ public class PlayerListener implements Listener {
final Player p = e . getPlayer ( ) ;
if ( ! plugin . getConfig ( ) . getBoolean ( "chat.enabled" ) )
return ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( p ) ;
e . setCancelled ( true ) ;
if ( game . isState ( State . WAITING ) | | game . isState ( State . STARTING ) | | game . isState ( State . FINISH )
| | game . isState ( State . RESTARTING ) ) {
@ -488,8 +598,8 @@ public class PlayerListener implements Listener {
return ;
}
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( p ) ;
e . setCancelled ( true ) ;
if ( game . isState ( FState . WAITING ) | | game . isState ( FState . STARTING ) | | game . isState ( FState . FINISH )
| | game . isState ( FState . RESTARTING ) ) {
@ -521,8 +631,8 @@ public class PlayerListener implements Listener {
public void onDamage ( EntityDamageEvent e ) {
if ( e . getEntity ( ) instanceof Player ) {
final Player p = ( Player ) e . getEntity ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( p ) ;
if ( e . getCause ( ) . equals ( DamageCause . FALL ) ) {
e . setCancelled ( true ) ;
return ;
@ -532,8 +642,8 @@ public class PlayerListener implements Listener {
e . setCancelled ( true ) ;
return ;
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( p ) ;
if ( e . getCause ( ) . equals ( DamageCause . FALL ) ) {
e . setCancelled ( true ) ;
return ;
@ -565,7 +675,7 @@ public class PlayerListener implements Listener {
if ( inv . getTitle ( ) = = null )
return ;
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null | | plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null | | plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
if ( e . getSlotType ( ) . equals ( SlotType . ARMOR ) )
e . setCancelled ( true ) ;
if ( e . getCurrentItem ( ) = = null | | e . getCurrentItem ( ) . getType ( ) = = Material . AIR )
@ -574,7 +684,7 @@ public class PlayerListener implements Listener {
. equals ( plugin . getLang ( ) . get ( "items.leave.nameItem" ) ) )
e . setCancelled ( true ) ;
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) = = null & & plugin . getGM ( ) . getGameByPlayer ( p ) = = null ) {
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) = = null & & plugin . getGm ( ) . getGameByPlayer ( p ) = = null ) {
if ( p . getOpenInventory ( ) ! = null )
if ( p . getOpenInventory ( ) . getTitle ( ) . equals ( plugin . getLang ( ) . get ( "menus.hotbar.title" ) ) ) {
if ( p . getOpenInventory ( ) ! = null & & e . getClickedInventory ( ) ! = null
@ -639,10 +749,29 @@ public class PlayerListener implements Listener {
if ( item . equals ( random ) )
e . setCancelled ( true ) ;
}
if ( plugin . getConfig ( ) . getBoolean ( "items.lobby.enabled" ) ) {
final ItemStack random = ItemBuilder . item (
Material . valueOf ( plugin . getConfig ( ) . getString ( "items.lobby.material" ) ) ,
plugin . getConfig ( ) . getInt ( "items.lobby.amount" ) ,
( short ) plugin . getConfig ( ) . getInt ( "items.lobby.data" ) ,
plugin . getConfig ( ) . getString ( "items.lobby.nameItem" ) . replaceAll ( "&" , "§" ) ,
plugin . getConfig ( ) . getString ( "items.lobby.loreItem" ) . replaceAll ( "&" , "§" ) ) ;
if ( item . equals ( random ) )
e . setCancelled ( true ) ;
}
if ( plugin . getConfig ( ) . getBoolean ( "items.archievements.enabled" ) ) {
final ItemStack random = ItemBuilder . item (
Material . valueOf ( plugin . getConfig ( ) . getString ( "items.archievements.material" ) ) ,
plugin . getConfig ( ) . getInt ( "items.archievements.amount" ) ,
( short ) plugin . getConfig ( ) . getInt ( "items.archievements.data" ) ,
plugin . getConfig ( ) . getString ( "items.archievements.nameItem" ) . replaceAll ( "&" , "§" ) ,
plugin . getConfig ( ) . getString ( "items.archievements.loreItem" ) . replaceAll ( "&" , "§" ) ) ;
if ( item . equals ( random ) )
e . setCancelled ( true ) ;
}
}
}
if ( inv . getTitle ( )
. equals ( plugin . getAchievement ( ) . get ( "title" ) . replaceAll ( "<player>" , p . getName ( ) ) ) ) {
if ( inv . getTitle ( ) . equals ( plugin . getAchievement ( ) . get ( "title" ) . replaceAll ( "<player>" , p . getName ( ) ) ) ) {
e . setCancelled ( true ) ;
if ( e . getCurrentItem ( ) = = null | | e . getCurrentItem ( ) . getType ( ) = = Material . AIR )
return ;
@ -656,13 +785,13 @@ public class PlayerListener implements Listener {
page . put ( p , 2 ) ;
else
page . put ( p , page . get ( p ) + 1 ) ;
plugin . getArchiM enu ( ) . createArchievementsMenu ( p , page . get ( p ) ) ;
plugin . getArchim enu ( ) . createArchievementsMenu ( p , page . get ( p ) ) ;
e . setCancelled ( true ) ;
}
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( )
. equals ( plugin . getAchievement ( ) . get ( "back" ) . replaceAll ( "<back>" , "� ?" ) ) ) {
. equals ( plugin . getAchievement ( ) . get ( "back" ) . replaceAll ( "<back>" , "§ ?" ) ) ) {
page . put ( p , page . get ( p ) - 1 ) ;
plugin . getArchiM enu ( ) . createArchievementsMenu ( p , page . get ( p ) ) ;
plugin . getArchim enu ( ) . createArchievementsMenu ( p , page . get ( p ) ) ;
e . setCancelled ( true ) ;
}
}
@ -671,7 +800,9 @@ public class PlayerListener implements Listener {
if ( e . getCurrentItem ( ) = = null | | e . getCurrentItem ( ) . getType ( ) = = Material . AIR )
return ;
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . equals ( plugin . getLang ( ) . get ( "shop.glass.nameItem" ) ) )
plugin . getGLAM ( ) . createGlassMenu ( p ) ;
plugin . getGlam ( ) . createGlassMenu ( p ) ;
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . equals ( plugin . getLang ( ) . get ( "shop.arrow.nameItem" ) ) )
plugin . getAmu ( ) . createArrowMenu ( p ) ;
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . equals ( plugin . getLang ( ) . get ( "shop.close.nameItem" ) ) )
p . getOpenInventory ( ) . close ( ) ;
}
@ -679,7 +810,7 @@ public class PlayerListener implements Listener {
e . setCancelled ( true ) ;
if ( e . getCurrentItem ( ) = = null | | e . getCurrentItem ( ) . getType ( ) = = Material . AIR )
return ;
for ( final Cage cage : plugin . getCM ( ) . getCages ( ) . values ( ) )
for ( final Cage cage : plugin . getCm ( ) . getCages ( ) . values ( ) )
if ( cage . getSlot ( ) = = e . getSlot ( ) )
if ( ! p . hasPermission ( cage . getPermission ( ) ) ) {
if ( ! cage . isBuy ( ) )
@ -695,7 +826,7 @@ public class PlayerListener implements Listener {
new BukkitRunnable ( ) {
@Override
public void run ( ) {
plugin . getGLAM ( ) . createGlassMenu ( p ) ;
plugin . getGlam ( ) . createGlassMenu ( p ) ;
}
} . runTaskLater ( plugin , 2L ) ;
p . playSound ( p . getLocation ( ) , Sound . valueOf ( plugin . getSounds ( ) . get ( "sounds.shop.buy" ) ) , 1 . 0f ,
@ -709,16 +840,50 @@ public class PlayerListener implements Listener {
PlayerStat . getPlayerStat ( p ) . setCage ( cage . getId ( ) ) ;
}
}
if ( inv . getTitle ( ) . equals ( plugin . getArrow ( ) . get ( "title" ) ) ) {
e . setCancelled ( true ) ;
if ( e . getCurrentItem ( ) = = null | | e . getCurrentItem ( ) . getType ( ) = = Material . AIR )
return ;
for ( final cx . sfy . TheBridge . cosmetics . Arrow arrow : plugin . getArm ( ) . getArrows ( ) . values ( ) )
if ( arrow . getSlot ( ) = = e . getSlot ( ) )
if ( ! p . hasPermission ( arrow . getPermission ( ) ) ) {
if ( ! arrow . isBuy ( ) )
p . sendMessage ( plugin . getLang ( ) . get ( "messages.noBuy" ) ) ;
else if ( arrow . getPrice ( ) > PlayerStat . getPlayerStat ( p ) . getCoins ( ) )
p . sendMessage ( plugin . getLang ( ) . get ( "messages.noMoney" ) ) ;
else if ( arrow . isBuy ( ) & & arrow . getPrice ( ) < = PlayerStat . getPlayerStat ( p ) . getCoins ( ) ) {
Bukkit . dispatchCommand ( Bukkit . getConsoleSender ( ) ,
plugin . getConfig ( ) . getString ( "permFormat" ) . replaceAll ( "<name>" , p . getName ( ) )
. replaceAll ( "<permission>" , arrow . getPermission ( ) ) ) ;
PlayerStat . getPlayerStat ( p ) . removeCoins ( arrow . getPrice ( ) ) ;
p . getOpenInventory ( ) . close ( ) ;
new BukkitRunnable ( ) {
@Override
public void run ( ) {
plugin . getAmu ( ) . createArrowMenu ( p ) ;
}
} . runTaskLater ( plugin , 2L ) ;
p . playSound ( p . getLocation ( ) , Sound . valueOf ( plugin . getSounds ( ) . get ( "sounds.shop.buy" ) ) , 1 . 0f ,
1 . 0f ) ;
p . sendMessage (
plugin . getLang ( ) . get ( "messages.buyTrail" ) . replaceAll ( "<trail>" , arrow . getName ( ) ) ) ;
}
} else {
p . sendMessage (
plugin . getLang ( ) . get ( "messages.selectedTrail" ) . replaceAll ( "<trail>" , arrow . getName ( ) ) ) ;
PlayerStat . getPlayerStat ( p ) . setArrow ( arrow . getId ( ) ) ;
}
}
if ( inv . getTitle ( ) . equals ( plugin . getLang ( ) . get ( "menus.type.title" ) ) ) {
e . setCancelled ( true ) ;
if ( e . getCurrentItem ( ) = = null | | e . getCurrentItem ( ) . getType ( ) = = Material . AIR )
return ;
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( )
. equals ( plugin . getLang ( ) . get ( "menus.type.normal.nameItem" ) ) )
plugin . getGMU ( ) . openGameMenu ( p ) ;
plugin . getGmu ( ) . openGameMenu ( p ) ;
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( )
. equals ( plugin . getLang ( ) . get ( "menus.type.four.nameItem" ) ) )
plugin . getGMU ( ) . openGameFourMenu ( p ) ;
plugin . getGmu ( ) . openGameFourMenu ( p ) ;
}
if ( inv . getTitle ( ) . equals ( plugin . getLang ( ) . get ( "menus.hotbar.title" ) ) ) {
if ( e . getCurrentItem ( ) = = null | | e . getCurrentItem ( ) . getType ( ) = = Material . AIR ) {
@ -746,16 +911,16 @@ public class PlayerListener implements Listener {
| | e . getSlotType ( ) . equals ( SlotType . OUTSIDE ) )
return ;
e . setCancelled ( true ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) = = null )
if ( plugin . getGm ( ) . getGameByPlayer ( p ) = = null )
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . contains ( "§a" ) ) {
final String arena = e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . replaceAll ( "§a" , "" ) ;
final GameDuo game = plugin . getGM ( ) . getGameByName ( arena ) ;
final GameDuo game = plugin . getGm ( ) . getGameByName ( arena ) ;
if ( game . getPlayers ( ) > = game . getMax ( ) ) {
p . sendMessage ( plugin . getLang ( ) . get ( "messages.gameFull" ) ) ;
return ;
}
if ( game . isState ( State . WAITING ) | | game . isState ( State . STARTING ) )
plugin . getGM ( ) . addPlayerGame ( p , game ) ;
plugin . getGm ( ) . addPlayerGame ( p , game ) ;
else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.gameAlreadyStart" ) ) ;
}
@ -765,10 +930,10 @@ public class PlayerListener implements Listener {
| | e . getSlotType ( ) . equals ( SlotType . OUTSIDE ) )
return ;
e . setCancelled ( true ) ;
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) = = null )
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) = = null )
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . contains ( "§a" ) ) {
final String arena = e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . replaceAll ( "§a" , "" ) ;
final GameFour game = plugin . getGM ( ) . getGameFourByName ( arena ) ;
final GameFour game = plugin . getGm ( ) . getGameFourByName ( arena ) ;
if ( game = = null )
return ;
if ( game . getPlayers ( ) . size ( ) > = game . getMax ( ) ) {
@ -776,15 +941,15 @@ public class PlayerListener implements Listener {
return ;
}
if ( game . isState ( FState . WAITING ) | | game . isState ( FState . STARTING ) )
plugin . getGM ( ) . addPlayerGameFour ( p , game ) ;
plugin . getGm ( ) . addPlayerGameFour ( p , game ) ;
else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.gameAlreadyStart" ) ) ;
}
}
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null )
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null )
if ( inv . getTitle ( ) . equals ( plugin . getLang ( ) . get ( "menus.team.title" ) ) ) {
e . setCancelled ( true ) ;
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( p ) ;
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( p ) ;
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . contains ( "§9" ) ) {
if ( p . hasPermission ( "bridges.bypass" ) ) {
if ( game . getTeamPlayer ( p ) ! = null )
@ -792,7 +957,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . BLUE ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§9" + plugin . getConfig ( ) . getString ( "names.blue" ) ) ) ;
plugin . getTEM ( ) . openTeamNormalMenu ( p ) ;
plugin . getTem ( ) . openTeamNormalMenu ( p ) ;
return ;
}
if ( game . getTeamPlayer ( p ) ! = null )
@ -802,7 +967,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . BLUE ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§9" + plugin . getConfig ( ) . getString ( "names.blue" ) ) ) ;
plugin . getTEM ( ) . openTeamNormalMenu ( p ) ;
plugin . getTem ( ) . openTeamNormalMenu ( p ) ;
} else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.unbalancedTeam" ) ) ;
}
@ -813,7 +978,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . RED ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§c" + plugin . getConfig ( ) . getString ( "names.red" ) ) ) ;
plugin . getTEM ( ) . openTeamNormalMenu ( p ) ;
plugin . getTem ( ) . openTeamNormalMenu ( p ) ;
return ;
}
if ( game . getTeamPlayer ( p ) ! = null )
@ -823,12 +988,12 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . RED ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§c" + plugin . getConfig ( ) . getString ( "names.red" ) ) ) ;
plugin . getTEM ( ) . openTeamNormalMenu ( p ) ;
plugin . getTem ( ) . openTeamNormalMenu ( p ) ;
} else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.unbalancedTeam" ) ) ;
}
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
if ( inv . getTitle ( ) . equals ( plugin . getLang ( ) . get ( "menus.options.title" ) ) ) {
e . setCancelled ( true ) ;
if ( Bukkit . getPlayer ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . replaceAll ( "§7" , "" ) ) = = null )
@ -856,20 +1021,20 @@ public class PlayerListener implements Listener {
p . setFlySpeed ( 1 . 0f ) ;
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . equals (
plugin . getLang ( ) . get ( "menus.options.vision.nameItem" ) . replaceAll ( "<type>" , "§aActivar" ) ) ) {
plugin . getSOM ( ) . settings . put ( p , true ) ;
plugin . getSom ( ) . settings . put ( p , true ) ;
p . addPotionEffect ( new PotionEffect ( PotionEffectType . NIGHT_VISION , 9999 , 1 , true ) ) ;
plugin . getSOM ( ) . openOptionsMenu ( p ) ;
plugin . getSom ( ) . openOptionsMenu ( p ) ;
}
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . equals (
plugin . getLang ( ) . get ( "menus.options.vision.nameItem" ) . replaceAll ( "<type>" , "§cDesactivar" ) ) ) {
plugin . getSOM ( ) . settings . put ( p , false ) ;
plugin . getSom ( ) . settings . put ( p , false ) ;
p . removePotionEffect ( PotionEffectType . NIGHT_VISION ) ;
plugin . getSOM ( ) . openOptionsMenu ( p ) ;
plugin . getSom ( ) . openOptionsMenu ( p ) ;
}
}
if ( inv . getTitle ( ) . equals ( plugin . getLang ( ) . get ( "menus.teamFour.title" ) ) ) {
e . setCancelled ( true ) ;
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( p ) ;
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( p ) ;
if ( e . getCurrentItem ( ) . getItemMeta ( ) . getDisplayName ( ) . contains ( "§9" ) ) {
if ( p . hasPermission ( "bridges.bypass" ) ) {
if ( game . getTeamPlayer ( p ) ! = null )
@ -877,7 +1042,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . BLUE ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§9" + plugin . getConfig ( ) . getString ( "names.blue" ) ) ) ;
plugin . getTEM ( ) . openTeamFourMenu ( p ) ;
plugin . getTem ( ) . openTeamFourMenu ( p ) ;
return ;
}
if ( game . getTeamPlayer ( p ) ! = null )
@ -892,7 +1057,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . BLUE ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§9" + plugin . getConfig ( ) . getString ( "names.blue" ) ) ) ;
plugin . getTEM ( ) . openTeamFourMenu ( p ) ;
plugin . getTem ( ) . openTeamFourMenu ( p ) ;
} else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.unbalancedTeam" ) ) ;
}
@ -903,7 +1068,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . RED ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§c" + plugin . getConfig ( ) . getString ( "names.red" ) ) ) ;
plugin . getTEM ( ) . openTeamFourMenu ( p ) ;
plugin . getTem ( ) . openTeamFourMenu ( p ) ;
return ;
}
if ( game . getTeamPlayer ( p ) ! = null )
@ -918,7 +1083,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . RED ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§c" + plugin . getConfig ( ) . getString ( "names.red" ) ) ) ;
plugin . getTEM ( ) . openTeamFourMenu ( p ) ;
plugin . getTem ( ) . openTeamFourMenu ( p ) ;
} else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.unbalancedTeam" ) ) ;
}
@ -929,7 +1094,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . GREEN ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§a" + plugin . getConfig ( ) . getString ( "names.green" ) ) ) ;
plugin . getTEM ( ) . openTeamFourMenu ( p ) ;
plugin . getTem ( ) . openTeamFourMenu ( p ) ;
return ;
}
if ( game . getTeamPlayer ( p ) ! = null )
@ -944,7 +1109,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . GREEN ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§a" + plugin . getConfig ( ) . getString ( "names.green" ) ) ) ;
plugin . getTEM ( ) . openTeamFourMenu ( p ) ;
plugin . getTem ( ) . openTeamFourMenu ( p ) ;
} else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.unbalancedTeam" ) ) ;
}
@ -955,7 +1120,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . YELLOW ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§e" + plugin . getConfig ( ) . getString ( "names.yellow" ) ) ) ;
plugin . getTEM ( ) . openTeamFourMenu ( p ) ;
plugin . getTem ( ) . openTeamFourMenu ( p ) ;
return ;
}
if ( game . getTeamPlayer ( p ) ! = null )
@ -970,7 +1135,7 @@ public class PlayerListener implements Listener {
game . addPlayerTeam ( p , game . getTeams ( ) . get ( ChatColor . YELLOW ) ) ;
p . sendMessage ( plugin . getLang ( ) . get ( "messages.joinedTeam" ) . replaceAll ( "<team>" ,
"§e" + plugin . getConfig ( ) . getString ( "names.yellow" ) ) ) ;
plugin . getTEM ( ) . openTeamFourMenu ( p ) ;
plugin . getTem ( ) . openTeamFourMenu ( p ) ;
} else
p . sendMessage ( plugin . getLang ( ) . get ( "messages.unbalancedTeam" ) ) ;
}
@ -1028,8 +1193,8 @@ public class PlayerListener implements Listener {
if ( e . getDamager ( ) instanceof Player ) {
final Player p = ( Player ) e . getEntity ( ) ;
final Player d = ( Player ) e . getDamager ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( p ) ;
if ( game . isState ( State . WAITING ) | | game . isState ( State . STARTING ) | | game . isState ( State . PREGAME ) ) {
e . setCancelled ( true ) ;
return ;
@ -1044,8 +1209,8 @@ public class PlayerListener implements Listener {
respawn ( p , Tagged . getTag ( p ) ) ;
}
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( p ) ;
if ( game . isState ( FState . WAITING ) | | game . isState ( FState . STARTING ) | | game . isState ( FState . PREGAME ) ) {
e . setCancelled ( true ) ;
return ;
@ -1066,8 +1231,8 @@ public class PlayerListener implements Listener {
if ( proj . getShooter ( ) instanceof Player ) {
final Player p = ( Player ) e . getEntity ( ) ;
final Player d = ( Player ) proj . getShooter ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( p ) ;
if ( game . isState ( State . WAITING ) | | game . isState ( State . STARTING )
| | game . isState ( State . PREGAME ) ) {
e . setCancelled ( true ) ;
@ -1083,8 +1248,8 @@ public class PlayerListener implements Listener {
respawn ( p , Tagged . getTag ( p ) ) ;
}
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( p ) ;
if ( game . isState ( FState . WAITING ) | | game . isState ( FState . STARTING )
| | game . isState ( FState . PREGAME ) ) {
e . setCancelled ( true ) ;
@ -1108,7 +1273,7 @@ public class PlayerListener implements Listener {
@EventHandler
public void onConsume ( PlayerItemConsumeEvent e ) {
final Player p = e . getPlayer ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null )
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null )
if ( e . getItem ( ) . getType ( ) . equals ( Material . GOLDEN_APPLE ) ) {
p . setHealth ( p . getMaxHealth ( ) ) ;
if ( plugin . getConfig ( ) . getBoolean ( "remove.absorption" ) = = true )
@ -1126,7 +1291,7 @@ public class PlayerListener implements Listener {
}
} . runTaskLater ( plugin , 1 ) ;
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null )
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null )
if ( e . getItem ( ) . getType ( ) . equals ( Material . GOLDEN_APPLE ) ) {
p . setHealth ( p . getMaxHealth ( ) ) ;
if ( plugin . getConfig ( ) . getBoolean ( "remove.absorption" ) = = true )
@ -1149,62 +1314,62 @@ public class PlayerListener implements Listener {
@EventHandler
public void onQuit ( PlayerQuitEvent e ) {
final Player p = e . getPlayer ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( p ) ;
game . removePlayer ( p ) ;
if ( game . getTeamsAlive ( ) = = 1 )
game . checkWin ( p , game . getLastTeam ( ) , game . getLastTeam ( ) . getGoals ( ) ) ;
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( p ) ;
game . removePlayer ( p ) ;
if ( game . getTeamsAlive ( ) = = 1 )
game . checkWin ( game . getLastTeam ( ) , game . getTeamPlayer ( p ) , game . getLastTeam ( ) . getTeamPlayers ( ) . get ( 0 ) ) ;
}
for ( final Player on : plugin . getSB ( ) . getSB ( ) . keySet ( ) )
plugin . getSB ( ) . update ( on ) ;
for ( final Player on : plugin . getSb ( ) . getSB ( ) . keySet ( ) )
plugin . getSb ( ) . update ( on ) ;
if ( InventoryData . getInventoryData ( p ) ! = null ) {
InventoryData . getInventoryData ( p ) . restore ( ) ;
InventoryData . remove ( p ) ;
}
plugin . getSB ( ) . remove ( p ) ;
plugin . getTOP ( ) . removeHolo ( p ) ;
plugin . getDB ( ) . saveData ( PlayerStat . getPlayerStat ( p ) ) ;
plugin . getCB ( ) . saveData ( PlayerStat . getPlayerStat ( p ) ) ;
plugin . getSb ( ) . remove ( p ) ;
plugin . getTop ( ) . removeHolo ( p ) ;
plugin . getDb ( ) . saveData ( PlayerStat . getPlayerStat ( p ) ) ;
plugin . getCb ( ) . saveData ( PlayerStat . getPlayerStat ( p ) ) ;
}
@EventHandler
public void onKick ( PlayerKickEvent e ) {
final Player p = e . getPlayer ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( p ) ;
game . removePlayer ( p ) ;
if ( game . getTeamsAlive ( ) = = 1 )
game . checkWin ( p , game . getLastTeam ( ) , game . getLastTeam ( ) . getGoals ( ) ) ;
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( p ) ;
game . removePlayer ( p ) ;
if ( game . getTeamsAlive ( ) = = 1 )
game . checkWin ( game . getLastTeam ( ) , game . getTeamPlayer ( p ) , game . getLastTeam ( ) . getTeamPlayers ( ) . get ( 0 ) ) ;
}
for ( final Player on : plugin . getSB ( ) . getSB ( ) . keySet ( ) )
plugin . getSB ( ) . update ( on ) ;
for ( final Player on : plugin . getSb ( ) . getSB ( ) . keySet ( ) )
plugin . getSb ( ) . update ( on ) ;
if ( InventoryData . getInventoryData ( p ) ! = null ) {
InventoryData . getInventoryData ( p ) . restore ( ) ;
InventoryData . remove ( p ) ;
}
plugin . getSB ( ) . remove ( p ) ;
plugin . getTOP ( ) . removeHolo ( p ) ;
plugin . getDB ( ) . saveData ( PlayerStat . getPlayerStat ( p ) ) ;
plugin . getCB ( ) . saveData ( PlayerStat . getPlayerStat ( p ) ) ;
plugin . getSb ( ) . remove ( p ) ;
plugin . getTop ( ) . removeHolo ( p ) ;
plugin . getDb ( ) . saveData ( PlayerStat . getPlayerStat ( p ) ) ;
plugin . getCb ( ) . saveData ( PlayerStat . getPlayerStat ( p ) ) ;
}
@EventHandler
public void onBreak ( BlockBreakEvent e ) {
final Player p = e . getPlayer ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( p ) ;
if ( game . isState ( State . WAITING ) | | game . isState ( State . STARTING ) | | game . isState ( State . PREGAME )
| | game . isState ( State . PREGAME ) | | game . isState ( State . FINISH ) | | game . isState ( State . RESTARTING ) )
e . setCancelled ( true ) ;
@ -1216,8 +1381,8 @@ public class PlayerListener implements Listener {
PlayerStat . getPlayerStat ( p ) . addBroken ( ) ;
return ;
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( p ) ;
if ( game . isState ( FState . WAITING ) | | game . isState ( FState . STARTING ) | | game . isState ( FState . PREGAME )
| | game . isState ( FState . PREGAME ) | | game . isState ( FState . FINISH ) | | game . isState ( FState . RESTARTING ) )
e . setCancelled ( true ) ;
@ -1234,8 +1399,8 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlace ( BlockPlaceEvent e ) {
final Player p = e . getPlayer ( ) ;
if ( plugin . getGM ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameByPlayer ( p ) ! = null ) {
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( p ) ;
if ( game . isState ( State . WAITING ) | | game . isState ( State . STARTING ) | | game . isState ( State . PREGAME )
| | game . isState ( State . FINISH ) | | game . isState ( State . RESTARTING ) )
e . setCancelled ( true ) ;
@ -1249,8 +1414,8 @@ public class PlayerListener implements Listener {
}
return ;
}
if ( plugin . getGM ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( p ) ;
if ( plugin . getGm ( ) . getGameFourByPlayer ( p ) ! = null ) {
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( p ) ;
if ( game . isState ( FState . WAITING ) | | game . isState ( FState . STARTING ) | | game . isState ( FState . PREGAME )
| | game . isState ( FState . PREGAME ) | | game . isState ( FState . FINISH ) | | game . isState ( FState . RESTARTING ) )
e . setCancelled ( true ) ;
@ -1271,7 +1436,7 @@ public class PlayerListener implements Listener {
d . getInventory ( ) . clear ( ) ;
d . setHealth ( d . getMaxHealth ( ) ) ;
if ( k ! = null ) {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( k ) ;
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( k ) ;
if ( game = = null )
return ;
game . addKill ( k ) ;
@ -1322,7 +1487,7 @@ public class PlayerListener implements Listener {
. replaceAll ( "<death>" , d . getName ( ) ) . replaceAll ( "<player>" , k . getName ( ) ) ) ;
}
} else {
final GameDuo game = plugin . getGM ( ) . getGameByPlayer ( d ) ;
final GameDuo game = plugin . getGm ( ) . getGameByPlayer ( d ) ;
d . teleport ( game . getTeamPlayer ( d ) . getTeamRespawn ( ) ) ;
game . giveKit ( d , game . getTeamPlayer ( d ) ) ;
if ( d . getLastDamageCause ( ) = = null )
@ -1356,7 +1521,7 @@ public class PlayerListener implements Listener {
d . getInventory ( ) . clear ( ) ;
d . setHealth ( d . getMaxHealth ( ) ) ;
if ( k ! = null ) {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( k ) ;
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( k ) ;
game . addKill ( k ) ;
PlayerStat . getPlayerStat ( k ) . addFourKills ( ) ;
d . teleport ( game . getTeamPlayer ( d ) . getTeamRespawn ( ) ) ;
@ -1405,7 +1570,7 @@ public class PlayerListener implements Listener {
. replaceAll ( "<death>" , d . getName ( ) ) . replaceAll ( "<player>" , k . getName ( ) ) ) ;
}
} else {
final GameFour game = plugin . getGM ( ) . getGameFourByPlayer ( d ) ;
final GameFour game = plugin . getGm ( ) . getGameFourByPlayer ( d ) ;
d . teleport ( game . getTeamPlayer ( d ) . getTeamRespawn ( ) ) ;
game . giveKit ( d , game . getTeamPlayer ( d ) ) ;
if ( d . getLastDamageCause ( ) = = null )