Merge remote-tracking branch 'origin/TFM-1.13' into TFM-1.13

# Conflicts:
#	TotalFreedomMod.iml
This commit is contained in:
Robinson Gallego 2019-07-28 00:05:26 -04:00
commit 7e83297731
24 changed files with 660 additions and 14 deletions

View File

@ -12,9 +12,9 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.9.4-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-jdk14:1.7.26" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.14.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.13.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />

View File

@ -102,7 +102,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.13.1-R0.1-SNAPSHOT</version>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View File

@ -128,7 +128,7 @@ public class EntityWiper extends FreedomService
{
int removed = 0;
boolean wipeExpl = ConfigEntry.ALLOW_EXPLOSIONS.getBoolean();
boolean wipeExpl = !ConfigEntry.ALLOW_EXPLOSIONS.getBoolean();
Iterator<Entity> entities = world.getEntities().iterator();
// Organise the entities in the world

View File

@ -188,6 +188,16 @@ public class LoginProcess extends FreedomService
final Player player = event.getPlayer();
final FPlayer fPlayer = plugin.pl.getPlayer(player);
if (!ConfigEntry.SERVER_TABLIST_HEADER.getString().isEmpty())
{
player.setPlayerListHeader(FUtil.colorize(ConfigEntry.SERVER_TABLIST_HEADER.getString()).replace("\\n", "\n"));
}
if (!ConfigEntry.SERVER_TABLIST_FOOTER.getString().isEmpty())
{
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
}
for (Player p : Command_vanish.VANISHED)
{
if (!plugin.al.isAdmin(player))

View File

@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod;
import java.io.File;
import java.io.InputStream;
import java.util.Properties;
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.amp.AMP;
import me.totalfreedom.totalfreedommod.banning.BanManager;
@ -27,6 +28,7 @@ import me.totalfreedom.totalfreedommod.command.CommandLoader;
import me.totalfreedom.totalfreedommod.config.MainConfig;
import me.totalfreedom.totalfreedommod.discord.Discord;
import me.totalfreedom.totalfreedommod.freeze.Freezer;
import me.totalfreedom.totalfreedommod.fun.CurseListener;
import me.totalfreedom.totalfreedommod.fun.ItemFun;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.fun.Landminer;
@ -75,6 +77,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public WorldManager wm;
public LogViewer lv;
public AdminList al;
public ActivityLog acl;
public RankManager rm;
public CommandLoader cl;
public CommandBlocker cb;
@ -111,6 +114,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public EntityWiper ew;
public FrontDoor fd;
public ServerPing sp;
public CurseListener cul;
public ItemFun it;
public Landminer lm;
public MobStacker ms;
@ -182,6 +186,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
wm = services.registerService(WorldManager.class);
lv = services.registerService(LogViewer.class);
al = services.registerService(AdminList.class);
acl = services.registerService(ActivityLog.class);
rm = services.registerService(RankManager.class);
cl = services.registerService(CommandLoader.class);
cb = services.registerService(CommandBlocker.class);
@ -229,6 +234,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
pv = services.registerService(PlayerVerification.class);
// Fun
cul = services.registerService(CurseListener.class);
it = services.registerService(ItemFun.class);
lm = services.registerService(Landminer.class);
ms = services.registerService(MobStacker.class);

View File

@ -0,0 +1,192 @@
package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Maps;
import java.util.Map;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class ActivityLog extends FreedomService
{
public static final String FILENAME = "activitylog.yml";
@Getter
private final Map<String, ActivityLogEntry> allActivityLogs = Maps.newHashMap();
private final Map<String, ActivityLogEntry> nameTable = Maps.newHashMap();
private final Map<String, ActivityLogEntry> ipTable = Maps.newHashMap();
private final YamlConfig config;
public ActivityLog(TotalFreedomMod plugin)
{
super(plugin);
this.config = new YamlConfig(plugin, FILENAME, true);
}
@Override
protected void onStart()
{
load();
}
@Override
protected void onStop()
{
save();
}
public void load()
{
config.load();
allActivityLogs.clear();
nameTable.clear();
ipTable.clear();
for (String key : config.getKeys(false))
{
ConfigurationSection section = config.getConfigurationSection(key);
if (section == null)
{
logger.warning("Invalid activity log format: " + key);
continue;
}
ActivityLogEntry activityLogEntry = new ActivityLogEntry(key);
activityLogEntry.loadFrom(section);
if (!activityLogEntry.isValid())
{
FLog.warning("Could not load activity log: " + key + ". Missing details!");
continue;
}
allActivityLogs.put(key, activityLogEntry);
}
updateTables();
FLog.info("Loaded " + allActivityLogs.size() + " activity logs");
}
public void save()
{
// Clear the config
for (String key : config.getKeys(false))
{
config.set(key, null);
}
for (ActivityLogEntry activityLog : allActivityLogs.values())
{
activityLog.saveTo(config.createSection(activityLog.getConfigKey()));
}
config.save();
}
public ActivityLogEntry getActivityLog(CommandSender sender)
{
if (sender instanceof Player)
{
return getActivityLog((Player)sender);
}
return getEntryByName(sender.getName());
}
public ActivityLogEntry getActivityLog(Player player)
{
ActivityLogEntry activityLog = getEntryByName(player.getName());
if (activityLog == null)
{
String ip = Ips.getIp(player);
activityLog = getEntryByIp(ip);
if (activityLog != null)
{
// Set the new username
activityLog.setName(player.getName());
save();
updateTables();
}
else
{
activityLog = new ActivityLogEntry(player);
allActivityLogs.put(activityLog.getConfigKey(), activityLog);
updateTables();
activityLog.saveTo(config.createSection(activityLog.getConfigKey()));
config.save();
}
}
String ip = Ips.getIp(player);
if (!activityLog.getIps().contains(ip))
{
activityLog.addIp(ip);
save();
updateTables();
}
return activityLog;
}
public ActivityLogEntry getEntryByName(String name)
{
return nameTable.get(name.toLowerCase());
}
public ActivityLogEntry getEntryByIp(String ip)
{
return ipTable.get(ip);
}
public void updateTables()
{
nameTable.clear();
ipTable.clear();
for (ActivityLogEntry activityLog : allActivityLogs.values())
{
nameTable.put(activityLog.getName().toLowerCase(), activityLog);
for (String ip : activityLog.getIps())
{
ipTable.put(ip, activityLog);
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
if (plugin.al.isAdmin(player))
{
getActivityLog(event.getPlayer()).addLogin();
plugin.acl.save();
plugin.acl.updateTables();
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
if (plugin.al.isAdmin(player))
{
getActivityLog(event.getPlayer()).addLogout();
plugin.acl.save();
plugin.acl.updateTables();
}
}
}

View File

@ -0,0 +1,130 @@
package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Lists;
import java.time.Instant;
import java.util.Date;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.base.ConfigLoadable;
import net.pravian.aero.base.ConfigSavable;
import net.pravian.aero.base.Validatable;
import org.apache.commons.lang3.Validate;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
public class ActivityLogEntry implements ConfigLoadable, ConfigSavable, Validatable
{
@Getter
private String configKey;
@Getter
@Setter
private String name;
@Getter
private final List<String> ips = Lists.newArrayList();
@Getter
@Setter
private List<String> timestamps = Lists.newArrayList();
@Getter
@Setter
private List<String> durations = Lists.newArrayList();
public static final String FILENAME = "activitylog.yml";
public ActivityLogEntry(Player player)
{
this.configKey = player.getName().toLowerCase();
this.name = player.getName();
}
public ActivityLogEntry(String configKey)
{
this.configKey = configKey;
}
public void loadFrom(Player player)
{
configKey = player.getName().toLowerCase();
name = player.getName();
}
@Override
public void loadFrom(ConfigurationSection cs)
{
name = cs.getString("username", configKey);
ips.clear();
ips.addAll(cs.getStringList("ips"));
timestamps.clear();
timestamps.addAll(cs.getStringList("timestamps"));
durations.clear();
durations.addAll(cs.getStringList("durations"));
}
@Override
public void saveTo(ConfigurationSection cs)
{
Validate.isTrue(isValid(), "Could not save activity entry: " + name + ". Entry not valid!");
cs.set("username", name);
cs.set("ips", Lists.newArrayList(ips));
cs.set("timestamps", Lists.newArrayList(timestamps));
cs.set("durations", Lists.newArrayList(durations));
}
public void addLogin()
{
Date currentTime = Date.from(Instant.now());
timestamps.add("Login: " + FUtil.dateToString(currentTime));
}
public void addLogout()
{
String lastLoginString = timestamps.get(timestamps.size() - 1);
Date currentTime = Date.from(Instant.now());
timestamps.add("Logout: " + FUtil.dateToString(currentTime));
lastLoginString = lastLoginString.replace("Login: ", "");
Date lastLogin = FUtil.stringToDate(lastLoginString);
long duration = currentTime.getTime() - lastLogin.getTime();
long seconds = duration / 1000 % 60;
long minutes = duration / (60 * 1000) % 60;
long hours = duration / (60 * 60 * 1000);
durations.add(hours + " hours, " + minutes + " minutes, and " + seconds + " seconds");
}
public void addIp(String ip)
{
if (!ips.contains(ip))
{
ips.add(ip);
}
}
public void addIps(List<String> ips)
{
for (String ip : ips)
{
addIp(ip);
}
}
public void removeIp(String ip)
{
if (ips.contains(ip))
{
ips.remove(ip);
}
}
public void clearIPs()
{
ips.clear();
}
@Override
public boolean isValid()
{
return configKey != null
&& name != null;
}
}

View File

@ -1,7 +1,9 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Lists;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
@ -36,6 +38,9 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
private String by = null;
@Getter
@Setter
private Date at = null;
@Getter
@Setter
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
@Getter
@Setter
@ -45,7 +50,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
{
}
public Ban(String username, String ip, String by, Date expire, String reason)
public Ban(String username, String ip, String by, Date at, Date expire, String reason)
{
this(username,
new String[]
@ -53,11 +58,12 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
ip
},
by,
at,
expire,
reason);
}
public Ban(String username, String[] ips, String by, Date expire, String reason)
public Ban(String username, String[] ips, String by, Date at, Date expire, String reason)
{
this.username = username;
if (ips != null)
@ -66,6 +72,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
}
dedupeIps();
this.by = by;
this.at = at;
this.expiryUnix = FUtil.getUnixTime(expire);
this.reason = reason;
}
@ -82,12 +89,12 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
return new Ban(null, new String[]
{
Ips.getIp(player)
}, by.getName(), expiry, reason);
}, by.getName(), Date.from(Instant.now()), expiry, reason);
}
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
{
return new Ban(null, ip, by.getName(), expiry, reason);
return new Ban(null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
}
//
@ -102,6 +109,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
return new Ban(player,
(String[])null,
by.getName(),
Date.from(Instant.now()),
expiry,
reason);
}
@ -118,6 +126,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
return new Ban(player.getName(),
Ips.getIp(player),
by.getName(),
Date.from(Instant.now()),
expiry,
reason);
}
@ -127,6 +136,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
return new Ban(player.getName(),
FUtil.getFuzzyIp(Ips.getIp(player)),
by.getName(),
Date.from(Instant.now()),
expiry,
reason);
}
@ -181,6 +191,12 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
.append(by);
}
if (at != null)
{
message.append("\n").append(ChatColor.RED).append("Issued: ").append(ChatColor.GOLD)
.append(DATE_FORMAT.format(at));
}
if (getExpiryUnix() != 0)
{
message.append("\n").append(ChatColor.RED).append("Expires: ").append(ChatColor.GOLD)
@ -234,6 +250,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
this.ips.clear();
this.ips.addAll(cs.getStringList("ips"));
this.by = cs.getString("by", null);
this.at = FUtil.stringToDate(cs.getString("at", null));
this.reason = cs.getString("reason", null);
this.expiryUnix = cs.getLong("expiry_unix", 0);
dedupeIps();
@ -246,6 +263,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
cs.set("username", username);
cs.set("ips", ips.isEmpty() ? null : ips);
cs.set("by", by);
cs.set("at", FUtil.dateToString(at));
cs.set("reason", reason);
cs.set("expiry_unix", expiryUnix > 0 ? expiryUnix : null);
}

