Permalink
Browse files

It compiles

  • Loading branch information...
me4502 committed Dec 21, 2018
1 parent db740e7 commit 8088d0dac6031163e48040f2cf8b702ca14b70a7
Showing with 730 additions and 527 deletions.
  1. +8 −0 worldguard-core/src/main/java/com/sk89q/worldguard/LocalPlayer.java
  2. +33 −0 worldguard-core/src/main/java/com/sk89q/worldguard/WorldGuard.java
  3. +3 −2 worldguard-core/src/main/java/com/sk89q/worldguard/blacklist/Blacklist.java
  4. +3 −10 ...orldguard/bukkit → worldguard-core/src/main/java/com/sk89q/worldguard}/commands/CommandUtils.java
  5. +5 −5 ...uard/bukkit → worldguard-core/src/main/java/com/sk89q/worldguard}/commands/DebuggingCommands.java
  6. +13 −75 ...dguard/bukkit → worldguard-core/src/main/java/com/sk89q/worldguard}/commands/GeneralCommands.java
  7. +3 −3 ...ard/bukkit → worldguard-core/src/main/java/com/sk89q/worldguard}/commands/ProtectionCommands.java
  8. +8 −8 ...ldguard/bukkit → worldguard-core/src/main/java/com/sk89q/worldguard}/commands/ToggleCommands.java
  9. +7 −17 ...ard/bukkit → worldguard-core/src/main/java/com/sk89q/worldguard}/commands/WorldGuardCommands.java
  10. +1 −1 .../bukkit → worldguard-core/src/main/java/com/sk89q/worldguard}/commands/region/MemberCommands.java
  11. +5 −8 .../bukkit → worldguard-core/src/main/java/com/sk89q/worldguard}/commands/region/RegionCommands.java
  12. +2 −2 ...kit → worldguard-core/src/main/java/com/sk89q/worldguard}/commands/region/RegionCommandsBase.java
  13. +173 −0 worldguard-core/src/main/java/com/sk89q/worldguard/internal/platform/StringMatcher.java
  14. +33 −30 worldguard-core/src/main/java/com/sk89q/worldguard/internal/platform/WorldGuardPlatform.java
  15. +1 −1 worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/LazyLocation.java
  16. +2 −1 worldguard-core/src/main/java/com/sk89q/worldguard/session/handler/EntryFlag.java
  17. +2 −1 worldguard-core/src/main/java/com/sk89q/worldguard/session/handler/ExitFlag.java
  18. +3 −2 worldguard-core/src/main/java/com/sk89q/worldguard/session/handler/FarewellFlag.java
  19. +3 −2 worldguard-core/src/main/java/com/sk89q/worldguard/session/handler/GreetingFlag.java
  20. +5 −0 worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitOfflinePlayer.java
  21. +7 −0 worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitPlayer.java
  22. +242 −0 worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitStringMatcher.java
  23. +2 −2 worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldConfiguration.java
  24. +100 −31 worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldGuardPlatform.java
  25. +4 −302 worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java
  26. +1 −1 worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionFlagsListener.java
  27. +5 −3 worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardEntityListener.java
  28. +27 −20 worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/Entities.java
  29. +29 −0 worldguard-legacy/src/test/java/com/sk89q/worldguard/TestPlayer.java
@@ -20,6 +20,7 @@
package com.sk89q.worldguard;

import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldguard.domains.Association;
import com.sk89q.worldguard.protection.association.RegionAssociable;
@@ -189,4 +190,11 @@ default Association getAssociation(List<ProtectedRegion> regions) {
* @param fireTicks The fire ticks
*/
void setFireTicks(int fireTicks);

/**
* Sets the target of the compass
*
* @param location The location
*/
void setCompassTarget(Location location);
}
@@ -33,6 +33,7 @@
import com.sk89q.squirrelid.resolver.CombinedProfileService;
import com.sk89q.squirrelid.resolver.HttpRepositoryService;
import com.sk89q.squirrelid.resolver.ProfileService;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.task.SimpleSupervisor;
import com.sk89q.worldedit.util.task.Supervisor;
@@ -56,7 +57,9 @@

public static final Logger logger = Logger.getLogger(WorldGuard.class.getCanonicalName());

private static String version;
private static final WorldGuard instance = new WorldGuard();

private WorldGuardPlatform platform;
private final SimpleFlagRegistry flagRegistry = new SimpleFlagRegistry();
private final Supervisor supervisor = new SimpleSupervisor();
@@ -209,4 +212,34 @@ public void disable() {

platform.unload();
}

/**
* Get the version.
*
* @return the version of WorldEdit
*/
public static String getVersion() {
if (version != null) {
return version;
}

Package p = WorldEdit.class.getPackage();

if (p == null) {
p = Package.getPackage("com.sk89q.worldguard");
}

if (p == null) {
version = "(unknown)";
} else {
version = p.getImplementationVersion();

if (version == null) {
version = "(unknown)";
}
}

return version;
}

}
@@ -33,6 +33,7 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.sk89q.worldguard.commands.CommandUtils;

import java.io.BufferedReader;
import java.io.File;
@@ -185,10 +186,10 @@ public void load(File file) throws IOException {
entry.setIgnorePermissions(parts[1].split(","));

} else if (parts[0].equalsIgnoreCase("message")) {
entry.setMessage(WorldGuard.getInstance().getPlatform().replaceColorMacros(parts[1].trim()));
entry.setMessage(CommandUtils.replaceColorMacros(parts[1].trim()));

} else if (parts[0].equalsIgnoreCase("comment")) {
entry.setComment(WorldGuard.getInstance().getPlatform().replaceColorMacros(parts[1].trim()));
entry.setComment(CommandUtils.replaceColorMacros(parts[1].trim()));

} else {
boolean found = false;
@@ -17,14 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldguard.bukkit.commands;
package com.sk89q.worldguard.commands;

import com.google.common.base.Function;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.Style;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

import javax.annotation.Nullable;

@@ -93,12 +90,8 @@ public static String replaceColorMacros(String str) {
public static String getOwnerName(@Nullable Object owner) {
if (owner == null) {
return "?";
} else if (owner instanceof Player) {
return ((Player) owner).getName();
} else if (owner instanceof ConsoleCommandSender) {
return "*CONSOLE*";
} else if (owner instanceof BlockCommandSender) {
return ((BlockCommandSender) owner).getBlock().getLocation().toString();
} else if (owner instanceof Actor) {
return ((Actor) owner).getName();
} else {
return "?";
}
@@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldguard.bukkit.commands;
package com.sk89q.worldguard.commands;

import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
@@ -43,29 +43,29 @@ public DebuggingCommands(WorldGuard worldGuard) {
@Command(aliases = {"testbreak"}, usage = "[player]", desc = "Simulate a block break", min = 1, max = 1, flags = "ts")
@CommandPermissions("worldguard.debug.event")
public void fireBreakEvent(CommandContext args, final Actor sender) throws CommandException {
LocalPlayer target = plugin.matchSinglePlayer(sender, args.getString(0));
LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
worldGuard.getPlatform().getDebugHandler().testBreak(sender, target, args.hasFlag('t'), args.hasFlag('s'));
}


@Command(aliases = {"testplace"}, usage = "[player]", desc = "Simulate a block place", min = 1, max = 1, flags = "ts")
@CommandPermissions("worldguard.debug.event")
public void firePlaceEvent(CommandContext args, final Actor sender) throws CommandException {
LocalPlayer target = plugin.matchSinglePlayer(sender, args.getString(0));
LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
worldGuard.getPlatform().getDebugHandler().testPlace(sender, target, args.hasFlag('t'), args.hasFlag('s'));
}

@Command(aliases = {"testinteract"}, usage = "[player]", desc = "Simulate a block interact", min = 1, max = 1, flags = "ts")
@CommandPermissions("worldguard.debug.event")
public void fireInteractEvent(CommandContext args, final Actor sender) throws CommandException {
LocalPlayer target = plugin.matchSinglePlayer(sender, args.getString(0));
LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
worldGuard.getPlatform().getDebugHandler().testInteract(sender, target, args.hasFlag('t'), args.hasFlag('s'));
}

@Command(aliases = {"testdamage"}, usage = "[player]", desc = "Simulate an entity damage", min = 1, max = 1, flags = "ts")
@CommandPermissions("worldguard.debug.event")
public void fireDamageEvent(CommandContext args, final Actor sender) throws CommandException {
LocalPlayer target = plugin.matchSinglePlayer(sender, args.getString(0));
LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
worldGuard.getPlatform().getDebugHandler().testDamage(sender, target, args.hasFlag('t'), args.hasFlag('s'));
}
}
@@ -17,22 +17,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldguard.bukkit.commands;
package com.sk89q.worldguard.commands;

import com.google.common.collect.Lists;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.config.ConfigurationManager;
import com.sk89q.worldguard.session.Session;
import com.sk89q.worldguard.session.handler.GodMode;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

public class GeneralCommands {
private final WorldGuard worldGuard;
@@ -44,19 +42,17 @@ public GeneralCommands(WorldGuard worldGuard) {
@Command(aliases = {"god"}, usage = "[player]",
desc = "Enable godmode on a player", flags = "s", max = 1)
public void god(CommandContext args, Actor sender) throws CommandException, AuthorizationException {
ConfigurationManager config = WorldGuard.getInstance().getPlatform().getGlobalStateManager();

Iterable<? extends LocalPlayer> targets = null;
boolean included = false;

// Detect arguments based on the number of arguments provided
if (args.argsLength() == 0) {
targets = plugin.matchPlayers(worldGuard.checkPlayer(sender));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));

// Check permissions!
sender.checkPermission("worldguard.god");
} else {
targets = plugin.matchPlayers(sender, args.getString(0));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));

// Check permissions!
sender.checkPermission("worldguard.god.other");
@@ -96,12 +92,12 @@ public void ungod(CommandContext args, Actor sender) throws CommandException, Au

// Detect arguments based on the number of arguments provided
if (args.argsLength() == 0) {
targets = plugin.matchPlayers(worldGuard.checkPlayer(sender));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));

// Check permissions!
sender.checkPermission("worldguard.god");
} else {
targets = plugin.matchPlayers(sender, args.getString(0));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));

