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