View File

@ -8,7 +8,6 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;

View File

@ -3,7 +3,9 @@ package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.ShulkerBox;

View File

@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -54,6 +55,12 @@ public class InteractBlocker extends FreedomService
{
final Player player = event.getPlayer();
if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK))
{
event.setCancelled(true);
event.getPlayer().closeInventory();
}
switch (event.getMaterial())
{
case WATER_BUCKET:

View File

@ -0,0 +1,58 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.ChatColor;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Cuck someone", usage = "/<command> <player>")
public class Command_cuck extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!FUtil.isExecutive(sender.getName()))
{
return noPerms();
}
if (args.length == 0)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
player.remove();
msg("Cucked " + player.getName());
player.sendTitle(ChatColor.DARK_RED + "HAHA CUCKED", ChatColor.RED + "relog if u want to be uncucked loser", 20, 200, 60);
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.al.isAdmin(sender) && FUtil.isExecutive(sender.getName()))
{
return FUtil.getPlayerList();
}
return Collections.emptyList();
}
}

View File

@ -0,0 +1,66 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.ChatColor;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Curse someone", usage = "/<command> <player>")
public class Command_curse extends FreedomCommand
{
/* The only problem with this is someone can prevent themself from being cursed by declining to download the
resource pack. However, if they hit yes, then you can curse them whenever you want and they can't stop it unless
they go into their server settings. and set server resource packs to prompt or disabled */
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!FUtil.isExecutive(sender.getName()))
{
return noPerms();
}
if (args.length == 0)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
if (plugin.cul.cursedPlayers.containsKey(player))
{
msg("Already attempting to cruse!", ChatColor.RED);
return true;
}
player.setResourcePack("http://play.totalfreedom.me/cursed.zip");
msg("Attempting to curse " + player.getName(), ChatColor.GREEN);
plugin.cul.cursedPlayers.put(player, playerSender);
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.al.isAdmin(sender) && FUtil.isExecutive(sender.getName()))
{
return FUtil.getPlayerList();
}
return Collections.emptyList();
}
}

View File

@ -0,0 +1,31 @@
package me.totalfreedom.totalfreedommod.command;
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.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Make arrows explode", usage = "/<command>", aliases = "ea")
public class Command_explosivearrows extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean onList = plugin.it.explosivePlayers.contains(playerSender);
if (onList)
{
plugin.it.explosivePlayers.remove(playerSender);
msg("You no longer have explosive arrows", ChatColor.RED);
}
else
{
plugin.it.explosivePlayers.add(playerSender);
msg("You now have explosive arrows", ChatColor.GREEN);
}
return true;
}
}

View File

@ -7,7 +7,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Control mob rezzing parameters.", usage = "/<command> <on|off|setmax <count>|dragon|giant|ghast|slime>")
public class Command_moblimiter extends FreedomCommand
{

View File

@ -153,7 +153,7 @@ public class Command_tag extends FreedomCommand
int tagLimit = (plugin.al.isAdmin(sender) ? 30 : 20);
final String rawTag = ChatColor.stripColor(strippedTag).toLowerCase();
final String rawTag = ChatColor.stripColor(outputTag).toLowerCase();
if (rawTag.length() > tagLimit)
{

View File

@ -45,6 +45,8 @@ public enum ConfigEntry
SERVER_MASTER_BUILDER_MANAGEMENT(List.class, "server.master_builder_management"),
SERVER_BAN_URL(String.class, "server.ban_url"),
SERVER_PERMBAN_URL(String.class, "server.permban_url"),
SERVER_TABLIST_HEADER(String.class, "server.tablist_header"),
SERVER_TABLIST_FOOTER(String.class, "server.tablist_footer"),
//
DISCORD_TOKEN(String.class, "discord.token"),
DISCORD_REPORT_CHANNEL_ID(String.class, "discord.report_channel_id"),

View File

@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.discord;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
@ -30,6 +29,7 @@ public class MessageListener extends ListenerAdapter
{
VPlayer player = Discord.PLAYER_LINK_CODES.get(code);
player.setDiscordId(event.getMessage().getAuthor().getId());
player.setEnabled(true);
TotalFreedomMod.plugin().pv.saveVerificationData(player);
Discord.PLAYER_LINK_CODES.remove(code);

View File

@ -0,0 +1,61 @@
package me.totalfreedom.totalfreedommod.fun;
import java.util.HashMap;
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.player.PlayerResourcePackStatusEvent;
import static org.bukkit.event.player.PlayerResourcePackStatusEvent.Status;
public class CurseListener extends FreedomService
{
public HashMap<Player, Player> cursedPlayers = new HashMap<Player, Player>();
public CurseListener(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.MONITOR)
public void onResourcePackStatus(PlayerResourcePackStatusEvent event)
{
Player player = event.getPlayer();
PlayerResourcePackStatusEvent.Status cursed = event.getStatus();
Player cursedBy = cursedPlayers.get(player);
if (cursed.equals(Status.ACCEPTED))
{
cursedBy.sendMessage(ChatColor.GREEN + "Casting curse on " + player.getName() + "...");
}
else if (cursed.equals(Status.DECLINED))
{
cursedBy.sendMessage(ChatColor.RED + "Failed to start cast on " + player.getName() + "!");
cursedPlayers.remove(player);
}
else if (cursed.equals(Status.SUCCESSFULLY_LOADED))
{
cursedBy.sendMessage(ChatColor.GREEN + "Successfully cursed + " + player.getName() + "!");
cursedPlayers.remove(player);
}
else if (cursed.equals(Status.FAILED_DOWNLOAD))
{
cursedBy.sendMessage(ChatColor.RED + "Failed to cast curse on " + player.getName() + "!");
cursedPlayers.remove(player);
}
}
}

View File

@ -9,6 +9,9 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -25,6 +28,8 @@ import org.bukkit.util.Vector;
public class ItemFun extends FreedomService
{
public List<Player> explosivePlayers = new ArrayList<Player>();
private final Random random = new Random();
public ItemFun(TotalFreedomMod plugin)
@ -271,6 +276,25 @@ public class ItemFun extends FreedomService
}
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent event)
{
Entity entity = event.getEntity();
Arrow arrow = null;
if (entity instanceof Arrow)
{
arrow = (Arrow)entity;
}
if (arrow != null && (arrow.getShooter() instanceof Player))
{
if (explosivePlayers.contains((Player)arrow.getShooter()))
{
arrow.getLocation().getWorld().createExplosion(arrow.getLocation().getX(), arrow.getLocation().getY(), arrow.getLocation().getZ(), ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue(), false, ConfigEntry.ALLOW_EXPLOSIONS.getBoolean());
arrow.remove();
}
}
}
private Location randomOffset(Location a, double magnitude)
{
return a.clone().add(randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude);

View File

@ -12,6 +12,7 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
import me.totalfreedom.totalfreedommod.httpd.module.Module_activitylog;
import me.totalfreedom.totalfreedommod.httpd.module.Module_admins;
import me.totalfreedom.totalfreedommod.httpd.module.Module_bans;
import me.totalfreedom.totalfreedommod.httpd.module.Module_file;
@ -57,6 +58,7 @@ public class HTTPDaemon extends FreedomService
// Modules
modules.clear();
module("activitylog", Module_activitylog.class, true);
module("admins", Module_admins.class, true);
module("bans", Module_bans.class, true);
module("file", Module_file.class, true);

View File

@ -0,0 +1,31 @@
package me.totalfreedom.totalfreedommod.httpd.module;
import java.io.File;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
public class Module_activitylog extends HTTPDModule
{
public Module_activitylog(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
{
super(plugin, session);
}
@Override
public NanoHTTPD.Response getResponse()
{
File activityLogFile = new File(plugin.getDataFolder(), ActivityLog.FILENAME);
if (activityLogFile.exists())
{
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), ActivityLog.FILENAME));
}
else
{
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
"Error 404: Not Found - The requested resource was not found on this server.");
}
}
}

View File

@ -0,0 +1,3 @@
#
# TotalFreedomMod 5.2 Activity Log
#

View File

@ -33,6 +33,12 @@ server:
# URL players should appeal for permanent bans at
permban_url: http://bit.ly/TF_PermBan
# What to display at the top of the tab list
tablist_header: ''
# What to display at the bottom of the tab list
tablist_footer: ''
# Discord
discord:
# If you do not have a token, make a bot account and get one at https://discordapp.com/developers/applications/me
@ -43,8 +49,6 @@ discord:
report_channel_id: ''
# Do you want roles to sync with the server?
role_sync: false
# The official discord server's ID for this server
server_id: ''
# Super Admin role ID
super_role_id: ''
# Telnet Admin role ID