Change logger. Correct eject on plugin disable.
This commit is contained in:
parent
05b697c911
commit
661397bd46
@ -3,6 +3,7 @@ package com.cnaude.chairs;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -38,9 +39,7 @@ public class Chairs extends JavaPlugin {
|
|||||||
public int sitEffectInterval;
|
public int sitEffectInterval;
|
||||||
private File pluginFolder;
|
private File pluginFolder;
|
||||||
private File configFile;
|
private File configFile;
|
||||||
public static final String PLUGIN_NAME = "Chairs";
|
private Logger log;
|
||||||
public static final String LOG_HEADER = "[" + PLUGIN_NAME + "]";
|
|
||||||
static final Logger log = Bukkit.getLogger();
|
|
||||||
public PluginManager pm;
|
public PluginManager pm;
|
||||||
public static ChairsIgnoreList ignoreList;
|
public static ChairsIgnoreList ignoreList;
|
||||||
public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled;
|
public String msgSitting, msgStanding, msgOccupied, msgNoPerm, msgReloaded, msgDisabled, msgEnabled;
|
||||||
@ -48,6 +47,7 @@ public class Chairs extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
log = this.getLogger();
|
||||||
ignoreList = new ChairsIgnoreList(this);
|
ignoreList = new ChairsIgnoreList(this);
|
||||||
ignoreList.load();
|
ignoreList.load();
|
||||||
pm = this.getServer().getPluginManager();
|
pm = this.getServer().getPluginManager();
|
||||||
@ -71,11 +71,8 @@ public class Chairs extends JavaPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
protocolManager.removePacketListeners(this);
|
protocolManager.removePacketListeners(this);
|
||||||
protocolManager = null;
|
protocolManager = null;
|
||||||
for (String pName : sit.keySet()) {
|
for (String pName : new HashSet<String>(sit.keySet())) {
|
||||||
Player player = getServer().getPlayer(pName);
|
ejectPlayerOnDisable(Bukkit.getPlayerExact(pName));
|
||||||
Location loc = player.getLocation().clone();
|
|
||||||
loc.setY(loc.getY() + 1);
|
|
||||||
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
}
|
}
|
||||||
if (ignoreList != null) {
|
if (ignoreList != null) {
|
||||||
ignoreList.save();
|
ignoreList.save();
|
||||||
@ -84,6 +81,7 @@ public class Chairs extends JavaPlugin {
|
|||||||
chairEffects.cancel();
|
chairEffects.cancel();
|
||||||
}
|
}
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
|
log = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restartEffectsTask() {
|
public void restartEffectsTask() {
|
||||||
@ -142,6 +140,15 @@ public class Chairs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void ejectPlayerOnDisable(Player player)
|
||||||
|
{
|
||||||
|
player.eject();
|
||||||
|
sit.get(player.getName()).remove();
|
||||||
|
sitblock.remove(sitblockbr.get(player.getName()));
|
||||||
|
sitblockbr.remove(player.getName());
|
||||||
|
sitstopteleportloc.remove(player.getName());
|
||||||
|
sit.remove(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void loadConfig() {
|
public void loadConfig() {
|
||||||
@ -246,11 +253,11 @@ public class Chairs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void logInfo(String _message) {
|
public void logInfo(String _message) {
|
||||||
log.log(Level.INFO, String.format("%s %s", LOG_HEADER, _message));
|
log.log(Level.INFO, _message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logError(String _message) {
|
public void logError(String _message) {
|
||||||
log.log(Level.SEVERE, String.format("%s %s", LOG_HEADER, _message));
|
log.log(Level.SEVERE, _message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user