Merge branch 'development' into Elmon11-patch-2

This commit is contained in:
Nathan Curran 2022-01-24 12:41:47 +11:00 committed by GitHub
commit 1c4647290a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 236 additions and 205 deletions

View File

@ -177,7 +177,7 @@
<dependency> <dependency>
<groupId>net.coreprotect</groupId> <groupId>net.coreprotect</groupId>
<artifactId>coreprotect</artifactId> <artifactId>coreprotect</artifactId>
<version>19.5</version> <version>20.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -1,98 +0,0 @@
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 static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
public class SavedFlags extends FreedomService
{
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
@SuppressWarnings("unchecked")
public Map<String, Boolean> getSavedFlags()
{
Map<String, Boolean> flags = null;
File input = new File(TotalFreedomMod.getPlugin().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);
}
}
}

View File

@ -75,7 +75,6 @@ public class TotalFreedomMod extends JavaPlugin
public CommandLoader cl; public CommandLoader cl;
// Services // Services
public ServerInterface si; public ServerInterface si;
public SavedFlags sf;
public WorldManager wm; public WorldManager wm;
public LogViewer lv; public LogViewer lv;
public AdminList al; public AdminList al;
@ -187,7 +186,6 @@ public class TotalFreedomMod extends JavaPlugin
fsh = new FreedomServiceHandler(); fsh = new FreedomServiceHandler();
config = new MainConfig(); config = new MainConfig();
config.load();
if (FUtil.inDeveloperMode()) if (FUtil.inDeveloperMode())
{ {
@ -299,7 +297,6 @@ public class TotalFreedomMod extends JavaPlugin
{ {
// Start services // Start services
si = new ServerInterface(); si = new ServerInterface();
sf = new SavedFlags();
wm = new WorldManager(); wm = new WorldManager();
lv = new LogViewer(); lv = new LogViewer();
sql = new SQLite(); sql = new SQLite();

View File

@ -192,7 +192,6 @@ public class CoreProtectBridge extends FreedomService
return (megabytes / 1024); return (megabytes / 1024);
} }
// Wipes DB for the specified world
public void clearDatabase(World world) public void clearDatabase(World world)
{ {
clearDatabase(world, false); clearDatabase(world, false);
@ -260,12 +259,6 @@ public class CoreProtectBridge extends FreedomService
{ {
FLog.warning("Failed to delete the CoreProtect data for the " + world.getName()); FLog.warning("Failed to delete the CoreProtect data for the " + world.getName());
} }
// This exits for flatlands wipes
if (shutdown)
{
server.shutdown();
}
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)

View File

@ -1,13 +1,20 @@
package me.totalfreedom.totalfreedommod.bridge; package me.totalfreedom.totalfreedommod.bridge;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer; import com.sk89q.worldguard.protection.regions.RegionContainer;
import java.util.Map; import java.util.Map;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public class WorldGuardBridge extends FreedomService public class WorldGuardBridge extends FreedomService
@ -23,6 +30,16 @@ public class WorldGuardBridge extends FreedomService
{ {
} }
public boolean canEditCurrentWorld(Player player)
{
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
return query.testBuild(localPlayer.getLocation(), localPlayer);
}
public RegionManager getRegionManager(World world) public RegionManager getRegionManager(World world)
{ {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();

View File

@ -9,8 +9,11 @@ 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;
import java.util.ArrayList;
import java.util.List;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) @CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Shows the amount of coins you have or another player has", usage = "/<command> [playername]") @CommandParameters(description = "Shows the amount of coins you or another player has. Also allows you to give coins to other players.", usage = "/<command> [player] | pay <player> <amount>")
public class Command_coins extends FreedomCommand public class Command_coins extends FreedomCommand
{ {
@Override @Override
@ -21,34 +24,119 @@ public class Command_coins extends FreedomCommand
msg("The shop is currently disabled!", ChatColor.RED); msg("The shop is currently disabled!", ChatColor.RED);
return true; return true;
} }
Player p;
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " "); final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
if (args.length > 0)
switch (args.length)
{ {
if (getPlayer(args[0]) != null) // Mode for seeing how many coins the sender has (doesn't work from console)
case 0:
{ {
p = getPlayer(args[0]); if (senderIsConsole)
} {
else msg("When used from the console, you must define a target player.");
{ }
msg(PLAYER_NOT_FOUND); else
{
PlayerData playerData = getData(playerSender);
msg(prefix + ChatColor.GREEN + "You have " + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN
+ " coins.");
}
return true; return true;
} }
}
else // Mode for seeing how many coins a player has.
{ case 1:
if (senderIsConsole)
{ {
msg(prefix + ChatColor.RED + "You are not a player, use /coins <playername>"); Player target = getPlayer(args[0]);
if (target == null)
{
msg(PLAYER_NOT_FOUND);
}
else
{
PlayerData playerData = getData(target);
msg(prefix + ChatColor.GREEN + target.getName() + " has " + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins.");
}
return true; return true;
} }
else
// Mode for paying another player coins
case 3:
{ {
p = playerSender; if (args[0].equalsIgnoreCase("pay"))
{
checkPlayer();
final Player target = getPlayer(args[1]);
final PlayerData senderData = getData(playerSender);
int coinsToTransfer;
// Processes args[2]
try
{
// Prevents players from trying to be cheeky with negative numbers.
coinsToTransfer = Math.max(Math.abs(Integer.parseInt(args[2])), 1);
}
catch (NumberFormatException ex)
{
msg("Invalid number: " + args[2], ChatColor.RED);
return true;
}
// Prevents players from performing transactions they can't afford to do.
if (senderData.getCoins() < coinsToTransfer)
{
msg("You don't have enough coins to perform this transaction.", ChatColor.RED);
return true;
}
if (target == null)
{
msg(PLAYER_NOT_FOUND);
}
else
{
PlayerData playerData = getData(target);
playerData.setCoins(playerData.getCoins() + coinsToTransfer);
senderData.setCoins(senderData.getCoins() - coinsToTransfer);
msg(target, sender.getName()
+ ChatColor.GREEN + " has given you "
+ ChatColor.GOLD + coinsToTransfer
+ ChatColor.GREEN + " coin" + (coinsToTransfer > 1 ? "s" : "") + "!", ChatColor.GOLD);
msg("You have given "
+ ChatColor.GOLD + coinsToTransfer
+ ChatColor.GREEN + " coin" + (coinsToTransfer > 1 ? "s" : "")
+ " to " + ChatColor.GOLD + target.getName() + ChatColor.GREEN + ".", ChatColor.GREEN);
}
return true;
}
}
default:
{
return false;
} }
} }
PlayerData playerData = plugin.pl.getData(p); }
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins.");
return true; @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1)
{
List<String> options = new ArrayList<>(FUtil.getPlayerList());
options.add("pay");
return options;
}
return FUtil.getPlayerList();
} }
} }