// Check permissions!
sender.checkPermission("worldguard.god.other");
@@ -139,12 +135,12 @@ public void heal(CommandContext args, Actor sender) throws CommandException, Aut

// Detect arguments based on the number of arguments provided
if (args.argsLength() == 0) {
targets = plugin.matchPlayers(plugin.checkPlayer(sender));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));

// Check permissions!
sender.checkPermission("worldguard.heal");
} else if (args.argsLength() == 1) {
targets = plugin.matchPlayers(sender, args.getString(0));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));

// Check permissions!
sender.checkPermission("worldguard.heal.other");
@@ -183,12 +179,12 @@ public void slay(CommandContext args, Actor sender) throws CommandException, Aut

// Detect arguments based on the number of arguments provided
if (args.argsLength() == 0) {
targets = plugin.matchPlayers(worldGuard.checkPlayer(sender));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));

// Check permissions!
sender.checkPermission("worldguard.slay");
} else if (args.argsLength() == 1) {
targets = plugin.matchPlayers(sender, args.getString(0));
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));

// Check permissions!
sender.checkPermission("worldguard.slay.other");
@@ -222,11 +218,11 @@ public void locate(CommandContext args, Actor sender) throws CommandException {
LocalPlayer player = worldGuard.checkPlayer(sender);

if (args.argsLength() == 0) {
player.setCompassTarget(player.getWorld().getSpawnLocation());
player.setCompassTarget(new Location(player.getWorld(), player.getWorld().getSpawnPosition().toVector3()));

sender.print("Compass reset to spawn.");
} else {
Player target = plugin.matchSinglePlayer(sender, args.getString(0));
LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
player.setCompassTarget(target.getLocation());

sender.print("Compass repointed.");
@@ -237,66 +233,8 @@ public void locate(CommandContext args, Actor sender) throws CommandException {
@CommandPermissions({"worldguard.stack"})
public void stack(CommandContext args, Actor sender) throws CommandException {
LocalPlayer player = worldGuard.checkPlayer(sender);
boolean ignoreMax = player.hasPermission("worldguard.stack.illegitimate");
boolean ignoreDamaged = player.hasPermission("worldguard.stack.damaged");

ItemStack[] items = player.getInventory().getContents();
int len = items.length;

int affected = 0;

for (int i = 0; i < len; i++) {
ItemStack item = items[i];

// Avoid infinite stacks and stacks with durability
if (item == null || item.getAmount() <= 0
|| (!ignoreMax && item.getMaxStackSize() == 1)) {
continue;
}

int max = ignoreMax ? 64 : item.getMaxStackSize();

if (item.getAmount() < max) {
int needed = max - item.getAmount(); // Number of needed items until max

// Find another stack of the same type
for (int j = i + 1; j < len; j++) {
ItemStack item2 = items[j];

// Avoid infinite stacks and stacks with durability
if (item2 == null || item2.getAmount() <= 0
|| (!ignoreMax && item.getMaxStackSize() == 1)) {
continue;
}

// Same type?
// Blocks store their color in the damage value
if (item2.getType() == item.getType() &&
(ignoreDamaged || item.getDurability() == item2.getDurability()) &&
((item.getItemMeta() == null && item2.getItemMeta() == null)
|| (item.getItemMeta() != null &&
item.getItemMeta().equals(item2.getItemMeta())))) {
// This stack won't fit in the parent stack
if (item2.getAmount() > needed) {
item.setAmount(max);
item2.setAmount(item2.getAmount() - needed);
break;
// This stack will
} else {
items[j] = null;
item.setAmount(item.getAmount() + item2.getAmount());
needed = max - item.getAmount();
}

affected++;
}
}
}
}

if (affected > 0) {
player.getInventory().setContents(items);
}
WorldGuard.getInstance().getPlatform().stackPlayerInventory(player);

player.print("Items compacted into stacks!");
}
@@ -17,15 +17,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldguard.bukkit.commands;
package com.sk89q.worldguard.commands;

import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.NestedCommand;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.commands.region.MemberCommands;
import com.sk89q.worldguard.bukkit.commands.region.RegionCommands;
import com.sk89q.worldguard.commands.region.MemberCommands;
import com.sk89q.worldguard.commands.region.RegionCommands;

public class ProtectionCommands {
@SuppressWarnings("unused")
Oops, something went wrong.

0 comments on commit 8088d0d

Please sign in to comment.