mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-11 19:02:13 +01:00
Support both MC 1.7.10 and 1.8.
This commit is contained in:
parent
e747e3a3fa
commit
f33889b88f
15
pom.xml
15
pom.xml
@ -137,6 +137,16 @@
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- Contains parts of Guava that are not compatible
|
||||
between Bukkit 10.0.1 and 17+ -->
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>guavabackport</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>compile</scope>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
@ -377,9 +387,14 @@
|
||||
<include>org.khelekore:prtree</include>
|
||||
<include>org.flywaydb:flyway-core</include>
|
||||
<include>com.sk89q:squirrelid</include>
|
||||
<include>com.sk89q:guavabackport</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.sk89q.guavabackport</pattern>
|
||||
<shadedPattern>com.sk89q.worldguard.internal.guava</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.flywaydb</pattern>
|
||||
<shadedPattern>com.sk89q.worldguard.internal.flywaydb</shadedPattern>
|
||||
|
@ -19,9 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.sk89q.worldguard.blacklist.action.Action;
|
||||
import com.sk89q.worldguard.blacklist.action.ActionType;
|
||||
import com.sk89q.worldguard.blacklist.event.BlacklistEvent;
|
||||
@ -29,6 +26,9 @@
|
||||
import com.sk89q.worldguard.blacklist.target.TargetMatcher;
|
||||
import com.sk89q.worldguard.blacklist.target.TargetMatcherParseException;
|
||||
import com.sk89q.worldguard.blacklist.target.TargetMatcherParser;
|
||||
import com.sk89q.guavabackport.cache.CacheBuilder;
|
||||
import com.sk89q.guavabackport.cache.CacheLoader;
|
||||
import com.sk89q.guavabackport.cache.LoadingCache;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -49,7 +49,7 @@ public abstract class Blacklist {
|
||||
private final BlacklistLoggerHandler blacklistLogger = new BlacklistLoggerHandler();
|
||||
private BlacklistEvent lastEvent;
|
||||
private boolean useAsWhitelist;
|
||||
private Cache<String, TrackedEvent> repeatingEventCache = CacheBuilder.newBuilder()
|
||||
private LoadingCache<String, TrackedEvent> repeatingEventCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(1000)
|
||||
.expireAfterAccess(30, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<String, TrackedEvent>() {
|
||||
@ -284,7 +284,7 @@ public void notify(BlacklistEvent event, String comment) {
|
||||
*/
|
||||
public abstract void broadcastNotification(String msg);
|
||||
|
||||
public Cache<String, TrackedEvent> getRepeatingEventCache() {
|
||||
public LoadingCache<String, TrackedEvent> getRepeatingEventCache() {
|
||||
return repeatingEventCache;
|
||||
}
|
||||
|
||||
|
@ -19,20 +19,14 @@
|
||||
|
||||
package com.sk89q.worldguard.blacklist;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.action.Action;
|
||||
import com.sk89q.worldguard.blacklist.action.ActionResult;
|
||||
import com.sk89q.worldguard.blacklist.event.BlacklistEvent;
|
||||
import com.sk89q.guavabackport.cache.LoadingCache;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class BlacklistEntry {
|
||||
|
||||
@ -178,7 +172,7 @@ public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean force
|
||||
|
||||
boolean repeating = false;
|
||||
String eventCacheKey = event.getCauseName();
|
||||
Cache<String, TrackedEvent> repeatingEventCache = blacklist.getRepeatingEventCache();
|
||||
LoadingCache<String, TrackedEvent> repeatingEventCache = blacklist.getRepeatingEventCache();
|
||||
|
||||
// Check to see whether this event is being repeated
|
||||
TrackedEvent tracked = repeatingEventCache.getUnchecked(eventCacheKey);
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Ranges;
|
||||
import com.sk89q.guavabackport.collect.Range;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldguard.util.Enums;
|
||||
import org.bukkit.Material;
|
||||
@ -84,22 +84,22 @@ private Predicate<Short> parseRange(String input) throws TargetMatcherParseExcep
|
||||
|
||||
matcher = LESS_THAN_PATTERN.matcher(input);
|
||||
if (matcher.matches()) {
|
||||
return Ranges.atMost(Short.parseShort(matcher.group(1)));
|
||||
return Range.atMost(Short.parseShort(matcher.group(1)));
|
||||
}
|
||||
|
||||
matcher = GREATER_THAN_PATTERN.matcher(input);
|
||||
if (matcher.matches()) {
|
||||
return Ranges.atLeast(Short.parseShort(matcher.group(1)));
|
||||
return Range.atLeast(Short.parseShort(matcher.group(1)));
|
||||
}
|
||||
|
||||
matcher = RANGE_PATTERN.matcher(input);
|
||||
if (matcher.matches()) {
|
||||
return Ranges.closed(Short.parseShort(matcher.group(1)), Short.parseShort(matcher.group(2)));
|
||||
return Range.closed(Short.parseShort(matcher.group(1)), Short.parseShort(matcher.group(2)));
|
||||
}
|
||||
|
||||
try {
|
||||
short s = Short.parseShort(input);
|
||||
return Ranges.closed(s, s);
|
||||
return Range.closed(s, s);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new TargetMatcherParseException("Unknown data value range: " + input);
|
||||
}
|
||||
|
@ -19,9 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
@ -29,6 +26,9 @@
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.listener.FlagStateManager.PlayerFlagState;
|
||||
import com.sk89q.guavabackport.cache.CacheBuilder;
|
||||
import com.sk89q.guavabackport.cache.CacheLoader;
|
||||
import com.sk89q.guavabackport.cache.LoadingCache;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
@ -50,7 +50,7 @@
|
||||
public class PlayerMoveListener implements Listener {
|
||||
|
||||
private final WorldGuardPlugin plugin;
|
||||
private Cache<WorldPlayerTuple, Boolean> bypassCache = CacheBuilder.newBuilder()
|
||||
private LoadingCache<WorldPlayerTuple, Boolean> bypassCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(1000)
|
||||
.expireAfterAccess(5, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<WorldPlayerTuple, Boolean>() {
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener.debounce;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.sk89q.worldguard.bukkit.util.Events;
|
||||
import com.sk89q.guavabackport.cache.CacheBuilder;
|
||||
import com.sk89q.guavabackport.cache.CacheLoader;
|
||||
import com.sk89q.guavabackport.cache.LoadingCache;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
public class EventDebounce<K> {
|
||||
|
||||
private final Cache<K, Entry> cache;
|
||||
private final LoadingCache<K, Entry> cache;
|
||||
|
||||
public EventDebounce(int debounceTime) {
|
||||
cache = CacheBuilder.newBuilder()
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener.debounce.legacy;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.sk89q.worldguard.bukkit.util.Events;
|
||||
import com.sk89q.guavabackport.cache.CacheBuilder;
|
||||
import com.sk89q.guavabackport.cache.CacheLoader;
|
||||
import com.sk89q.guavabackport.cache.LoadingCache;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
public class AbstractEventDebounce<K> {
|
||||
|
||||
private final Cache<K, Entry> cache;
|
||||
private final LoadingCache<K, Entry> cache;
|
||||
|
||||
AbstractEventDebounce(int debounceTime) {
|
||||
cache = CacheBuilder.newBuilder()
|
||||
|
Loading…
Reference in New Issue
Block a user