Changes making it ideal for SP server
Changes the player quit event so player gets sent back to lobby upon join Changes messages to return display name rather than name as it caused some issues with the name not showing up entirely. Prevent the event from getting cancelled (as the config option wasn't working)
This commit is contained in:
parent
e019460165
commit
ed36764386
9
.classpath
Normal file
9
.classpath
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="lib" path="lib/LibsDisguises.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/ProtocolLib.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/spigot-1.9.2-R0.1-SNAPSHOT.jar"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
target/
|
target/
|
||||||
lib/
|
lib/
|
||||||
|
/bin/
|
||||||
|
17
.project
Normal file
17
.project
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>BlockHunt</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
@ -38,14 +38,14 @@ public class ArenaHandler {
|
|||||||
|
|
||||||
public static void sendMessage(Arena arena, String message, String... vars) {
|
public static void sendMessage(Arena arena, String message, String... vars) {
|
||||||
for (Player player : arena.playersInArena) {
|
for (Player player : arena.playersInArena) {
|
||||||
String pMessage = message.replaceAll("%player%", player.getName());
|
String pMessage = message.replaceAll("%player%", player.getDisplayName());
|
||||||
player.sendMessage(MessageM.replaceAll(pMessage, vars));
|
player.sendMessage(MessageM.replaceAll(pMessage, vars));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendFMessage(Arena arena, ConfigC location, String... vars) {
|
public static void sendFMessage(Arena arena, ConfigC location, String... vars) {
|
||||||
for (Player player : arena.playersInArena) {
|
for (Player player : arena.playersInArena) {
|
||||||
String pMessage = location.config.getFile().get(location.location).toString().replaceAll("%player%", player.getName());
|
String pMessage = location.config.getFile().get(location.location).toString().replaceAll("%player%", player.getDisplayName());
|
||||||
player.sendMessage(MessageM.replaceAll(pMessage, vars));
|
player.sendMessage(MessageM.replaceAll(pMessage, vars));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,13 +277,8 @@ public class ArenaHandler {
|
|||||||
|
|
||||||
// Fix for client not showing players after they join
|
// Fix for client not showing players after they join
|
||||||
for (Player otherplayer : arena.playersInArena) {
|
for (Player otherplayer : arena.playersInArena) {
|
||||||
if (otherplayer.canSee(player))
|
otherplayer.showPlayer(player);
|
||||||
otherplayer.showPlayer(player); // Make new player
|
player.showPlayer(otherplayer);
|
||||||
// visible to others
|
|
||||||
if (player.canSee(otherplayer))
|
|
||||||
player.showPlayer(otherplayer); // Make other
|
|
||||||
// players visible
|
|
||||||
// to new player
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,7 +357,7 @@ public class ArenaHandler {
|
|||||||
|
|
||||||
if (arena.seekersWinCommands != null) {
|
if (arena.seekersWinCommands != null) {
|
||||||
for (String command : arena.seekersWinCommands) {
|
for (String command : arena.seekersWinCommands) {
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replaceAll("%player%", player.getName()));
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replaceAll("%player%", player.getDisplayName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (W.shop.getFile().get(player.getName() + ".tokens") == null) {
|
if (W.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||||
@ -414,7 +409,7 @@ public class ArenaHandler {
|
|||||||
|
|
||||||
if (arena.hidersWinCommands != null) {
|
if (arena.hidersWinCommands != null) {
|
||||||
for (String command : arena.hidersWinCommands) {
|
for (String command : arena.hidersWinCommands) {
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replaceAll("%player%", player.getName()));
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replaceAll("%player%", player.getDisplayName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (W.shop.getFile().get(player.getName() + ".tokens") == null) {
|
if (W.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||||
|
@ -76,7 +76,7 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
// Seeker damaged by hider
|
// Seeker damaged by hider
|
||||||
if (!arena.hidersCanHurtSeekers) {
|
if (!arena.hidersCanHurtSeekers) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,23 +3,40 @@ package nl.Steffion.BlockHunt.Listeners;
|
|||||||
import nl.Steffion.BlockHunt.Arena;
|
import nl.Steffion.BlockHunt.Arena;
|
||||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||||
import nl.Steffion.BlockHunt.W;
|
import nl.Steffion.BlockHunt.W;
|
||||||
|
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
public class OnPlayerQuitEvent implements Listener {
|
public class OnPlayerQuitEvent implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
public ArrayList<String> leftPlayer = new ArrayList<String>();
|
||||||
public void onPlayerQuitEvent(PlayerQuitEvent event) {
|
public LocationSerializable spawnWarp;
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onPlayerQuitEvent(PlayerQuitEvent event) {
|
||||||
|
Player playerLeaving = event.getPlayer();
|
||||||
for (Arena arena : W.arenaList) {
|
for (Arena arena : W.arenaList) {
|
||||||
if (arena.playersInArena.contains(player)) {
|
if (arena.playersInArena.contains(playerLeaving)) {
|
||||||
ArenaHandler.playerLeaveArena(player, true, true);
|
spawnWarp = arena.spawnWarp;
|
||||||
|
leftPlayer.add(playerLeaving.getUniqueId().toString());
|
||||||
|
ArenaHandler.playerLeaveArena(playerLeaving, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onPlayerJoinEvent(PlayerJoinEvent event) {
|
||||||
|
Player playerJoining = event.getPlayer();
|
||||||
|
if(leftPlayer.contains(playerJoining.getUniqueId().toString())) {
|
||||||
|
playerJoining.teleport(spawnWarp);
|
||||||
|
leftPlayer.remove(playerJoining.getUniqueId().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class MessageM {
|
|||||||
if (player == null) {
|
if (player == null) {
|
||||||
Bukkit.getConsoleSender().sendMessage(MessageM.replaceAll(message.replaceAll("%player%", "Console"), vars));
|
Bukkit.getConsoleSender().sendMessage(MessageM.replaceAll(message.replaceAll("%player%", "Console"), vars));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(MessageM.replaceAll(message.replaceAll("%player%", player.getName()), vars));
|
player.sendMessage(MessageM.replaceAll(message.replaceAll("%player%", player.getDisplayName()), vars));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public class MessageM {
|
|||||||
Bukkit.getConsoleSender().sendMessage(
|
Bukkit.getConsoleSender().sendMessage(
|
||||||
MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", "Console"), vars));
|
MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", "Console"), vars));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", player.getName()), vars));
|
player.sendMessage(MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", player.getDisplayName()), vars));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ public class MessageM {
|
|||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
// String pMessage = message.replaceAll("%player%",
|
// String pMessage = message.replaceAll("%player%",
|
||||||
// player.getName());
|
// player.getName());
|
||||||
player.sendMessage(MessageM.replaceAll(message.replaceAll("%player%", player.getName()), vars));
|
player.sendMessage(MessageM.replaceAll(message.replaceAll("%player%", player.getDisplayName()), vars));
|
||||||
}
|
}
|
||||||
// message = message.replaceAll("%player%", "Console");
|
// message = message.replaceAll("%player%", "Console");
|
||||||
Bukkit.getConsoleSender().sendMessage(MessageM.replaceAll(message.replaceAll("%player%", "Console"), vars));
|
Bukkit.getConsoleSender().sendMessage(MessageM.replaceAll(message.replaceAll("%player%", "Console"), vars));
|
||||||
@ -95,7 +95,7 @@ public class MessageM {
|
|||||||
// String pMessage =
|
// String pMessage =
|
||||||
// location.config.getFile().get(location.location)
|
// location.config.getFile().get(location.location)
|
||||||
// .toString().replaceAll("%player%", player.getName());
|
// .toString().replaceAll("%player%", player.getName());
|
||||||
player.sendMessage(MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", player.getName()), vars));
|
player.sendMessage(MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", player.getDisplayName()), vars));
|
||||||
}
|
}
|
||||||
// String message = location.config.getFile().get(location.location)
|
// String message = location.config.getFile().get(location.location)
|
||||||
// .toString().replaceAll("%player%", "Console");
|
// .toString().replaceAll("%player%", "Console");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user