diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java index d58f8761..56e2937d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java @@ -114,8 +114,7 @@ public class EssentialsBridge extends FreedomService User user = getEssentialsUser(username); if (user != null) { - Long l = FUtil.getField(user, "lastActivity"); - return (l != null) ? l : 0L; + return user.getLastOnlineActivity(); } } catch (Exception ex) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java index 79ccaa6f..bb75d14a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java @@ -48,52 +48,6 @@ public class WorldEditBridge extends FreedomService return worldeditPlugin; } - public void undo(Player player, int count) - { - try - { - LocalSession session = getPlayerSession(player); - if (session != null) - { - final BukkitPlayer bukkitPlayer = getBukkitPlayer(player); - if (bukkitPlayer != null) - { - for (int i = 0; i < count; i++) - { - session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer); - } - } - } - } - catch (Exception ex) - { - FLog.severe(ex); - } - } - - public void redo(Player player, int count) - { - try - { - LocalSession session = getPlayerSession(player); - if (session != null) - { - final BukkitPlayer bukkitPlayer = getBukkitPlayer(player); - if (bukkitPlayer != null) - { - for (int i = 0; i < count; i++) - { - session.redo(session.getBlockBag(bukkitPlayer), bukkitPlayer); - } - } - } - } - catch (Exception ex) - { - FLog.severe(ex); - } - } - public void setLimit(Player player, int limit) { try @@ -153,23 +107,4 @@ public class WorldEditBridge extends FreedomService return null; } } - - private BukkitPlayer getBukkitPlayer(Player player) - { - final WorldEditPlugin wep = getWorldEditPlugin(); - if (wep == null) - { - return null; - } - - try - { - return wep.wrapPlayer(player); - } - catch (Exception ex) - { - FLog.severe(ex); - return null; - } - } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java index ea03b670..e7632719 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java @@ -1,19 +1,12 @@ package me.totalfreedom.totalfreedommod.bridge; -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.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.flags.Flags; -import com.sk89q.worldguard.protection.managers.RegionManager; -import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.RegionContainer; -import java.util.Map; import com.sk89q.worldguard.protection.regions.RegionQuery; import me.totalfreedom.totalfreedommod.FreedomService; -import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -22,7 +15,6 @@ public class WorldGuardBridge extends FreedomService @Override public void onStart() { - plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld()); } @Override @@ -32,34 +24,19 @@ 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) - { - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - return container.get(BukkitAdapter.adapt(world)); - } - - public int wipeRegions(World world) - { - int count = 0; - RegionManager regionManager = getRegionManager(world); - if (regionManager != null) + // If WorldGuard integration is enabled, do a check with it. + if (isEnabled()) { - Map regions = regionManager.getRegions(); - for (ProtectedRegion region : regions.values()) - { - regionManager.removeRegion(region.getId()); - count++; - } + LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); + + RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); + RegionQuery query = container.createQuery(); + + return query.testBuild(localPlayer.getLocation(), localPlayer); } - return count; + + // If the plugin isn't present, return true. + return true; } public boolean isEnabled() diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java index 555d52e9..693c7cf9 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java @@ -5,7 +5,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; @@ -95,7 +94,7 @@ public class Command_whitelist extends FreedomCommand if (player == null) { - player = DepreciationAggregator.getOfflinePlayer(server, search_name); + player = server.getOfflinePlayer(search_name); } FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the whitelist", false); @@ -117,7 +116,7 @@ public class Command_whitelist extends FreedomCommand if (player == null) { - player = DepreciationAggregator.getOfflinePlayer(server, search_name); + player = server.getOfflinePlayer(search_name); } if (player.isWhitelisted()) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/DepreciationAggregator.java b/src/main/java/me/totalfreedom/totalfreedommod/util/DepreciationAggregator.java deleted file mode 100644 index fa87fc18..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/DepreciationAggregator.java +++ /dev/null @@ -1,28 +0,0 @@ -package me.totalfreedom.totalfreedommod.util; - -import java.util.HashSet; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.Server; -import org.bukkit.block.Block; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; - -@SuppressWarnings("deprecation") -public class DepreciationAggregator -{ - public static Block getTargetBlock(LivingEntity entity, HashSet transparent, int maxDistance) - { - return entity.getTargetBlock(transparent, maxDistance); - } - - public static OfflinePlayer getOfflinePlayer(Server server, String name) - { - return server.getOfflinePlayer(name); - } - - public static String getName_EntityType(EntityType et) - { - return et.getName(); - } -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java index f6988aec..520ee630 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java @@ -225,33 +225,6 @@ public class FUtil return names; } - @SuppressWarnings("unchecked") - public static UUID nameToUUID(String name) - { - try - { - JSONArray json = new JSONArray(); - json.add(name); - List headers = new ArrayList<>(); - headers.add("Accept:application/json"); - headers.add("Content-Type:application/json"); - Response response = sendRequest("https://api.mojang.com/profiles/minecraft", "POST", headers, json.toString()); - // Don't care how stupid this looks, couldn't find anything to parse a json string to something readable in java with something not horrendously huge, maybe im just retarded - Pattern pattern = Pattern.compile("(?<=\"id\":\")[a-f0-9].{31}"); - Matcher matcher = pattern.matcher(response.getMessage()); - if (matcher.find()) - { - String rawUUID = matcher.group(0).replaceFirst("([a-f0-9]{8})([a-f0-9]{4})([a-f0-9]{4})([a-f0-9]{4})([a-f0-9]+)", "$1-$2-$3-$4-$5"); - return UUID.fromString(rawUUID); - } - } - catch (Exception e) - { - FLog.severe("Failed to convert name to UUID:\n" + e.toString()); - } - return null; - } - public static Response sendRequest(String endpoint, String method, List headers, String body) throws IOException { URL url = new URL(endpoint); @@ -537,30 +510,6 @@ public class FUtil return ip; } - //getField: Borrowed from WorldEdit - @SuppressWarnings("unchecked") - public static T getField(Object from, String name) - { - Class checkClass = from.getClass(); - do - { - try - { - Field field = checkClass.getDeclaredField(name); - field.setAccessible(true); - return (T) field.get(from); - - } - catch (NoSuchFieldException | IllegalAccessException ignored) - { - } - } - while (checkClass.getSuperclass() != Object.class - && ((checkClass = checkClass.getSuperclass()) != null)); - - return null; - } - public static ChatColor randomChatColor() { return CHAT_COLOR_POOL.get(RANDOM.nextInt(CHAT_COLOR_POOL.size())); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java b/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java index 4aef7377..3dc501b0 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java @@ -32,14 +32,6 @@ public class WorldRestrictions extends FreedomService private final List BLOCKED_ESSENTIALS_COMMANDS = Arrays.asList( "bigtree", "ebigtree", "largetree", "elargetree"); - private final Map, Object> flags = new HashMap, Object>() - {{ - put(Flags.PLACE_VEHICLE, StateFlag.State.DENY); - put(Flags.DESTROY_VEHICLE, StateFlag.State.DENY); - put(Flags.ENTITY_ITEM_FRAME_DESTROY, StateFlag.State.DENY); - put(Flags.ENTITY_PAINTING_DESTROY, StateFlag.State.DENY); - }}; - @Override public void onStart() { @@ -155,20 +147,4 @@ public class WorldRestrictions extends FreedomService } } } - - public void protectWorld(World world) - { - if (!plugin.wgb.isEnabled()) - { - return; - } - - RegionManager regionManager = plugin.wgb.getRegionManager(world); - - GlobalProtectedRegion region = new GlobalProtectedRegion("__global__"); - - region.setFlags(flags); - - regionManager.addRegion(region); - } } \ No newline at end of file