mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-14 13:13:24 +00:00
Merge branch '2.x' of https://github.com/EssentialsX/Essentials into 2.x-upstream
This commit is contained in:
commit
849efa9756
7 changed files with 101 additions and 12 deletions
|
@ -308,6 +308,9 @@ public class EssentialsPlayerListener implements Listener {
|
||||||
user.setGodModeEnabled(false);
|
user.setGodModeEnabled(false);
|
||||||
ess.getLogger().log(Level.INFO, "Set god mode to false for {0} because they had it enabled without permission.", user.getName());
|
ess.getLogger().log(Level.INFO, "Set god mode to false for {0} because they had it enabled without permission.", user.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user.setConfirmingClearCommand(null);
|
||||||
|
user.getConfirmingPayments().clear();
|
||||||
|
|
||||||
user.stopTransaction();
|
user.stopTransaction();
|
||||||
}
|
}
|
||||||
|
@ -350,7 +353,10 @@ public class EssentialsPlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Makes the compass item ingame always point to the first essentials home. #EasterEgg
|
// Makes the compass item ingame always point to the first essentials home. #EasterEgg
|
||||||
|
// EssentialsX: This can now optionally require a permission to enable, if set in the config.
|
||||||
private void updateCompass(final User user) {
|
private void updateCompass(final User user) {
|
||||||
|
if (ess.getSettings().isCompassTowardsHomePerm() && !user.isAuthorized("essentials.home.compass")) return;
|
||||||
|
|
||||||
Location loc = user.getHome(user.getLocation());
|
Location loc = user.getHome(user.getLocation());
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
loc = user.getBase().getBedSpawnLocation();
|
loc = user.getBase().getBedSpawnLocation();
|
||||||
|
|
|
@ -306,4 +306,6 @@ public interface ISettings extends IConf {
|
||||||
List<String> getDefaultEnabledConfirmCommands();
|
List<String> getDefaultEnabledConfirmCommands();
|
||||||
|
|
||||||
boolean isConfirmCommandEnabledByDefault(String commandName);
|
boolean isConfirmCommandEnabledByDefault(String commandName);
|
||||||
|
|
||||||
|
boolean isCompassTowardsHomePerm();
|
||||||
}
|
}
|
||||||
|
|
|
@ -533,6 +533,7 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
currencyFormat = _getCurrencyFormat();
|
currencyFormat = _getCurrencyFormat();
|
||||||
unprotectedSigns = _getUnprotectedSign();
|
unprotectedSigns = _getUnprotectedSign();
|
||||||
defaultEnabledConfirmCommands = _getDefaultEnabledConfirmCommands();
|
defaultEnabledConfirmCommands = _getDefaultEnabledConfirmCommands();
|
||||||
|
isCompassTowardsHomePerm = _isCompassTowardsHomePerm();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
||||||
|
@ -1439,4 +1440,15 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
public boolean isConfirmCommandEnabledByDefault(String commandName) {
|
public boolean isConfirmCommandEnabledByDefault(String commandName) {
|
||||||
return getDefaultEnabledConfirmCommands().contains(commandName.toLowerCase());
|
return getDefaultEnabledConfirmCommands().contains(commandName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isCompassTowardsHomePerm;
|
||||||
|
|
||||||
|
private boolean _isCompassTowardsHomePerm() {
|
||||||
|
return config.getBoolean("compass-towards-home-perm", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCompassTowardsHomePerm() {
|
||||||
|
return isCompassTowardsHomePerm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor;
|
||||||
import org.yaml.snakeyaml.introspector.PropertyUtils;
|
import org.yaml.snakeyaml.introspector.PropertyUtils;
|
||||||
import org.yaml.snakeyaml.nodes.*;
|
import org.yaml.snakeyaml.nodes.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,10 +34,30 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
|
||||||
|
|
||||||
|
|
||||||
private class ConstructBukkitScalar extends ConstructScalar {
|
private class ConstructBukkitScalar extends ConstructScalar {
|
||||||
|
|
||||||
|
private Method constructScalarMethod = null;
|
||||||
|
|
||||||
|
protected String constructScalarRefl(ScalarNode scalarNode) {
|
||||||
|
try {
|
||||||
|
if (constructScalarMethod == null) {
|
||||||
|
constructScalarMethod = ConstructScalar.class.getMethod("constructScalar", ScalarNode.class);
|
||||||
|
}
|
||||||
|
return (String) constructScalarMethod.invoke(this, scalarNode);
|
||||||
|
} catch (NoSuchMethodException
|
||||||
|
| SecurityException
|
||||||
|
| IllegalAccessException
|
||||||
|
| IllegalArgumentException
|
||||||
|
| InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object construct(final Node node) {
|
public Object construct(final Node node) {
|
||||||
if (node.getType().equals(Material.class)) {
|
if (node.getType().equals(Material.class)) {
|
||||||
final String val = (String) constructScalar((ScalarNode) node);
|
final String val = constructScalarRefl((ScalarNode) node);
|
||||||
Material mat;
|
Material mat;
|
||||||
if (NumberUtil.isInt(val)) {
|
if (NumberUtil.isInt(val)) {
|
||||||
final int typeId = Integer.parseInt(val);
|
final int typeId = Integer.parseInt(val);
|
||||||
|
@ -46,7 +68,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
if (node.getType().equals(MaterialData.class)) {
|
if (node.getType().equals(MaterialData.class)) {
|
||||||
final String val = (String) constructScalar((ScalarNode) node);
|
final String val = constructScalarRefl((ScalarNode) node);
|
||||||
if (val.isEmpty()) {
|
if (val.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +93,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
|
||||||
return new MaterialData(mat, data);
|
return new MaterialData(mat, data);
|
||||||
}
|
}
|
||||||
if (node.getType().equals(ItemStack.class)) {
|
if (node.getType().equals(ItemStack.class)) {
|
||||||
final String val = (String) constructScalar((ScalarNode) node);
|
final String val = constructScalarRefl((ScalarNode) node);
|
||||||
if (val.isEmpty()) {
|
if (val.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +156,7 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
if (node.getType().equals(EnchantmentLevel.class)) {
|
if (node.getType().equals(EnchantmentLevel.class)) {
|
||||||
final String val = (String) constructScalar((ScalarNode) node);
|
final String val = constructScalarRefl((ScalarNode) node);
|
||||||
if (val.isEmpty()) {
|
if (val.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -522,6 +522,13 @@ default-enabled-confirm-commands:
|
||||||
#- pay
|
#- pay
|
||||||
#- clearinventory
|
#- clearinventory
|
||||||
|
|
||||||
|
# Set the timeout, in seconds for players to accept a tpa before the request is cancelled.
|
||||||
|
# Set to 0 for no timeout.
|
||||||
|
tpa-accept-cancellation: 120
|
||||||
|
|
||||||
|
# Allow players to set hats by clicking on their helmet slot.
|
||||||
|
allow-direct-hat: true
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
# | EssentialsHome | #
|
# | EssentialsHome | #
|
||||||
|
@ -551,12 +558,12 @@ sethome-multiple:
|
||||||
# In this example someone with 'essentials.sethome.multiple' and 'essentials.sethome.multiple.vip' will have 5 homes.
|
# In this example someone with 'essentials.sethome.multiple' and 'essentials.sethome.multiple.vip' will have 5 homes.
|
||||||
# Remember, they MUST have both permission nodes in order to be able to set multiple homes.
|
# Remember, they MUST have both permission nodes in order to be able to set multiple homes.
|
||||||
|
|
||||||
# Set the timeout, in seconds for players to accept a tpa before the request is cancelled.
|
# Controls whether players need the permission "essentials.home.compass" in order to point
|
||||||
# Set to 0 for no timeout.
|
# the player's compass at their first home.
|
||||||
tpa-accept-cancellation: 120
|
#
|
||||||
|
# Leaving this as false will retain Essentials' original behaviour, which is to always
|
||||||
# Allow players to set hats by clicking on their helmet slot.
|
# change the compass' direction to point towards their first home.
|
||||||
allow-direct-hat: true
|
compass-towards-home-perm: false
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
|
|
|
@ -10,9 +10,16 @@ import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
|
|
||||||
|
|
||||||
public class EmergencyListener implements Listener {
|
public class EmergencyListener implements Listener {
|
||||||
|
EssentialsProtect plugin;
|
||||||
|
|
||||||
|
EmergencyListener(final EssentialsProtect essProtPlugin) {
|
||||||
|
plugin = essProtPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onBlockBurn(final BlockBurnEvent event) {
|
public void onBlockBurn(final BlockBurnEvent event) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -47,4 +54,11 @@ public class EmergencyListener implements Listener {
|
||||||
public void onEntityDamage(final EntityDamageEvent event) {
|
public void onEntityDamage(final EntityDamageEvent event) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginEnabled(final PluginEnableEvent event) {
|
||||||
|
if (event.getPlugin().getName().equals("Essentials")) {
|
||||||
|
plugin.disableEmergencyMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.earth2me.essentials.protect;
|
package com.earth2me.essentials.protect;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
@ -19,6 +20,8 @@ public class EssentialsProtect extends JavaPlugin implements IProtect {
|
||||||
private final Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class);
|
private final Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class);
|
||||||
private EssentialsConnect ess = null;
|
private EssentialsConnect ess = null;
|
||||||
|
|
||||||
|
private final EmergencyListener emListener = new EmergencyListener(this);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
final PluginManager pm = this.getServer().getPluginManager();
|
final PluginManager pm = this.getServer().getPluginManager();
|
||||||
|
@ -27,6 +30,12 @@ public class EssentialsProtect extends JavaPlugin implements IProtect {
|
||||||
enableEmergencyMode(pm);
|
enableEmergencyMode(pm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initialize(pm, essPlugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(final PluginManager pm, final Plugin essPlugin) {
|
||||||
|
LOGGER.log(Level.INFO, "Continuing to enable Protect.");
|
||||||
ess = new EssentialsConnect(essPlugin, this);
|
ess = new EssentialsConnect(essPlugin, this);
|
||||||
|
|
||||||
final EssentialsProtectBlockListener blockListener = new EssentialsProtectBlockListener(this);
|
final EssentialsProtectBlockListener blockListener = new EssentialsProtectBlockListener(this);
|
||||||
|
@ -40,13 +49,30 @@ public class EssentialsProtect extends JavaPlugin implements IProtect {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableEmergencyMode(final PluginManager pm) {
|
private void enableEmergencyMode(final PluginManager pm) {
|
||||||
final EmergencyListener emListener = new EmergencyListener();
|
|
||||||
pm.registerEvents(emListener, this);
|
pm.registerEvents(emListener, this);
|
||||||
|
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
player.sendMessage("Essentials Protect is in emergency mode. Check your log for errors.");
|
player.sendMessage("Essentials Protect is in emergency mode. Check your log for errors.");
|
||||||
}
|
}
|
||||||
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. Essentials Protect is in emergency mode now.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void disableEmergencyMode() {
|
||||||
|
final PluginManager pm = this.getServer().getPluginManager();
|
||||||
|
final Plugin essPlugin = pm.getPlugin("Essentials");
|
||||||
|
if (essPlugin == null || !essPlugin.isEnabled()) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Tried to disable emergency mode, but Essentials still isn't enabled!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HandlerList.unregisterAll(emListener);
|
||||||
|
|
||||||
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
|
player.sendMessage("Essentials Protect is no longer in emergency mode.");
|
||||||
|
}
|
||||||
|
LOGGER.log(Level.SEVERE, "Essentials was loaded late! Essentials Protect is no longer in emergency mode.");
|
||||||
|
|
||||||
|
initialize(pm, essPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue