mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +00:00
TotalFreedomMod Electrum
Version 5.0 This TotalFreedomMod release implements many changes. Most notably, the internals have been completely revamped. TotalFreedomMod now relies on the Aero library for core mechanics such as command handling and services. Another important change is the UUID system. In TotalFreedomMod Electrum, it has been completely removed. The core reason for this is that the system as a whole was very bugged. Additionally, it did not solve the primary reason for its conception: preserving player data when the player changes their username. This is because TotalFreedomMod servers usually run in offline-mode. This meaning that some of the players joining do not have a registerd Mojang UUID whatsoever. All in all, the UUID system was buggy, and it did not fix the reason it was implemented, so it has been completely removed. The admin list and the ban list now use usernames and IPs again. Lastly, many smaller changes have been implemented. Due to the amount of changes, they have not been named individualy. Please refer to the issues below for more details. Fixes #342 Fixes #350 Fixes #380 Fixes #684 Fixes #704 Fixes #716 Fixes #735 Fixes #745 Fixes #784 Fixes #765 Fixes #791 Fixes #805 Fixes #826 Fixes #883 Fixes #1524 Fixes #1534 Fixes #1536 Fixes #1538 Fixes #1545 Fixes #1546 Fixes #1568 Fixes #1627 Resolves #403 Resolves #435 Resolves #597 Resolves #603 Resolves #628 Resolves #690 Resolves #708 Resolves #747 Resolves #748 Resolves #749 Resolves #764 Resolves #767 Resolves #782 Resolves #809 Resolves #803 Resolves #811 Resolves #813 Resolves #830 Resolves #848 Resolves #856 Resolves #876 Resolves #908 Resolves #992 Resolves #1018 Resolves #1432 Resolves #1446 Resolves #1494 Resolves #1501 Resolves #1526 Resolves #1540 Resolves #1550 Resolves #1560 Resolves #1561 Resolves #1578 Resolves #1613
This commit is contained in:
parent
924f718d5a
commit
aca3398d21
@ -4,4 +4,8 @@ TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the
|
|||||||
|
|
||||||
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
|
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
|
||||||
|
|
||||||
|
### Download ###
|
||||||
|
You may download official binaries from the [releases page](https://github.com/TotalFreedom/TotalFreedomMod/releases).
|
||||||
|
|
||||||
|
### Contributing ###
|
||||||
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod. For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
|
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod. For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
|
||||||
|
3
pom.xml
3
pom.xml
@ -10,6 +10,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<tfm.build.version>${project.version}</tfm.build.version>
|
<tfm.build.version>${project.version}</tfm.build.version>
|
||||||
|
<tfm.build.codename>Electrum</tfm.build.codename>
|
||||||
<tfm.build.number>${maven.buildnumber}</tfm.build.number>
|
<tfm.build.number>${maven.buildnumber}</tfm.build.number>
|
||||||
<tfm.build.date>${maven.build.timestamp}</tfm.build.date>
|
<tfm.build.date>${maven.build.timestamp}</tfm.build.date>
|
||||||
<tfm.build.author>${buildAuthor}</tfm.build.author>
|
<tfm.build.author>${buildAuthor}</tfm.build.author>
|
||||||
@ -224,7 +225,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
|
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
|
||||||
<buildNumberPropertiesFileLocation>${basedir}/build.properties</buildNumberPropertiesFileLocation>
|
<buildNumberPropertiesFileLocation>${basedir}/build.properties</buildNumberPropertiesFileLocation>
|
||||||
<format>{0,number}</format>
|
<format>{0,number,#}</format>
|
||||||
<items>
|
<items>
|
||||||
<item>buildNumber</item>
|
<item>buildNumber</item>
|
||||||
</items>
|
</items>
|
||||||
|
@ -58,9 +58,9 @@ public class Announcer extends FreedomService
|
|||||||
current = 0;
|
current = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.bcastMsg(prefix + announcements.get(current));
|
announce(announcements.get(current));
|
||||||
}
|
}
|
||||||
}.runTaskTimer(TotalFreedomMod.plugin, interval, interval);
|
}.runTaskTimer(plugin, interval, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,4 +80,9 @@ public class Announcer extends FreedomService
|
|||||||
return Collections.unmodifiableList(announcements);
|
return Collections.unmodifiableList(announcements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void announce(String message)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(prefix + message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class AntiNuke extends FreedomService
|
|||||||
if (fPlayer.incrementAndGetFreecamDestroyCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
|
if (fPlayer.incrementAndGetFreecamDestroyCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
||||||
FUtil.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
|
plugin.ae.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
|
||||||
|
|
||||||
fPlayer.resetFreecamDestroyCount();
|
fPlayer.resetFreecamDestroyCount();
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public class AntiNuke extends FreedomService
|
|||||||
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||||
FUtil.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||||
|
|
||||||
fPlayer.resetBlockDestroyCount();
|
fPlayer.resetBlockDestroyCount();
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ public class AntiNuke extends FreedomService
|
|||||||
if (fPlayer.incrementAndGetFreecamPlaceCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
|
if (fPlayer.incrementAndGetFreecamPlaceCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
|
||||||
FUtil.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
|
plugin.ae.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
|
||||||
|
|
||||||
fPlayer.resetFreecamPlaceCount();
|
fPlayer.resetFreecamPlaceCount();
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ public class AntiNuke extends FreedomService
|
|||||||
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||||
FUtil.autoEject(player, "You are placing blocks too fast.");
|
plugin.ae.autoEject(player, "You are placing blocks too fast.");
|
||||||
|
|
||||||
fPlayer.resetBlockPlaceCount();
|
fPlayer.resetBlockPlaceCount();
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public class AntiSpam extends FreedomService
|
|||||||
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
||||||
FUtil.autoEject(player, "Kicked for spamming commands.");
|
plugin.ae.autoEject(player, "Kicked for spamming commands.");
|
||||||
|
|
||||||
fPlayer.resetMsgCount();
|
fPlayer.resetMsgCount();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
116
src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java
Normal file
116
src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class AutoEject extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount
|
||||||
|
|
||||||
|
public AutoEject(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void autoEject(Player player, String kickMessage)
|
||||||
|
{
|
||||||
|
EjectMethod method = EjectMethod.STRIKE_ONE;
|
||||||
|
final String ip = Ips.getIp(player);
|
||||||
|
|
||||||
|
if (!ejects.containsKey(ip))
|
||||||
|
{
|
||||||
|
ejects.put(ip, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int kicks = ejects.get(ip);
|
||||||
|
kicks += 1;
|
||||||
|
|
||||||
|
ejects.put(ip, kicks);
|
||||||
|
|
||||||
|
if (kicks <= 1)
|
||||||
|
{
|
||||||
|
method = EjectMethod.STRIKE_ONE;
|
||||||
|
}
|
||||||
|
else if (kicks == 2)
|
||||||
|
{
|
||||||
|
method = EjectMethod.STRIKE_TWO;
|
||||||
|
}
|
||||||
|
else if (kicks >= 3)
|
||||||
|
{
|
||||||
|
method = EjectMethod.STRIKE_THREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("AutoEject -> name: " + player.getName() + " - player ip: " + ip + " - method: " + method.toString());
|
||||||
|
|
||||||
|
player.setOp(false);
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
player.getInventory().clear();
|
||||||
|
|
||||||
|
switch (method)
|
||||||
|
{
|
||||||
|
case STRIKE_ONE:
|
||||||
|
{
|
||||||
|
final Calendar cal = new GregorianCalendar();
|
||||||
|
cal.add(Calendar.MINUTE, 5);
|
||||||
|
final Date expires = cal.getTime();
|
||||||
|
|
||||||
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 5 minutes.");
|
||||||
|
|
||||||
|
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
|
||||||
|
player.kickPlayer(kickMessage);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STRIKE_TWO:
|
||||||
|
{
|
||||||
|
final Calendar c = new GregorianCalendar();
|
||||||
|
c.add(Calendar.MINUTE, 10);
|
||||||
|
final Date expires = c.getTime();
|
||||||
|
|
||||||
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 10 minutes.");
|
||||||
|
|
||||||
|
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
|
||||||
|
player.kickPlayer(kickMessage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STRIKE_THREE:
|
||||||
|
{
|
||||||
|
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
|
||||||
|
|
||||||
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
|
||||||
|
|
||||||
|
player.kickPlayer(kickMessage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EjectMethod
|
||||||
|
{
|
||||||
|
|
||||||
|
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.component.PluginComponent;
|
||||||
|
import net.pravian.aero.config.YamlConfig;
|
||||||
|
import org.bukkit.util.FileUtil;
|
||||||
|
|
||||||
|
public class BackupManager extends PluginComponent<TotalFreedomMod>
|
||||||
|
{
|
||||||
|
|
||||||
|
public BackupManager(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createBackups(String file)
|
||||||
|
{
|
||||||
|
createBackups(file, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createBackups(String file, boolean onlyWeekly)
|
||||||
|
{
|
||||||
|
final String save = file.split("\\.")[0];
|
||||||
|
final YamlConfig config = new YamlConfig(plugin, "backup/backup.yml", false);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
// Weekly
|
||||||
|
if (!config.isInt(save + ".weekly"))
|
||||||
|
{
|
||||||
|
performBackup(file, "weekly");
|
||||||
|
config.set(save + ".weekly", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int lastBackupWeekly = config.getInt(save + ".weekly");
|
||||||
|
|
||||||
|
if (lastBackupWeekly + 3600 * 24 * 7 < FUtil.getUnixTime())
|
||||||
|
{
|
||||||
|
performBackup(file, "weekly");
|
||||||
|
config.set(save + ".weekly", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlyWeekly)
|
||||||
|
{
|
||||||
|
config.save();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Daily
|
||||||
|
if (!config.isInt(save + ".daily"))
|
||||||
|
{
|
||||||
|
performBackup(file, "daily");
|
||||||
|
config.set(save + ".daily", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int lastBackupDaily = config.getInt(save + ".daily");
|
||||||
|
|
||||||
|
if (lastBackupDaily + 3600 * 24 < FUtil.getUnixTime())
|
||||||
|
{
|
||||||
|
performBackup(file, "daily");
|
||||||
|
config.set(save + ".daily", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performBackup(String file, String type)
|
||||||
|
{
|
||||||
|
FLog.info("Backing up " + file + " to " + file + "." + type + ".bak");
|
||||||
|
final File backupFolder = new File(plugin.getDataFolder(), "backup");
|
||||||
|
|
||||||
|
if (!backupFolder.exists())
|
||||||
|
{
|
||||||
|
backupFolder.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
final File oldYaml = new File(plugin.getDataFolder(), file);
|
||||||
|
final File newYaml = new File(backupFolder, file + "." + type + ".bak");
|
||||||
|
FileUtil.copy(oldYaml, newYaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,10 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -84,10 +87,41 @@ public class ChatManager extends FreedomService
|
|||||||
// Finally, set message
|
// Finally, set message
|
||||||
event.setMessage(message);
|
event.setMessage(message);
|
||||||
|
|
||||||
// Set the tag
|
// Make format
|
||||||
if (fPlayer.getTag() != null)
|
String format = "<%1$s> %2$s";
|
||||||
|
|
||||||
|
String tag = fPlayer.getTag();
|
||||||
|
if (tag != null && !tag.isEmpty())
|
||||||
{
|
{
|
||||||
event.setFormat("<" + fPlayer.getTag().replaceAll("%", "%%") + " %1$s> %2$s");
|
format = tag.replace("%", "%%") + " " + format;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set format
|
||||||
|
event.setFormat(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void adminChat(CommandSender sender, String message)
|
||||||
|
{
|
||||||
|
String name = sender.getName() + " " + plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
|
||||||
|
FLog.info("[ADMIN] " + name + ": " + message);
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.GOLD + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reportAction(Player reporter, Player reported, String report)
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,36 +6,28 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
public class CommandSpy extends FreedomService
|
public class CommandSpy extends FreedomService {
|
||||||
{
|
|
||||||
|
|
||||||
public CommandSpy(TotalFreedomMod plugin)
|
public CommandSpy(TotalFreedomMod plugin) {
|
||||||
{
|
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
protected void onStart() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
{
|
if (plugin.al.isAdmin(event.getPlayer())) {
|
||||||
if (plugin.al.isAdmin(event.getPlayer()))
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers()) {
|
||||||
{
|
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).cmdspyEnabled()) {
|
||||||
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).cmdspyEnabled())
|
|
||||||
{
|
|
||||||
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.AreaEffectCloud;
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Boat;
|
import org.bukkit.entity.Boat;
|
||||||
import org.bukkit.entity.EnderCrystal;
|
import org.bukkit.entity.EnderCrystal;
|
||||||
import org.bukkit.entity.EnderSignal;
|
import org.bukkit.entity.EnderSignal;
|
||||||
@ -18,6 +21,13 @@ import org.bukkit.entity.Firework;
|
|||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Minecart;
|
import org.bukkit.entity.Minecart;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
|
import org.bukkit.entity.ThrownExpBottle;
|
||||||
|
import org.bukkit.entity.ThrownPotion;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@ -40,6 +50,9 @@ public class EntityWiper extends FreedomService
|
|||||||
wipables.add(FallingBlock.class);
|
wipables.add(FallingBlock.class);
|
||||||
wipables.add(Firework.class);
|
wipables.add(Firework.class);
|
||||||
wipables.add(Item.class);
|
wipables.add(Item.class);
|
||||||
|
wipables.add(ThrownPotion.class);
|
||||||
|
wipables.add(ThrownExpBottle.class);
|
||||||
|
wipables.add(AreaEffectCloud.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -125,4 +138,22 @@ public class EntityWiper extends FreedomService
|
|||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onContainerBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockState state = event.getBlock().getState();
|
||||||
|
if (!(state instanceof InventoryHolder))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Inventory inv = ((InventoryHolder) state).getInventory();
|
||||||
|
inv.clear();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ public class FrontDoor extends FreedomService
|
|||||||
URL tempUrl = null;
|
URL tempUrl = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tempUrl = new URL("http://frontdoor.pravian.net/frontdoor/poll"
|
tempUrl = new URL("http://frontdoor.pravian.net:1337/frontdoor/poll"
|
||||||
+ "?version=" + TotalFreedomMod.build.formattedVersion()
|
+ "?version=" + TotalFreedomMod.build.formattedVersion()
|
||||||
+ "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
|
+ "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
|
||||||
+ "&name=" + ConfigEntry.SERVER_NAME.getString()
|
+ "&name=" + ConfigEntry.SERVER_NAME.getString()
|
||||||
@ -137,7 +137,7 @@ public class FrontDoor extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
updater = getNewUpdater().runTaskTimerAsynchronously(TotalFreedomMod.plugin, 2L * 20L, UPDATER_INTERVAL);
|
updater = getNewUpdater().runTaskTimerAsynchronously(plugin, 2L * 20L, UPDATER_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -254,7 +254,7 @@ public class FrontDoor extends FreedomService
|
|||||||
FUtil.cancel(updater);
|
FUtil.cancel(updater);
|
||||||
unregisterListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class);
|
unregisterListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class);
|
||||||
FLog.info("Disabled FrontDoor, thank you for being kind.");
|
FLog.info("Disabled FrontDoor, thank you for being kind.");
|
||||||
MainConfig.load();
|
plugin.config.load();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -278,12 +278,12 @@ public class FrontDoor extends FreedomService
|
|||||||
|
|
||||||
if (getRegisteredListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class) == null)
|
if (getRegisteredListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class) == null)
|
||||||
{
|
{
|
||||||
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, TotalFreedomMod.plugin);
|
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTask(TotalFreedomMod.plugin);
|
}.runTask(plugin);
|
||||||
|
|
||||||
frontdoor = getNewFrontDoor().runTaskTimer(TotalFreedomMod.plugin, 20L, FRONTDOOR_INTERVAL);
|
frontdoor = getNewFrontDoor().runTaskTimer(plugin, 20L, FRONTDOOR_INTERVAL);
|
||||||
|
|
||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
@ -347,7 +347,7 @@ public class FrontDoor extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
|
FUtil.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
|
||||||
Command_trail.startTrail(player);
|
plugin.tr.add(player);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,9 @@ public class GameRuleHandler extends FreedomService
|
|||||||
world.setGameRuleValue(gameRuleName, gameRuleValue);
|
world.setGameRuleValue(gameRuleName, gameRuleValue);
|
||||||
if (gameRuleEntry.getKey() == GameRule.DO_DAYLIGHT_CYCLE && !gameRuleEntry.getValue())
|
if (gameRuleEntry.getKey() == GameRule.DO_DAYLIGHT_CYCLE && !gameRuleEntry.getValue())
|
||||||
{
|
{
|
||||||
FUtil.setWorldTime(world, 6000L);
|
long time = world.getTime();
|
||||||
|
time -= time % 24000;
|
||||||
|
world.setTime(time + 24000 + 6000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
170
src/main/java/me/totalfreedom/totalfreedommod/LogViewer.java
Normal file
170
src/main/java/me/totalfreedom/totalfreedommod/LogViewer.java
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.command.Command_logs;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class LogViewer extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public LogViewer(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
||||||
|
{
|
||||||
|
updateLogsRegistration(sender, target.getName(), target.getAddress().getAddress().getHostAddress().trim(), mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLogsRegistration(final CommandSender sender, final String targetName, final String targetIP, final LogsRegistrationMode mode)
|
||||||
|
{
|
||||||
|
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
||||||
|
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
||||||
|
|
||||||
|
if (logsRegisterUrl == null || logsRegisterPassword == null || logsRegisterUrl.isEmpty() || logsRegisterPassword.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (sender != null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
||||||
|
}
|
||||||
|
|
||||||
|
URL url = new URLBuilder(logsRegisterUrl)
|
||||||
|
.addQueryParameter("mode", mode.toString())
|
||||||
|
.addQueryParameter("password", logsRegisterPassword)
|
||||||
|
.addQueryParameter("name", targetName)
|
||||||
|
.addQueryParameter("ip", targetIP)
|
||||||
|
.getURL();
|
||||||
|
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setConnectTimeout(1000 * 5);
|
||||||
|
connection.setReadTimeout(1000 * 5);
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
connection.setRequestMethod("HEAD");
|
||||||
|
|
||||||
|
final int responseCode = connection.getResponseCode();
|
||||||
|
|
||||||
|
if (sender != null)
|
||||||
|
{
|
||||||
|
if (!plugin.isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (responseCode == 200)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Registration " + mode.toString() + "d.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "Error contacting logs registration server.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTask(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deactivateSuperadmin(Admin superadmin)
|
||||||
|
{
|
||||||
|
for (String ip : superadmin.getIps())
|
||||||
|
{
|
||||||
|
updateLogsRegistration(null, superadmin.getName(), ip, LogsRegistrationMode.DELETE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum LogsRegistrationMode
|
||||||
|
{
|
||||||
|
|
||||||
|
UPDATE("update"), DELETE("delete");
|
||||||
|
private final String mode;
|
||||||
|
|
||||||
|
private LogsRegistrationMode(String mode)
|
||||||
|
{
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class URLBuilder
|
||||||
|
{
|
||||||
|
|
||||||
|
private final String requestPath;
|
||||||
|
private final Map<String, String> queryStringMap = new HashMap<>();
|
||||||
|
|
||||||
|
private URLBuilder(String requestPath)
|
||||||
|
{
|
||||||
|
this.requestPath = requestPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URLBuilder addQueryParameter(String key, String value)
|
||||||
|
{
|
||||||
|
queryStringMap.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URL getURL() throws MalformedURLException
|
||||||
|
{
|
||||||
|
List<String> pairs = new ArrayList<>();
|
||||||
|
Iterator<Map.Entry<String, String>> it = queryStringMap.entrySet().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
Map.Entry<String, String> pair = it.next();
|
||||||
|
pairs.add(pair.getKey() + "=" + pair.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -199,7 +199,7 @@ public class LoginProcess extends FreedomService
|
|||||||
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskLater(TotalFreedomMod.plugin, 20L * 1L);
|
}.runTaskLater(plugin, 20L * 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -18,8 +18,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|||||||
public class Muter extends FreedomService
|
public class Muter extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
// TODO: Match actual commands
|
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
||||||
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply,mail,email", ","));
|
|
||||||
|
|
||||||
public Muter(TotalFreedomMod plugin)
|
public Muter(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
@ -69,27 +68,36 @@ public class Muter extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String command = event.getMessage();
|
String message = event.getMessage();
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Find match actual command, instead of label
|
String cmdName = message.split(" ")[0].toLowerCase();
|
||||||
for (String commandName : MUTE_COMMANDS)
|
if (cmdName.startsWith("/"))
|
||||||
{
|
{
|
||||||
if (Pattern.compile("^/" + commandName.toLowerCase() + " ").matcher(command.toLowerCase()).find())
|
cmdName = cmdName.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Command command = server.getPluginCommand(cmdName);
|
||||||
|
if (command != null)
|
||||||
|
{
|
||||||
|
cmdName = command.getName().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MUTE_COMMANDS.contains(cmdName))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// TODO: Should this go here?
|
||||||
if (ConfigEntry.ENABLE_PREPROCESS_LOG.getBoolean())
|
if (ConfigEntry.ENABLE_PREPROCESS_LOG.getBoolean())
|
||||||
{
|
{
|
||||||
FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command), true);
|
FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), message), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class ProtectArea extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File input = new File(TotalFreedomMod.plugin.getDataFolder(), DATA_FILENAME);
|
File input = new File(plugin.getDataFolder(), DATA_FILENAME);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (input.exists())
|
if (input.exists())
|
||||||
@ -77,7 +77,7 @@ public class ProtectArea extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileOutputStream fos = new FileOutputStream(new File(TotalFreedomMod.plugin.getDataFolder(), DATA_FILENAME));
|
FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), DATA_FILENAME));
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
oos.writeObject(areas);
|
oos.writeObject(areas);
|
||||||
oos.close();
|
oos.close();
|
||||||
|
105
src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java
Normal file
105
src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
|
||||||
|
|
||||||
|
public class SavedFlags extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public SavedFlags(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Map<String, Boolean> getSavedFlags()
|
||||||
|
{
|
||||||
|
Map<String, Boolean> flags = null;
|
||||||
|
|
||||||
|
File input = new File(TotalFreedomMod.plugin().getDataFolder(), SAVED_FLAGS_FILENAME);
|
||||||
|
if (input.exists())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
try (FileInputStream fis = new FileInputStream(input); ObjectInputStream ois = new ObjectInputStream(fis))
|
||||||
|
{
|
||||||
|
flags = (HashMap<String, Boolean>) ois.readObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getSavedFlag(String flag) throws Exception
|
||||||
|
{
|
||||||
|
Boolean flagValue = null;
|
||||||
|
|
||||||
|
Map<String, Boolean> flags = getSavedFlags();
|
||||||
|
|
||||||
|
if (flags != null)
|
||||||
|
{
|
||||||
|
if (flags.containsKey(flag))
|
||||||
|
{
|
||||||
|
flagValue = flags.get(flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flagValue != null)
|
||||||
|
{
|
||||||
|
return flagValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSavedFlag(String flag, boolean value)
|
||||||
|
{
|
||||||
|
Map<String, Boolean> flags = getSavedFlags();
|
||||||
|
|
||||||
|
if (flags == null)
|
||||||
|
{
|
||||||
|
flags = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.put(flag, value);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), SAVED_FLAGS_FILENAME));
|
||||||
|
final ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
|
oos.writeObject(flags);
|
||||||
|
oos.close();
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -55,22 +55,24 @@ public class ServerPing extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
|
||||||
|
baseMotd = baseMotd.replace("\\n", "\n");
|
||||||
|
baseMotd = FUtil.colorize(baseMotd);
|
||||||
|
|
||||||
if (!ConfigEntry.SERVER_COLORFUL_MOTD.getBoolean())
|
if (!ConfigEntry.SERVER_COLORFUL_MOTD.getBoolean())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_MOTD.getString()
|
event.setMotd(baseMotd);
|
||||||
.replace("%mcversion%", plugin.si.getVersion())));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colorful MOTD
|
// Colorful MOTD
|
||||||
final StringBuilder motd = new StringBuilder();
|
final StringBuilder motd = new StringBuilder();
|
||||||
|
for (String word : baseMotd.split(" "))
|
||||||
for (String word : ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion()).split(" "))
|
|
||||||
{
|
{
|
||||||
motd.append(FUtil.randomChatColor()).append(word).append(" ");
|
motd.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setMotd(FUtil.colorize(motd.toString()));
|
event.setMotd(motd.toString().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,236 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.JSONValue;
|
|
||||||
|
|
||||||
public class ServiceChecker extends FreedomService
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final long SERVICE_CHECKER_RATE = 120L;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Map<String, ServiceStatus> services = Maps.newHashMap();
|
|
||||||
//
|
|
||||||
private BukkitTask task;
|
|
||||||
private URL url = null;
|
|
||||||
@Getter
|
|
||||||
private String lastCheck = "Never";
|
|
||||||
@Getter
|
|
||||||
private String version = "Mojang";
|
|
||||||
|
|
||||||
public ServiceChecker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
|
|
||||||
services.put("minecraft.net", new ServiceStatus("Minecraft.net"));
|
|
||||||
services.put("account.mojang.com", new ServiceStatus("Mojang Account Website"));
|
|
||||||
services.put("authserver.mojang.com", new ServiceStatus("Mojang Authentication"));
|
|
||||||
services.put("sessionserver.mojang.com", new ServiceStatus("Mojang Multiplayer sessions"));
|
|
||||||
services.put("skins.minecraft.net", new ServiceStatus("Minecraft Skins"));
|
|
||||||
services.put("auth.mojang.com", new ServiceStatus("Mojang Authentiation (Legacy)"));
|
|
||||||
services.put("session.minecraft.net", new ServiceStatus("Minecraft Sessions (Legacy)"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
final String serviceCheckerURL = ConfigEntry.SERVICE_CHECKER_URL.getString();
|
|
||||||
|
|
||||||
if (serviceCheckerURL == null || serviceCheckerURL.isEmpty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
url = new URL(serviceCheckerURL);
|
|
||||||
}
|
|
||||||
catch (MalformedURLException ex)
|
|
||||||
{
|
|
||||||
FLog.severe("Invalid ServiceChecker URL, disabling service checker");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
task = getUpdateRunnable().runTaskTimerAsynchronously(TotalFreedomMod.plugin, 40L, SERVICE_CHECKER_RATE * 20L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
task.cancel();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
task = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public BukkitRunnable getUpdateRunnable()
|
|
||||||
{
|
|
||||||
return new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if (url == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final JSONArray statusJson;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
|
|
||||||
statusJson = (JSONArray) JSONValue.parse(in.readLine());
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe("Error updating mojang services from " + url);
|
|
||||||
FLog.severe(ex);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Iterator status = statusJson.iterator();
|
|
||||||
while (status.hasNext())
|
|
||||||
{
|
|
||||||
final Iterator serviceIt = ((JSONObject) status.next()).entrySet().iterator();
|
|
||||||
while (serviceIt.hasNext())
|
|
||||||
{
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
final Entry<String, String> pair = (Entry<String, String>) serviceIt.next();
|
|
||||||
|
|
||||||
if ("lastcheck".equals(pair.getKey()))
|
|
||||||
{
|
|
||||||
lastCheck = pair.getValue();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("version".equals(pair.getKey()))
|
|
||||||
{
|
|
||||||
version = pair.getValue();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ServiceStatus service = services.get(pair.getKey());
|
|
||||||
if (service == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pair.getValue().contains(":"))
|
|
||||||
{
|
|
||||||
String[] statusString = pair.getValue().split(":");
|
|
||||||
service.setColor(statusString[0]);
|
|
||||||
service.setMessage(statusString[1]);
|
|
||||||
service.setUptime(statusString[2]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
service.setColor(pair.getValue());
|
|
||||||
service.setMessage(("red".equals(pair.getValue()) ? "Offline" : ("yellow".equals(pair.getValue()) ? "Problem" : "Online")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lastCheck.equals("Unknown"))
|
|
||||||
{
|
|
||||||
lastCheck = FUtil.dateToString(new Date());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ServiceStatus> getAllStatuses()
|
|
||||||
{
|
|
||||||
List<ServiceStatus> servicesList = new ArrayList<>();
|
|
||||||
for (String key : services.keySet())
|
|
||||||
{
|
|
||||||
servicesList.add(services.get(key));
|
|
||||||
}
|
|
||||||
return servicesList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ServiceStatus
|
|
||||||
{
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final String name;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String uptime = "100.0"; // skins.minecraft.net, minecraft.net, etc..
|
|
||||||
@Getter
|
|
||||||
private ChatColor color = ChatColor.DARK_GREEN;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String message = "Online"; // Online, Offline, Quite Slow, 404 Error, 500 Error, etc..
|
|
||||||
|
|
||||||
public ServiceStatus(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getUptimeFloat()
|
|
||||||
{
|
|
||||||
return Float.parseFloat(uptime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatColor getUptimeColor()
|
|
||||||
{
|
|
||||||
return (getUptimeFloat() > 95 ? ChatColor.GREEN : (getUptimeFloat() > 90 ? ChatColor.GOLD : ChatColor.RED));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFormattedStatus()
|
|
||||||
{
|
|
||||||
String status = ChatColor.BLUE + "- " + ChatColor.GRAY + name + ChatColor.WHITE + ": " + color + message + ChatColor.WHITE;
|
|
||||||
|
|
||||||
if (!version.contains("Mojang"))
|
|
||||||
{
|
|
||||||
status += " (" + getUptimeColor() + getUptime() + ChatColor.WHITE + "%)";
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColor(String color)
|
|
||||||
{
|
|
||||||
if ("green".equals(color))
|
|
||||||
{
|
|
||||||
this.color = ChatColor.DARK_GREEN;
|
|
||||||
}
|
|
||||||
else if ("yellow".equals(color))
|
|
||||||
{
|
|
||||||
this.color = ChatColor.YELLOW;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.color = ChatColor.RED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -11,12 +12,14 @@ import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
|||||||
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
||||||
import me.totalfreedom.totalfreedommod.caging.Cager;
|
import me.totalfreedom.totalfreedommod.caging.Cager;
|
||||||
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
||||||
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
||||||
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
||||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||||
@ -28,9 +31,12 @@ import me.totalfreedom.totalfreedommod.rank.RankManager;
|
|||||||
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||||
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
||||||
import net.pravian.aero.component.service.ServiceManager;
|
import net.pravian.aero.component.service.ServiceManager;
|
||||||
import net.pravian.aero.plugin.AeroPlugin;
|
import net.pravian.aero.plugin.AeroPlugin;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.mcstats.Metrics;
|
import org.mcstats.Metrics;
|
||||||
|
|
||||||
@ -41,33 +47,35 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
//
|
//
|
||||||
public static final BuildProperties build = new BuildProperties();
|
public static final BuildProperties build = new BuildProperties();
|
||||||
//
|
//
|
||||||
@SuppressWarnings("FieldNameHidesFieldInSuperclass")
|
|
||||||
public static TotalFreedomMod plugin;
|
|
||||||
public static String pluginName;
|
public static String pluginName;
|
||||||
public static String pluginVersion;
|
public static String pluginVersion;
|
||||||
//
|
//
|
||||||
|
public MainConfig config;
|
||||||
|
//
|
||||||
// Services
|
// Services
|
||||||
public ServiceManager<TotalFreedomMod> services;
|
public ServiceManager<TotalFreedomMod> services;
|
||||||
public ServerInterface si;
|
public ServerInterface si;
|
||||||
|
public SavedFlags sf;
|
||||||
public WorldManager wm;
|
public WorldManager wm;
|
||||||
|
public LogViewer lv;
|
||||||
public AdminList al;
|
public AdminList al;
|
||||||
|
public RankManager rm;
|
||||||
|
public CommandLoader cl;
|
||||||
|
public CommandBlocker cb;
|
||||||
public EventBlocker eb;
|
public EventBlocker eb;
|
||||||
public BlockBlocker bb;
|
public BlockBlocker bb;
|
||||||
public MobBlocker mb;
|
public MobBlocker mb;
|
||||||
public InteractBlocker ib;
|
public InteractBlocker ib;
|
||||||
|
public PotionBlocker pb;
|
||||||
public LoginProcess lp;
|
public LoginProcess lp;
|
||||||
public AntiNuke nu;
|
public AntiNuke nu;
|
||||||
public AntiSpam as;
|
public AntiSpam as;
|
||||||
public RankManager rm;
|
|
||||||
public PlayerList pl;
|
public PlayerList pl;
|
||||||
public CommandLoader cl;
|
|
||||||
public CommandBlocker cb;
|
|
||||||
public Announcer an;
|
public Announcer an;
|
||||||
public ChatManager cm;
|
public ChatManager cm;
|
||||||
public BanManager bm;
|
public BanManager bm;
|
||||||
public PermbanList pb;
|
public PermbanList pm;
|
||||||
public ProtectArea pa;
|
public ProtectArea pa;
|
||||||
public ServiceChecker sc;
|
|
||||||
public GameRuleHandler gr;
|
public GameRuleHandler gr;
|
||||||
public RollbackManager rb;
|
public RollbackManager rb;
|
||||||
public CommandSpy cs;
|
public CommandSpy cs;
|
||||||
@ -77,6 +85,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public Muter mu;
|
public Muter mu;
|
||||||
public Fuckoff fo;
|
public Fuckoff fo;
|
||||||
public AutoKick ak;
|
public AutoKick ak;
|
||||||
|
public AutoEject ae;
|
||||||
public MovementValidator mv;
|
public MovementValidator mv;
|
||||||
public EntityWiper ew;
|
public EntityWiper ew;
|
||||||
public FrontDoor fd;
|
public FrontDoor fd;
|
||||||
@ -85,6 +94,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public Landminer lm;
|
public Landminer lm;
|
||||||
public MP44 mp;
|
public MP44 mp;
|
||||||
public Jumppads jp;
|
public Jumppads jp;
|
||||||
|
public Trailer tr;
|
||||||
public HTTPDaemon hd;
|
public HTTPDaemon hd;
|
||||||
//
|
//
|
||||||
// Bridges
|
// Bridges
|
||||||
@ -96,26 +106,23 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
@Override
|
@Override
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
TotalFreedomMod.plugin = this;
|
|
||||||
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
||||||
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
FLog.setPluginLogger(plugin.getLogger());
|
FLog.setPluginLogger(plugin.getLogger());
|
||||||
FLog.setServerLogger(server.getLogger());
|
FLog.setServerLogger(server.getLogger());
|
||||||
|
|
||||||
build.load();
|
build.load(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable()
|
public void enable()
|
||||||
{
|
{
|
||||||
TotalFreedomMod.plugin = this;
|
|
||||||
|
|
||||||
FLog.info("Created by Madgeek1450 and Prozza");
|
FLog.info("Created by Madgeek1450 and Prozza");
|
||||||
FLog.info("Version " + build.formattedVersion());
|
FLog.info("Version " + build.formattedVersion());
|
||||||
FLog.info("Compiled " + build.date + " by " + build.author);
|
FLog.info("Compiled " + build.date + " by " + build.author);
|
||||||
|
|
||||||
final FUtil.MethodTimer timer = new FUtil.MethodTimer();
|
final MethodTimer timer = new MethodTimer();
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
// Warn if we're running on a wrong version
|
// Warn if we're running on a wrong version
|
||||||
@ -128,33 +135,39 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
// Convert old config files
|
// Convert old config files
|
||||||
new ConfigConverter(plugin).convert();
|
new ConfigConverter(plugin).convert();
|
||||||
|
|
||||||
FUtil.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
BackupManager backups = new BackupManager(this);
|
||||||
FUtil.createBackups(AdminList.CONFIG_FILENAME);
|
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
||||||
FUtil.createBackups(PermbanList.CONFIG_FILENAME);
|
backups.createBackups(AdminList.CONFIG_FILENAME);
|
||||||
|
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
||||||
|
|
||||||
|
config = new MainConfig(this);
|
||||||
|
config.load();
|
||||||
|
|
||||||
// Start services
|
// Start services
|
||||||
services = new ServiceManager<>(plugin);
|
services = new ServiceManager<>(plugin);
|
||||||
si = services.registerService(ServerInterface.class);
|
si = services.registerService(ServerInterface.class);
|
||||||
|
sf = services.registerService(SavedFlags.class);
|
||||||
wm = services.registerService(WorldManager.class);
|
wm = services.registerService(WorldManager.class);
|
||||||
|
lv = services.registerService(LogViewer.class);
|
||||||
al = services.registerService(AdminList.class);
|
al = services.registerService(AdminList.class);
|
||||||
|
rm = services.registerService(RankManager.class);
|
||||||
|
cl = services.registerService(CommandLoader.class);
|
||||||
|
cb = services.registerService(CommandBlocker.class);
|
||||||
eb = services.registerService(EventBlocker.class);
|
eb = services.registerService(EventBlocker.class);
|
||||||
bb = services.registerService(BlockBlocker.class);
|
bb = services.registerService(BlockBlocker.class);
|
||||||
mb = services.registerService(MobBlocker.class);
|
mb = services.registerService(MobBlocker.class);
|
||||||
ib = services.registerService(InteractBlocker.class);
|
ib = services.registerService(InteractBlocker.class);
|
||||||
|
pb = services.registerService(PotionBlocker.class);
|
||||||
lp = services.registerService(LoginProcess.class);
|
lp = services.registerService(LoginProcess.class);
|
||||||
nu = services.registerService(AntiNuke.class);
|
nu = services.registerService(AntiNuke.class);
|
||||||
as = services.registerService(AntiSpam.class);
|
as = services.registerService(AntiSpam.class);
|
||||||
rm = services.registerService(RankManager.class);
|
|
||||||
|
|
||||||
pl = services.registerService(PlayerList.class);
|
pl = services.registerService(PlayerList.class);
|
||||||
cl = services.registerService(CommandLoader.class);
|
|
||||||
cb = services.registerService(CommandBlocker.class);
|
|
||||||
an = services.registerService(Announcer.class);
|
an = services.registerService(Announcer.class);
|
||||||
cm = services.registerService(ChatManager.class);
|
cm = services.registerService(ChatManager.class);
|
||||||
bm = services.registerService(BanManager.class);
|
bm = services.registerService(BanManager.class);
|
||||||
pb = services.registerService(PermbanList.class);
|
pm = services.registerService(PermbanList.class);
|
||||||
pa = services.registerService(ProtectArea.class);
|
pa = services.registerService(ProtectArea.class);
|
||||||
sc = services.registerService(ServiceChecker.class);
|
|
||||||
gr = services.registerService(GameRuleHandler.class);
|
gr = services.registerService(GameRuleHandler.class);
|
||||||
|
|
||||||
// Single admin utils
|
// Single admin utils
|
||||||
@ -166,6 +179,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
mu = services.registerService(Muter.class);
|
mu = services.registerService(Muter.class);
|
||||||
fo = services.registerService(Fuckoff.class);
|
fo = services.registerService(Fuckoff.class);
|
||||||
ak = services.registerService(AutoKick.class);
|
ak = services.registerService(AutoKick.class);
|
||||||
|
ae = services.registerService(AutoEject.class);
|
||||||
|
|
||||||
mv = services.registerService(MovementValidator.class);
|
mv = services.registerService(MovementValidator.class);
|
||||||
ew = services.registerService(EntityWiper.class);
|
ew = services.registerService(EntityWiper.class);
|
||||||
@ -177,6 +191,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
lm = services.registerService(Landminer.class);
|
lm = services.registerService(Landminer.class);
|
||||||
mp = services.registerService(MP44.class);
|
mp = services.registerService(MP44.class);
|
||||||
jp = services.registerService(Jumppads.class);
|
jp = services.registerService(Jumppads.class);
|
||||||
|
tr = services.registerService(Trailer.class);
|
||||||
|
|
||||||
// HTTPD
|
// HTTPD
|
||||||
hd = services.registerService(HTTPDaemon.class);
|
hd = services.registerService(HTTPDaemon.class);
|
||||||
@ -224,29 +239,31 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
server.getScheduler().cancelTasks(plugin);
|
server.getScheduler().cancelTasks(plugin);
|
||||||
|
|
||||||
FLog.info("Plugin disabled");
|
FLog.info("Plugin disabled");
|
||||||
TotalFreedomMod.plugin = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BuildProperties
|
public static class BuildProperties
|
||||||
{
|
{
|
||||||
|
|
||||||
public String author;
|
public String author;
|
||||||
|
public String codename;
|
||||||
public String version;
|
public String version;
|
||||||
public String number;
|
public String number;
|
||||||
public String date;
|
public String date;
|
||||||
public String head;
|
public String head;
|
||||||
|
|
||||||
public void load()
|
public void load(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final InputStream in = plugin.getResource("build.properties");
|
final Properties props;
|
||||||
|
try (InputStream in = plugin.getResource("build.properties"))
|
||||||
final Properties props = new Properties();
|
{
|
||||||
|
props = new Properties();
|
||||||
props.load(in);
|
props.load(in);
|
||||||
in.close();
|
}
|
||||||
|
|
||||||
author = props.getProperty("program.build.author", "unknown");
|
author = props.getProperty("program.build.author", "unknown");
|
||||||
|
codename = props.getProperty("program.build.codename", "unknown");
|
||||||
version = props.getProperty("program.build.version", "unknown");
|
version = props.getProperty("program.build.version", "unknown");
|
||||||
number = props.getProperty("program.build.number", "1");
|
number = props.getProperty("program.build.number", "1");
|
||||||
date = props.getProperty("program.build.date", "unknown");
|
date = props.getProperty("program.build.date", "unknown");
|
||||||
@ -265,4 +282,16 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TotalFreedomMod plugin()
|
||||||
|
{
|
||||||
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
||||||
|
{
|
||||||
|
if (plugin.getName().equalsIgnoreCase(pluginName))
|
||||||
|
{
|
||||||
|
return (TotalFreedomMod) plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
final StringBuilder output = new StringBuilder();
|
final StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
output.append("Admin: ").append(name).append("\n")
|
output.append("Admin: ").append(name).append("\n")
|
||||||
.append("- Last Login Name: ").append(name).append("\n")
|
|
||||||
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
|
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
|
||||||
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
|
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
|
||||||
.append("- Custom Login Message: ").append(loginMessage).append("\n")
|
.append("- Custom Login Message: ").append(loginMessage).append("\n")
|
||||||
|
@ -12,20 +12,15 @@ import me.totalfreedom.totalfreedommod.FreedomService;
|
|||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_logs;
|
import me.totalfreedom.totalfreedommod.command.Command_logs;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.config.YamlConfig;
|
import net.pravian.aero.config.YamlConfig;
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.plugin.ServicePriority;
|
import org.bukkit.plugin.ServicePriority;
|
||||||
|
|
||||||
public class AdminList extends FreedomService
|
public class AdminList extends FreedomService
|
||||||
@ -47,7 +42,7 @@ public class AdminList extends FreedomService
|
|||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
|
||||||
this.config = new YamlConfig(TotalFreedomMod.plugin, CONFIG_FILENAME, true);
|
this.config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,7 +95,7 @@ public class AdminList extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateTables();
|
updateTables();
|
||||||
FLog.info("Loaded " + nameTable.size() + " admins (" + nameTable.size() + " active) and " + ipTable.size() + " IPs.");
|
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save()
|
public void save()
|
||||||
@ -119,17 +114,6 @@ public class AdminList extends FreedomService
|
|||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(Admin admin)
|
|
||||||
{
|
|
||||||
if (!allAdmins.values().contains(admin))
|
|
||||||
{ // Ensure admin is present
|
|
||||||
addAdmin(admin, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
admin.saveTo(config.createSection(admin.getConfigKey()));
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isAdminSync(CommandSender sender)
|
public synchronized boolean isAdminSync(CommandSender sender)
|
||||||
{
|
{
|
||||||
return isAdmin(sender);
|
return isAdmin(sender);
|
||||||
@ -142,7 +126,9 @@ public class AdminList extends FreedomService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getAdmin((Player) sender) != null;
|
Admin admin = getAdmin((Player) sender);
|
||||||
|
|
||||||
|
return admin != null && admin.isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSeniorAdmin(CommandSender sender)
|
public boolean isSeniorAdmin(CommandSender sender)
|
||||||
@ -168,22 +154,41 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
public Admin getAdmin(Player player)
|
public Admin getAdmin(Player player)
|
||||||
{
|
{
|
||||||
|
// Find admin
|
||||||
String ip = Ips.getIp(player);
|
String ip = Ips.getIp(player);
|
||||||
Admin admin = getEntryByIp(ip, true);
|
Admin admin = getEntryByName(player.getName());
|
||||||
|
|
||||||
if (admin == null && Bukkit.getOnlineMode())
|
// Admin by name
|
||||||
{
|
|
||||||
admin = getEntryByName(player.getName());
|
|
||||||
|
|
||||||
// Add new IP
|
|
||||||
if (admin != null)
|
if (admin != null)
|
||||||
{
|
{
|
||||||
|
// Check if we're in online mode,
|
||||||
|
// Or the players IP is in the admin entry
|
||||||
|
if (Bukkit.getOnlineMode() || admin.getIps().contains(ip))
|
||||||
|
{
|
||||||
|
if (!admin.getIps().contains(ip))
|
||||||
|
{
|
||||||
|
// Add the new IP if we have to
|
||||||
admin.addIp(ip);
|
admin.addIp(ip);
|
||||||
save(admin);
|
save();
|
||||||
|
updateTables();
|
||||||
}
|
}
|
||||||
|
return admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return admin;
|
// Impostor
|
||||||
|
}
|
||||||
|
|
||||||
|
// Admin by ip
|
||||||
|
admin = getEntryByIp(ip);
|
||||||
|
if (admin != null)
|
||||||
|
{
|
||||||
|
// Set the new username
|
||||||
|
admin.setName(player.getName());
|
||||||
|
save();
|
||||||
|
updateTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Admin getEntryByName(String name)
|
public Admin getEntryByName(String name)
|
||||||
@ -193,16 +198,15 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
public Admin getEntryByIp(String ip)
|
public Admin getEntryByIp(String ip)
|
||||||
{
|
{
|
||||||
return getEntryByIp(ip, false);
|
return ipTable.get(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Admin getEntryByIp(String needleIp, boolean fuzzy)
|
public Admin getEntryByIpFuzzy(String needleIp)
|
||||||
{
|
{
|
||||||
Admin admin = ipTable.get(needleIp);
|
final Admin directAdmin = getEntryByIp(needleIp);
|
||||||
|
if (directAdmin != null)
|
||||||
if (admin != null || !fuzzy)
|
|
||||||
{
|
{
|
||||||
return admin;
|
return directAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String ip : ipTable.keySet())
|
for (String ip : ipTable.keySet())
|
||||||
@ -212,7 +216,8 @@ public class AdminList extends FreedomService
|
|||||||
return ipTable.get(ip);
|
return ipTable.get(ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return admin;
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLastLogin(Player player)
|
public void updateLastLogin(Player player)
|
||||||
@ -225,7 +230,7 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
admin.setLastLogin(new Date());
|
admin.setLastLogin(new Date());
|
||||||
admin.setName(player.getName());
|
admin.setName(player.getName());
|
||||||
save(admin);
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdminImpostor(Player player)
|
public boolean isAdminImpostor(Player player)
|
||||||
@ -245,11 +250,6 @@ public class AdminList extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean addAdmin(Admin admin)
|
public boolean addAdmin(Admin admin)
|
||||||
{
|
|
||||||
return addAdmin(admin, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean addAdmin(Admin admin, boolean overwrite)
|
|
||||||
{
|
{
|
||||||
if (!admin.isValid())
|
if (!admin.isValid())
|
||||||
{
|
{
|
||||||
@ -259,11 +259,6 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
final String key = admin.getConfigKey();
|
final String key = admin.getConfigKey();
|
||||||
|
|
||||||
if (!overwrite && allAdmins.containsKey(key))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store admin, update views
|
// Store admin, update views
|
||||||
allAdmins.put(key, admin);
|
allAdmins.put(key, admin);
|
||||||
updateTables();
|
updateTables();
|
||||||
@ -327,28 +322,6 @@ public class AdminList extends FreedomService
|
|||||||
return ipTable.keySet();
|
return ipTable.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
// Verify strict IP match
|
|
||||||
if (plugin.al.isIdentityMatched(player))
|
|
||||||
{
|
|
||||||
fPlayer.setSuperadminIdVerified(true);
|
|
||||||
plugin.al.updateLastLogin(player);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fPlayer.setSuperadminIdVerified(false);
|
|
||||||
FUtil.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deactivateOldEntries(boolean verbose)
|
public void deactivateOldEntries(boolean verbose)
|
||||||
{
|
{
|
||||||
for (Admin admin : allAdmins.values())
|
for (Admin admin : allAdmins.values())
|
||||||
@ -372,7 +345,7 @@ public class AdminList extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
Command_logs.deactivateSuperadmin(admin);
|
plugin.lv.deactivateSuperadmin(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
save();
|
||||||
|
@ -67,6 +67,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
dedupeIps();
|
dedupeIps();
|
||||||
this.by = by;
|
this.by = by;
|
||||||
this.expiryUnix = FUtil.getUnixTime(expire);
|
this.expiryUnix = FUtil.getUnixTime(expire);
|
||||||
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -36,7 +36,7 @@ public class BanManager extends FreedomService
|
|||||||
public BanManager(TotalFreedomMod plugin)
|
public BanManager(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.config = new YamlConfig(TotalFreedomMod.plugin, "bans.yml");
|
this.config = new YamlConfig(plugin, "bans.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,7 @@ public class PermbanList extends FreedomService
|
|||||||
permbannedNames.clear();
|
permbannedNames.clear();
|
||||||
permbannedIps.clear();
|
permbannedIps.clear();
|
||||||
|
|
||||||
final YamlConfig config = new YamlConfig(TotalFreedomMod.plugin, CONFIG_FILENAME, true);
|
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
for (String name : config.getKeys(false))
|
for (String name : config.getKeys(false))
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
|
public class PotionBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
|
||||||
|
|
||||||
|
public PotionBlocker(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
public void onThrowPotion(PotionSplashEvent event)
|
||||||
|
{
|
||||||
|
ProjectileSource source = event.getEntity().getShooter();
|
||||||
|
|
||||||
|
if (!(source instanceof Player))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player thrower = (Player) source;
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(thrower))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : thrower.getWorld().getPlayers())
|
||||||
|
{
|
||||||
|
if (thrower.getLocation().distanceSquared(player.getLocation()) < POTION_BLOCK_RADIUS_SQUARED)
|
||||||
|
{
|
||||||
|
thrower.sendMessage(ChatColor.RED + "You cannot use splash potions close to other players.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking.command;
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -38,7 +39,7 @@ public class CommandBlockerEntry
|
|||||||
{
|
{
|
||||||
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
||||||
{
|
{
|
||||||
FUtil.autoEject((Player) sender, "You used a prohibited command: " + command);
|
TotalFreedomMod.plugin().ae.autoEject((Player) sender, "You used a prohibited command: " + command);
|
||||||
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public enum CommandBlockerRank
|
|||||||
return TELNET;
|
return TELNET;
|
||||||
}
|
}
|
||||||
|
|
||||||
Admin admin = TotalFreedomMod.plugin.al.getAdmin(sender);
|
Admin admin = TotalFreedomMod.plugin().al.getAdmin(sender);
|
||||||
if (admin != null)
|
if (admin != null)
|
||||||
{
|
{
|
||||||
if (admin.getRank() == Rank.SENIOR_ADMIN)
|
if (admin.getRank() == Rank.SENIOR_ADMIN)
|
||||||
|
@ -41,9 +41,9 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Admin admin = plugin.al.getEntryByIp(ip, true);
|
final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
|
||||||
|
|
||||||
if (admin == null || !admin.isActive() || !admin.getRank().hasConsole())
|
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class CommandLoader extends FreedomService
|
|||||||
protected void onStart()
|
protected void onStart()
|
||||||
{
|
{
|
||||||
handler.clearCommands();
|
handler.clearCommands();
|
||||||
handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory());
|
handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory(plugin));
|
||||||
handler.setCommandClassPrefix("Command_");
|
handler.setCommandClassPrefix("Command_");
|
||||||
handler.setPermissionMessage(ChatColor.RED + "You do not have permission to use this command.");
|
handler.setPermissionMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||||
handler.setOnlyConsoleMessage(ChatColor.RED + "This command can only be used from the console.");
|
handler.setOnlyConsoleMessage(ChatColor.RED + "This command can only be used from the console.");
|
||||||
|
@ -33,7 +33,7 @@ public class Command_adminchat extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminChatMessage(sender, StringUtils.join(args, " "));
|
plugin.cm.adminChat(sender, StringUtils.join(args, " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Make an announcement", usage = "/<command> <message>")
|
||||||
|
public class Command_announce extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.an.announce(StringUtils.join(args, " "));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -9,16 +9,12 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
@CommandParameters(description = "Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||||
public class Command_banlist extends FreedomCommand
|
public class Command_banlist extends FreedomCommand {
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||||
{
|
if (args.length > 0) {
|
||||||
if (args.length > 0)
|
if (args[0].equalsIgnoreCase("purge")) {
|
||||||
{
|
|
||||||
if (args[0].equalsIgnoreCase("purge"))
|
|
||||||
{
|
|
||||||
checkRank(Rank.SENIOR_ADMIN);
|
checkRank(Rank.SENIOR_ADMIN);
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
||||||
|
@ -3,12 +3,13 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Block all commands for a specific player.", usage = "/<command> <purge | <partialname>>", aliases = "blockcommands,blockcommand")
|
@CommandParameters(description = "Block all commands for a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
||||||
public class Command_blockcmd extends FreedomCommand
|
public class Command_blockcmd extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("purge"))
|
if (args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking commands for all players", true);
|
FUtil.adminAction(sender.getName(), "Unblocking commands for all players", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
@ -37,6 +38,26 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("-a"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Blocking commands for all non-admins", true);
|
||||||
|
int counter = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (isAdmin(player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
counter += 1;
|
||||||
|
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
||||||
|
msg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Blocked commands for " + counter + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
@ -45,7 +66,7 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdmin(sender))
|
if (isAdmin(player))
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is a Superadmin, and cannot have their commands blocked.");
|
msg(player.getName() + " is a Superadmin, and cannot have their commands blocked.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -12,15 +12,19 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Essentials Interface Command - Color your current nickname.", usage = "/<command> <color>")
|
@CommandParameters(description = "Essentials Interface Command - Color your current nickname.", usage = "/<command> <color>")
|
||||||
public class Command_colorme extends FreedomCommand {
|
public class Command_colorme extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
if (args.length != 1) {
|
{
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("list".equalsIgnoreCase(args[0])) {
|
if ("list".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
|
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -28,15 +32,18 @@ public class Command_colorme extends FreedomCommand {
|
|||||||
final String needle = args[0].trim().toLowerCase();
|
final String needle = args[0].trim().toLowerCase();
|
||||||
ChatColor color = null;
|
ChatColor color = null;
|
||||||
final Iterator<Map.Entry<String, ChatColor>> it = FUtil.CHAT_COLOR_NAMES.entrySet().iterator();
|
final Iterator<Map.Entry<String, ChatColor>> it = FUtil.CHAT_COLOR_NAMES.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext())
|
||||||
|
{
|
||||||
final Map.Entry<String, ChatColor> entry = it.next();
|
final Map.Entry<String, ChatColor> entry = it.next();
|
||||||
if (entry.getKey().contains(needle)) {
|
if (entry.getKey().contains(needle))
|
||||||
|
{
|
||||||
color = entry.getValue();
|
color = entry.getValue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color == null) {
|
if (color == null)
|
||||||
|
{
|
||||||
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
|
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,37 +8,30 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Quickly change your own gamemode to creative, or define someone's username to change theirs.", usage = "/<command> [partialname]", aliases = "gmc")
|
@CommandParameters(description = "Quickly change your own gamemode to creative, or define someone's username to change theirs.", usage = "/<command> <-a | [partialname]>", aliases = "gmc")
|
||||||
public class Command_creative extends FreedomCommand
|
public class Command_creative extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
|
||||||
if (senderIsConsole)
|
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
sender.sendMessage("When used from the console, you must define a target user to change gamemode on.");
|
if (isConsole())
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player;
|
|
||||||
if (args.length == 0)
|
|
||||||
{
|
{
|
||||||
player = playerSender;
|
sender.sendMessage("When used from the console, you must define a target player.");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (args[0].equalsIgnoreCase("-a"))
|
|
||||||
{
|
|
||||||
if (!isAdmin(sender))
|
|
||||||
{
|
|
||||||
noPerms();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playerSender.setGameMode(GameMode.CREATIVE);
|
||||||
|
msg("Gamemode set to creative.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRank(Rank.SUPER_ADMIN);
|
||||||
|
|
||||||
|
if (args[0].equals("-a"))
|
||||||
|
{
|
||||||
for (Player targetPlayer : server.getOnlinePlayers())
|
for (Player targetPlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
targetPlayer.setGameMode(GameMode.CREATIVE);
|
targetPlayer.setGameMode(GameMode.CREATIVE);
|
||||||
@ -48,13 +41,7 @@ public class Command_creative extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(senderIsConsole || isAdmin(sender)))
|
Player player = getPlayer(args[0]);
|
||||||
{
|
|
||||||
msg("Only superadmins can change other user's gamemode.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
player = getPlayer(args[0]);
|
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
@ -62,10 +49,8 @@ public class Command_creative extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
msg("Setting " + player.getName() + " to game mode creative");
|
||||||
|
msg(player, sender.getName() + " set your game mode to creative");
|
||||||
msg("Setting " + player.getName() + " to game mode 'Creative'.");
|
|
||||||
msg(player, sender.getName() + " set your game mode to 'Creative'.");
|
|
||||||
player.setGameMode(GameMode.CREATIVE);
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -13,7 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||||
@CommandParameters(description = "For the bad Superadmins", usage = "/<command> <playername>")
|
@CommandParameters(description = "For the bad admins", usage = "/<command> <playername>")
|
||||||
public class Command_doom extends FreedomCommand
|
public class Command_doom extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -21,11 +21,11 @@ public class Command_enchant extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack itemInHand = playerSender.getItemInHand();
|
ItemStack item = playerSender.getEquipment().getItemInMainHand();
|
||||||
|
|
||||||
if (itemInHand == null)
|
if (item == null || item.getType() == Material.AIR)
|
||||||
{
|
{
|
||||||
msg("You are holding an invalid item.");
|
msg("You have to hold an item to enchant it");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ public class Command_enchant extends FreedomCommand
|
|||||||
StringBuilder possible_ench = new StringBuilder("Possible enchantments for held item: ");
|
StringBuilder possible_ench = new StringBuilder("Possible enchantments for held item: ");
|
||||||
for (Enchantment ench : Enchantment.values())
|
for (Enchantment ench : Enchantment.values())
|
||||||
{
|
{
|
||||||
if (ench.canEnchantItem(itemInHand))
|
if (ench.canEnchantItem(item))
|
||||||
{
|
{
|
||||||
has_enchantments = true;
|
has_enchantments = true;
|
||||||
possible_ench.append(ench.getName()).append(", ");
|
possible_ench.append(ench.getName()).append(", ");
|
||||||
@ -58,14 +58,14 @@ public class Command_enchant extends FreedomCommand
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (ench.canEnchantItem(itemInHand))
|
if (ench.canEnchantItem(item))
|
||||||
{
|
{
|
||||||
itemInHand.addEnchantment(ench, ench.getMaxLevel());
|
item.addEnchantment(ench, ench.getMaxLevel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
FLog.info("Error using " + ench.getName() + " on " + itemInHand.getType().name() + " held by " + playerSender.getName() + ".");
|
msg("Could not add enchantment: " + ench.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,9 +73,9 @@ public class Command_enchant extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("reset"))
|
else if (args[0].equalsIgnoreCase("reset"))
|
||||||
{
|
{
|
||||||
for (Enchantment ench : itemInHand.getEnchantments().keySet())
|
for (Enchantment ench : item.getEnchantments().keySet())
|
||||||
{
|
{
|
||||||
itemInHand.removeEnchantment(ench);
|
item.removeEnchantment(ench);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Removed all enchantments.");
|
msg("Removed all enchantments.");
|
||||||
@ -105,9 +105,9 @@ public class Command_enchant extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("add"))
|
if (args[0].equalsIgnoreCase("add"))
|
||||||
{
|
{
|
||||||
if (ench.canEnchantItem(itemInHand))
|
if (ench.canEnchantItem(item))
|
||||||
{
|
{
|
||||||
itemInHand.addEnchantment(ench, ench.getMaxLevel());
|
item.addEnchantment(ench, ench.getMaxLevel());
|
||||||
|
|
||||||
msg("Added enchantment: " + ench.getName());
|
msg("Added enchantment: " + ench.getName());
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ public class Command_enchant extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else if (args[0].equals("remove"))
|
else if (args[0].equals("remove"))
|
||||||
{
|
{
|
||||||
itemInHand.removeEnchantment(ench);
|
item.removeEnchantment(ench);
|
||||||
|
|
||||||
msg("Removed enchantment: " + ench.getName());
|
msg("Removed enchantment: " + ench.getName());
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public class Command_ender extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
FUtil.gotoWorld(playerSender, server.getWorlds().get(0).getName() + "_the_end");
|
plugin.wm.gotoWorld(playerSender, server.getWorlds().get(0).getName() + "_the_end");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,6 @@ public class Command_freeze extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Enabling global player freeze", false);
|
FUtil.adminAction(sender.getName(), "Enabling global player freeze", false);
|
||||||
msg("Players are now frozen.");
|
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!isAdmin(player))
|
if (!isAdmin(player))
|
||||||
@ -38,6 +36,8 @@ public class Command_freeze extends FreedomCommand
|
|||||||
msg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED);
|
msg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
msg("Players are now frozen.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "You'll never even see it coming.", usage = "/<command>")
|
@CommandParameters(description = "You'll never even see it coming.", usage = "/<command> <on [radius (default=25)] | off>")
|
||||||
public class Command_fuckoff extends FreedomCommand
|
public class Command_fuckoff extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ public class Command_gadmin extends FreedomCommand
|
|||||||
case OP:
|
case OP:
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), String.format("Opping %s.", target.getName()), false);
|
FUtil.adminAction(sender.getName(), String.format("Opping %s.", target.getName()), false);
|
||||||
target.setOp(false);
|
target.setOp(true);
|
||||||
target.sendMessage(FreedomCommand.YOU_ARE_OP);
|
target.sendMessage(FreedomCommand.YOU_ARE_OP);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -73,7 +73,7 @@ public class Command_glist extends FreedomCommand
|
|||||||
|
|
||||||
final String reason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
|
final String reason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
|
||||||
|
|
||||||
Ban ban = Ban.forPlayerName(player, sender, null, reason);
|
Ban ban = Ban.forPlayerName(username, sender, null, reason);
|
||||||
for (String ip : ips)
|
for (String ip : ips)
|
||||||
{
|
{
|
||||||
ban.addIp(ip);
|
ban.addIp(ip);
|
||||||
|
@ -45,6 +45,12 @@ public class Command_health extends FreedomCommand
|
|||||||
Thread.sleep(2500);
|
Thread.sleep(2500);
|
||||||
final double ticksPerSecond = tickMeter.stopTicking();
|
final double ticksPerSecond = tickMeter.stopTicking();
|
||||||
|
|
||||||
|
// Plugin was disabled during async task
|
||||||
|
if (!plugin.isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Kick a player.", usage = "/<command> <player> [reason]", aliases = "k")
|
||||||
|
public class Command_kick extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = getPlayer(args[0]);
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
msg(PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAdmin(player))
|
||||||
|
{
|
||||||
|
msg("Admins can not be kicked", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder()
|
||||||
|
.append(ChatColor.RED).append("You have been kicked from the server.")
|
||||||
|
.append("\n").append(ChatColor.RED).append("Kicked by: ").append(ChatColor.GOLD).append(sender.getName());
|
||||||
|
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
builder.append("\n").append(ChatColor.RED).append("Reason: ").append(ChatColor.GOLD).append(reason);
|
||||||
|
FUtil.adminAction(sender.getName(), "Kicking " + player.getName() + " - Reason: " + reason, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Kicking " + player.getName(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.kickPlayer(builder.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,8 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -10,16 +12,17 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a | -i]", aliases = "who")
|
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a | -i | -f]", aliases = "who")
|
||||||
public class Command_list extends FreedomCommand
|
public class Command_list extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private static enum ListFilter
|
private static enum ListFilter
|
||||||
{
|
{
|
||||||
|
|
||||||
ALL,
|
PLAYERS,
|
||||||
ADMINS,
|
ADMINS,
|
||||||
|
FAMOUS_PLAYERS,
|
||||||
IMPOSTORS;
|
IMPOSTORS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,22 +48,24 @@ public class Command_list extends FreedomCommand
|
|||||||
final ListFilter listFilter;
|
final ListFilter listFilter;
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
if ("-a".equals(args[0]))
|
switch (args[0])
|
||||||
{
|
{
|
||||||
|
case "-a":
|
||||||
listFilter = ListFilter.ADMINS;
|
listFilter = ListFilter.ADMINS;
|
||||||
}
|
break;
|
||||||
else if ("-i".equals(args[0]))
|
case "-i":
|
||||||
{
|
|
||||||
listFilter = ListFilter.IMPOSTORS;
|
listFilter = ListFilter.IMPOSTORS;
|
||||||
}
|
break;
|
||||||
else
|
case "-f":
|
||||||
{
|
listFilter = ListFilter.FAMOUS_PLAYERS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
listFilter = ListFilter.ALL;
|
listFilter = ListFilter.PLAYERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder onlineStats = new StringBuilder();
|
final StringBuilder onlineStats = new StringBuilder();
|
||||||
@ -83,11 +88,20 @@ public class Command_list extends FreedomCommand
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
names.add(plugin.rm.getDisplay(player).getColoredTag() + player.getName());
|
if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(player.getName().toLowerCase()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Displayable display = plugin.rm.getDisplay(player);
|
||||||
|
|
||||||
|
names.add(display.getColoredTag() + player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
String playerType = listFilter == null ? "players" : listFilter.toString().toLowerCase().replace('_', ' ');
|
||||||
|
|
||||||
onlineUsers.append("Connected ");
|
onlineUsers.append("Connected ");
|
||||||
onlineUsers.append(listFilter == ListFilter.ADMINS ? "admins: " : "players: ");
|
onlineUsers.append(playerType + ": ");
|
||||||
onlineUsers.append(StringUtils.join(names, ChatColor.WHITE + ", "));
|
onlineUsers.append(StringUtils.join(names, ChatColor.WHITE + ", "));
|
||||||
|
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
|
@ -9,6 +9,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
@ -36,134 +37,9 @@ public class Command_logs extends FreedomCommand
|
|||||||
mode = ("off".equals(args[0]) ? LogsRegistrationMode.DELETE : LogsRegistrationMode.UPDATE);
|
mode = ("off".equals(args[0]) ? LogsRegistrationMode.DELETE : LogsRegistrationMode.UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLogsRegistration(sender, playerSender, mode);
|
plugin.lv.updateLogsRegistration(sender, playerSender, mode);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
|
||||||
{
|
|
||||||
updateLogsRegistration(sender, target.getName(), target.getAddress().getAddress().getHostAddress().trim(), mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateLogsRegistration(final CommandSender sender, final String targetName, final String targetIP, final LogsRegistrationMode mode)
|
|
||||||
{
|
|
||||||
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
|
||||||
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
|
||||||
|
|
||||||
if (logsRegisterUrl == null || logsRegisterPassword == null || logsRegisterUrl.isEmpty() || logsRegisterPassword.isEmpty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (sender != null)
|
|
||||||
{
|
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
|
||||||
}
|
|
||||||
|
|
||||||
URL url = new URLBuilder(logsRegisterUrl)
|
|
||||||
.addQueryParameter("mode", mode.toString())
|
|
||||||
.addQueryParameter("password", logsRegisterPassword)
|
|
||||||
.addQueryParameter("name", targetName)
|
|
||||||
.addQueryParameter("ip", targetIP)
|
|
||||||
.getURL();
|
|
||||||
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
||||||
connection.setConnectTimeout(1000 * 5);
|
|
||||||
connection.setReadTimeout(1000 * 5);
|
|
||||||
connection.setUseCaches(false);
|
|
||||||
connection.setRequestMethod("HEAD");
|
|
||||||
|
|
||||||
final int responseCode = connection.getResponseCode();
|
|
||||||
|
|
||||||
if (sender != null)
|
|
||||||
{
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if (responseCode == 200)
|
|
||||||
{
|
|
||||||
sender.sendMessage(ChatColor.GREEN + "Registration " + mode.toString() + "d.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage(ChatColor.RED + "Error contacting logs registration server.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTask(TotalFreedomMod.plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskAsynchronously(TotalFreedomMod.plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void deactivateSuperadmin(Admin superadmin)
|
|
||||||
{
|
|
||||||
for (String ip : superadmin.getIps())
|
|
||||||
{
|
|
||||||
updateLogsRegistration(null, superadmin.getName(), ip, Command_logs.LogsRegistrationMode.DELETE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum LogsRegistrationMode
|
|
||||||
{
|
|
||||||
|
|
||||||
UPDATE("update"), DELETE("delete");
|
|
||||||
private final String mode;
|
|
||||||
|
|
||||||
private LogsRegistrationMode(String mode)
|
|
||||||
{
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class URLBuilder
|
|
||||||
{
|
|
||||||
|
|
||||||
private final String requestPath;
|
|
||||||
private final Map<String, String> queryStringMap = new HashMap<>();
|
|
||||||
|
|
||||||
public URLBuilder(String requestPath)
|
|
||||||
{
|
|
||||||
this.requestPath = requestPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public URLBuilder addQueryParameter(String key, String value)
|
|
||||||
{
|
|
||||||
queryStringMap.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public URL getURL() throws MalformedURLException
|
|
||||||
{
|
|
||||||
List<String> pairs = new ArrayList<>();
|
|
||||||
Iterator<Entry<String, String>> it = queryStringMap.entrySet().iterator();
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<String, String> pair = it.next();
|
|
||||||
pairs.add(pair.getKey() + "=" + pair.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -21,7 +22,7 @@ public class Command_mobpurge extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
msg("Purging all mobs...");
|
FUtil.adminAction(sender.getName(), "Purging all mobs", true);
|
||||||
msg(purgeMobs() + " mobs removed.");
|
msg(purgeMobs() + " mobs removed.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class Command_mp44 extends FreedomCommand
|
|||||||
msg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN);
|
msg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN);
|
||||||
msg("Type /mp44 sling to disable. -by Madgeek1450", ChatColor.GREEN);
|
msg("Type /mp44 sling to disable. -by Madgeek1450", ChatColor.GREEN);
|
||||||
|
|
||||||
playerSender.setItemInHand(new ItemStack(Material.SULPHUR, 1));
|
playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.SULPHUR, 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,168 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.ChatUtils;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Manage my admin entry", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin>")
|
||||||
|
public class Command_myadmin extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
checkPlayer();
|
||||||
|
checkRank(Rank.SUPER_ADMIN);
|
||||||
|
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player init = null;
|
||||||
|
Admin target = getAdmin(playerSender);
|
||||||
|
Player targetPlayer = playerSender;
|
||||||
|
String targetIp = Ips.getIp(targetPlayer);
|
||||||
|
|
||||||
|
// -o switch
|
||||||
|
if (args[0].equals("-o"))
|
||||||
|
{
|
||||||
|
checkRank(Rank.SENIOR_ADMIN);
|
||||||
|
init = playerSender;
|
||||||
|
targetPlayer = getPlayer(args[1]);
|
||||||
|
if (targetPlayer == null)
|
||||||
|
{
|
||||||
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
target = getAdmin(targetPlayer);
|
||||||
|
if (target == null)
|
||||||
|
{
|
||||||
|
msg("That player is not admin", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shift 2
|
||||||
|
args = Arrays.copyOfRange(args, 2, args.length);
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args[0])
|
||||||
|
{
|
||||||
|
case "clearips":
|
||||||
|
{
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
|
return false; // Double check: the player might mean "clearip"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (init == null)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Clearing my supered IPs", true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Clearing " + target.getName() + "' supered IPs", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int counter = target.getIps().size() - 1;
|
||||||
|
target.clearIPs();
|
||||||
|
target.addIp(targetIp);
|
||||||
|
|
||||||
|
plugin.al.save();
|
||||||
|
|
||||||
|
msg(counter + " IPs removed.");
|
||||||
|
msg(targetPlayer, target.getIps().get(0) + " is now your only IP address");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "clearip":
|
||||||
|
{
|
||||||
|
if (args.length != 2)
|
||||||
|
{
|
||||||
|
return false; // Double check: the player might mean "clearips"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target.getIps().contains(args[1]))
|
||||||
|
{
|
||||||
|
if (init == null)
|
||||||
|
{
|
||||||
|
msg("That IP is not registered to you.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("That IP does not belong to that player.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetIp.equals(args[1]))
|
||||||
|
{
|
||||||
|
if (init == null)
|
||||||
|
{
|
||||||
|
msg("You cannot remove your current IP.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("You cannot remove that admin's current IP.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Removing a supered IP" + (init == null ? "" : " from " + targetPlayer.getName() + "'s IPs"), true);
|
||||||
|
|
||||||
|
target.removeIp(args[1]);
|
||||||
|
plugin.al.save();
|
||||||
|
plugin.al.updateTables();
|
||||||
|
|
||||||
|
msg("Removed IP " + args[1]);
|
||||||
|
msg("Current IPs: " + StringUtils.join(target.getIps(), ", "));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "setlogin":
|
||||||
|
{
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String msg = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
FUtil.adminAction(sender.getName(), "Setting personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
||||||
|
target.setLoginMessage(msg);
|
||||||
|
msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: ");
|
||||||
|
msg("> " + ChatColor.AQUA + targetPlayer.getName() + " is " + ChatUtils.colorize(target.getLoginMessage()));
|
||||||
|
plugin.al.save();
|
||||||
|
plugin.al.updateTables();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "clearlogin":
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Clearing personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false);
|
||||||
|
target.setLoginMessage(null);
|
||||||
|
plugin.al.save();
|
||||||
|
plugin.al.updateTables();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,7 +14,7 @@ public class Command_nether extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
FUtil.gotoWorld(playerSender, server.getWorlds().get(0).getName() + "_nether");
|
plugin.wm.gotoWorld(playerSender, server.getWorlds().get(0).getName() + "_nether");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,12 @@ public class Command_nickclean extends FreedomCommand
|
|||||||
ChatColor.UNDERLINE,
|
ChatColor.UNDERLINE,
|
||||||
ChatColor.BLACK
|
ChatColor.BLACK
|
||||||
};
|
};
|
||||||
private static final Pattern REGEX = Pattern.compile(ChatColor.COLOR_CHAR + "[" + StringUtils.join(BLOCKED, "") + "]");
|
private static final Pattern REGEX = Pattern.compile(ChatColor.COLOR_CHAR + "[" + StringUtils.join(BLOCKED, "") + "]", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Cleaning all nicknames.", false);
|
FUtil.adminAction(sender.getName(), "Cleaning all nicknames", false);
|
||||||
|
|
||||||
for (final Player player : server.getOnlinePlayers())
|
for (final Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
@ -15,7 +16,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Overlord - control this server in-game", usage = "access", aliases = "ov")
|
@CommandParameters(description = "Overlord - control this server in-game", usage = "access", aliases = "ov")
|
||||||
public class Command_overlord extends FreedomCommand
|
public class Command_ov extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -25,8 +26,8 @@ public class Command_overlord extends FreedomCommand
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<?> ips = (List) MainConfig.getDefaults().get(ConfigEntry.OVERLORD_IPS.getConfigName());
|
Object ips = plugin.config.getDefaults().get(ConfigEntry.OVERLORD_IPS.getConfigName());
|
||||||
if (!ips.contains(Ips.getIp(playerSender)))
|
if (ips instanceof Collection && !((Collection) ips).contains(Ips.getIp(playerSender)))
|
||||||
{
|
{
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
@ -25,11 +25,11 @@ public class Command_permban extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg("Reloading permban list...", ChatColor.RED);
|
msg("Reloading permban list...", ChatColor.RED);
|
||||||
plugin.pb.stop();
|
plugin.pm.stop();
|
||||||
plugin.pb.start();
|
plugin.pm.start();
|
||||||
msg("Reloaded permban list.");
|
msg("Reloaded permban list.");
|
||||||
msg(plugin.pb.getPermbannedIps().size() + " IPs and "
|
msg(plugin.pm.getPermbannedIps().size() + " IPs and "
|
||||||
+ plugin.pb.getPermbannedNames().size() + " usernames loaded.");
|
+ plugin.pm.getPermbannedNames().size() + " usernames loaded.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,11 @@ public class Command_premium extends FreedomCommand
|
|||||||
final String message = ("false".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
|
final String message = ("false".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
|
if (!plugin.isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -14,26 +15,26 @@ public class Command_rank extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (senderIsConsole && args.length < 1)
|
if (isConsole() && args.length == 0)
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is " + plugin.rm.getDisplay(player).getColoredLoginMessage());
|
msg(message(player));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
msg(message(playerSender));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 0)
|
|
||||||
{
|
|
||||||
msg(sender.getName() + " is " + plugin.rm.getDisplay(sender).getColoredLoginMessage(), ChatColor.AQUA);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
@ -42,8 +43,33 @@ public class Command_rank extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(player.getName() + " is " + plugin.rm.getDisplay(player).getColoredLoginMessage(), ChatColor.AQUA);
|
msg(message(player));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String message(Player player)
|
||||||
|
{
|
||||||
|
Displayable display = plugin.rm.getDisplay(player);
|
||||||
|
Rank rank = plugin.rm.getRank(player);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb
|
||||||
|
.append(ChatColor.AQUA)
|
||||||
|
.append(player.getName())
|
||||||
|
.append(" is ")
|
||||||
|
.append(display.getColoredLoginMessage());
|
||||||
|
|
||||||
|
if (rank != display)
|
||||||
|
{
|
||||||
|
sb
|
||||||
|
.append(ChatColor.AQUA)
|
||||||
|
.append(" (")
|
||||||
|
.append(rank.getColoredName())
|
||||||
|
.append(ChatColor.AQUA)
|
||||||
|
.append(')');
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class Command_report extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
String report = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
String report = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
FUtil.reportAction(playerSender, player, report);
|
plugin.cm.reportAction(playerSender, player, report);
|
||||||
|
|
||||||
msg(ChatColor.GREEN + "Thank you, your report has been successfully logged.");
|
msg(ChatColor.GREEN + "Thank you, your report has been successfully logged.");
|
||||||
|
|
||||||
|
@ -7,8 +7,10 @@ import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
|||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -42,9 +44,9 @@ public class Command_ro extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromMaterial == null)
|
if (fromMaterial == null || fromMaterial == Material.AIR || !fromMaterial.isBlock())
|
||||||
{
|
{
|
||||||
msg("Invalid block: " + materialName, ChatColor.RED);
|
msg("Invalid material: " + materialName, ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +107,7 @@ public class Command_ro extends FreedomCommand
|
|||||||
|
|
||||||
for (final Material material : materials)
|
for (final Material material : materials)
|
||||||
{
|
{
|
||||||
affected += FUtil.replaceBlocks(player.getLocation(), material, Material.AIR, radius);
|
affected += replaceBlocks(player.getLocation(), material, Material.AIR, radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +118,7 @@ public class Command_ro extends FreedomCommand
|
|||||||
for (Material material : materials)
|
for (Material material : materials)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Removing all " + names + " within " + radius + " blocks of " + targetPlayer.getName(), false);
|
FUtil.adminAction(sender.getName(), "Removing all " + names + " within " + radius + " blocks of " + targetPlayer.getName(), false);
|
||||||
affected += FUtil.replaceBlocks(targetPlayer.getLocation(), material, Material.AIR, radius);
|
affected += replaceBlocks(targetPlayer.getLocation(), material, Material.AIR, radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,4 +127,32 @@ public class Command_ro extends FreedomCommand
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int replaceBlocks(Location center, Material fromMaterial, Material toMaterial, int radius)
|
||||||
|
{
|
||||||
|
int affected = 0;
|
||||||
|
|
||||||
|
Block centerBlock = center.getBlock();
|
||||||
|
for (int xOffset = -radius; xOffset <= radius; xOffset++)
|
||||||
|
{
|
||||||
|
for (int yOffset = -radius; yOffset <= radius; yOffset++)
|
||||||
|
{
|
||||||
|
for (int zOffset = -radius; zOffset <= radius; zOffset++)
|
||||||
|
{
|
||||||
|
Block block = centerBlock.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
|
||||||
|
if (block.getType().equals(fromMaterial))
|
||||||
|
{
|
||||||
|
if (block.getLocation().distanceSquared(center) < (radius * radius))
|
||||||
|
{
|
||||||
|
block.setType(toMaterial);
|
||||||
|
affected++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return affected;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Manage admins.", usage = "/<command> <list | clean | reload | clearme [ip] | setrank <username> <rank> | <add | remove | info> <username>>")
|
@CommandParameters(description = "Manage admins.", usage = "/<command> <list | clean | reload | | setrank <username> <rank> | <add | remove | info> <username>>")
|
||||||
public class Command_saconfig extends FreedomCommand
|
public class Command_saconfig extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -37,6 +37,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
case "clean":
|
case "clean":
|
||||||
{
|
{
|
||||||
checkConsole();
|
checkConsole();
|
||||||
|
checkRank(Rank.TELNET_ADMIN);
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Cleaning admin list", true);
|
FUtil.adminAction(sender.getName(), "Cleaning admin list", true);
|
||||||
plugin.al.deactivateOldEntries(true);
|
plugin.al.deactivateOldEntries(true);
|
||||||
@ -55,71 +56,24 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "clearme":
|
|
||||||
{
|
|
||||||
checkPlayer();
|
|
||||||
checkRank(Rank.SUPER_ADMIN);
|
|
||||||
|
|
||||||
final Admin admin = plugin.al.getAdmin(playerSender);
|
|
||||||
|
|
||||||
if (admin == null)
|
|
||||||
{
|
|
||||||
msg("Could not find your admin entry! Please notify a developer.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String ip = Ips.getIp(playerSender);
|
|
||||||
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Cleaning my supered IPs", true);
|
|
||||||
|
|
||||||
int counter = admin.getIps().size() - 1;
|
|
||||||
admin.clearIPs();
|
|
||||||
admin.addIp(ip);
|
|
||||||
|
|
||||||
plugin.al.save(admin);
|
|
||||||
|
|
||||||
msg(counter + " IPs removed.");
|
|
||||||
msg(admin.getIps().get(0) + " is now your only IP address");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!admin.getIps().contains(args[1]))
|
|
||||||
{
|
|
||||||
msg("That IP is not registered to you.");
|
|
||||||
}
|
|
||||||
else if (ip.equals(args[1]))
|
|
||||||
{
|
|
||||||
msg("You cannot remove your current IP.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Removing a supered IP", true);
|
|
||||||
|
|
||||||
admin.removeIp(args[1]);
|
|
||||||
|
|
||||||
plugin.al.save(admin);
|
|
||||||
|
|
||||||
msg("Removed IP " + args[1]);
|
|
||||||
msg("Current IPs: " + StringUtils.join(admin.getIps(), ", "));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "setrank":
|
case "setrank":
|
||||||
{
|
{
|
||||||
|
checkConsole();
|
||||||
|
checkNotHostConsole();
|
||||||
|
checkRank(Rank.SENIOR_CONSOLE);
|
||||||
|
|
||||||
if (args.length < 3)
|
if (args.length < 3)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkConsole();
|
|
||||||
checkRank(Rank.SENIOR_CONSOLE);
|
|
||||||
|
|
||||||
Rank rank = Rank.findRank(args[2]);
|
Rank rank = Rank.findRank(args[2]);
|
||||||
|
if (rank == null)
|
||||||
|
{
|
||||||
|
msg("Unknown rank: " + rank);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!rank.isAtLeast(Rank.SUPER_ADMIN))
|
if (!rank.isAtLeast(Rank.SUPER_ADMIN))
|
||||||
{
|
{
|
||||||
msg("Rank must be superadmin or higher.", ChatColor.RED);
|
msg("Rank must be superadmin or higher.", ChatColor.RED);
|
||||||
@ -133,8 +87,10 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Setting " + admin.getName() + "'s rank to " + rank.getName(), true);
|
||||||
|
|
||||||
admin.setRank(rank);
|
admin.setRank(rank);
|
||||||
plugin.al.save(admin);
|
plugin.al.save();
|
||||||
|
|
||||||
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
||||||
return true;
|
return true;
|
||||||
@ -182,16 +138,16 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
checkConsole();
|
checkConsole();
|
||||||
checkRank(Rank.TELNET_ADMIN);
|
checkRank(Rank.TELNET_ADMIN);
|
||||||
|
|
||||||
|
// Player already an admin?
|
||||||
final Player player = getPlayer(args[1]);
|
final Player player = getPlayer(args[1]);
|
||||||
|
if (player != null && plugin.al.isAdmin(player))
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
{
|
||||||
msg("That player is already admin.");
|
msg("That player is already admin.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find the old admin entry
|
||||||
String name = player != null ? player.getName() : args[1];
|
String name = player != null ? player.getName() : args[1];
|
||||||
|
|
||||||
Admin admin = null;
|
Admin admin = null;
|
||||||
for (Admin loopAdmin : plugin.al.getAllAdmins().values())
|
for (Admin loopAdmin : plugin.al.getAllAdmins().values())
|
||||||
{
|
{
|
||||||
@ -202,29 +158,8 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (admin != null) // Existing admin
|
if (admin == null) // New admin
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Readding " + admin.getName() + " to the admin list", true);
|
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
admin.loadFrom(player); // Reset IP, username
|
|
||||||
}
|
|
||||||
|
|
||||||
admin.setActive(true);
|
|
||||||
admin.setLastLogin(new Date());
|
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
admin.addIp(Ips.getIp(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.al.save(admin);
|
|
||||||
plugin.al.updateTables();
|
|
||||||
}
|
|
||||||
else // New admin
|
|
||||||
{
|
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
@ -233,7 +168,22 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
||||||
plugin.al.addAdmin(new Admin(player));
|
plugin.al.addAdmin(new Admin(player));
|
||||||
|
}
|
||||||
|
else // Existing admin
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Readding " + admin.getName() + " to the admin list", true);
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
admin.setName(player.getName());
|
||||||
|
admin.addIp(Ips.getIp(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
admin.setActive(true);
|
||||||
|
admin.setLastLogin(new Date());
|
||||||
|
|
||||||
|
plugin.al.save();
|
||||||
|
plugin.al.updateTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
@ -260,7 +210,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
checkRank(Rank.TELNET_ADMIN);
|
checkRank(Rank.TELNET_ADMIN);
|
||||||
|
|
||||||
Player player = getPlayer(args[1]);
|
Player player = getPlayer(args[1]);
|
||||||
Admin admin = player == null ? plugin.al.getAdmin(player) : plugin.al.getEntryByName(args[1]);
|
Admin admin = player != null ? plugin.al.getAdmin(player) : plugin.al.getEntryByName(args[1]);
|
||||||
|
|
||||||
if (admin == null)
|
if (admin == null)
|
||||||
{
|
{
|
||||||
@ -270,7 +220,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true);
|
FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true);
|
||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
plugin.al.save(admin);
|
plugin.al.save();
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.ServiceChecker.ServiceStatus;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
|
||||||
@CommandParameters(description = "Shows the status of all Mojang services", usage = "/<command>")
|
|
||||||
public class Command_services extends FreedomCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
msg("Mojang Services" + ChatColor.WHITE + ":", ChatColor.BLUE);
|
|
||||||
|
|
||||||
for (ServiceStatus service : plugin.sc.getAllStatuses())
|
|
||||||
{
|
|
||||||
msg(service.getFormattedStatus());
|
|
||||||
}
|
|
||||||
msg("Version" + ChatColor.WHITE + ": " + plugin.sc.getVersion(), ChatColor.DARK_PURPLE);
|
|
||||||
msg("Last Check" + ChatColor.WHITE + ": " + plugin.sc.getLastCheck(), ChatColor.DARK_PURPLE);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,8 +7,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Sets everyone's Worldedit block modification limit to 500.", usage = "/<command>")
|
@CommandParameters(description = "Sets everyone's Worldedit block modification limit to the default.", usage = "/<command>", aliases = "setl,swl")
|
||||||
public class Command_setl extends FreedomCommand
|
public class Command_setlimit extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -11,45 +12,60 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> [playername]")
|
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason]")
|
||||||
public class Command_smite extends FreedomCommand
|
public class Command_smite extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length != 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
}
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
smite(player);
|
smite(player, reason);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void smite(final Player player)
|
public static void smite(Player player)
|
||||||
|
{
|
||||||
|
smite(player, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void smite(Player player, String reason)
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
||||||
|
|
||||||
//Deop
|
if (reason != null)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(" Reason: " + reason, ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deop
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
|
|
||||||
//Set gamemode to survival:
|
// Set gamemode to survival
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
//Clear inventory:
|
// Clear inventory
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
|
|
||||||
//Strike with lightning effect:
|
// Strike with lightning effect
|
||||||
final Location targetPos = player.getLocation();
|
final Location targetPos = player.getLocation();
|
||||||
final World world = player.getWorld();
|
final World world = player.getWorld();
|
||||||
for (int x = -1; x <= 1; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
@ -61,7 +77,12 @@ public class Command_smite extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Kill:
|
// Kill
|
||||||
player.setHealth(0.0);
|
player.setHealth(0.0);
|
||||||
|
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "You've been smitten. Reason: " + reason);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Make an announcement", usage = "/<command> <mobtype> [amount]")
|
||||||
|
public class Command_spawnmob extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityType type = null;
|
||||||
|
for (EntityType loop : EntityType.values())
|
||||||
|
{
|
||||||
|
if (loop.getName().equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
type = loop;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
msg("Unknown entity type: " + args[0], ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!type.isSpawnable() || !type.isAlive())
|
||||||
|
{
|
||||||
|
msg("Can not spawn entity type: " + type.getName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int amount = 1;
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
amount = Integer.parseInt(args[1]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfex)
|
||||||
|
{
|
||||||
|
msg("Invalid amount: " + args[1], ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amount > 10 || amount < 1)
|
||||||
|
{
|
||||||
|
msg("Invalid amount: " + args[1] + ". Must be 1-10.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location l = playerSender.getLocation();
|
||||||
|
World w = playerSender.getWorld();
|
||||||
|
msg("Spawning " + amount + " of " + type.getName());
|
||||||
|
|
||||||
|
for (int i = 0; i < amount; amount++)
|
||||||
|
{
|
||||||
|
w.spawnEntity(l, type);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Quickly change your own gamemode to spectator.", usage = "/<command>", aliases = "gmsp")
|
||||||
|
public class Command_spectator extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
playerSender.setGameMode(GameMode.SPECTATOR);
|
||||||
|
msg("Gamemode set to spectator.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -3,19 +3,22 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> [<player> [-s] | list | purge | all]", aliases = "mute")
|
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "mute")
|
||||||
public class Command_stfu extends FreedomCommand
|
public class Command_stfu extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length == 0 || args.length > 2)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -38,8 +41,11 @@ public class Command_stfu extends FreedomCommand
|
|||||||
{
|
{
|
||||||
msg("- none");
|
msg("- none");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("purge"))
|
|
||||||
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unmuting all players.", true);
|
FUtil.adminAction(sender.getName(), "Unmuting all players.", true);
|
||||||
FPlayer info;
|
FPlayer info;
|
||||||
@ -54,8 +60,10 @@ public class Command_stfu extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg("Unmuted " + count + " players.");
|
msg("Unmuted " + count + " players.");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("all"))
|
|
||||||
|
if (args[0].equalsIgnoreCase("all"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Muting all non-Superadmins", true);
|
FUtil.adminAction(sender.getName(), "Muting all non-Superadmins", true);
|
||||||
|
|
||||||
@ -72,43 +80,64 @@ public class Command_stfu extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg("Muted " + counter + " players.");
|
msg("Muted " + counter + " players.");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
final Player player = getPlayer(args[0]);
|
|
||||||
|
|
||||||
|
boolean smite = args[0].equals("-s");
|
||||||
|
if (smite)
|
||||||
|
{
|
||||||
|
args = ArrayUtils.subarray(args, 1, args.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
}
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
if (playerdata.isMuted())
|
if (playerdata.isMuted())
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
||||||
playerdata.setMuted(false);
|
playerdata.setMuted(false);
|
||||||
msg("Unmuted " + player.getName());
|
msg("Unmuted " + player.getName());
|
||||||
|
|
||||||
|
msg(player, "You have been unmuted.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
|
msg(player.getName() + " is a superadmin, and can't be muted.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
||||||
playerdata.setMuted(true);
|
playerdata.setMuted(true);
|
||||||
|
|
||||||
if (args.length == 2 && args[1].equalsIgnoreCase("-s"))
|
if (smite)
|
||||||
{
|
{
|
||||||
Command_smite.smite(player);
|
Command_smite.smite(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Muted " + player.getName());
|
if (reason != null)
|
||||||
|
{
|
||||||
|
msg(player, "You have been muted. Reason: " + reason, ChatColor.RED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is a superadmin, and can't be muted.");
|
msg(player, "You have been muted.", ChatColor.RED);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg("Muted " + player.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -14,32 +14,24 @@ public class Command_survival extends FreedomCommand
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
|
||||||
if (senderIsConsole)
|
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
msg("When used from the console, you must define a target user to change gamemode on.");
|
if (isConsole())
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player;
|
|
||||||
|
|
||||||
if (args.length == 0)
|
|
||||||
{
|
{
|
||||||
player = playerSender;
|
sender.sendMessage("When used from the console, you must define a target player.");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (args[0].equalsIgnoreCase("-a"))
|
|
||||||
{
|
|
||||||
if (!plugin.al.isAdmin(sender) || senderIsConsole)
|
|
||||||
{
|
|
||||||
noPerms();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playerSender.setGameMode(GameMode.SURVIVAL);
|
||||||
|
msg("Gamemode set to survival.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRank(Rank.SUPER_ADMIN);
|
||||||
|
|
||||||
|
if (args[0].equals("-a"))
|
||||||
|
{
|
||||||
for (Player targetPlayer : server.getOnlinePlayers())
|
for (Player targetPlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
targetPlayer.setGameMode(GameMode.SURVIVAL);
|
targetPlayer.setGameMode(GameMode.SURVIVAL);
|
||||||
@ -49,27 +41,17 @@ public class Command_survival extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (senderIsConsole || plugin.al.isAdmin(sender))
|
Player player = getPlayer(args[0]);
|
||||||
{
|
|
||||||
player = getPlayer(args[0]);
|
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("Only superadmins can change other user's gamemode.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Setting " + player.getName() + " to game mode 'Survival'.");
|
msg("Setting " + player.getName() + " to game mode survival.");
|
||||||
player.sendMessage(sender.getName() + " set your game mode to 'Survival'.");
|
msg(player, sender.getName() + " set your game mode to survival.");
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,18 @@ public class Command_tagnyan extends FreedomCommand
|
|||||||
tag.append(FUtil.randomChatColor()).append(c);
|
tag.append(FUtil.randomChatColor()).append(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String tagStr = tag.toString();
|
||||||
|
for (String word : Command_tag.FORBIDDEN_WORDS)
|
||||||
|
{
|
||||||
|
if (tagStr.contains(word))
|
||||||
|
{
|
||||||
|
msg("That tag contains a forbidden word.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final FPlayer data = plugin.pl.getPlayer(playerSender);
|
final FPlayer data = plugin.pl.getPlayer(playerSender);
|
||||||
data.setTag(tag.toString());
|
data.setTag(tagStr);
|
||||||
|
|
||||||
msg("Set tag to " + tag);
|
msg("Set tag to " + tag);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -10,14 +11,14 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <partialname>", aliases = "noob")
|
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <player> [reason]", aliases = "noob")
|
||||||
public class Command_tban extends FreedomCommand
|
public class Command_tban extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length != 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -30,6 +31,16 @@ public class Command_tban extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String reason;
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reason = "You have been temporarily banned for 5 minutes.";
|
||||||
|
}
|
||||||
|
|
||||||
// strike with lightning effect:
|
// strike with lightning effect:
|
||||||
final Location targetPos = player.getLocation();
|
final Location targetPos = player.getLocation();
|
||||||
for (int x = -1; x <= 1; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
@ -42,7 +53,7 @@ public class Command_tban extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Tempbanning: " + player.getName() + " for 5 minutes.", true);
|
FUtil.adminAction(sender.getName(), "Tempbanning: " + player.getName() + " for 5 minutes.", true);
|
||||||
plugin.bm.addBan(Ban.forPlayer(player, sender, FUtil.parseDateOffset("5m"), ChatColor.RED + "You have been temporarily banned for 5 minutes."));
|
plugin.bm.addBan(Ban.forPlayer(player, sender, FUtil.parseDateOffset("5m"), reason));
|
||||||
|
|
||||||
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
||||||
|
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
|
||||||
@CommandParameters(description = "Update server files.", usage = "/<command>")
|
|
||||||
public class Command_tfupdate extends FreedomCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String[] FILES
|
|
||||||
=
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
if (FILES.length == 0)
|
|
||||||
{
|
|
||||||
msg("This command is disabled.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sender.getName().equalsIgnoreCase("madgeek1450"))
|
|
||||||
{
|
|
||||||
noPerms();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (final String url : FILES)
|
|
||||||
{
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
FLog.info("Downloading: " + url);
|
|
||||||
|
|
||||||
File file = new File("./updates/" + url.substring(url.lastIndexOf("/") + 1));
|
|
||||||
if (file.exists())
|
|
||||||
{
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
if (!file.getParentFile().exists())
|
|
||||||
{
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.downloadFile(url, file, true);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskAsynchronously(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,9 +28,9 @@ public class Command_toggle extends FreedomCommand
|
|||||||
msg("- prelog");
|
msg("- prelog");
|
||||||
msg("- lockdown");
|
msg("- lockdown");
|
||||||
msg("- petprotect");
|
msg("- petprotect");
|
||||||
msg("- droptoggle");
|
msg("- entitywipe");
|
||||||
msg("- nonuke");
|
msg("- nonuke [range] [count]");
|
||||||
msg("- explosives");
|
msg("- explosives [radius]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ public class Command_toggle extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equals("droptoggle"))
|
if (args[0].equals("entitywipe"))
|
||||||
{
|
{
|
||||||
toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE);
|
toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE);
|
||||||
return true;
|
return true;
|
||||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -30,7 +31,7 @@ public class Command_tossmob extends FreedomCommand
|
|||||||
|
|
||||||
FPlayer playerData = plugin.pl.getPlayer(playerSender);
|
FPlayer playerData = plugin.pl.getPlayer(playerSender);
|
||||||
|
|
||||||
EntityType creature = EntityType.PIG;
|
EntityType type = null;
|
||||||
if (args.length >= 1)
|
if (args.length >= 1)
|
||||||
{
|
{
|
||||||
if ("off".equals(args[0]))
|
if ("off".equals(args[0]))
|
||||||
@ -42,19 +43,32 @@ public class Command_tossmob extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
msg("Supported mobs: " + StringUtils.join(FUtil.MOB_TYPES.keySet(), ", "), ChatColor.GREEN);
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (EntityType loop : EntityType.values())
|
||||||
|
{
|
||||||
|
if (loop.isAlive())
|
||||||
|
{
|
||||||
|
sb.append(" ").append(DepreciationAggregator.getName_EntityType(loop));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg("Supported mobs: " + sb.toString().trim(), ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
for (EntityType loopType : EntityType.values())
|
||||||
{
|
{
|
||||||
creature = FUtil.getEntityType(args[0]);
|
if (DepreciationAggregator.getName_EntityType(loopType).toLowerCase().equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
type = loopType;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
{
|
{
|
||||||
msg(args[0] + " is not a supported mob type. Using a pig instead.", ChatColor.RED);
|
msg(args[0] + " is not a supported mob type. Using a pig instead.", ChatColor.RED);
|
||||||
msg("By the way, you can type /tossmob list to see all possible mobs.", ChatColor.RED);
|
msg("By the way, you can type /tossmob list to see all possible mobs.", ChatColor.RED);
|
||||||
creature = EntityType.PIG;
|
type = EntityType.PIG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,12 +93,12 @@ public class Command_tossmob extends FreedomCommand
|
|||||||
speed = 5.0;
|
speed = 5.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerData.enableMobThrower(creature, speed);
|
playerData.enableMobThrower(type, speed);
|
||||||
msg("MobThrower is enabled. Creature: " + creature + " - Speed: " + speed + ".", ChatColor.GREEN);
|
msg("MobThrower is enabled. Creature: " + type + " - Speed: " + speed + ".", ChatColor.GREEN);
|
||||||
msg("Left click while holding a " + Material.BONE.toString() + " to throw mobs!", ChatColor.GREEN);
|
msg("Left click while holding a " + Material.BONE.toString() + " to throw mobs!", ChatColor.GREEN);
|
||||||
msg("Type '/tossmob off' to disable. -By Madgeek1450", ChatColor.GREEN);
|
msg("Type '/tossmob off' to disable. -By Madgeek1450", ChatColor.GREEN);
|
||||||
|
|
||||||
playerSender.setItemInHand(new ItemStack(Material.BONE, 1));
|
playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.BONE, 1));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ import org.bukkit.entity.Player;
|
|||||||
* See https://github.com/TotalFreedom/License - This file may not be edited or removed.
|
* See https://github.com/TotalFreedom/License - This file may not be edited or removed.
|
||||||
*/
|
*/
|
||||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Shows information about TotalFreedomMod or reloads it", usage = "/<command> [reload]")
|
@CommandParameters(description = "Shows information about TotalFreedomMod or reloads it", usage = "/<command> [reload]", aliases = "tfm")
|
||||||
public class Command_tfm extends FreedomCommand
|
public class Command_totalfreedommod extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,7 +34,7 @@ public class Command_tfm extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainConfig.load();
|
plugin.config.load();
|
||||||
plugin.services.stop();
|
plugin.services.stop();
|
||||||
plugin.services.start();
|
plugin.services.start();
|
||||||
|
|
||||||
@ -52,8 +52,9 @@ public class Command_tfm extends FreedomCommand
|
|||||||
msg("Running on " + ConfigEntry.SERVER_NAME.getString() + ".", ChatColor.GOLD);
|
msg("Running on " + ConfigEntry.SERVER_NAME.getString() + ".", ChatColor.GOLD);
|
||||||
msg("Created by Madgeek1450 and Prozza.", ChatColor.GOLD);
|
msg("Created by Madgeek1450 and Prozza.", ChatColor.GOLD);
|
||||||
msg(String.format("Version "
|
msg(String.format("Version "
|
||||||
+ ChatColor.BLUE + "%s.%s " + ChatColor.GOLD + "("
|
+ ChatColor.BLUE + "%s %s.%s " + ChatColor.GOLD + "("
|
||||||
+ ChatColor.BLUE + "%s" + ChatColor.GOLD + ")",
|
+ ChatColor.BLUE + "%s" + ChatColor.GOLD + ")",
|
||||||
|
build.codename,
|
||||||
build.version,
|
build.version,
|
||||||
build.number,
|
build.number,
|
||||||
build.head), ChatColor.GOLD);
|
build.head), ChatColor.GOLD);
|
@ -23,111 +23,21 @@ import org.bukkit.plugin.RegisteredListener;
|
|||||||
public class Command_trail extends FreedomCommand
|
public class Command_trail extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private static Listener movementListener = null;
|
|
||||||
private static final List<Player> trailPlayers = new ArrayList<>();
|
|
||||||
private static final Random RANDOM = new Random();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length > 0 && "off".equals(args[0]))
|
if (args.length > 0 && "off".equals(args[0]))
|
||||||
{
|
{
|
||||||
trailPlayers.remove(playerSender);
|
plugin.tr.remove(playerSender);
|
||||||
|
|
||||||
msg("Trail disabled.");
|
msg("Trail disabled.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!trailPlayers.contains(playerSender))
|
plugin.tr.add(playerSender);
|
||||||
{
|
|
||||||
trailPlayers.add(playerSender);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Trail enabled. Use \"/trail off\" to disable.");
|
msg("Trail enabled. Use \"/trail off\" to disable.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!trailPlayers.isEmpty())
|
|
||||||
{
|
|
||||||
registerMovementHandler();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unregisterMovementHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerMovementHandler()
|
|
||||||
{
|
|
||||||
if (getRegisteredListener(movementListener) == null)
|
|
||||||
{
|
|
||||||
Bukkit.getPluginManager().registerEvents(movementListener = new Listener()
|
|
||||||
{
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event)
|
|
||||||
{
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (trailPlayers.contains(player))
|
|
||||||
{
|
|
||||||
Block fromBlock = event.getFrom().getBlock();
|
|
||||||
if (fromBlock.isEmpty())
|
|
||||||
{
|
|
||||||
Block toBlock = event.getTo().getBlock();
|
|
||||||
if (!fromBlock.equals(toBlock))
|
|
||||||
{
|
|
||||||
fromBlock.setType(Material.WOOL);
|
|
||||||
DepreciationAggregator.setData_Block(fromBlock, (byte) RANDOM.nextInt(16));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, TotalFreedomMod.plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void unregisterMovementHandler()
|
|
||||||
{
|
|
||||||
Listener registeredListener = getRegisteredListener(movementListener);
|
|
||||||
if (registeredListener != null)
|
|
||||||
{
|
|
||||||
PlayerMoveEvent.getHandlerList().unregister(registeredListener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Listener getRegisteredListener(Listener listener)
|
|
||||||
{
|
|
||||||
RegisteredListener[] registeredListeners = PlayerMoveEvent.getHandlerList().getRegisteredListeners();
|
|
||||||
for (RegisteredListener registeredListener : registeredListeners)
|
|
||||||
{
|
|
||||||
if (registeredListener.getListener() == listener)
|
|
||||||
{
|
|
||||||
return listener;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void startTrail(Player player)
|
|
||||||
{
|
|
||||||
if (!trailPlayers.contains(player))
|
|
||||||
{
|
|
||||||
trailPlayers.add(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!trailPlayers.isEmpty())
|
|
||||||
{
|
|
||||||
registerMovementHandler();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void stopTrail(Player player)
|
|
||||||
{
|
|
||||||
trailPlayers.remove(player);
|
|
||||||
|
|
||||||
if (trailPlayers.isEmpty())
|
|
||||||
{
|
|
||||||
unregisterMovementHandler();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class Command_wipeflatlands extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
FUtil.setSavedFlag("do_wipe_flatlands", true);
|
plugin.sf.setSavedFlag("do_wipe_flatlands", true);
|
||||||
|
|
||||||
FUtil.bcastMsg("Server is going offline for flatlands wipe.", ChatColor.GRAY);
|
FUtil.bcastMsg("Server is going offline for flatlands wipe.", ChatColor.GRAY);
|
||||||
|
|
||||||
|
@ -4,8 +4,9 @@ import lombok.Getter;
|
|||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.RankBase;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.command.AbstractCommandBase;
|
import net.pravian.aero.command.AbstractCommandBase;
|
||||||
import net.pravian.aero.util.Players;
|
import net.pravian.aero.util.Players;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -83,7 +84,15 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkRank(RankBase rank)
|
protected void checkNotHostConsole()
|
||||||
|
{
|
||||||
|
if (isConsole() && FUtil.isFromHostConsole(sender.getName()))
|
||||||
|
{
|
||||||
|
throw new CommandFailException("This command can not be used from the host console.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void checkRank(Rank rank)
|
||||||
{
|
{
|
||||||
if (!plugin.rm.getRank(sender).isAtLeast(rank))
|
if (!plugin.rm.getRank(sender).isAtLeast(rank))
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.rank.RankBase;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.command.AeroCommandBase;
|
import net.pravian.aero.command.AeroCommandBase;
|
||||||
@ -20,9 +19,12 @@ import org.bukkit.entity.Player;
|
|||||||
public class FreedomCommandExecutor<C extends AeroCommandBase<?>> extends AbstractCommandExecutor<C>
|
public class FreedomCommandExecutor<C extends AeroCommandBase<?>> extends AbstractCommandExecutor<C>
|
||||||
{
|
{
|
||||||
|
|
||||||
public FreedomCommandExecutor(AeroCommandHandler<?> handler, String name, C command)
|
private final TotalFreedomMod plugin;
|
||||||
|
|
||||||
|
public FreedomCommandExecutor(TotalFreedomMod plugin, AeroCommandHandler<?> handler, String name, C command)
|
||||||
{
|
{
|
||||||
super(handler, name, command);
|
super(handler, name, command);
|
||||||
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected FreedomCommand getCommand()
|
protected FreedomCommand getCommand()
|
||||||
@ -45,9 +47,25 @@ public class FreedomCommandExecutor<C extends AeroCommandBase<?>> extends Abstra
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String aliasString = params.aliases();
|
||||||
|
|
||||||
|
if (aliasString.length() > 0)
|
||||||
|
{
|
||||||
pluginCommand.setAliases(Arrays.asList(params.aliases().split(",")));
|
pluginCommand.setAliases(Arrays.asList(params.aliases().split(",")));
|
||||||
|
}
|
||||||
pluginCommand.setDescription(params.description());
|
pluginCommand.setDescription(params.description());
|
||||||
pluginCommand.setUsage(params.usage());
|
pluginCommand.setUsage(params.usage());
|
||||||
|
|
||||||
|
// Check if permisions are correctly set up
|
||||||
|
CommandPermissions perms = command.getPerms();
|
||||||
|
if (perms != null)
|
||||||
|
{
|
||||||
|
if (perms.level().isConsole())
|
||||||
|
{
|
||||||
|
FLog.warning("[Command] " + pluginCommand.getName() + " - permission is set to a console rank, "
|
||||||
|
+ "should be set to player variant with 'source = SourceType.ONLY_CONSOLE'");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -125,7 +143,7 @@ public class FreedomCommandExecutor<C extends AeroCommandBase<?>> extends Abstra
|
|||||||
// Player permissions
|
// Player permissions
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
Rank rank = TotalFreedomMod.plugin.rm.getRank(player);
|
Rank rank = plugin.rm.getRank(player);
|
||||||
boolean result = rank.isAtLeast(perms.level());
|
boolean result = rank.isAtLeast(perms.level());
|
||||||
if (!result && sendMsg)
|
if (!result && sendMsg)
|
||||||
{
|
{
|
||||||
@ -135,7 +153,7 @@ public class FreedomCommandExecutor<C extends AeroCommandBase<?>> extends Abstra
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Console permissions
|
// Console permissions
|
||||||
RankBase rank = TotalFreedomMod.plugin.rm.getRank(sender);
|
Rank rank = plugin.rm.getRank(sender);
|
||||||
boolean result = rank.isAtLeast(perms.level());
|
boolean result = rank.isAtLeast(perms.level());
|
||||||
if (!result && sendMsg)
|
if (!result && sendMsg)
|
||||||
{
|
{
|
||||||
@ -147,10 +165,17 @@ public class FreedomCommandExecutor<C extends AeroCommandBase<?>> extends Abstra
|
|||||||
public static class FreedomExecutorFactory implements AeroCommandExecutorFactory
|
public static class FreedomExecutorFactory implements AeroCommandExecutorFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final TotalFreedomMod plugin;
|
||||||
|
|
||||||
|
public FreedomExecutorFactory(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AeroCommandExecutor<? extends AeroCommandBase<?>> newExecutor(AeroCommandHandler<?> handler, String name, AeroCommandBase<?> command)
|
public AeroCommandExecutor<? extends AeroCommandBase<?>> newExecutor(AeroCommandHandler<?> handler, String name, AeroCommandBase<?> command)
|
||||||
{
|
{
|
||||||
return new FreedomCommandExecutor<>(handler, name, command);
|
return new FreedomCommandExecutor<>(plugin, handler, name, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.config;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.UUID;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
|
|
||||||
public class ConfigConverter
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void convert()
|
|
||||||
{
|
|
||||||
|
|
||||||
for (File file : new File(TotalFreedomMod.plugin.getDataFolder(), "players").listFiles())
|
|
||||||
{
|
|
||||||
if (file.isDirectory())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final UUID uuid;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
uuid = UUID.fromString(file.getName().split(".")[0]);
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.config;
|
package me.totalfreedom.totalfreedommod.config;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
|
||||||
public enum ConfigEntry
|
public enum ConfigEntry
|
||||||
{
|
{
|
||||||
@ -106,51 +107,62 @@ public enum ConfigEntry
|
|||||||
|
|
||||||
public String getString()
|
public String getString()
|
||||||
{
|
{
|
||||||
return MainConfig.getString(this);
|
return getConfig().getString(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String setString(String value)
|
public String setString(String value)
|
||||||
{
|
{
|
||||||
MainConfig.setString(this, value);
|
getConfig().setString(this, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getDouble()
|
public Double getDouble()
|
||||||
{
|
{
|
||||||
return MainConfig.getDouble(this);
|
return getConfig().getDouble(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double setDouble(Double value)
|
public Double setDouble(Double value)
|
||||||
{
|
{
|
||||||
MainConfig.setDouble(this, value);
|
getConfig().setDouble(this, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getBoolean()
|
public Boolean getBoolean()
|
||||||
{
|
{
|
||||||
return MainConfig.getBoolean(this);
|
return getConfig().getBoolean(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean setBoolean(Boolean value)
|
public Boolean setBoolean(Boolean value)
|
||||||
{
|
{
|
||||||
MainConfig.setBoolean(this, value);
|
getConfig().setBoolean(this, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getInteger()
|
public Integer getInteger()
|
||||||
{
|
{
|
||||||
return MainConfig.getInteger(this);
|
return getConfig().getInteger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer setInteger(Integer value)
|
public Integer setInteger(Integer value)
|
||||||
{
|
{
|
||||||
MainConfig.setInteger(this, value);
|
getConfig().setInteger(this, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<?> getList()
|
public List<?> getList()
|
||||||
{
|
{
|
||||||
return MainConfig.getList(this);
|
return getConfig().getList(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<String> getStringList()
|
||||||
|
{
|
||||||
|
return (List<String>) getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private MainConfig getConfig()
|
||||||
|
{
|
||||||
|
return TotalFreedomMod.plugin().config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigEntry findConfigEntry(String name)
|
public static ConfigEntry findConfigEntry(String name)
|
||||||
|
@ -9,41 +9,45 @@ import java.util.EnumMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.pravian.aero.component.PluginComponent;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
public class MainConfig
|
public class MainConfig extends PluginComponent<TotalFreedomMod>
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final File CONFIG_FILE = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.CONFIG_FILENAME);
|
public static final String CONFIG_FILENAME = "config.yml";
|
||||||
//
|
//
|
||||||
private static final EnumMap<ConfigEntry, Object> ENTRY_MAP;
|
private final EnumMap<ConfigEntry, Object> entries;
|
||||||
private static final TFM_Defaults DEFAULTS;
|
private final ConfigDefaults defaults;
|
||||||
|
|
||||||
static
|
public MainConfig(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
ENTRY_MAP = new EnumMap<>(ConfigEntry.class);
|
super(plugin);
|
||||||
|
|
||||||
TFM_Defaults tempDefaults = null;
|
entries = new EnumMap<>(ConfigEntry.class);
|
||||||
|
|
||||||
|
ConfigDefaults tempDefaults = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream defaultConfig = getDefaultConfig();
|
try (InputStream defaultConfig = getDefaultConfig())
|
||||||
tempDefaults = new TFM_Defaults(defaultConfig);
|
{
|
||||||
|
tempDefaults = new ConfigDefaults(defaultConfig);
|
||||||
for (ConfigEntry entry : ConfigEntry.values())
|
for (ConfigEntry entry : ConfigEntry.values())
|
||||||
{
|
{
|
||||||
ENTRY_MAP.put(entry, tempDefaults.get(entry.getConfigName()));
|
entries.put(entry, tempDefaults.get(entry.getConfigName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
defaultConfig.close();
|
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyDefaultConfig(CONFIG_FILE);
|
copyDefaultConfig(getConfigFile());
|
||||||
|
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
@ -52,21 +56,16 @@ public class MainConfig
|
|||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFAULTS = tempDefaults;
|
defaults = tempDefaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MainConfig()
|
public void load()
|
||||||
{
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void load()
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
|
|
||||||
config.load(CONFIG_FILE);
|
config.load(getConfigFile());
|
||||||
|
|
||||||
for (ConfigEntry entry : ConfigEntry.values())
|
for (ConfigEntry entry : ConfigEntry.values())
|
||||||
{
|
{
|
||||||
@ -76,7 +75,7 @@ public class MainConfig
|
|||||||
Object value = config.get(path);
|
Object value = config.get(path);
|
||||||
if (value == null || entry.getType().isAssignableFrom(value.getClass()))
|
if (value == null || entry.getType().isAssignableFrom(value.getClass()))
|
||||||
{
|
{
|
||||||
ENTRY_MAP.put(entry, value);
|
entries.put(entry, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -90,21 +89,18 @@ public class MainConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException ex)
|
catch (IOException | InvalidConfigurationException ex)
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
catch (InvalidConfigurationException ex)
|
|
||||||
{
|
{
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getString(ConfigEntry entry)
|
private File getConfigFile()
|
||||||
|
{
|
||||||
|
return new File(plugin.getDataFolder(), "config.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString(ConfigEntry entry)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -117,7 +113,7 @@ public class MainConfig
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setString(ConfigEntry entry, String value)
|
public void setString(ConfigEntry entry, String value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -129,7 +125,7 @@ public class MainConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Double getDouble(ConfigEntry entry)
|
public Double getDouble(ConfigEntry entry)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -142,7 +138,7 @@ public class MainConfig
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDouble(ConfigEntry entry, Double value)
|
public void setDouble(ConfigEntry entry, Double value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -154,7 +150,7 @@ public class MainConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean getBoolean(ConfigEntry entry)
|
public Boolean getBoolean(ConfigEntry entry)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -167,7 +163,7 @@ public class MainConfig
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBoolean(ConfigEntry entry, Boolean value)
|
public void setBoolean(ConfigEntry entry, Boolean value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -179,7 +175,7 @@ public class MainConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer getInteger(ConfigEntry entry)
|
public Integer getInteger(ConfigEntry entry)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -192,7 +188,7 @@ public class MainConfig
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setInteger(ConfigEntry entry, Integer value)
|
public void setInteger(ConfigEntry entry, Integer value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -204,7 +200,7 @@ public class MainConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List getList(ConfigEntry entry)
|
public List getList(ConfigEntry entry)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -217,9 +213,9 @@ public class MainConfig
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T get(ConfigEntry entry, Class<T> type) throws IllegalArgumentException
|
public <T> T get(ConfigEntry entry, Class<T> type) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
Object value = ENTRY_MAP.get(entry);
|
Object value = entries.get(entry);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return type.cast(value);
|
return type.cast(value);
|
||||||
@ -230,7 +226,7 @@ public class MainConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void set(ConfigEntry entry, T value, Class<T> type) throws IllegalArgumentException
|
public <T> void set(ConfigEntry entry, T value, Class<T> type) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (!type.isAssignableFrom(entry.getType()))
|
if (!type.isAssignableFrom(entry.getType()))
|
||||||
{
|
{
|
||||||
@ -240,10 +236,10 @@ public class MainConfig
|
|||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Value is not of type " + type.getSimpleName());
|
throw new IllegalArgumentException("Value is not of type " + type.getSimpleName());
|
||||||
}
|
}
|
||||||
ENTRY_MAP.put(entry, value);
|
entries.put(entry, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyDefaultConfig(File targetFile)
|
private void copyDefaultConfig(File targetFile)
|
||||||
{
|
{
|
||||||
if (targetFile.exists())
|
if (targetFile.exists())
|
||||||
{
|
{
|
||||||
@ -254,9 +250,10 @@ public class MainConfig
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream defaultConfig = getDefaultConfig();
|
try (InputStream defaultConfig = getDefaultConfig())
|
||||||
|
{
|
||||||
FileUtils.copyInputStreamToFile(defaultConfig, targetFile);
|
FileUtils.copyInputStreamToFile(defaultConfig, targetFile);
|
||||||
defaultConfig.close();
|
}
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
@ -264,22 +261,22 @@ public class MainConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InputStream getDefaultConfig()
|
private InputStream getDefaultConfig()
|
||||||
{
|
{
|
||||||
return TotalFreedomMod.plugin.getResource(TotalFreedomMod.CONFIG_FILENAME);
|
return plugin.getResource(TotalFreedomMod.CONFIG_FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TFM_Defaults getDefaults()
|
public ConfigDefaults getDefaults()
|
||||||
{
|
{
|
||||||
return DEFAULTS;
|
return defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TFM_Defaults
|
public static class ConfigDefaults
|
||||||
{
|
{
|
||||||
|
|
||||||
private YamlConfiguration defaults = null;
|
private YamlConfiguration defaults = null;
|
||||||
|
|
||||||
private TFM_Defaults(InputStream defaultConfig)
|
private ConfigDefaults(InputStream defaultConfig)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,12 @@ public class FreezeData
|
|||||||
|
|
||||||
location = player.getLocation(); // Blockify location
|
location = player.getLocation(); // Blockify location
|
||||||
FUtil.setFlying(player, true); // Avoid infinite falling
|
FUtil.setFlying(player, true); // Avoid infinite falling
|
||||||
|
|
||||||
|
if (fPlayer.getPlugin().al.isAdminImpostor(player))
|
||||||
|
{
|
||||||
|
return; // Don't run unfreeze task for impostors
|
||||||
|
}
|
||||||
|
|
||||||
unfreeze = new BukkitRunnable()
|
unfreeze = new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -65,7 +71,7 @@ public class FreezeData
|
|||||||
setFrozen(false);
|
setFrozen(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}.runTaskLater(TotalFreedomMod.plugin, AUTO_PURGE_TICKS);
|
}.runTaskLater(fPlayer.getPlugin(), AUTO_PURGE_TICKS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,12 @@ public class Freezer extends FreedomService
|
|||||||
|
|
||||||
public void setGlobalFreeze(boolean frozen)
|
public void setGlobalFreeze(boolean frozen)
|
||||||
{
|
{
|
||||||
this.globalFreeze = true;
|
this.globalFreeze = frozen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void purge()
|
public void purge()
|
||||||
{
|
{
|
||||||
setGlobalFreeze(false);
|
this.globalFreeze = false;
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
|
@ -70,14 +70,14 @@ public class ItemFun extends FreedomService
|
|||||||
if (!plugin.al.isSeniorAdmin(player))
|
if (!plugin.al.isSeniorAdmin(player))
|
||||||
{
|
{
|
||||||
final StringBuilder msg = new StringBuilder();
|
final StringBuilder msg = new StringBuilder();
|
||||||
final char[] chars = (player.getName() + " is a clown.").toCharArray();
|
final char[] chars = ("You are a clown.").toCharArray();
|
||||||
for (char c : chars)
|
for (char c : chars)
|
||||||
{
|
{
|
||||||
msg.append(FUtil.randomChatColor()).append(c);
|
msg.append(FUtil.randomChatColor()).append(c);
|
||||||
}
|
}
|
||||||
FUtil.bcastMsg(msg.toString());
|
player.sendMessage(msg.toString());
|
||||||
|
|
||||||
player.getInventory().getItemInHand().setType(Material.POTATO_ITEM);
|
player.getEquipment().getItemInMainHand().setType(Material.POTATO_ITEM);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public class ItemFun extends FreedomService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CARROT:
|
case CARROT_ITEM:
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
{
|
{
|
||||||
@ -185,7 +185,7 @@ public class ItemFun extends FreedomService
|
|||||||
tntBlock.setType(Material.AIR);
|
tntBlock.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskLater(TotalFreedomMod.plugin, 30L);
|
}.runTaskLater(plugin, 30L);
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
break;
|
break;
|
||||||
@ -220,7 +220,7 @@ public class ItemFun extends FreedomService
|
|||||||
|
|
||||||
if (fPlayer.toggleMP44Firing())
|
if (fPlayer.toggleMP44Firing())
|
||||||
{
|
{
|
||||||
fPlayer.startArrowShooter(TotalFreedomMod.plugin);
|
fPlayer.startArrowShooter(plugin);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.fun;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
public class Trailer extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Random random = new Random();
|
||||||
|
private final Set<String> trailPlayers = new HashSet<>(); // player name
|
||||||
|
|
||||||
|
public Trailer(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
if (trailPlayers.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!trailPlayers.contains(event.getPlayer().getName()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block fromBlock = event.getFrom().getBlock();
|
||||||
|
if (!fromBlock.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block toBlock = event.getTo().getBlock();
|
||||||
|
if (fromBlock.equals(toBlock))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromBlock.setType(Material.WOOL);
|
||||||
|
DepreciationAggregator.setData_Block(fromBlock, (byte) random.nextInt(16));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Player player)
|
||||||
|
{
|
||||||
|
trailPlayers.remove(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Player player)
|
||||||
|
{
|
||||||
|
trailPlayers.add(player.getName());
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,6 @@ public class HTMLGenerationTools
|
|||||||
|
|
||||||
private HTMLGenerationTools()
|
private HTMLGenerationTools()
|
||||||
{
|
{
|
||||||
throw new AssertionError();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String paragraph(String data)
|
public static String paragraph(String data)
|
||||||
|
@ -3,7 +3,8 @@ package me.totalfreedom.totalfreedommod.httpd;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
@ -11,6 +12,8 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_dump;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_file;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_file;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_help;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_help;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_list;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_list;
|
||||||
@ -21,18 +24,16 @@ import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
|
|||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
public class HTTPDaemon extends FreedomService
|
public class HTTPDaemon extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static String MIME_DEFAULT_BINARY = "application/octet-stream";
|
public static String MIME_DEFAULT_BINARY = "application/octet-stream";
|
||||||
//
|
|
||||||
private static final Pattern EXT_REGEX = Pattern.compile("\\.([^\\.\\s]+)$");
|
private static final Pattern EXT_REGEX = Pattern.compile("\\.([^\\.\\s]+)$");
|
||||||
//
|
//
|
||||||
public static final int PORT = ConfigEntry.HTTPD_PORT.getInteger();
|
public int port;
|
||||||
//
|
private HTTPD httpd;
|
||||||
private static final TFM_HTTPD HTTPD = new TFM_HTTPD(PORT);
|
public Map<String, ModuleExecutable> modules = new HashMap<>();
|
||||||
|
|
||||||
public HTTPDaemon(TotalFreedomMod plugin)
|
public HTTPDaemon(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
@ -47,13 +48,27 @@ public class HTTPDaemon extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
port = ConfigEntry.HTTPD_PORT.getInteger();;
|
||||||
|
httpd = new HTTPD(port);
|
||||||
|
|
||||||
|
// Modules
|
||||||
|
modules.clear();
|
||||||
|
module("dump", Module_dump.class, true);
|
||||||
|
module("file", Module_file.class, true);
|
||||||
|
module("help", Module_help.class, false);
|
||||||
|
module("list", Module_list.class, false);
|
||||||
|
module("logs", Module_logs.class, true);
|
||||||
|
module("permbans", Module_permbans.class, true);
|
||||||
|
module("players", Module_players.class, false);
|
||||||
|
module("schematic", Module_schematic.class, true);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HTTPD.start();
|
httpd.start();
|
||||||
|
|
||||||
if (HTTPD.isAlive())
|
if (httpd.isAlive())
|
||||||
{
|
{
|
||||||
FLog.info("TFM HTTPd started. Listening on port: " + HTTPD.getListeningPort());
|
FLog.info("TFM HTTPd started. Listening on port: " + httpd.getListeningPort());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -74,160 +89,25 @@ public class HTTPDaemon extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTPD.stop();
|
httpd.stop();
|
||||||
|
|
||||||
FLog.info("TFM HTTPd stopped.");
|
FLog.info("TFM HTTPd stopped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static enum ModuleType
|
private void module(String name, Class<? extends HTTPDModule> clazz, boolean async)
|
||||||
{
|
{
|
||||||
|
modules.put(name, ModuleExecutable.forClass(plugin, clazz, async));
|
||||||
DUMP(new ModuleExecutable(false, "dump")
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Response getResponse(HTTPSession session)
|
|
||||||
{
|
|
||||||
return new Response(Response.Status.OK, NanoHTTPD.MIME_PLAINTEXT, "The DUMP module is disabled. It is intended for debugging use only.");
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
HELP(new ModuleExecutable(true, "help")
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Response getResponse(HTTPSession session)
|
|
||||||
{
|
|
||||||
return new Module_help(session).getResponse();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
LIST(new ModuleExecutable(true, "list")
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Response getResponse(HTTPSession session)
|
|
||||||
{
|
|
||||||
return new Module_list(session).getResponse();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
FILE(new ModuleExecutable(false, "file")
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Response getResponse(HTTPSession session)
|
|
||||||
{
|
|
||||||
return new Module_file(session).getResponse();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
SCHEMATIC(new ModuleExecutable(false, "schematic")
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Response getResponse(HTTPSession session)
|
|
||||||
{
|
|
||||||
return new Module_schematic(session).getResponse();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
PERMBANS(new ModuleExecutable(false, "permbans")
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Response getResponse(HTTPSession session)
|
|
||||||
{
|
|
||||||
return new Module_permbans(session).getResponse();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
PLAYERS(new ModuleExecutable(true, "players")
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Response getResponse(HTTPSession session)
|
|
||||||
{
|
|
||||||
return new Module_players(session).getResponse();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
LOGS(new ModuleExecutable(false, "logs")
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Response getResponse(HTTPSession session)
|
|
||||||
{
|
|
||||||
return new Module_logs(session).getResponse();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//
|
|
||||||
private final ModuleExecutable moduleExecutable;
|
|
||||||
|
|
||||||
private ModuleType(ModuleExecutable moduleExecutable)
|
|
||||||
{
|
|
||||||
this.moduleExecutable = moduleExecutable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract static class ModuleExecutable
|
private class HTTPD extends NanoHTTPD
|
||||||
{
|
{
|
||||||
|
|
||||||
private final boolean runOnBukkitThread;
|
private HTTPD(int port)
|
||||||
private final String name;
|
|
||||||
|
|
||||||
private ModuleExecutable(boolean runOnBukkitThread, String name)
|
|
||||||
{
|
|
||||||
this.runOnBukkitThread = runOnBukkitThread;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Response execute(final HTTPSession session)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (this.runOnBukkitThread)
|
|
||||||
{
|
|
||||||
return Bukkit.getScheduler().callSyncMethod(TotalFreedomMod.plugin, new Callable<Response>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Response call() throws Exception
|
|
||||||
{
|
|
||||||
return getResponse(session);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return getResponse(session);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract Response getResponse(HTTPSession session);
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModuleExecutable getModuleExecutable()
|
|
||||||
{
|
|
||||||
return moduleExecutable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ModuleType getByName(String needle)
|
|
||||||
{
|
|
||||||
for (ModuleType type : values())
|
|
||||||
{
|
|
||||||
if (type.getModuleExecutable().getName().equalsIgnoreCase(needle))
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FILE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class TFM_HTTPD extends NanoHTTPD
|
|
||||||
{
|
|
||||||
|
|
||||||
public TFM_HTTPD(int port)
|
|
||||||
{
|
{
|
||||||
super(port);
|
super(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TFM_HTTPD(String hostname, int port)
|
private HTTPD(String hostname, int port)
|
||||||
{
|
{
|
||||||
super(hostname, port);
|
super(hostname, port);
|
||||||
}
|
}
|
||||||
@ -235,25 +115,28 @@ public class HTTPDaemon extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
public Response serve(HTTPSession session)
|
public Response serve(HTTPSession session)
|
||||||
{
|
{
|
||||||
Response response;
|
final String[] args = StringUtils.split(session.getUri(), "/");
|
||||||
|
|
||||||
|
ModuleExecutable mex = modules.get("file");
|
||||||
|
if (args.length >= 1)
|
||||||
|
{
|
||||||
|
mex = modules.get(args[0].toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mex == null)
|
||||||
|
{
|
||||||
|
return new Response(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "Error 404: Not Found - The requested resource was not found on this server.");
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final String[] args = StringUtils.split(session.getUri(), "/");
|
return mex.execute(session);
|
||||||
final ModuleType moduleType = args.length >= 1 ? ModuleType.getByName(args[0]) : ModuleType.FILE;
|
|
||||||
response = moduleType.getModuleExecutable().execute(session);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
response = new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "Error 500: Internal Server Error\r\n" + ex.getMessage() + "\r\n" + ExceptionUtils.getStackTrace(ex));
|
FLog.severe(ex);
|
||||||
|
return new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "Error 500: Internal Server Error\r\n" + ex.getMessage() + "\r\n" + ExceptionUtils.getStackTrace(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response == null)
|
|
||||||
{
|
|
||||||
response = new Response(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "Error 404: Not Found - The requested resource was not found on this server.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,4 +172,5 @@ public class HTTPDaemon extends FreedomService
|
|||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.httpd;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.pravian.aero.component.PluginComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
public abstract class ModuleExecutable
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final boolean async;
|
||||||
|
|
||||||
|
public ModuleExecutable(boolean async)
|
||||||
|
{
|
||||||
|
this.async = async;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NanoHTTPD.Response execute(final NanoHTTPD.HTTPSession session)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (async)
|
||||||
|
{
|
||||||
|
return getResponse(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync to server thread
|
||||||
|
return Bukkit.getScheduler().callSyncMethod(TotalFreedomMod.plugin(), new Callable<NanoHTTPD.Response>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public NanoHTTPD.Response call() throws Exception
|
||||||
|
{
|
||||||
|
return getResponse(session);
|
||||||
|
}
|
||||||
|
}).get();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract NanoHTTPD.Response getResponse(NanoHTTPD.HTTPSession session);
|
||||||
|
|
||||||
|
public static ModuleExecutable forClass(final TotalFreedomMod plugin, Class<? extends HTTPDModule> clazz, boolean async)
|
||||||
|
{
|
||||||
|
final Constructor<? extends HTTPDModule> cons;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cons = clazz.getConstructor(TotalFreedomMod.class, NanoHTTPD.HTTPSession.class);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Improperly defined module!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ModuleExecutable(async)
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public NanoHTTPD.Response getResponse(NanoHTTPD.HTTPSession session)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return cons.newInstance(plugin, session).getResponse();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,13 +3,16 @@ package me.totalfreedom.totalfreedommod.httpd.module;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDPageBuilder;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDPageBuilder;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.pravian.aero.component.PluginComponent;
|
||||||
|
|
||||||
public abstract class HTTPDModule
|
public abstract class HTTPDModule extends PluginComponent<TotalFreedomMod>
|
||||||
{
|
{
|
||||||
|
|
||||||
protected final String uri;
|
protected final String uri;
|
||||||
@ -19,8 +22,9 @@ public abstract class HTTPDModule
|
|||||||
protected final Socket socket;
|
protected final Socket socket;
|
||||||
protected final HTTPSession session;
|
protected final HTTPSession session;
|
||||||
|
|
||||||
public HTTPDModule(HTTPSession session)
|
public HTTPDModule(TotalFreedomMod plugin, HTTPSession session)
|
||||||
{
|
{
|
||||||
|
super(plugin);
|
||||||
this.uri = session.getUri();
|
this.uri = session.getUri();
|
||||||
this.method = session.getMethod();
|
this.method = session.getMethod();
|
||||||
this.headers = session.getHeaders();
|
this.headers = session.getHeaders();
|
||||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.list;
|
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.list;
|
||||||
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.paragraph;
|
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.paragraph;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
@ -18,9 +19,9 @@ public class Module_dump extends HTTPDModule
|
|||||||
private File echoFile = null;
|
private File echoFile = null;
|
||||||
private final String body;
|
private final String body;
|
||||||
|
|
||||||
public Module_dump(NanoHTTPD.HTTPSession session)
|
public Module_dump(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
{
|
{
|
||||||
super(session);
|
super(plugin, session);
|
||||||
|
|
||||||
//Body needs to be computed before getResponse, so we know if a text response or a file echo is needed.
|
//Body needs to be computed before getResponse, so we know if a text response or a file echo is needed.
|
||||||
this.body = body();
|
this.body = body();
|
||||||
|
@ -12,6 +12,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
@ -57,9 +58,9 @@ public class Module_file extends HTTPDModule
|
|||||||
MIME_TYPES.put("class", "application/octet-stream");
|
MIME_TYPES.put("class", "application/octet-stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Module_file(NanoHTTPD.HTTPSession session)
|
public Module_file(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
{
|
{
|
||||||
super(session);
|
super(plugin, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getRootDir()
|
private File getRootDir()
|
||||||
|
@ -13,7 +13,7 @@ import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
|||||||
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.heading;
|
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.heading;
|
||||||
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.paragraph;
|
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.paragraph;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
import me.totalfreedom.totalfreedommod.rank.RankBase;
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import net.pravian.aero.command.CommandReflection;
|
import net.pravian.aero.command.CommandReflection;
|
||||||
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
|
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -25,9 +25,9 @@ import org.bukkit.command.SimpleCommandMap;
|
|||||||
public class Module_help extends HTTPDModule
|
public class Module_help extends HTTPDModule
|
||||||
{
|
{
|
||||||
|
|
||||||
public Module_help(NanoHTTPD.HTTPSession session)
|
public Module_help(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
{
|
{
|
||||||
super(session);
|
super(plugin, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,7 +77,7 @@ public class Module_help extends HTTPDModule
|
|||||||
|
|
||||||
responseBody.append(heading(pluginName, 2)).append("<ul>\r\n");
|
responseBody.append(heading(pluginName, 2)).append("<ul>\r\n");
|
||||||
|
|
||||||
RankBase lastTfmCommandLevel = null;
|
Displayable lastTfmCommandLevel = null;
|
||||||
for (Command command : commands)
|
for (Command command : commands)
|
||||||
{
|
{
|
||||||
if (!TotalFreedomMod.pluginName.equals(pluginName))
|
if (!TotalFreedomMod.pluginName.equals(pluginName))
|
||||||
@ -86,7 +86,7 @@ public class Module_help extends HTTPDModule
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RankBase tfmCommandLevel = FreedomCommand.getFrom(command).getPerms().level();
|
Displayable tfmCommandLevel = FreedomCommand.getFrom(command).getPerms().level();
|
||||||
if (lastTfmCommandLevel == null || lastTfmCommandLevel != tfmCommandLevel)
|
if (lastTfmCommandLevel == null || lastTfmCommandLevel != tfmCommandLevel)
|
||||||
{
|
{
|
||||||
responseBody.append("</ul>\r\n").append(heading(tfmCommandLevel.getName(), 3)).append("<ul>\r\n");
|
responseBody.append("</ul>\r\n").append(heading(tfmCommandLevel.getName(), 3)).append("<ul>\r\n");
|
||||||
|
@ -9,9 +9,9 @@ import org.bukkit.entity.Player;
|
|||||||
public class Module_list extends HTTPDModule
|
public class Module_list extends HTTPDModule
|
||||||
{
|
{
|
||||||
|
|
||||||
public Module_list(NanoHTTPD.HTTPSession session)
|
public Module_list(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
{
|
{
|
||||||
super(session);
|
super(plugin, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,7 +27,7 @@ public class Module_list extends HTTPDModule
|
|||||||
|
|
||||||
for (Player player : onlinePlayers)
|
for (Player player : onlinePlayers)
|
||||||
{
|
{
|
||||||
String tag = TotalFreedomMod.plugin.rm.getDisplay(player).getTag();
|
String tag = plugin.rm.getDisplay(player).getTag();
|
||||||
body.append("<li>").append(tag).append(player.getName()).append("</li>\r\n");
|
body.append("<li>").append(tag).append(player.getName()).append("</li>\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
|
|
||||||
public class Module_logs extends Module_file
|
public class Module_logs extends Module_file
|
||||||
{
|
{
|
||||||
|
|
||||||
public Module_logs(NanoHTTPD.HTTPSession session)
|
public Module_logs(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
{
|
{
|
||||||
super(session);
|
super(plugin, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,18 +9,18 @@ import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
|||||||
public class Module_permbans extends HTTPDModule
|
public class Module_permbans extends HTTPDModule
|
||||||
{
|
{
|
||||||
|
|
||||||
public Module_permbans(NanoHTTPD.HTTPSession session)
|
public Module_permbans(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
{
|
{
|
||||||
super(session);
|
super(plugin, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NanoHTTPD.Response getResponse()
|
public NanoHTTPD.Response getResponse()
|
||||||
{
|
{
|
||||||
File permbanFile = new File(TotalFreedomMod.plugin.getDataFolder(), PermbanList.CONFIG_FILENAME);
|
File permbanFile = new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME);
|
||||||
if (permbanFile.exists())
|
if (permbanFile.exists())
|
||||||
{
|
{
|
||||||
return HTTPDaemon.serveFileBasic(new File(TotalFreedomMod.plugin.getDataFolder(), PermbanList.CONFIG_FILENAME));
|
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ import org.json.simple.JSONObject;
|
|||||||
public class Module_players extends HTTPDModule
|
public class Module_players extends HTTPDModule
|
||||||
{
|
{
|
||||||
|
|
||||||
public Module_players(NanoHTTPD.HTTPSession session)
|
public Module_players(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
{
|
{
|
||||||
super(session);
|
super(plugin, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -36,7 +36,7 @@ public class Module_players extends HTTPDModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Admins
|
// Admins
|
||||||
for (Admin admin : TotalFreedomMod.plugin.al.getAllAdmins().values())
|
for (Admin admin : plugin.al.getAllAdmins().values())
|
||||||
{
|
{
|
||||||
final String username = admin.getName();
|
final String username = admin.getName();
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class Module_players extends HTTPDModule
|
|||||||
telnetadmins.add(username);
|
telnetadmins.add(username);
|
||||||
break;
|
break;
|
||||||
case SENIOR_ADMIN:
|
case SENIOR_ADMIN:
|
||||||
senioradmins.add(senioradmins);
|
senioradmins.add(username);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,9 @@ public class Module_schematic extends HTTPDModule
|
|||||||
+ "<button type=\"submit\">Submit</button>\n"
|
+ "<button type=\"submit\">Submit</button>\n"
|
||||||
+ "</form>";
|
+ "</form>";
|
||||||
|
|
||||||
public Module_schematic(NanoHTTPD.HTTPSession session)
|
public Module_schematic(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
{
|
{
|
||||||
super(session);
|
super(plugin, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -235,7 +235,7 @@ public class Module_schematic extends HTTPDModule
|
|||||||
|
|
||||||
private boolean isAuthorized(String remoteAddress)
|
private boolean isAuthorized(String remoteAddress)
|
||||||
{
|
{
|
||||||
Admin entry = TotalFreedomMod.plugin.al.getEntryByIp(remoteAddress);
|
Admin entry = plugin.al.getEntryByIp(remoteAddress);
|
||||||
return entry != null && entry.isActive();
|
return entry != null && entry.isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ public class FPlayer
|
|||||||
|
|
||||||
public static final long AUTO_PURGE_TICKS = 5L * 60L * 20L;
|
public static final long AUTO_PURGE_TICKS = 5L * 60L * 20L;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final TotalFreedomMod plugin;
|
||||||
@Getter
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
@Getter
|
@Getter
|
||||||
@ -33,7 +35,6 @@ public class FPlayer
|
|||||||
private Player player;
|
private Player player;
|
||||||
//
|
//
|
||||||
private BukkitTask unmuteTask;
|
private BukkitTask unmuteTask;
|
||||||
private BukkitTask unfreezeTask;
|
|
||||||
@Getter
|
@Getter
|
||||||
private final FreezeData freezeData = new FreezeData(this);
|
private final FreezeData freezeData = new FreezeData(this);
|
||||||
@Getter
|
@Getter
|
||||||
@ -58,19 +59,22 @@ public class FPlayer
|
|||||||
private String lastMessage = "";
|
private String lastMessage = "";
|
||||||
private boolean inAdminchat = false;
|
private boolean inAdminchat = false;
|
||||||
private boolean allCommandsBlocked = false;
|
private boolean allCommandsBlocked = false;
|
||||||
private boolean verifiedSuperadminId = false;
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean superadminIdVerified = false;
|
||||||
private String lastCommand = "";
|
private String lastCommand = "";
|
||||||
private boolean cmdspyEnabled = false;
|
private boolean cmdspyEnabled = false;
|
||||||
private String tag = null;
|
private String tag = null;
|
||||||
private int warningCount = 0;
|
private int warningCount = 0;
|
||||||
|
|
||||||
public FPlayer(Player player)
|
public FPlayer(TotalFreedomMod plugin, Player player)
|
||||||
{
|
{
|
||||||
this(player.getName(), Ips.getIp(player));
|
this(plugin, player.getName(), Ips.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
private FPlayer(String name, String ip)
|
private FPlayer(TotalFreedomMod plugin, String name, String ip)
|
||||||
{
|
{
|
||||||
|
this.plugin = plugin;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
}
|
}
|
||||||
@ -278,15 +282,19 @@ public class FPlayer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getPlayer() == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
unmuteTask = new BukkitRunnable()
|
unmuteTask = new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
FUtil.adminAction("TotalFreedom", "Unmuting " + player.getName(), false);
|
FUtil.adminAction("TotalFreedom", "Unmuting " + getPlayer().getName(), false);
|
||||||
setMuted(false);
|
setMuted(false);
|
||||||
}
|
}
|
||||||
}.runTaskLater(TotalFreedomMod.plugin, AUTO_PURGE_TICKS);
|
}.runTaskLater(plugin, AUTO_PURGE_TICKS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitTask getLockupScheduleID()
|
public BukkitTask getLockupScheduleID()
|
||||||
@ -329,20 +337,6 @@ public class FPlayer
|
|||||||
this.allCommandsBlocked = commandsBlocked;
|
this.allCommandsBlocked = commandsBlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If someone logs in to telnet or minecraft, and they are an admin, make sure that they are using a username that is associated with their IP.
|
|
||||||
// After the check for this is done in TFM_PlayerListener, never change it elsewhere.
|
|
||||||
public boolean isSuperadminIdVerified()
|
|
||||||
{
|
|
||||||
return this.verifiedSuperadminId;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If someone logs in to telnet or minecraft, and they are an admin, make sure that they are using a username that is associated with their IP.
|
|
||||||
// After the check for this is done in TFM_PlayerListener, never change it elsewhere.
|
|
||||||
public void setSuperadminIdVerified(boolean verifiedSuperadminId)
|
|
||||||
{
|
|
||||||
this.verifiedSuperadminId = verifiedSuperadminId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLastCommand()
|
public String getLastCommand()
|
||||||
{
|
{
|
||||||
return lastCommand;
|
return lastCommand;
|
||||||
@ -391,8 +385,9 @@ public class FPlayer
|
|||||||
|
|
||||||
if (this.warningCount % 2 == 0)
|
if (this.warningCount % 2 == 0)
|
||||||
{
|
{
|
||||||
this.player.getWorld().strikeLightning(this.player.getLocation());
|
Player p = getPlayer();
|
||||||
FUtil.playerMsg(this.player, ChatColor.RED + "You have been warned at least twice now, make sure to read the rules at " + ConfigEntry.SERVER_BAN_URL.getString());
|
p.getWorld().strikeLightning(p.getLocation());
|
||||||
|
FUtil.playerMsg(p, ChatColor.RED + "You have been warned at least twice now, make sure to read the rules at " + ConfigEntry.SERVER_BAN_URL.getString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class PlayerList extends FreedomService
|
|||||||
return tPlayer;
|
return tPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
tPlayer = new FPlayer(player);
|
tPlayer = new FPlayer(plugin, player);
|
||||||
playerMap.put(Ips.getIp(player), tPlayer);
|
playerMap.put(Ips.getIp(player), tPlayer);
|
||||||
|
|
||||||
return tPlayer;
|
return tPlayer;
|
||||||
@ -214,7 +214,7 @@ public class PlayerList extends FreedomService
|
|||||||
|
|
||||||
protected YamlConfig getConfig(PlayerData data)
|
protected YamlConfig getConfig(PlayerData data)
|
||||||
{
|
{
|
||||||
final YamlConfig config = new YamlConfig(TotalFreedomMod.plugin, getConfigFile(data.getUsername().toLowerCase()), false);
|
final YamlConfig config = new YamlConfig(plugin, getConfigFile(data.getUsername().toLowerCase()), false);
|
||||||
config.load();
|
config.load();
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.rank;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public interface RankBase
|
public interface Displayable
|
||||||
{
|
{
|
||||||
|
|
||||||
public String getName();
|
public String getName();
|
||||||
@ -17,8 +17,4 @@ public interface RankBase
|
|||||||
|
|
||||||
public String getColoredLoginMessage();
|
public String getColoredLoginMessage();
|
||||||
|
|
||||||
public boolean isAtLeast(RankBase rank);
|
|
||||||
|
|
||||||
public int getLevel();
|
|
||||||
|
|
||||||
}
|
}
|
@ -3,18 +3,17 @@ package me.totalfreedom.totalfreedommod.rank;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public enum Rank implements RankBase
|
public enum Rank implements Displayable
|
||||||
{
|
{
|
||||||
|
|
||||||
IMPOSTOR(Type.PLAYER, "an", "Imp", ChatColor.YELLOW),
|
IMPOSTOR("an", "Impostor", Type.PLAYER, "Imp", ChatColor.YELLOW),
|
||||||
NON_OP(Type.PLAYER, "a", "", ChatColor.GREEN),
|
NON_OP("a", "Non-Op", Type.PLAYER, "", ChatColor.GREEN),
|
||||||
OP(Type.PLAYER, "an", "OP", ChatColor.RED),
|
OP("an", "Op", Type.PLAYER, "OP", ChatColor.RED),
|
||||||
SUPER_ADMIN(Type.ADMIN, "a", "SA", ChatColor.GOLD),
|
SUPER_ADMIN("a", "Super Admin", Type.ADMIN, "SA", ChatColor.AQUA),
|
||||||
TELNET_ADMIN(Type.ADMIN, "a", "STA", ChatColor.DARK_GREEN),
|
TELNET_ADMIN("a", "Telnet Admin", Type.ADMIN, "STA", ChatColor.DARK_GREEN),
|
||||||
SENIOR_ADMIN(Type.ADMIN, "a", "SrA", ChatColor.LIGHT_PURPLE),
|
SENIOR_ADMIN("a", "Senior Admin", Type.ADMIN, "SrA", ChatColor.GOLD),
|
||||||
TELNET_CONSOLE(),
|
TELNET_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE),
|
||||||
SENIOR_CONSOLE();
|
SENIOR_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE);
|
||||||
//
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Type type;
|
private final Type type;
|
||||||
@Getter
|
@Getter
|
||||||
@ -23,58 +22,30 @@ public enum Rank implements RankBase
|
|||||||
@Getter
|
@Getter
|
||||||
private final String tag;
|
private final String tag;
|
||||||
@Getter
|
@Getter
|
||||||
|
private final String coloredTag;
|
||||||
|
@Getter
|
||||||
private final ChatColor color;
|
private final ChatColor color;
|
||||||
|
|
||||||
private Rank()
|
private Rank(String determiner, String name, Type type, String abbr, ChatColor color)
|
||||||
{
|
|
||||||
this("Console", Type.ADMIN_CONSOLE, "the", "Console", ChatColor.DARK_PURPLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rank(Type type, String determiner, String tag, ChatColor color)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
|
|
||||||
// Name
|
|
||||||
final String[] nameParts = name().toLowerCase().split("_");
|
|
||||||
String tempName = "";
|
|
||||||
for (String part : nameParts)
|
|
||||||
{
|
|
||||||
tempName += Character.toUpperCase(part.charAt(0)) + part.substring(1) + " ";
|
|
||||||
}
|
|
||||||
name = tempName.trim();
|
|
||||||
|
|
||||||
this.determiner = determiner;
|
|
||||||
this.tag = tag.length() > 0 ? "[" + tag + "]" : "";
|
|
||||||
|
|
||||||
// Colors
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rank(String name, Type type, String determiner, String tag, ChatColor color)
|
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.determiner = determiner;
|
this.determiner = determiner;
|
||||||
this.tag = "[" + tag + "]";
|
this.tag = abbr.isEmpty() ? "" : "[" + abbr + "]";
|
||||||
|
this.coloredTag = abbr.isEmpty() ? "" : ChatColor.DARK_GRAY + "[" + color + abbr + ChatColor.DARK_GRAY + "]" + color;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColoredName()
|
public String getColoredName()
|
||||||
{
|
{
|
||||||
return getColor() + getName();
|
return color + name;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getColoredTag()
|
|
||||||
{
|
|
||||||
return getColor() + getTag();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColoredLoginMessage()
|
public String getColoredLoginMessage()
|
||||||
{
|
{
|
||||||
return determiner + " " + getColoredName();
|
return determiner + " " + color + ChatColor.ITALIC + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConsole()
|
public boolean isConsole()
|
||||||
@ -82,16 +53,24 @@ public enum Rank implements RankBase
|
|||||||
return getType() == Type.ADMIN_CONSOLE;
|
return getType() == Type.ADMIN_CONSOLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLevel()
|
public int getLevel()
|
||||||
{
|
{
|
||||||
return ordinal();
|
return ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean isAtLeast(Rank rank)
|
||||||
public boolean isAtLeast(RankBase rank)
|
|
||||||
{
|
{
|
||||||
return getLevel() >= rank.getLevel();
|
if (getLevel() < rank.getLevel())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasConsoleVariant() || !rank.hasConsoleVariant())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getConsoleVariant().getLevel() >= rank.getConsoleVariant().getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdmin()
|
public boolean isAdmin()
|
||||||
@ -99,7 +78,7 @@ public enum Rank implements RankBase
|
|||||||
return getType() == Type.ADMIN || getType() == Type.ADMIN_CONSOLE;
|
return getType() == Type.ADMIN || getType() == Type.ADMIN_CONSOLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasConsole()
|
public boolean hasConsoleVariant()
|
||||||
{
|
{
|
||||||
return getConsoleVariant() != null;
|
return getConsoleVariant() != null;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod.rank;
|
package me.totalfreedom.totalfreedommod.rank;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.ChatUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -34,7 +34,7 @@ public class RankManager extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public RankBase getDisplay(CommandSender sender)
|
public Displayable getDisplay(CommandSender sender)
|
||||||
{
|
{
|
||||||
if (!(sender instanceof Player))
|
if (!(sender instanceof Player))
|
||||||
{
|
{
|
||||||
@ -64,7 +64,7 @@ public class RankManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the player's an owner, display that
|
// If the player's an owner, display that
|
||||||
if (MainConfig.get(ConfigEntry.SERVER_OWNERS, List.class).contains(player.getName()))
|
if (ConfigEntry.SERVER_OWNERS.getList().contains(player.getName()))
|
||||||
{
|
{
|
||||||
return Title.OWNER;
|
return Title.OWNER;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,14 @@ public class RankManager extends FreedomService
|
|||||||
return Rank.SENIOR_CONSOLE;
|
return Rank.SENIOR_CONSOLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return admin.getRank();
|
Rank rank = admin.getRank();
|
||||||
|
|
||||||
|
// Get console
|
||||||
|
if (rank.hasConsoleVariant())
|
||||||
|
{
|
||||||
|
rank = rank.getConsoleVariant();
|
||||||
|
}
|
||||||
|
return rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank getRank(Player player)
|
public Rank getRank(Player player)
|
||||||
@ -122,13 +129,13 @@ public class RankManager extends FreedomService
|
|||||||
|
|
||||||
// Unban admins
|
// Unban admins
|
||||||
boolean isAdmin = plugin.al.isAdmin(player);
|
boolean isAdmin = plugin.al.isAdmin(player);
|
||||||
fPlayer.setSuperadminIdVerified(false);
|
|
||||||
if (isAdmin)
|
if (isAdmin)
|
||||||
{
|
{
|
||||||
// Verify strict IP match
|
// Verify strict IP match
|
||||||
if (!plugin.al.isIdentityMatched(player))
|
if (!plugin.al.isIdentityMatched(player))
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
|
FUtil.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
|
||||||
|
fPlayer.setSuperadminIdVerified(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -153,7 +160,7 @@ public class RankManager extends FreedomService
|
|||||||
// Set display
|
// Set display
|
||||||
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()))
|
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()))
|
||||||
{
|
{
|
||||||
final RankBase display = getDisplay(player);
|
final Displayable display = getDisplay(player);
|
||||||
String loginMsg = display.getColoredLoginMessage();
|
String loginMsg = display.getColoredLoginMessage();
|
||||||
|
|
||||||
if (isAdmin)
|
if (isAdmin)
|
||||||
@ -161,17 +168,17 @@ public class RankManager extends FreedomService
|
|||||||
Admin admin = plugin.al.getAdmin(player);
|
Admin admin = plugin.al.getAdmin(player);
|
||||||
if (admin.hasLoginMessage())
|
if (admin.hasLoginMessage())
|
||||||
{
|
{
|
||||||
loginMsg = admin.getLoginMessage();
|
loginMsg = ChatUtils.colorize(admin.getLoginMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + loginMsg);
|
FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + loginMsg);
|
||||||
plugin.pl.getPlayer(player).setTag(display.getColoredTag());
|
plugin.pl.getPlayer(player).setTag(display.getColoredTag());
|
||||||
|
|
||||||
|
String displayName = display.getColor() + player.getName();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String displayName = display.getColor() + player.getName();
|
player.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
||||||
player.setPlayerListName(displayName.substring(0, Math.min(displayName.length(), 16)));
|
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex)
|
catch (IllegalArgumentException ex)
|
||||||
{
|
{
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user