-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe21287
commit 26fcbeb
Showing
25 changed files
with
598 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/com/klnsyf/battleroyale/events/EntityGlowingEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.klnsyf.battleroyale.events; | ||
|
||
import org.bukkit.World; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
|
||
public class EntityGlowingEvent extends Event implements Cancellable { | ||
private static final HandlerList handlers = new HandlerList(); | ||
private boolean cancelled; | ||
private final World world; | ||
private final Player player; | ||
|
||
public EntityGlowingEvent(World world, Player player) { | ||
super(false); | ||
this.world = world; | ||
this.player = player; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean cancel) { | ||
this.cancelled = cancel; | ||
} | ||
|
||
@Override | ||
public HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
public World getWorld() { | ||
return world; | ||
} | ||
|
||
public Player getPlayer() { | ||
return player; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/klnsyf/battleroyale/events/PlayerOpenBattlefieldGUIEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.klnsyf.battleroyale.events; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
|
||
public class PlayerOpenBattlefieldGUIEvent extends Event implements Cancellable { | ||
private static final HandlerList handlers = new HandlerList(); | ||
private boolean cancelled; | ||
private final Player player; | ||
|
||
public PlayerOpenBattlefieldGUIEvent(Player player) { | ||
super(false); | ||
this.player = player; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean cancel) { | ||
this.cancelled = cancel; | ||
} | ||
|
||
@Override | ||
public HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
public Player getPlayer() { | ||
return player; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/klnsyf/battleroyale/events/PlayerRequestBattlefieldBookEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.klnsyf.battleroyale.events; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
|
||
public class PlayerRequestBattlefieldBookEvent extends Event implements Cancellable { | ||
private static final HandlerList handlers = new HandlerList(); | ||
private boolean cancelled; | ||
private final Player player; | ||
|
||
public PlayerRequestBattlefieldBookEvent(Player player) { | ||
super(false); | ||
this.player = player; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean cancel) { | ||
this.cancelled = cancel; | ||
} | ||
|
||
@Override | ||
public HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
public Player getPlayer() { | ||
return player; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/main/java/com/klnsyf/battleroyale/listeners/EntityGlowing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.klnsyf.battleroyale.listeners; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.Particle; | ||
import org.bukkit.Server; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerToggleSneakEvent; | ||
import org.bukkit.potion.PotionEffect; | ||
import org.bukkit.potion.PotionEffectType; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
|
||
import com.klnsyf.battleroyale.BattleRoyale; | ||
import com.klnsyf.battleroyale.battlefield.BattlefieldHandler; | ||
import com.klnsyf.battleroyale.configuration.Configuration; | ||
import com.klnsyf.battleroyale.configuration.ConfigurationKey; | ||
import com.klnsyf.battleroyale.events.EntityGlowingEvent; | ||
|
||
public class EntityGlowing implements Listener { | ||
private final BattleRoyale plugin = BattleRoyale.plugin; | ||
private final Server server = BattleRoyale.server; | ||
private final Configuration configuration = new Configuration(); | ||
|
||
public EntityGlowing() { | ||
server.getPluginManager().registerEvents(this, plugin); | ||
} | ||
|
||
@EventHandler | ||
public void onPlayerGlowing(PlayerToggleSneakEvent event) { | ||
if (BattlefieldHandler.battlefields.get(event.getPlayer().getWorld()) != null) { | ||
if (BattlefieldHandler.battlefields.get(event.getPlayer().getWorld()).getStatue() == 2) { | ||
if ((boolean) configuration.getValue(event.getPlayer().getWorld(), | ||
ConfigurationKey.BATTLE_MISC_PLAYER_GLOWING_ENABLED)) { | ||
if (event.getPlayer().getInventory().getItemInOffHand().getType() == Material | ||
.getMaterial((String) configuration.getValue(event.getPlayer().getWorld(), | ||
ConfigurationKey.BATTLE_MISC_PLAYER_GLOWING_ITEM))) { | ||
if (!event.getPlayer().isSneaking()) { | ||
new BukkitRunnable() { | ||
@Override | ||
public void run() { | ||
if (!(event.getPlayer().getInventory().getItemInOffHand().getType() == Material | ||
.getMaterial((String) configuration.getValue(event.getPlayer().getWorld(), | ||
ConfigurationKey.BATTLE_MISC_PLAYER_GLOWING_ITEM)) | ||
&& | ||
event.getPlayer().isSneaking())) { | ||
this.cancel(); | ||
} else { | ||
event.getPlayer().getInventory().getItemInOffHand() | ||
.setAmount(event.getPlayer().getInventory().getItemInOffHand().getAmount() - 1); | ||
server.getPluginManager().callEvent( | ||
new EntityGlowingEvent(event.getPlayer().getWorld(), event.getPlayer())); | ||
} | ||
} | ||
}.runTaskTimer(plugin, 0, | ||
(int) configuration.getValue(event.getPlayer().getWorld(), | ||
ConfigurationKey.BATTLE_MISC_PLAYER_GLOWING_DURATION)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onEntityGlowing(EntityGlowingEvent event) { | ||
event.getPlayer().getWorld().spawnParticle(Particle.SPELL_WITCH, | ||
event.getPlayer().getLocation(), 255, 0, | ||
event.getPlayer().getWorld().getMaxHeight() | ||
- event.getPlayer().getLocation().getY(), | ||
0); | ||
for (Entity entity : event.getPlayer().getNearbyEntities( | ||
configuration.getValue(event.getPlayer().getWorld(), | ||
ConfigurationKey.BATTLE_MISC_PLAYER_GLOWING_RADIUS), | ||
configuration.getValue(event.getPlayer().getWorld(), | ||
ConfigurationKey.BATTLE_MISC_PLAYER_GLOWING_RADIUS), | ||
configuration.getValue(event.getPlayer().getWorld(), | ||
ConfigurationKey.BATTLE_MISC_PLAYER_GLOWING_RADIUS))) { | ||
if (entity instanceof LivingEntity) { | ||
((LivingEntity) entity).removePotionEffect(PotionEffectType.GLOWING); | ||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, | ||
(int) configuration.getValue(event.getPlayer().getWorld(), | ||
ConfigurationKey.BATTLE_MISC_PLAYER_GLOWING_DURATION) + 1, | ||
0, false, false)); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.