mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-10 17:41:52 +01:00
Style!
This commit is contained in:
parent
fd9464ced1
commit
d0ea4168bc
@ -469,13 +469,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
wantedConfig = (MultiverseCoreConfiguration) multiverseConfig.get("multiverse-configuration");
|
||||
} catch (Exception ignore) {
|
||||
} finally {
|
||||
Thread thread = Thread.currentThread();
|
||||
if (configLock.isLocked()) {
|
||||
//log(Level.FINER, "configLock is locked when attempting to set config variable on thread: " + thread);
|
||||
}
|
||||
configLock.lock();
|
||||
try {
|
||||
//log(Level.FINER, "Setting config on thread: " + thread);
|
||||
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
|
||||
} finally {
|
||||
configLock.unlock();
|
||||
|
@ -32,9 +32,9 @@ public class MVAsyncPlayerChatListener implements MVChatListener<AsyncPlayerChat
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when a player wants to chat.
|
||||
* @param event The Event that was fired.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@EventHandler
|
||||
public void playerChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
@ -45,19 +45,19 @@ public class MVAsyncPlayerChatListener implements MVChatListener<AsyncPlayerChat
|
||||
if (plugin.getMVConfig().getPrefixChat()) {
|
||||
String world;
|
||||
Thread thread = Thread.currentThread();
|
||||
if (playerListener.worldsLock.isLocked()) {
|
||||
if (playerListener.getWorldsLock().isLocked()) {
|
||||
plugin.log(Level.FINEST, "worldsLock is locked when attempting to handle player chat on thread: " + thread);
|
||||
}
|
||||
playerListener.worldsLock.lock();
|
||||
playerListener.getWorldsLock().lock();
|
||||
try {
|
||||
plugin.log(Level.FINEST, "Handling player chat on thread: " + thread);
|
||||
world = playerListener.playerWorld.get(event.getPlayer().getName());
|
||||
world = playerListener.getPlayerWorld().get(event.getPlayer().getName());
|
||||
if (world == null) {
|
||||
world = event.getPlayer().getWorld().getName();
|
||||
playerListener.playerWorld.put(event.getPlayer().getName(), world);
|
||||
playerListener.getPlayerWorld().put(event.getPlayer().getName(), world);
|
||||
}
|
||||
} finally {
|
||||
playerListener.worldsLock.unlock();
|
||||
playerListener.getWorldsLock().unlock();
|
||||
}
|
||||
String prefix = "";
|
||||
// If we're not a MV world, don't do anything
|
||||
|
@ -4,8 +4,15 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* This interface is implemented by {@link MVPlayerChatListener} and {@link MVAsyncPlayerChatListener}.
|
||||
* @param <E> The chat event-type.
|
||||
*/
|
||||
public interface MVChatListener<E extends Event> extends Listener {
|
||||
|
||||
/**
|
||||
* This method is called when a player wants to chat.
|
||||
* @param event The Event that was fired.
|
||||
*/
|
||||
@EventHandler
|
||||
public void playerChat(E event);
|
||||
void playerChat(E event);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public class MVPlayerChatListener implements MVChatListener<PlayerChatEvent> {
|
||||
* This method is called when a player wants to chat.
|
||||
* @param event The Event that was fired.
|
||||
*/
|
||||
@Override
|
||||
@EventHandler
|
||||
public void playerChat(PlayerChatEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
@ -45,19 +46,19 @@ public class MVPlayerChatListener implements MVChatListener<PlayerChatEvent> {
|
||||
if (plugin.getMVConfig().getPrefixChat()) {
|
||||
String world;
|
||||
Thread thread = Thread.currentThread();
|
||||
if (playerListener.worldsLock.isLocked()) {
|
||||
if (playerListener.getWorldsLock().isLocked()) {
|
||||
plugin.log(Level.FINEST, "worldsLock is locked when attempting to handle player chat on thread: " + thread);
|
||||
}
|
||||
playerListener.worldsLock.lock();
|
||||
playerListener.getWorldsLock().lock();
|
||||
try {
|
||||
plugin.log(Level.FINEST, "Handling player chat on thread: " + thread);
|
||||
world = playerListener.playerWorld.get(event.getPlayer().getName());
|
||||
world = playerListener.getPlayerWorld().get(event.getPlayer().getName());
|
||||
if (world == null) {
|
||||
world = event.getPlayer().getWorld().getName();
|
||||
playerListener.playerWorld.put(event.getPlayer().getName(), world);
|
||||
playerListener.getPlayerWorld().put(event.getPlayer().getName(), world);
|
||||
}
|
||||
} finally {
|
||||
playerListener.worldsLock.unlock();
|
||||
playerListener.getWorldsLock().unlock();
|
||||
}
|
||||
String prefix = "";
|
||||
// If we're not a MV world, don't do anything
|
||||
|
@ -40,8 +40,8 @@ public class MVPlayerListener implements Listener {
|
||||
private final MVWorldManager worldManager;
|
||||
private final PermissionTools pt;
|
||||
|
||||
final ReentrantLock worldsLock = new ReentrantLock();
|
||||
final Map<String, String> playerWorld = new HashMap<String, String>();
|
||||
private final ReentrantLock worldsLock = new ReentrantLock();
|
||||
private final Map<String, String> playerWorld = new HashMap<String, String>();
|
||||
|
||||
public MVPlayerListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -49,6 +49,20 @@ public class MVPlayerListener implements Listener {
|
||||
pt = new PermissionTools(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the worldsLock
|
||||
*/
|
||||
public ReentrantLock getWorldsLock() {
|
||||
return worldsLock;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the playerWorld-map
|
||||
*/
|
||||
public Map<String, String> getPlayerWorld() {
|
||||
return playerWorld;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when a player respawns.
|
||||
* @param event The Event that was fired.
|
||||
@ -299,6 +313,7 @@ public class MVPlayerListener implements Listener {
|
||||
// Remove the player 1 tick after the login. I'm sure there's GOT to be a better way to do this...
|
||||
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(plugin.getMVWorldManager().getFirstSpawnWorld().getSpawnLocation());
|
||||
}
|
||||
@ -328,6 +343,7 @@ public class MVPlayerListener implements Listener {
|
||||
if (!this.pt.playerCanIgnoreGameModeRestriction(world, player)) {
|
||||
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Check that the player is in the new world and they haven't been teleported elsewhere or the event cancelled.
|
||||
if (player.getWorld() == world.getCBWorld()) {
|
||||
|
Loading…
Reference in New Issue
Block a user