Refactor
This commit is contained in:
parent
c4386ab262
commit
526f785677
@ -2,6 +2,7 @@ package com.cnaude.chairs;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -25,7 +26,6 @@ import com.comphenix.protocol.ProtocolLibrary;
|
|||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
|
|
||||||
public class Chairs extends JavaPlugin {
|
public class Chairs extends JavaPlugin {
|
||||||
private static Chairs instance = null;
|
|
||||||
public static ChairEffects chairEffects;
|
public static ChairEffects chairEffects;
|
||||||
public List<ChairBlock> allowedBlocks;
|
public List<ChairBlock> allowedBlocks;
|
||||||
public List<Material> validSigns;
|
public List<Material> validSigns;
|
||||||
@ -49,8 +49,7 @@ public class Chairs extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
ignoreList = new ChairsIgnoreList(this);
|
||||||
ignoreList = new ChairsIgnoreList();
|
|
||||||
ignoreList.load();
|
ignoreList.load();
|
||||||
pm = this.getServer().getPluginManager();
|
pm = this.getServer().getPluginManager();
|
||||||
pluginFolder = getDataFolder();
|
pluginFolder = getDataFolder();
|
||||||
@ -67,7 +66,6 @@ public class Chairs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
new PacketListener(protocolManager, this);
|
new PacketListener(protocolManager, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,7 +85,6 @@ public class Chairs extends JavaPlugin {
|
|||||||
chairEffects.cancel();
|
chairEffects.cancel();
|
||||||
}
|
}
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
instance = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restartEffectsTask() {
|
public void restartEffectsTask() {
|
||||||
@ -257,9 +254,6 @@ public class Chairs extends JavaPlugin {
|
|||||||
log.log(Level.SEVERE, String.format("%s %s", LOG_HEADER, _message));
|
log.log(Level.SEVERE, String.format("%s %s", LOG_HEADER, _message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chairs get() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,18 +9,24 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author naudec
|
* @author cnaude
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ChairsIgnoreList implements Serializable{
|
public class ChairsIgnoreList implements Serializable{
|
||||||
private static ArrayList<String> ignoreList = new ArrayList<String>();
|
private static ArrayList<String> ignoreList = new ArrayList<String>();
|
||||||
private static final String IGNORE_FILE = "plugins/Chairs/ignores.ser";
|
private static final String IGNORE_FILE = "plugins/Chairs/ignores.ser";
|
||||||
|
|
||||||
|
private Chairs plugin;
|
||||||
|
public ChairsIgnoreList(Chairs plugin)
|
||||||
|
{
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void load() {
|
public void load() {
|
||||||
File file = new File(IGNORE_FILE);
|
File file = new File(IGNORE_FILE);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
Chairs.get().logInfo("Ignore file '"+file.getAbsolutePath()+"' does not exist.");
|
plugin.logInfo("Ignore file '"+file.getAbsolutePath()+"' does not exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -28,10 +34,10 @@ public class ChairsIgnoreList implements Serializable{
|
|||||||
ObjectInputStream obj_in = new ObjectInputStream (f_in);
|
ObjectInputStream obj_in = new ObjectInputStream (f_in);
|
||||||
ignoreList = (ArrayList<String>) obj_in.readObject();
|
ignoreList = (ArrayList<String>) obj_in.readObject();
|
||||||
obj_in.close();
|
obj_in.close();
|
||||||
Chairs.get().logInfo("Loaded ignore list. (Count = "+ignoreList.size()+")");
|
plugin.logInfo("Loaded ignore list. (Count = "+ignoreList.size()+")");
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
Chairs.get().logError(e.getMessage());
|
plugin.logError(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,10 +48,10 @@ public class ChairsIgnoreList implements Serializable{
|
|||||||
ObjectOutputStream obj_out = new ObjectOutputStream (f_out);
|
ObjectOutputStream obj_out = new ObjectOutputStream (f_out);
|
||||||
obj_out.writeObject (ignoreList);
|
obj_out.writeObject (ignoreList);
|
||||||
obj_out.close();
|
obj_out.close();
|
||||||
Chairs.get().logInfo("Saved ignore list. (Count = "+ignoreList.size()+")");
|
plugin.logInfo("Saved ignore list. (Count = "+ignoreList.size()+")");
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
Chairs.get().logError(e.getMessage());
|
plugin.logError(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user