mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-20 21:41:32 +02:00
Starting to break Protect
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
package com.earth2me.essentials.protect;
|
||||
|
||||
import com.earth2me.essentials.api.IReload;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IReload;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.protect.data.ProtectedBlockMemory;
|
||||
import com.earth2me.essentials.protect.data.ProtectedBlockMySQL;
|
||||
import com.earth2me.essentials.protect.data.ProtectedBlockSQLite;
|
||||
import java.beans.PropertyVetoException;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
@@ -30,7 +30,7 @@ public class EssentialsConnect
|
||||
ess = (IEssentials)essPlugin;
|
||||
protect = (IProtect)essProtect;
|
||||
ProtectReloader pr = new ProtectReloader();
|
||||
pr.reloadConfig();
|
||||
pr.onReload();
|
||||
ess.addReloadListener(pr);
|
||||
LOGGER.info(_("loadinfo", essProtect.getDescription().getName(), essProtect.getDescription().getVersion(), "essentials team"));
|
||||
|
||||
@@ -72,7 +72,8 @@ public class EssentialsConnect
|
||||
{
|
||||
protect.getStorage().onPluginDeactivation();
|
||||
}
|
||||
for (ProtectConfig protectConfig : ProtectConfig.values())
|
||||
|
||||
/*for (ProtectConfig protectConfig : ProtectConfig.values())
|
||||
{
|
||||
if (protectConfig.isList())
|
||||
{
|
||||
@@ -87,7 +88,7 @@ public class EssentialsConnect
|
||||
protect.getSettingsBoolean().put(protectConfig, ess.getSettings().getProtectBoolean(protectConfig.getConfigName(), protectConfig.getDefaultValueBoolean()));
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
if (protect.getSettingString(ProtectConfig.datatype).equalsIgnoreCase("mysql"))
|
||||
{
|
||||
|
@@ -1,9 +1,6 @@
|
||||
package com.earth2me.essentials.protect;
|
||||
|
||||
import com.earth2me.essentials.protect.data.IProtectedBlock;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
@@ -20,11 +17,12 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private static com.mchange.v2.log.MLogger C3P0logger;
|
||||
private final transient Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<ProtectConfig, Boolean>(ProtectConfig.class);
|
||||
private final transient Map<ProtectConfig, String> settingsString = new EnumMap<ProtectConfig, String>(ProtectConfig.class);
|
||||
private final transient Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class);
|
||||
//private final transient Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<ProtectConfig, Boolean>(ProtectConfig.class);
|
||||
//private final transient Map<ProtectConfig, String> settingsString = new EnumMap<ProtectConfig, String>(ProtectConfig.class);
|
||||
//private final transient Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class);
|
||||
private transient IProtectedBlock storage = null;
|
||||
private transient EssentialsConnect ess = null;
|
||||
private transient ProtectHolder settings = null;
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
@@ -95,12 +93,12 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
|
||||
LOGGER.log(Level.SEVERE, "Essentials not installed or failed to load. Essenials Protect is in emergency mode now.");
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public boolean checkProtectionItems(final ProtectConfig list, final int id)
|
||||
{
|
||||
final List<Integer> itemList = settingsList.get(list);
|
||||
return itemList != null && !itemList.isEmpty() && itemList.contains(id);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public IProtectedBlock getStorage()
|
||||
@@ -119,7 +117,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
|
||||
return ess;
|
||||
}
|
||||
|
||||
public Map<ProtectConfig, Boolean> getSettingsBoolean()
|
||||
/*public Map<ProtectConfig, Boolean> getSettingsBoolean()
|
||||
{
|
||||
return settingsBoolean;
|
||||
}
|
||||
@@ -146,7 +144,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
|
||||
{
|
||||
final String str = settingsString.get(protectConfig);
|
||||
return str == null ? protectConfig.getDefaultValueString() : str;
|
||||
}
|
||||
}*/
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
@@ -163,4 +161,14 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public ProtectHolder getSettings()
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
|
||||
public void setSettings(final ProtectHolder settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
}
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ public class EssentialsProtectBlockListener extends BlockListener
|
||||
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild())
|
||||
if (prot.getSettingBool(ProtectConfig.disable_build) && !user.isAuthorized(Permissions.BUILD))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -230,7 +230,7 @@ public class EssentialsProtectBlockListener extends BlockListener
|
||||
}
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild())
|
||||
if (prot.getSettingBool(ProtectConfig.disable_build) && !user.isAuthorized(Permissions.BUILD))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@@ -1,28 +1,24 @@
|
||||
package com.earth2me.essentials.protect;
|
||||
|
||||
import com.earth2me.essentials.protect.data.IProtectedBlock;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public interface IProtect extends Plugin
|
||||
{
|
||||
boolean checkProtectionItems(final ProtectConfig list, final int id);
|
||||
|
||||
boolean getSettingBool(final ProtectConfig protectConfig);
|
||||
|
||||
String getSettingString(final ProtectConfig protectConfig);
|
||||
|
||||
// boolean checkProtectionItems(final ProtectConfig list, final int id);
|
||||
// boolean getSettingBool(final ProtectConfig protectConfig);
|
||||
// String getSettingString(final ProtectConfig protectConfig);
|
||||
IProtectedBlock getStorage();
|
||||
|
||||
void setStorage(IProtectedBlock pb);
|
||||
|
||||
EssentialsConnect getEssentialsConnect();
|
||||
|
||||
Map<ProtectConfig, Boolean> getSettingsBoolean();
|
||||
// Map<ProtectConfig, Boolean> getSettingsBoolean();
|
||||
// Map<ProtectConfig, String> getSettingsString();
|
||||
// Map<ProtectConfig, List<Integer>> getSettingsList();
|
||||
ProtectHolder getSettings();
|
||||
|
||||
Map<ProtectConfig, String> getSettingsString();
|
||||
|
||||
Map<ProtectConfig, List<Integer>> getSettingsList();
|
||||
void setSettings(ProtectHolder settings);
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import java.util.Locale;
|
||||
|
||||
public enum Permissions implements IPermission
|
||||
{
|
||||
BUILD,
|
||||
PREVENTDAMAGE_FALL,
|
||||
PREVENTDAMAGE_NONE
|
||||
;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.earth2me.essentials.protect;
|
||||
|
||||
|
||||
public enum ProtectConfig
|
||||
/*public enum ProtectConfig
|
||||
{
|
||||
datatype("protect.datatype", "sqlite"),
|
||||
mysqlDB("protect.mysqlDb", "jdbc:mysql://localhost:3306/minecraft"),
|
||||
@@ -87,7 +87,7 @@ public enum ProtectConfig
|
||||
|
||||
/**
|
||||
* @return the configName
|
||||
*/
|
||||
*//*
|
||||
public String getConfigName()
|
||||
{
|
||||
return configName;
|
||||
@@ -95,7 +95,7 @@ public enum ProtectConfig
|
||||
|
||||
/**
|
||||
* @return the default value String
|
||||
*/
|
||||
*//*
|
||||
public String getDefaultValueString()
|
||||
{
|
||||
return defValueString;
|
||||
@@ -103,7 +103,7 @@ public enum ProtectConfig
|
||||
|
||||
/**
|
||||
* @return the default value boolean
|
||||
*/
|
||||
*//*
|
||||
public boolean getDefaultValueBoolean()
|
||||
{
|
||||
return defValueBoolean;
|
||||
@@ -118,4 +118,4 @@ public enum ProtectConfig
|
||||
{
|
||||
return isList;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.earth2me.essentials.protect;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.settings.protect.Protect;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class ProtectHolder extends AsyncStorageObjectHolder<Protect>
|
||||
{
|
||||
public ProtectHolder(IEssentials ess)
|
||||
{
|
||||
super(ess, Protect.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStorageFile() throws IOException
|
||||
{
|
||||
return new File(ess.getDataFolder(), "protect.yml");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user