Merge branch 'development' into FS-7

This commit is contained in:
Video 2021-11-29 03:01:22 -07:00 committed by GitHub
commit 1ecfb0b066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 23 deletions

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

@ -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

@ -111,6 +111,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

@ -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

@ -161,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: