Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.eidoscraft.theboss;
- import org.bukkit.block.Block;
- import org.bukkit.entity.Player;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerListener;
- import org.bukkit.event.player.PlayerMoveEvent;
- import org.bukkit.event.player.PlayerRespawnEvent;
- public class MinenionPlayerListener extends PlayerListener
- {
- public Minenion minenion;
- //Constants
- public static final int BLUE_TEAM = 1;
- public static final int RED_TEAM = 2;
- public int WEAPON_BLOCK = 3500;
- public byte WEAPON_BLOCK_DAMAGE;
- public int SKILL_BLOCK;
- public byte SKILL_BLOCK_DAMAGE;
- /*
- * Constructor
- * @param instance : instance of game
- */
- public MinenionPlayerListener(Minenion instance)
- {
- minenion = instance;
- }
- /*
- * Management of player respawn
- * @param event : event on player respawn
- */
- public void onPlayerRespawn(PlayerRespawnEvent event)
- {
- if(minenion.start == true)
- {
- // if a blue team player respawn move it to blue team start point
- if(minenion.playerTeam.get(event.getPlayer()) == BLUE_TEAM)
- {
- event.setRespawnLocation(minenion.blueTeamLocation);
- }
- // if a purple team player respawn move it to purple team start point
- if(minenion.playerTeam.get(event.getPlayer()) == RED_TEAM)
- {
- event.setRespawnLocation(minenion.purpleTeamLocation);
- }
- if(minenion.logging == true) minenion.mineLog(minenion.gameStartTime + " - " + event.getPlayer().getName() + " has respawn, giving " + minenion.playerExperience.get(event.getPlayer()) + " experience points.");
- }
- }
- /*
- * Management of player interaction
- * @param event : event on player interaction
- */
- public void onPlayerInteract(PlayerInteractEvent event)
- {
- if(minenion.start == true)
- {
- if(event.getPlayer().getLocation().getBlock() != null)
- {
- // if the event is a clicked block
- if(event.getClickedBlock() != null)
- {
- // if player interact on a pressure plate (id=70) near a tower
- if(event.getClickedBlock().getTypeId() == 70
- && event.getPlayer().getLocation().getBlock().getTypeId() == 70
- && minenion.inWhichZone(event.getPlayer().getLocation()) != 0)
- {
- // get the tower number
- int tower = minenion.inWhichZone(event.getPlayer().getLocation());
- // if the tower is not controled by the player team
- if(minenion.playerTeam.get(minenion.playerOnTower.get(tower)) == null)
- {
- // add controled tower to the player
- minenion.playerOnTower.put(tower, event.getPlayer());
- int team = minenion.playerTeam.get(event.getPlayer());
- String message;
- if(team == BLUE_TEAM)
- {
- message = "blue";
- }
- else
- {
- message = "red";
- }
- // messaging to the player
- if(minenion.logging == true) minenion.mineLog(minenion.gameStartTime + " - " + event.getPlayer().getName() + " : The tower #" + minenion.inWhichZone(event.getPlayer().getLocation()) + " is possessed by the " + message + " team.");
- }
- }
- if(minenion.light == false)
- {
- if(WEAPON_BLOCK == 3500)
- {
- WEAPON_BLOCK = minenion.shopblocks[0];
- WEAPON_BLOCK_DAMAGE = minenion.damage2byte(minenion.shopblocks[2]);
- SKILL_BLOCK = minenion.shopblocks[1];
- SKILL_BLOCK_DAMAGE = minenion.damage2byte(minenion.shopblocks[3]);
- }
- // if the player click on a SHOP BLOCK
- if(event.getClickedBlock().getTypeId() == WEAPON_BLOCK && event.getClickedBlock().getData() == WEAPON_BLOCK_DAMAGE)
- {
- minenion.buyweapon(event.getPlayer());
- }
- if(event.getClickedBlock().getTypeId() == SKILL_BLOCK && event.getClickedBlock().getData() == SKILL_BLOCK_DAMAGE)
- {
- minenion.buyskill(event.getPlayer());
- }
- }
- }
- }
- }
- // display block coordinate in check mode
- if(minenion.check == true)
- {
- Block block = event.getClickedBlock();
- event.getPlayer().sendMessage("X:" + block.getX() + "/Y:" + block.getY() + "/Z:"+ block.getZ());
- }
- }
- /*
- * Management of player move
- * @param event : event on player move
- */
- public void onPlayerMove(PlayerMoveEvent event)
- {
- if(minenion.start && minenion.light == false)
- {
- Player player = event.getPlayer();
- if(minenion.hasEffect(player) && minenion.getEffect(player).equals("stun"))
- {
- event.setCancelled(true);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement