Skip to content

Commit

Permalink
It compiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Jul 22, 2018
1 parent 45832b9 commit 04fc889
Show file tree
Hide file tree
Showing 41 changed files with 1,018 additions and 689 deletions.
Expand Up @@ -22,6 +22,7 @@
import static com.google.common.base.Preconditions.checkNotNull;

import com.sk89q.worldguard.internal.platform.WorldGuardPlatform;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;

Expand All @@ -40,7 +41,7 @@ public static WorldGuard getInstance() {
}

public WorldGuard() {
flagRegistry.setInitialized(true);
Flags.registerAll();
}

/**
Expand Down
Expand Up @@ -19,6 +19,7 @@

package com.sk89q.worldguard.config;

import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldguard.blacklist.Blacklist;
import com.sk89q.worldguard.util.report.Unreported;

Expand Down Expand Up @@ -66,4 +67,23 @@ public Blacklist getBlacklist() {
public String getWorldName() {
return this.worldName;
}

public String convertLegacyItem(String legacy) {
String item = legacy;
try {
String[] splitter = item.split(":", 2);
int id = 0;
byte data = 0;
if (splitter.length == 1) {
id = Integer.parseInt(item);
} else {
id = Integer.parseInt(splitter[0]);
data = Byte.parseByte(splitter[1]);
}
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
} catch (Throwable e) {
}

return item;
}
}
Expand Up @@ -17,14 +17,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldguard.bukkit.protection;
package com.sk89q.worldguard.protection;

import com.sk89q.worldedit.util.Location;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import com.sk89q.worldguard.domains.Association;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.association.RegionAssociable;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import org.bukkit.Location;

import javax.annotation.Nullable;
import java.util.List;
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -23,6 +23,7 @@

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -65,6 +66,13 @@ public interface FlagRegistry extends Iterable<Flag<?>> {
@Nullable
Flag<?> get(String name);

/**
* Get all flags
*
* @return All flags
*/
List<Flag<?>> getAll();

/**
* Unmarshal a raw map of values into a map of flags with their
* unmarshalled values.
Expand Down
Expand Up @@ -21,12 +21,14 @@

import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.sk89q.worldguard.protection.flags.Flag;

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentMap;
Expand All @@ -41,7 +43,7 @@ public class SimpleFlagRegistry implements FlagRegistry {

private final Object lock = new Object();
private final ConcurrentMap<String, Flag<?>> flags = Maps.newConcurrentMap();
private boolean initialized;
private boolean initialized = false;

public boolean isInitialized() {
return initialized;
Expand Down Expand Up @@ -98,6 +100,11 @@ public Flag<?> get(String name) {
return flags.get(name.toLowerCase());
}

@Override
public List<Flag<?>> getAll() {
return Lists.newArrayList(this.flags.values());
}

private Flag<?> getOrCreate(String name) {
Flag<?> flag = get(name);

Expand Down
Expand Up @@ -64,7 +64,7 @@ public Session(SessionManager manager) {
*
* @param handler A new handler
*/
void register(Handler handler) {
public void register(Handler handler) {
handlers.put(handler.getClass(), handler);
}

Expand Down Expand Up @@ -95,7 +95,7 @@ public <T extends Handler> T getHandler(Class<T> type) {
*
* @param player The player
*/
void initialize(LocalPlayer player) {
public void initialize(LocalPlayer player) {
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
Location location = player.getLocation();
ApplicableRegionSet set = query.getApplicableRegions(location);
Expand All @@ -113,7 +113,7 @@ void initialize(LocalPlayer player) {
*
* @param player The player
*/
void tick(LocalPlayer player) {
public void tick(LocalPlayer player) {
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
Location location = player.getLocation();
ApplicableRegionSet set = query.getApplicableRegions(location);
Expand All @@ -128,7 +128,7 @@ void tick(LocalPlayer player) {
*
* @param player The player
*/
void resetState(LocalPlayer player) {
public void resetState(LocalPlayer player) {
initialize(player);
needRefresh.set(true);
}
Expand Down
Expand Up @@ -22,12 +22,12 @@
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.LocalPlayer;

class WorldPlayerTuple {
public class WorldPlayerTuple {

final World world;
final LocalPlayer player;
private final World world;
private final LocalPlayer player;

WorldPlayerTuple(World world, LocalPlayer player) {
public WorldPlayerTuple(World world, LocalPlayer player) {
this.world = world;
this.player = player;
}
Expand All @@ -45,6 +45,14 @@ public boolean equals(Object o) {
return true;
}

public LocalPlayer getPlayer() {
return player;
}

public World getWorld() {
return world;
}

@Override
public int hashCode() {
int result = world.hashCode();
Expand Down
@@ -1,3 +1,22 @@
/*
* WorldGuard, a suite of tools for Minecraft
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldguard.bukkit;

import com.sk89q.worldedit.WorldEdit;
Expand Down
Expand Up @@ -208,6 +208,6 @@ public static Target createTarget(ItemStack item) {
*/
public static Target createTarget(Material material) {
checkNotNull(material);
return new ItemTarget(BukkitAdapter.adapt(material));
return new ItemTarget(BukkitAdapter.asItemType(material));
}
}
Expand Up @@ -22,6 +22,7 @@
import com.sk89q.util.yaml.YAMLFormat;
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.Blacklist;
import com.sk89q.worldguard.blacklist.BlacklistLoggerHandler;
Expand Down Expand Up @@ -127,7 +128,7 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
public boolean disableMobDamage;
public boolean highFreqFlags;
public boolean checkLiquidFlow;
public int regionWand;
public String regionWand;
public Set<EntityType> blockCreatureSpawn;
public boolean allowTamedSpawns;
// public boolean useiConomy;
Expand Down Expand Up @@ -361,7 +362,7 @@ public void loadConfiguration() {
explosionFlagCancellation = getBoolean("regions.explosion-flags-block-entity-damage", true);
highFreqFlags = getBoolean("regions.high-frequency-flags", false);
checkLiquidFlow = getBoolean("regions.protect-against-liquid-flow", false);
regionWand = getInt("regions.wand", 334);
regionWand = convertLegacyItem(getString("regions.wand", ItemTypes.LEATHER.getId()));
maxClaimVolume = getInt("regions.max-claim-volume", 30000);
claimOnlyInsideExistingRegions = getBoolean("regions.claim-only-inside-existing-regions", false);
boundedLocationFlags = getBoolean("regions.location-flags-only-inside-regions", false);
Expand Down
@@ -1,3 +1,22 @@
/*
* WorldGuard, a suite of tools for Minecraft
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldguard.bukkit;

import com.sk89q.worldedit.bukkit.BukkitAdapter;
Expand All @@ -11,7 +30,7 @@
import com.sk89q.worldguard.protection.flags.FlagContext;
import com.sk89q.worldguard.protection.flags.FlagContextCreateEvent;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.session.BukkitSessionManager;
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
import com.sk89q.worldguard.session.SessionManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
Expand Down
Expand Up @@ -73,11 +73,12 @@
import com.sk89q.worldguard.bukkit.util.Events;
import com.sk89q.worldguard.protection.GlobalRegionManager;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
import com.sk89q.worldguard.protection.managers.storage.StorageException;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.util.UnresolvedNamesException;
import com.sk89q.worldguard.session.BukkitSessionManager;
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
import com.sk89q.worldguard.util.concurrent.EvenMoreExecutors;
import com.sk89q.worldguard.util.logging.ClassSourceValidator;
import com.sk89q.worldguard.util.logging.RecordMessagePrefixer;
Expand Down Expand Up @@ -255,6 +256,8 @@ public void run() {
ProcessPlayerEvent event = new ProcessPlayerEvent(player);
Events.fire(event);
}

((SimpleFlagRegistry) WorldGuard.getInstance().getFlagRegistry()).setInitialized(true);
}

@Override
Expand Down

0 comments on commit 04fc889

Please sign in to comment.