View File

@ -24,6 +24,10 @@ public class Command_opall extends FreedomCommand
msg(player, YOU_ARE_OP); msg(player, YOU_ARE_OP);
plugin.rm.updateDisplay(player); plugin.rm.updateDisplay(player);
} }
else
{
player.recalculatePermissions();
}
} }
return true; return true;

View File

@ -1,6 +1,8 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.EnumUtils;
@ -55,6 +57,7 @@ public class Command_spawnmob extends FreedomCommand
return true; return true;
} }
int max = ConfigEntry.SPAWNMOB_MAX.getInteger();
int amount = 1; int amount = 1;
if (args.length > 1) if (args.length > 1)
{ {
@ -69,9 +72,9 @@ public class Command_spawnmob extends FreedomCommand
} }
} }
if (amount > 10 || amount < 1) if (amount > max || amount < 1)
{ {
msg("Invalid amount: " + args[1] + ". Must be 1-10.", ChatColor.RED); msg("Invalid amount: " + args[1] + ". Must be 1-" + max + ".", ChatColor.RED);
return true; return true;
} }

View File

@ -1,11 +1,13 @@
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.shop.ShopItem;
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.ADMIN, source = SourceType.ONLY_IN_GAME) @CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/<command>") @CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/<command>")
public class Command_trail extends FreedomCommand public class Command_trail extends FreedomCommand
{ {
@ -13,6 +15,12 @@ public class Command_trail 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 (!plugin.pl.getData(playerSender).hasItem(ShopItem.RAINBOW_TRAIL))
{
msg("You didn't purchase the ability to have a " + ShopItem.RAINBOW_TRAIL.getName() + "! Purchase it from the shop.", ChatColor.RED);
return true;
}
if (plugin.tr.contains(playerSender)) if (plugin.tr.contains(playerSender))
{ {
plugin.tr.remove(playerSender); plugin.tr.remove(playerSender);
@ -21,7 +29,7 @@ public class Command_trail extends FreedomCommand
else else
{ {
plugin.tr.add(playerSender); plugin.tr.add(playerSender);
msg("Trail enabled. Use \"/trail off\" to disable."); msg("Trail enabled. Run this command again to disable it.");
} }
return true; return true;

View File

@ -45,6 +45,8 @@ public enum ConfigEntry
MOB_LIMITER_DISABLE_GIANT(Boolean.class, "moblimiter.disable.giant"), MOB_LIMITER_DISABLE_GIANT(Boolean.class, "moblimiter.disable.giant"),
MOB_LIMITER_DISABLE_SLIME(Boolean.class, "moblimiter.disable.slime"), MOB_LIMITER_DISABLE_SLIME(Boolean.class, "moblimiter.disable.slime"),
// //
SPAWNMOB_MAX(Integer.class, "spawnmob.max"),
//
HTTPD_ENABLED(Boolean.class, "httpd.enabled"), HTTPD_ENABLED(Boolean.class, "httpd.enabled"),
HTTPD_HOST(String.class, "httpd.host"), HTTPD_HOST(String.class, "httpd.host"),
HTTPD_PORT(Integer.class, "httpd.port"), HTTPD_PORT(Integer.class, "httpd.port"),
@ -86,6 +88,7 @@ public enum ConfigEntry
DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID(String.class, "discord.assistant_executive_role_id"), DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID(String.class, "discord.assistant_executive_role_id"),
DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"), DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"),
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"), DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
DISCORD_INVITE_LINK(String.class, "discord.invite_link"),
// //
PTERO_URL(String.class, "ptero.url"), PTERO_URL(String.class, "ptero.url"),
PTERO_DEFAULT_EMAIL_DOMAIN(String.class, "ptero.default_email_domain"), PTERO_DEFAULT_EMAIL_DOMAIN(String.class, "ptero.default_email_domain"),
@ -110,6 +113,7 @@ public enum ConfigEntry
SHOP_PRICES_STACKING_POTATO(Integer.class, "shop.prices.stacking_potato"), SHOP_PRICES_STACKING_POTATO(Integer.class, "shop.prices.stacking_potato"),
SHOP_PRICES_CLOWN_FISH(Integer.class, "shop.prices.clown_fish"), SHOP_PRICES_CLOWN_FISH(Integer.class, "shop.prices.clown_fish"),
SHOP_PRICES_LOGIN_MESSAGES(Integer.class, "shop.prices.login_messages"), SHOP_PRICES_LOGIN_MESSAGES(Integer.class, "shop.prices.login_messages"),
SHOP_PRICES_RAINBOW_TRAIL(Integer.class, "shop.prices.rainbow_trail"),
// //
ADMINLIST_CLEAN_THESHOLD_HOURS(Integer.class, "adminlist.clean_threshold_hours"), ADMINLIST_CLEAN_THESHOLD_HOURS(Integer.class, "adminlist.clean_threshold_hours"),
ADMINLIST_CONSOLE_IS_ADMIN(Boolean.class, "adminlist.console_is_admin"), ADMINLIST_CONSOLE_IS_ADMIN(Boolean.class, "adminlist.console_is_admin"),

View File

@ -10,9 +10,12 @@ import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.hover.content.Text;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -28,39 +31,66 @@ public class DiscordToMinecraftListener extends ListenerAdapter
{ {
Member member = event.getMember(); Member member = event.getMember();
String tag = getDisplay(member); String tag = getDisplay(member);
StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "]");
Message msg = event.getMessage(); Message msg = event.getMessage();
ComponentBuilder emsg = new ComponentBuilder();
// Prefix
emsg.append(ChatColor.DARK_GRAY + "[");
TextComponent inviteLink = new TextComponent("Discord");
inviteLink.setColor(ChatColor.DARK_AQUA.asBungee());
inviteLink.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new Text("Click here to get the invite link!")));
inviteLink.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,
ConfigEntry.DISCORD_INVITE_LINK.getString()));
emsg.append(inviteLink);
emsg.append(ChatColor.DARK_GRAY + "] ", ComponentBuilder.FormatRetention.NONE);
// Tag (if they have one)
if (tag != null) if (tag != null)
{ {
message.append(" ").append(tag); emsg.append(tag);
}
message.append(" ").append(ChatColor.RED).append(ChatColor.stripColor(member.getEffectiveName())).append(ChatColor.DARK_GRAY).append(":").append(ChatColor.RESET);
ComponentBuilder builder = new ComponentBuilder(message.toString());
if (!msg.getContentDisplay().isEmpty())
{
builder.append(" ").append(ChatColor.stripColor(msg.getContentDisplay()));
message.append(" ").append(ChatColor.stripColor(msg.getContentDisplay())); // for logging
} }
emsg.append(" ");
// User
TextComponent user = new TextComponent(ChatColor.stripColor(member.getEffectiveName()));
user.setColor(ChatColor.RED.asBungee());
emsg.append(user);
// Message
emsg.append(ChatColor.DARK_GRAY + ": " + ChatColor.RESET
+ ChatColor.stripColor(msg.getContentDisplay()), ComponentBuilder.FormatRetention.NONE);
// Attachments
if (!msg.getAttachments().isEmpty()) if (!msg.getAttachments().isEmpty())
{ {
if (!msg.getContentDisplay().isEmpty())
emsg.append(" ");
for (Message.Attachment attachment : msg.getAttachments()) for (Message.Attachment attachment : msg.getAttachments())
{ {
attachment.getUrl(); TextComponent media = new TextComponent("[Media] ");
builder.append(" "); media.setColor(ChatColor.YELLOW.asBungee());
TextComponent text = new TextComponent(ChatColor.YELLOW + "[Media]"); media.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl())); media.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(attachment.getUrl())));
builder.append(text);
message.append(" [Media]"); // for logging emsg.append(media, ComponentBuilder.FormatRetention.NONE);
} }
} }
BaseComponent[] components = emsg.create();
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
{ {
if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord()) if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord())
{ {
player.spigot().sendMessage(builder.create()); player.spigot().sendMessage(components);
} }
} }
FLog.info(message.toString());
FLog.info(TextComponent.toLegacyText(components), true);
} }
} }
} }

