Allow admins to force enable /recipe if they want

Add `force-enable-recipe`, which allows server admins to manually enable `/recipe` despite potential duplication exploits. Use this at your own risk!

Related: #1397
This commit is contained in:
md678685 2018-12-08 16:41:09 +00:00
parent 44301fae4f
commit 6a6383462d
4 changed files with 20 additions and 3 deletions

View File

@ -316,4 +316,6 @@ public interface ISettings extends IConf {
boolean isAllowWorldInBroadcastworld();
String getItemDbType();
boolean isForceEnableRecipe();
}

View File

@ -1463,7 +1463,7 @@ public class Settings implements net.ess3.api.ISettings {
return isAllowWorldInBroadcastworld;
}
private String itemDbType;
private String itemDbType; // #EasterEgg - admins can manually switch items provider if they want
private String _getItemDbType() {
return config.getString("item-db-type", "auto");
@ -1473,4 +1473,15 @@ public class Settings implements net.ess3.api.ISettings {
public String getItemDbType() {
return itemDbType;
}
private boolean forceEnableRecipe; // https://github.com/EssentialsX/Essentials/issues/1397
private boolean _isForceEnableRecipe() {
return config.getBoolean("force-enable-recipe", false);
}
@Override
public boolean isForceEnableRecipe() {
return false;
}
}

View File

@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.VersionUtil;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.*;
@ -24,8 +25,10 @@ public class Commandrecipe extends EssentialsCommand {
}
private void disableCommandForVersion1_12() throws Exception {
if (ReflUtil.getNmsVersionObject().equals(ReflUtil.V1_12_R1)) {
throw new Exception("/recipe is temporarily disabled. Please use the recipe book in your inventory.");
VersionUtil.BukkitVersion version = VersionUtil.getServerBukkitVersion();
if (version.isHigherThanOrEqualTo(VersionUtil.v1_12_0_R01)
&& !ess.getSettings().isForceEnableRecipe()) {
throw new Exception("Please use the recipe book in your inventory.");
}
}

View File

@ -15,6 +15,7 @@ public class VersionUtil {
public static final BukkitVersion v1_9_4_R01 = BukkitVersion.fromString("1.9.4-R0.1-SNAPSHOT");
public static final BukkitVersion v1_10_2_R01 = BukkitVersion.fromString("1.10.2-R0.1-SNAPSHOT");
public static final BukkitVersion v1_11_2_R01 = BukkitVersion.fromString("1.11.2-R0.1-SNAPSHOT");
public static final BukkitVersion v1_12_0_R01 = BukkitVersion.fromString("1.12.0-R0.1-SNAPSHOT");
public static final BukkitVersion v1_12_2_R01 = BukkitVersion.fromString("1.12.2-R0.1-SNAPSHOT");
public static final BukkitVersion v1_13_0_R01 = BukkitVersion.fromString("1.13.0-R0.1-SNAPSHOT");
public static final BukkitVersion v1_13_2_R01 = BukkitVersion.fromString("1.13.2-R0.1-SNAPSHOT");