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:
CoolLord22 2018-03-02 15:42:45 -05:00
parent e019460165
commit ed36764386
7 changed files with 62 additions and 23 deletions

9
.classpath Normal file
View 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>

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
target/
lib/
lib/
/bin/

17
.project Normal file
View 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>

View File

@ -38,14 +38,14 @@ public class ArenaHandler {
public static void sendMessage(Arena arena, String message, String... vars) {
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));
}
}
public static void sendFMessage(Arena arena, ConfigC location, String... vars) {
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));
}
}
@ -277,13 +277,8 @@ public class ArenaHandler {
// Fix for client not showing players after they join
for (Player otherplayer : arena.playersInArena) {
if (otherplayer.canSee(player))
otherplayer.showPlayer(player); // Make new player
// visible to others
if (player.canSee(otherplayer))
player.showPlayer(otherplayer); // Make other
// players visible
// to new player
otherplayer.showPlayer(player);
player.showPlayer(otherplayer);
}
}
}
@ -362,7 +357,7 @@ public class ArenaHandler {
if (arena.seekersWinCommands != null) {
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) {
@ -414,7 +409,7 @@ public class ArenaHandler {
if (arena.hidersWinCommands != null) {
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) {

View File

@ -76,7 +76,7 @@ public class OnEntityDamageByEntityEvent implements Listener {
} else {
// Seeker damaged by hider
if (!arena.hidersCanHurtSeekers) {
event.setCancelled(true);
event.setCancelled(false);
return;
}
}

View File

@ -3,23 +3,40 @@ package nl.Steffion.BlockHunt.Listeners;
import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.ArenaHandler;
import nl.Steffion.BlockHunt.W;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import java.util.ArrayList;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class OnPlayerQuitEvent implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public ArrayList<String> leftPlayer = new ArrayList<String>();
public LocationSerializable spawnWarp;
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerQuitEvent(PlayerQuitEvent event) {
Player player = event.getPlayer();
Player playerLeaving = event.getPlayer();
for (Arena arena : W.arenaList) {
if (arena.playersInArena.contains(player)) {
ArenaHandler.playerLeaveArena(player, true, true);
if (arena.playersInArena.contains(playerLeaving)) {
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());
}
}
}

View File

@ -35,7 +35,7 @@ public class MessageM {
if (player == null) {
Bukkit.getConsoleSender().sendMessage(MessageM.replaceAll(message.replaceAll("%player%", "Console"), vars));
} 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(
MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", "Console"), vars));
} 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()) {
// String pMessage = message.replaceAll("%player%",
// 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");
Bukkit.getConsoleSender().sendMessage(MessageM.replaceAll(message.replaceAll("%player%", "Console"), vars));
@ -95,7 +95,7 @@ public class MessageM {
// String pMessage =
// location.config.getFile().get(location.location)
// .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)
// .toString().replaceAll("%player%", "Console");