View File

@ -4,7 +4,10 @@ import java.util.HashSet;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.SplittableRandom; import java.util.SplittableRandom;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
import me.totalfreedom.totalfreedommod.util.Groups; import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -18,7 +21,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class Trailer extends FreedomService public class Trailer extends FreedomService
{ {
private final SplittableRandom random = new SplittableRandom(); private final SplittableRandom random = new SplittableRandom();
private final Set<String> trailPlayers = new HashSet<>(); // player name private final Set<UUID> trailPlayers = new HashSet<>(); // player UUID
@Override @Override
public void onStart() public void onStart()
@ -33,17 +36,17 @@ public class Trailer extends FreedomService
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) public void onPlayerMove(PlayerMoveEvent event)
{ {
if (trailPlayers.isEmpty()) /* Doesn't continue any further if...
{ * - The trail list is empty
return; * - The player doesn't have their trail enabled in the first place
} * - The player doesn't have the trail item in the shop at all
* - The player doesn't have permission to modify blocks in their current world
if (!trailPlayers.contains(event.getPlayer().getName())) */
{ if (trailPlayers.isEmpty()
return; || !trailPlayers.contains(event.getPlayer().getUniqueId())
} || !plugin.pl.getData(event.getPlayer()).hasItem(ShopItem.RAINBOW_TRAIL)
|| plugin.wr.doRestrict(event.getPlayer())
if (event.getPlayer().getWorld().equals(plugin.wm.masterBuilderWorld.getWorld())) || !plugin.wgb.canEditCurrentWorld(event.getPlayer()))
{ {
return; return;
} }
@ -69,7 +72,7 @@ public class Trailer extends FreedomService
{ {
final Location trail_pos; final Location trail_pos;
trail_pos = new Location(event.getPlayer().getWorld(), fromBlock.getX() + x, fromBlock.getY(), fromBlock.getZ() + z); trail_pos = new Location(event.getPlayer().getWorld(), fromBlock.getX() + x, fromBlock.getY(), fromBlock.getZ() + z);
if (trailPlayers.contains(event.getPlayer().getName()) && plugin.cpb.isEnabled()) if (trailPlayers.contains(event.getPlayer().getUniqueId()) && plugin.cpb.isEnabled())
{ {
plugin.cpb.getCoreProtectAPI().logPlacement(event.getPlayer().getName(), trail_pos, material, data); plugin.cpb.getCoreProtectAPI().logPlacement(event.getPlayer().getName(), trail_pos, material, data);
} }
@ -79,16 +82,16 @@ public class Trailer extends FreedomService
public void remove(Player player) public void remove(Player player)
{ {
trailPlayers.remove(player.getName()); trailPlayers.remove(player.getUniqueId());
} }
public void add(Player player) public void add(Player player)
{ {
trailPlayers.add(player.getName()); trailPlayers.add(player.getUniqueId());
} }
public boolean contains(Player player) public boolean contains(Player player)
{ {
return trailPlayers.contains(player.getName()); return trailPlayers.contains(player.getUniqueId());
} }
} }

View File

@ -10,19 +10,29 @@ public enum ShopItem
LIGHTNING_ROD("Lightning Rod", Material.BLAZE_ROD, 12, ConfigEntry.SHOP_PRICES_LIGHTNING_ROD, ChatColor.LIGHT_PURPLE, "lightningRod", "/lightningrod"), LIGHTNING_ROD("Lightning Rod", Material.BLAZE_ROD, 12, ConfigEntry.SHOP_PRICES_LIGHTNING_ROD, ChatColor.LIGHT_PURPLE, "lightningRod", "/lightningrod"),
FIRE_BALL("Fire Ball", Material.FIRE_CHARGE, 14, ConfigEntry.SHOP_PRICES_FIRE_BALL, ChatColor.RED, "fireBall", "/fireball"), FIRE_BALL("Fire Ball", Material.FIRE_CHARGE, 14, ConfigEntry.SHOP_PRICES_FIRE_BALL, ChatColor.RED, "fireBall", "/fireball"),
RIDEABLE_PEARL("Rideable Ender Pearl", Material.ENDER_PEARL, 16, ConfigEntry.SHOP_PRICES_RIDEABLE_PEARL, ChatColor.DARK_PURPLE, "rideablePearl", "/rideablepearl"), RIDEABLE_PEARL("Rideable Ender Pearl", Material.ENDER_PEARL, 16, ConfigEntry.SHOP_PRICES_RIDEABLE_PEARL, ChatColor.DARK_PURPLE, "rideablePearl", "/rideablepearl"),
STACKING_POTATO("Stacking Potato", Material.POTATO, 20, ConfigEntry.SHOP_PRICES_STACKING_POTATO, ChatColor.YELLOW, "stackingPotato", "/stackingpotato"), STACKING_POTATO("Stacking Potato", Material.POTATO, 19, ConfigEntry.SHOP_PRICES_STACKING_POTATO, ChatColor.YELLOW, "stackingPotato", "/stackingpotato"),
CLOWN_FISH("Clown Fish", Material.TROPICAL_FISH, 22, ConfigEntry.SHOP_PRICES_CLOWN_FISH, ChatColor.GOLD, "clownFish", "/clownfish"), CLOWN_FISH("Clown Fish", Material.TROPICAL_FISH, 21, ConfigEntry.SHOP_PRICES_CLOWN_FISH, ChatColor.GOLD, "clownFish", "/clownfish"),
LOGIN_MESSAGES("Login Messages", Material.NAME_TAG, 24, ConfigEntry.SHOP_PRICES_LOGIN_MESSAGES, ChatColor.DARK_GREEN, "loginMessages", "/loginmessage"); LOGIN_MESSAGES("Login Messages", Material.NAME_TAG, 23, ConfigEntry.SHOP_PRICES_LOGIN_MESSAGES, ChatColor.DARK_GREEN, "loginMessages", "/loginmessage"),
RAINBOW_TRAIL("Rainbow Trail", Material.RED_WOOL, 25, ConfigEntry.SHOP_PRICES_RAINBOW_TRAIL, ChatColor.DARK_RED, "rainbowTrail", "/trail");
/* /*
Shop GUI Layout: Shop GUI Layout:
Dimensions: 9x4 = 36 Dimensions: 9x4 = 36
Key: g = Grappling Hook, l = Lightning Rod, f = Fire Ball, r = Rideable Ender Pearl, s = Stacking Potato, c = Clown Fish, x = Login Messages $ = Coins} Key:
g = Grappling Hook,
l = Lightning Rod
f = Fire Ball
r = Rideable Ender Pearl
s = Stacking Potato
c = Clown Fish
x = Login Messages
t = Rainbow Trail
$ = Coins
--------- ---------
-g-l-f-r- -g-l-f-r-
--s-c-x-- -s-c-x-t-
--------$ --------$
*/ */

View File

@ -36,8 +36,6 @@ import static org.bukkit.Bukkit.getServer;
public class FUtil public class FUtil
{ {
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
/* See https://github.com/TotalFreedom/License - None of the listed names may be removed. /* See https://github.com/TotalFreedom/License - None of the listed names may be removed.
Leaving this list here for anyone running TFM on a cracked server: Leaving this list here for anyone running TFM on a cracked server:
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "Telesphoreo", "CoolJWB"); public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "Telesphoreo", "CoolJWB");

View File

@ -1,9 +1,6 @@
package me.totalfreedom.totalfreedommod.world; package me.totalfreedom.totalfreedommod.world;
import java.io.File;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -32,8 +29,6 @@ public class Flatlands extends CustomWorld
return null; return null;
} }
wipeFlatlandsIfFlagged();
final WorldCreator worldCreator = new WorldCreator(getName()); final WorldCreator worldCreator = new WorldCreator(getName());
worldCreator.generateStructures(false); worldCreator.generateStructures(false);
worldCreator.type(WorldType.NORMAL); worldCreator.type(WorldType.NORMAL);
@ -63,32 +58,4 @@ public class Flatlands extends CustomWorld
return world; return world;
} }
public void wipeFlatlandsIfFlagged()
{
boolean doFlatlandsWipe = false;
try
{
doFlatlandsWipe = plugin.sf.getSavedFlag("do_wipe_flatlands");
}
catch (Exception ignored)
{
}
if (doFlatlandsWipe)
{
if (Bukkit.getServer().getWorld("flatlands") == null)
{
FLog.info("Wiping flatlands.");
plugin.sf.setSavedFlag("do_wipe_flatlands", false);
FileUtils.deleteQuietly(new File("./flatlands"));
}
else
{
FLog.severe("Can't wipe flatlands, it is already loaded.");
}
}
}
} }

View File

@ -84,6 +84,8 @@ discord:
executive_role_id: '' executive_role_id: ''
# Owner role ID # Owner role ID
server_owner_role_id: '' server_owner_role_id: ''
# Invite link for your Discord server
invite_link: 'https://discord.com/invite/PW4savJR9a'
# Pterodactyl # Pterodactyl
ptero: ptero:
@ -159,6 +161,7 @@ shop:
stacking_potato: 300 stacking_potato: 300
clown_fish: 1500 clown_fish: 1500
login_messages: 5000 login_messages: 5000
rainbow_trail: 1500
# Admin list # Admin list
adminlist: adminlist:
@ -506,6 +509,10 @@ moblimiter:
slime: true slime: true
giant: true giant: true
# Spawnmob
spawnmob:
max: 25
# Flatlands # Flatlands
flatlands: flatlands:
generate: true generate: true