-
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
fc3f5a6
commit 111de62
Showing
22 changed files
with
314 additions
and
69 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
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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/klnsyf/battleroyale/events/PlayerQuitBattlefieldEvent.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,41 @@ | ||
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 PlayerQuitBattlefieldEvent extends Event implements Cancellable { | ||
private static final HandlerList handlers = new HandlerList(); | ||
private boolean cancelled; | ||
private final Player player; | ||
|
||
public PlayerQuitBattlefieldEvent(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
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
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
40 changes: 40 additions & 0 deletions
40
src/main/java/com/klnsyf/battleroyale/listeners/PlayerQuitBattlefield.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.listeners; | ||
|
||
import org.bukkit.Server; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
import com.klnsyf.battleroyale.BattleRoyale; | ||
import com.klnsyf.battleroyale.battlefield.BattlefieldHandler; | ||
import com.klnsyf.battleroyale.events.PlayerQuitBattlefieldEvent; | ||
import com.klnsyf.battleroyale.messages.MessageKey; | ||
import com.klnsyf.battleroyale.messages.Messages; | ||
|
||
public class PlayerQuitBattlefield implements Listener { | ||
private final BattleRoyale plugin = BattleRoyale.plugin; | ||
private final Server server = BattleRoyale.server; | ||
private final String prefix = BattleRoyale.prefix; | ||
|
||
public PlayerQuitBattlefield() { | ||
server.getPluginManager().registerEvents(this, plugin); | ||
} | ||
|
||
@EventHandler | ||
public void onPlayerQuitBattlefield(PlayerQuitBattlefieldEvent event) { | ||
if (BattlefieldHandler.battlefields.get(event.getPlayer().getWorld()) != null) { | ||
server.getConsoleSender().sendMessage(prefix | ||
+ Messages.getMessage(MessageKey.PLAYER_QUIT_BATTLEFIELD_SUCCESS, event.getPlayer().getName(), | ||
event.getPlayer().getWorld().getName())); | ||
for (Player player : BattlefieldHandler.battlefields.get(event.getPlayer().getWorld()).players) { | ||
player.sendMessage(prefix | ||
+ Messages.getMessage(MessageKey.PLAYER_QUIT_BATTLEFIELD_SUCCESS, event.getPlayer().getName(), | ||
event.getPlayer().getWorld().getName())); | ||
} | ||
BattlefieldHandler.battlefields.get(event.getPlayer().getWorld()).players.remove(event.getPlayer()); | ||
if (BattlefieldHandler.battlefields.get(event.getPlayer().getWorld()).alivePlayers.contains(event.getPlayer())) { | ||
event.getPlayer().damage(11037); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.