Bump version, enhance project structure, minor fixes

This commit is contained in:
Gabriele C 2018-08-21 01:43:58 +02:00
parent adc81ed1d6
commit 60d23d0364
29 changed files with 333 additions and 386 deletions

View File

@ -7,37 +7,10 @@
<parent> <parent>
<groupId>org.codemc.worldguardwrapper</groupId> <groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper-parent</artifactId> <artifactId>worldguardwrapper-parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.1-SNAPSHOT</version>
</parent> </parent>
<artifactId>worldguardwrapper</artifactId> <artifactId>worldguardwrapper-api</artifactId>
<name>WorldGuardWrapper-API</name> <name>WorldGuardWrapper-API</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>worldguardwrapper-implementation-aggregated</artifactId>
<version>${project.version}</version>
<type>pom</type>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -1,9 +1,10 @@
package org.codemc.worldguardwrapper.implementation; package org.codemc.worldguardwrapper.event;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
public abstract class AbstractWrappedEvent extends Event implements Cancellable { public abstract class AbstractWrappedEvent extends Event implements Cancellable {
private Result result = Result.DEFAULT; private Result result = Result.DEFAULT;
@Override @Override
@ -18,11 +19,22 @@ public abstract class AbstractWrappedEvent extends Event implements Cancellable
} }
} }
/**
* Sets the event result.
*
* @param result the new event result
*/
public void setResult(Result result) { public void setResult(Result result) {
this.result = result; this.result = result;
} }
/**
* Returns the current event result.
*
* @return the event result
*/
public Result getResult() { public Result getResult() {
return result; return result;
} }
} }

View File

@ -1,17 +1,15 @@
package org.codemc.worldguardwrapper.event; package org.codemc.worldguardwrapper.event;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.codemc.worldguardwrapper.implementation.AbstractWrappedEvent;
import lombok.AllArgsConstructor;
import lombok.Getter;
@RequiredArgsConstructor
@Getter @Getter
@AllArgsConstructor
public class DamageEntityEvent extends AbstractWrappedEvent { public class DamageEntityEvent extends AbstractWrappedEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@ -29,5 +27,4 @@ public class DamageEntityEvent extends AbstractWrappedEvent {
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
} }

View File

@ -1,20 +1,18 @@
package org.codemc.worldguardwrapper.event; package org.codemc.worldguardwrapper.event;
import java.util.List; import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.codemc.worldguardwrapper.implementation.AbstractWrappedEvent;
import lombok.AllArgsConstructor; import java.util.List;
import lombok.Getter;
@RequiredArgsConstructor
@Getter @Getter
@AllArgsConstructor
public class UseBlockEvent extends AbstractWrappedEvent { public class UseBlockEvent extends AbstractWrappedEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();

View File

@ -1,17 +1,15 @@
package org.codemc.worldguardwrapper.event; package org.codemc.worldguardwrapper.event;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.codemc.worldguardwrapper.implementation.AbstractWrappedEvent;
import lombok.AllArgsConstructor;
import lombok.Getter;
@RequiredArgsConstructor
@Getter @Getter
@AllArgsConstructor
public class UseEntityEvent extends AbstractWrappedEvent { public class UseEntityEvent extends AbstractWrappedEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();

View File

@ -1,16 +1,17 @@
package org.codemc.worldguardwrapper.implementation; package org.codemc.worldguardwrapper.flags;
import org.bukkit.entity.Player;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.bukkit.entity.Player;
@RequiredArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public abstract class AbstractFlag<T> { @RequiredArgsConstructor
private @NonNull String name; public abstract class AbstractWrappedFlag<T> {
private @NonNull Class<T> type; @NonNull
private String name;
@NonNull
private Class<T> type;
private T defaultValue; private T defaultValue;
/** /**
@ -61,7 +62,7 @@ public abstract class AbstractFlag<T> {
/** /**
* Parse a given input to force it to a type compatible with the flag. * Parse a given input to force it to a type compatible with the flag.
* *
* @param player Player who entered the string. * @param player Player who entered the string.
* @param userInput Input string (e.g. a player input) * @param userInput Input string (e.g. a player input)
* @return A type compatible with the flag * @return A type compatible with the flag
*/ */

View File

@ -1,12 +1,11 @@
package org.codemc.worldguardwrapper.flags; package org.codemc.worldguardwrapper.flags;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.codemc.worldguardwrapper.implementation.AbstractFlag;
/** /**
* A flag that stores a boolean. * A flag that stores a boolean.
*/ */
public class BooleanFlag extends AbstractFlag<Boolean> { public class BooleanFlag extends AbstractWrappedFlag<Boolean> {
public BooleanFlag(String name) { public BooleanFlag(String name) {
this(name, false); this(name, false);

View File

@ -1,12 +1,11 @@
package org.codemc.worldguardwrapper.flags; package org.codemc.worldguardwrapper.flags;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.codemc.worldguardwrapper.implementation.AbstractFlag;
/** /**
* A flag that stores a double. * A flag that stores a double.
*/ */
public class DoubleFlag extends AbstractFlag<Double> { public class DoubleFlag extends AbstractWrappedFlag<Double> {
public DoubleFlag(String name) { public DoubleFlag(String name) {
this(name, 0d); this(name, 0d);

View File

@ -1,14 +1,11 @@
package org.codemc.worldguardwrapper.flags; package org.codemc.worldguardwrapper.flags;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.codemc.worldguardwrapper.implementation.AbstractFlag;
/** /**
* A flag that stores an enum value. * A flag that stores an enum value.
*/ */
public class EnumFlag<T extends Enum<T>> extends AbstractFlag<T> { public class EnumFlag<T extends Enum<T>> extends AbstractWrappedFlag<T> {
private Class<T> enumClass;
public EnumFlag(String name, Class<T> enumClass) { public EnumFlag(String name, Class<T> enumClass) {
this(name, enumClass, null); this(name, enumClass, null);
@ -20,11 +17,12 @@ public class EnumFlag<T extends Enum<T>> extends AbstractFlag<T> {
/** /**
* Get the enum class. * Get the enum class.
* TODO: really needed? we already have getType() -Gab
* *
* @return The enum class * @return The enum class
*/ */
public Class<T> getEnumClass() { public Class<T> getEnumClass() {
return enumClass; return getType();
} }
@Override @Override
@ -35,7 +33,7 @@ public class EnumFlag<T extends Enum<T>> extends AbstractFlag<T> {
@Override @Override
public T deserialize(Object serialized) { public T deserialize(Object serialized) {
if (serialized instanceof String) { if (serialized instanceof String) {
return Enum.valueOf(enumClass, (String) serialized); return Enum.valueOf(getEnumClass(), (String) serialized);
} else { } else {
return null; return null;
} }
@ -43,7 +41,7 @@ public class EnumFlag<T extends Enum<T>> extends AbstractFlag<T> {
@Override @Override
public T parse(Player player, String userInput) { public T parse(Player player, String userInput) {
return Enum.valueOf(enumClass, userInput); return Enum.valueOf(getEnumClass(), userInput);
} }
} }

View File

@ -1,12 +1,11 @@
package org.codemc.worldguardwrapper.flags; package org.codemc.worldguardwrapper.flags;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.codemc.worldguardwrapper.implementation.AbstractFlag;
/** /**
* A flag that stores an integer. * A flag that stores an integer.
*/ */
public class IntegerFlag extends AbstractFlag<Integer> { public class IntegerFlag extends AbstractWrappedFlag<Integer> {
public IntegerFlag(String name) { public IntegerFlag(String name) {
this(name, 0); this(name, 0);

View File

@ -1,18 +1,17 @@
package org.codemc.worldguardwrapper.flags; package org.codemc.worldguardwrapper.flags;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.codemc.worldguardwrapper.implementation.AbstractFlag;
import java.util.HashMap;
import java.util.Map;
/** /**
* A flag that stores a bukkit location. * A flag that stores a bukkit location.
*/ */
public class LocationFlag extends AbstractFlag<Location> { public class LocationFlag extends AbstractWrappedFlag<Location> {
public LocationFlag(String name) { public LocationFlag(String name) {
this(name, null); this(name, null);

View File

@ -1,28 +1,24 @@
package org.codemc.worldguardwrapper.flags; package org.codemc.worldguardwrapper.flags;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.codemc.worldguardwrapper.implementation.AbstractFlag;
import java.util.*;
/** /**
* A flag that stores a set of values of the sub flag's type. * A flag that stores a set of values of the sub flag's type.
*/ */
public class SetFlag<T> extends AbstractFlag<Set<T>> { public class SetFlag<T> extends AbstractWrappedFlag<Set<T>> {
private AbstractFlag<T> subFlag; private AbstractWrappedFlag<T> subFlag;
public SetFlag(String name, AbstractFlag<T> subFlag) { public SetFlag(String name, AbstractWrappedFlag<T> subFlag) {
this(name, new HashSet<>(), subFlag); this(name, new HashSet<>(), subFlag);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public SetFlag(String name, Set<T> defaultValue, AbstractFlag<T> subFlag) { public SetFlag(String name, Set<T> defaultValue, AbstractWrappedFlag<T> subFlag) {
super(name, (Class<Set<T>>) defaultValue.getClass(), defaultValue); super(name, (Class<Set<T>>) defaultValue.getClass(), defaultValue);
this.subFlag = subFlag;
} }
/** /**
@ -30,7 +26,7 @@ public class SetFlag<T> extends AbstractFlag<Set<T>> {
* *
* @return The stored flag type. * @return The stored flag type.
*/ */
public AbstractFlag<T> getSubType() { public AbstractWrappedFlag<T> getSubType() {
return subFlag; return subFlag;
} }

View File

@ -1,12 +1,11 @@
package org.codemc.worldguardwrapper.flags; package org.codemc.worldguardwrapper.flags;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.codemc.worldguardwrapper.implementation.AbstractFlag;
/** /**
* A flag that stores a string. * A flag that stores a string.
*/ */
public class StringFlag extends AbstractFlag<String> { public class StringFlag extends AbstractWrappedFlag<String> {
public StringFlag(String name) { public StringFlag(String name) {
this(name, ""); this(name, "");

View File

@ -0,0 +1,16 @@
package org.codemc.worldguardwrapper.region;
import java.util.Map;
import java.util.Optional;
public interface WrappedRegion {
String getId();
Optional<Object> getFlag(String name);
Map<String, Object> getFlags();
int getPriority();
}

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper-implementation</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>worldguardwrapper-implementation-aggregated</artifactId>
<packaging>pom</packaging>
<name>WorldGuardWrapper-Implementation-Aggregated</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>worldguardwrapper-implementation-v6</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>worldguardwrapper-implementation-v7</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -7,10 +7,18 @@
<parent> <parent>
<groupId>org.codemc.worldguardwrapper</groupId> <groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper-implementation</artifactId> <artifactId>worldguardwrapper-implementation</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.1-SNAPSHOT</version>
</parent> </parent>
<artifactId>worldguardwrapper-implementation-interface</artifactId> <artifactId>worldguardwrapper-implementation-interface</artifactId>
<name>WorldGuardWrapper-Implementation-Interface</name> <name>WorldGuardWrapper-Implementation-Interface</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>worldguardwrapper-api</artifactId>
<version>1.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project> </project>

View File

@ -1,20 +0,0 @@
package org.codemc.worldguardwrapper.implementation;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public abstract class AbstractRegion {
private String id;
public abstract Object getFlag(String name);
public abstract Map<String, Object> getFlags();
public abstract int getPriority();
}

View File

@ -1,7 +0,0 @@
package org.codemc.worldguardwrapper.implementation;
public abstract class AbstractWorldGuardImplementation implements IWorldGuardImplementation {
protected AbstractWorldGuardImplementation() {
}
}

View File

@ -1,15 +1,16 @@
package org.codemc.worldguardwrapper.implementation; package org.codemc.worldguardwrapper.implementation;
import java.util.Map; import lombok.NonNull;
import java.util.Optional;
import java.util.Set;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.codemc.worldguardwrapper.flags.AbstractWrappedFlag;
import org.codemc.worldguardwrapper.region.WrappedRegion;
import lombok.NonNull; import java.util.Map;
import java.util.Optional;
import java.util.Set;
public interface IWorldGuardImplementation { public interface IWorldGuardImplementation {
@ -32,7 +33,7 @@ public interface IWorldGuardImplementation {
* *
* @param player The player * @param player The player
* @param location The location * @param location The location
* @param flagName The flag's name * @param flagName The flag's name
* @return The flag's value * @return The flag's value
*/ */
Optional<Boolean> queryStateFlag(Player player, @NonNull Location location, @NonNull String flagName); Optional<Boolean> queryStateFlag(Player player, @NonNull Location location, @NonNull String flagName);
@ -65,7 +66,7 @@ public interface IWorldGuardImplementation {
* @param flag The flag * @param flag The flag
* @return The flag's value * @return The flag's value
*/ */
default <T> Optional<T> queryFlag(Player player, @NonNull Location location, @NonNull AbstractFlag<T> flag) { default <T> Optional<T> queryFlag(Player player, @NonNull Location location, @NonNull AbstractWrappedFlag<T> flag) {
return queryFlag(player, location, flag.getName(), flag.getType()); return queryFlag(player, location, flag.getName(), flag.getType());
} }
@ -75,16 +76,16 @@ public interface IWorldGuardImplementation {
* @param flag The flag to register * @param flag The flag to register
* @return Whether the flag has been registered * @return Whether the flag has been registered
*/ */
<T> boolean registerFlag(@NonNull AbstractFlag<T> flag); <T> boolean registerFlag(@NonNull AbstractWrappedFlag<T> flag);
/** /**
* Get a region by its ID. * Get a region by its ID.
* *
* @param world The world * @param world The world
* @param id ID of the region * @param id ID of the region
* @return The region * @return The region
*/ */
Optional<AbstractRegion> getRegion(World world, String id); Optional<WrappedRegion> getRegion(World world, String id);
/** /**
* Get an unmodifiable map of regions containing the state of the * Get an unmodifiable map of regions containing the state of the
@ -96,7 +97,7 @@ public interface IWorldGuardImplementation {
* @param world The world * @param world The world
* @return A map of regions * @return A map of regions
*/ */
Map<String, AbstractRegion> getRegions(World world); Map<String, WrappedRegion> getRegions(World world);
/** /**
* Get a set of regions at the given location. * Get a set of regions at the given location.
@ -104,5 +105,6 @@ public interface IWorldGuardImplementation {
* @param location The location * @param location The location
* @return A set of regions * @return A set of regions
*/ */
Set<AbstractRegion> getRegions(Location location); Set<WrappedRegion> getRegions(Location location);
} }

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.codemc.worldguardwrapper</groupId> <groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper-parent</artifactId> <artifactId>worldguardwrapper-parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.1-SNAPSHOT</version>
</parent> </parent>
<artifactId>worldguardwrapper-implementation</artifactId> <artifactId>worldguardwrapper-implementation</artifactId>
@ -17,7 +17,6 @@
<module>interface</module> <module>interface</module>
<module>v6</module> <module>v6</module>
<module>v7</module> <module>v7</module>
<module>aggregated</module>
</modules> </modules>
<name>WorldGuardWrapper-Implementation</name> <name>WorldGuardWrapper-Implementation</name>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.codemc.worldguardwrapper</groupId> <groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper-implementation</artifactId> <artifactId>worldguardwrapper-implementation</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.1-SNAPSHOT</version>
</parent> </parent>
<artifactId>worldguardwrapper-implementation-v6</artifactId> <artifactId>worldguardwrapper-implementation-v6</artifactId>
@ -18,7 +18,7 @@
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>worldguardwrapper-implementation-interface</artifactId> <artifactId>worldguardwrapper-implementation-interface</artifactId>
<version>${project.version}</version> <version>1.0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sk89q.worldguard</groupId> <groupId>com.sk89q.worldguard</groupId>

View File

@ -1,88 +1,67 @@
package org.codemc.worldguardwrapper.implementation.v6; package org.codemc.worldguardwrapper.implementation.v6;
import java.util.List;
import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent; import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent;
import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent; import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent;
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent; import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
import lombok.NoArgsConstructor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.codemc.worldguardwrapper.implementation.AbstractWrappedEvent; import org.codemc.worldguardwrapper.event.AbstractWrappedEvent;
import lombok.AllArgsConstructor; @NoArgsConstructor
@AllArgsConstructor
public class EventListener implements Listener { public class EventListener implements Listener {
private Class<? extends AbstractWrappedEvent> useBlockEventClass;
private Class<? extends AbstractWrappedEvent> useEntityEventClass;
private Class<? extends AbstractWrappedEvent> damageEntityEventClass;
@EventHandler @EventHandler
public void onUseBlock(UseBlockEvent e) { public void onUseBlock(UseBlockEvent worldGuardEvent) {
Player player = e.getCause().getFirstPlayer(); Player player = worldGuardEvent.getCause().getFirstPlayer();
if (player == null) { if (player == null) {
// Only forward player events for now // Only forward player events for now
return; return;
} }
try { AbstractWrappedEvent event = new org.codemc.worldguardwrapper.event.UseBlockEvent(
AbstractWrappedEvent event = useBlockEventClass worldGuardEvent.getOriginalEvent(),
.getConstructor(Event.class, Player.class, World.class, List.class, Material.class) player, worldGuardEvent.getWorld(),
.newInstance(e.getOriginalEvent(), player, e.getWorld(), e.getBlocks(), e.getEffectiveMaterial()); worldGuardEvent.getBlocks(),
worldGuardEvent.getEffectiveMaterial());
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
e.setResult(event.getResult()); worldGuardEvent.setResult(event.getResult());
} catch (ReflectiveOperationException ex) {
ex.printStackTrace(); // TODO: Handle differently
}
} }
@EventHandler @EventHandler
public void onUseEntity(UseEntityEvent e) { public void onUseEntity(UseEntityEvent worldGuardEvent) {
Player player = e.getCause().getFirstPlayer(); Player player = worldGuardEvent.getCause().getFirstPlayer();
if (player == null) { if (player == null) {
// Only forward player events for now // Only forward player events for now
return; return;
} }
try { AbstractWrappedEvent event = new org.codemc.worldguardwrapper.event.UseEntityEvent(
AbstractWrappedEvent event = useEntityEventClass worldGuardEvent.getOriginalEvent(),
.getConstructor(Event.class, Player.class, Location.class, Entity.class) player,
.newInstance(e.getOriginalEvent(), player, e.getTarget(), e.getEntity()); worldGuardEvent.getTarget(),
worldGuardEvent.getEntity());
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
e.setResult(event.getResult()); worldGuardEvent.setResult(event.getResult());
} catch (ReflectiveOperationException ex) {
ex.printStackTrace(); // TODO: Handle differently
}
} }
@EventHandler @EventHandler
public void onDamageEntity(DamageEntityEvent e) { public void onDamageEntity(DamageEntityEvent worldGuardEvent) {
Player player = e.getCause().getFirstPlayer(); Player player = worldGuardEvent.getCause().getFirstPlayer();
if (player == null) { if (player == null) {
// Only forward player events for now // Only forward player events for now
return; return;
} }
try { AbstractWrappedEvent event = new org.codemc.worldguardwrapper.event.DamageEntityEvent(
AbstractWrappedEvent event = damageEntityEventClass worldGuardEvent.getOriginalEvent(),
.getConstructor(Event.class, Player.class, Location.class, Entity.class) player,
.newInstance(e.getOriginalEvent(), player, e.getTarget(), e.getEntity()); worldGuardEvent.getTarget(),
worldGuardEvent.getEntity());
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
e.setResult(event.getResult()); worldGuardEvent.setResult(event.getResult());
} catch (ReflectiveOperationException ex) {
ex.printStackTrace(); // TODO: Handle differently
}
} }
} }

View File

@ -1,11 +1,5 @@
package org.codemc.worldguardwrapper.implementation.v6; package org.codemc.worldguardwrapper.implementation.v6;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
@ -17,26 +11,23 @@ import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
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 lombok.NoArgsConstructor;
import lombok.NonNull;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.codemc.worldguardwrapper.implementation.AbstractFlag; import org.codemc.worldguardwrapper.flags.AbstractWrappedFlag;
import org.codemc.worldguardwrapper.implementation.AbstractRegion; import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation;
import org.codemc.worldguardwrapper.implementation.AbstractWorldGuardImplementation; import org.codemc.worldguardwrapper.region.WrappedRegion;
import lombok.NonNull; import java.util.*;
public class WorldGuardImplementation extends AbstractWorldGuardImplementation { @NoArgsConstructor
public class WorldGuardImplementation implements IWorldGuardImplementation {
private final WorldGuardPlugin plugin; private final WorldGuardPlugin plugin = WorldGuardPlugin.inst();
private final FlagRegistry flagRegistry; private final FlagRegistry flagRegistry = plugin.getFlagRegistry();
public WorldGuardImplementation() {
plugin = WorldGuardPlugin.inst();
flagRegistry = plugin.getFlagRegistry();
}
private Optional<LocalPlayer> wrapPlayer(Player player) { private Optional<LocalPlayer> wrapPlayer(Player player) {
return Optional.ofNullable(player).map(bukkitPlayer -> plugin.wrapPlayer(player)); return Optional.ofNullable(player).map(bukkitPlayer -> plugin.wrapPlayer(player));
@ -58,8 +49,14 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryState(wrapPlayer(player).orElse(null), stateFlags)); return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryState(wrapPlayer(player).orElse(null), stateFlags));
} }
private AbstractRegion toRegion(ProtectedRegion region) { private WrappedRegion toRegion(ProtectedRegion region) {
return new AbstractRegion(region.getId()) { return new WrappedRegion() {
@Override
public String getId() {
return region.getId();
}
@Override @Override
public Map<String, Object> getFlags() { public Map<String, Object> getFlags() {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
@ -68,14 +65,16 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
} }
@Override @Override
public Object getFlag(String name) { public Optional<Object> getFlag(String name) {
return region.getFlag(flagRegistry.get(name)); return Optional.ofNullable(flagRegistry.get(name))
.map(region::getFlag);
} }
@Override @Override
public int getPriority() { public int getPriority() {
return region.getPriority(); return region.getPriority();
} }
}; };
} }
@ -120,7 +119,7 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
} }
@Override @Override
public <T> boolean registerFlag(AbstractFlag<T> flag) { public <T> boolean registerFlag(AbstractWrappedFlag<T> flag) {
Flag<T> wgFlag = new Flag<T>(flag.getName()) { Flag<T> wgFlag = new Flag<T>(flag.getName()) {
@Override @Override
public T getDefault() { public T getDefault() {
@ -152,25 +151,25 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
} }
@Override @Override
public Optional<AbstractRegion> getRegion(World world, String id) { public Optional<WrappedRegion> getRegion(World world, String id) {
return getWorldManager(world).map(regionManager -> toRegion(regionManager.getRegion(id))); return getWorldManager(world).map(regionManager -> toRegion(regionManager.getRegion(id)));
} }
@Override @Override
public Map<String, AbstractRegion> getRegions(World world) { public Map<String, WrappedRegion> getRegions(World world) {
RegionManager regionManager = plugin.getRegionManager(world); RegionManager regionManager = plugin.getRegionManager(world);
Map<String, ProtectedRegion> regions = regionManager.getRegions(); Map<String, ProtectedRegion> regions = regionManager.getRegions();
Map<String, AbstractRegion> map = new HashMap<>(); Map<String, WrappedRegion> map = new HashMap<>();
regions.forEach((name, region) -> map.put(name, toRegion(region))); regions.forEach((name, region) -> map.put(name, toRegion(region)));
return map; return map;
} }
@Override @Override
public Set<AbstractRegion> getRegions(Location location) { public Set<WrappedRegion> getRegions(Location location) {
ApplicableRegionSet regionSet = getApplicableRegions(location).orElse(null); ApplicableRegionSet regionSet = getApplicableRegions(location).orElse(null);
Set<AbstractRegion> set = new HashSet<>(); Set<WrappedRegion> set = new HashSet<>();
if (regionSet == null) { if (regionSet == null) {
return set; return set;
@ -179,4 +178,5 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
regionSet.forEach(region -> set.add(toRegion(region))); regionSet.forEach(region -> set.add(toRegion(region)));
return set; return set;
} }
} }

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.codemc.worldguardwrapper</groupId> <groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper-implementation</artifactId> <artifactId>worldguardwrapper-implementation</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.1-SNAPSHOT</version>
</parent> </parent>
<artifactId>worldguardwrapper-implementation-v7</artifactId> <artifactId>worldguardwrapper-implementation-v7</artifactId>
@ -18,7 +18,7 @@
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>worldguardwrapper-implementation-interface</artifactId> <artifactId>worldguardwrapper-implementation-interface</artifactId>
<version>${project.version}</version> <version>1.0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sk89q.worldguard</groupId> <groupId>com.sk89q.worldguard</groupId>

View File

@ -1,88 +1,67 @@
package org.codemc.worldguardwrapper.implementation.v7; package org.codemc.worldguardwrapper.implementation.v7;
import java.util.List;
import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent; import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent;
import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent; import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent;
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent; import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
import lombok.NoArgsConstructor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.codemc.worldguardwrapper.implementation.AbstractWrappedEvent; import org.codemc.worldguardwrapper.event.AbstractWrappedEvent;
import lombok.AllArgsConstructor; @NoArgsConstructor
@AllArgsConstructor
public class EventListener implements Listener { public class EventListener implements Listener {
private Class<? extends AbstractWrappedEvent> useBlockEventClass;
private Class<? extends AbstractWrappedEvent> useEntityEventClass;
private Class<? extends AbstractWrappedEvent> damageEntityEventClass;
@EventHandler @EventHandler
public void onUseBlock(UseBlockEvent e) { public void onUseBlock(UseBlockEvent worldGuardEvent) {
Player player = e.getCause().getFirstPlayer(); Player player = worldGuardEvent.getCause().getFirstPlayer();
if (player == null) { if (player == null) {
// Only forward player events for now // Only forward player events for now
return; return;
} }
try { AbstractWrappedEvent event = new org.codemc.worldguardwrapper.event.UseBlockEvent(
AbstractWrappedEvent event = useBlockEventClass worldGuardEvent.getOriginalEvent(),
.getConstructor(Event.class, Player.class, World.class, List.class, Material.class) player, worldGuardEvent.getWorld(),
.newInstance(e.getOriginalEvent(), player, e.getWorld(), e.getBlocks(), e.getEffectiveMaterial()); worldGuardEvent.getBlocks(),
worldGuardEvent.getEffectiveMaterial());
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
e.setResult(event.getResult()); worldGuardEvent.setResult(event.getResult());
} catch (ReflectiveOperationException ex) {
ex.printStackTrace(); // TODO: Handle differently
}
} }
@EventHandler @EventHandler
public void onUseEntity(UseEntityEvent e) { public void onUseEntity(UseEntityEvent worldGuardEvent) {
Player player = e.getCause().getFirstPlayer(); Player player = worldGuardEvent.getCause().getFirstPlayer();
if (player == null) { if (player == null) {
// Only forward player events for now // Only forward player events for now
return; return;
} }
try { AbstractWrappedEvent event = new org.codemc.worldguardwrapper.event.UseEntityEvent(
AbstractWrappedEvent event = useEntityEventClass worldGuardEvent.getOriginalEvent(),
.getConstructor(Event.class, Player.class, Location.class, Entity.class) player,
.newInstance(e.getOriginalEvent(), player, e.getTarget(), e.getEntity()); worldGuardEvent.getTarget(),
worldGuardEvent.getEntity());
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
e.setResult(event.getResult()); worldGuardEvent.setResult(event.getResult());
} catch (ReflectiveOperationException ex) {
ex.printStackTrace(); // TODO: Handle differently
}
} }
@EventHandler @EventHandler
public void onDamageEntity(DamageEntityEvent e) { public void onDamageEntity(DamageEntityEvent worldGuardEvent) {
Player player = e.getCause().getFirstPlayer(); Player player = worldGuardEvent.getCause().getFirstPlayer();
if (player == null) { if (player == null) {
// Only forward player events for now // Only forward player events for now
return; return;
} }
try { AbstractWrappedEvent event = new org.codemc.worldguardwrapper.event.DamageEntityEvent(
AbstractWrappedEvent event = damageEntityEventClass worldGuardEvent.getOriginalEvent(),
.getConstructor(Event.class, Player.class, Location.class, Entity.class) player,
.newInstance(e.getOriginalEvent(), player, e.getTarget(), e.getEntity()); worldGuardEvent.getTarget(),
worldGuardEvent.getEntity());
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
e.setResult(event.getResult()); worldGuardEvent.setResult(event.getResult());
} catch (ReflectiveOperationException ex) {
ex.printStackTrace(); // TODO: Handle differently
}
} }
} }

View File

@ -1,11 +1,5 @@
package org.codemc.worldguardwrapper.implementation.v7; package org.codemc.worldguardwrapper.implementation.v7;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
@ -20,19 +14,20 @@ import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
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 lombok.NonNull;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.codemc.worldguardwrapper.implementation.AbstractFlag; import org.codemc.worldguardwrapper.flags.AbstractWrappedFlag;
import org.codemc.worldguardwrapper.implementation.AbstractRegion; import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation;
import org.codemc.worldguardwrapper.implementation.AbstractWorldGuardImplementation; import org.codemc.worldguardwrapper.region.WrappedRegion;
import lombok.NonNull; import java.util.*;
import java.util.stream.Collectors;
public class WorldGuardImplementation extends AbstractWorldGuardImplementation { public class WorldGuardImplementation implements IWorldGuardImplementation {
private final WorldGuard core; private final WorldGuard core;
private final FlagRegistry flagRegistry; private final FlagRegistry flagRegistry;
@ -68,8 +63,14 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryState(wrapPlayer(player).orElse(null), stateFlags)); return getApplicableRegions(location).map(applicableRegions -> applicableRegions.queryState(wrapPlayer(player).orElse(null), stateFlags));
} }
private AbstractRegion toRegion(ProtectedRegion region) { private WrappedRegion toRegion(ProtectedRegion region) {
return new AbstractRegion(region.getId()) { return new WrappedRegion() {
@Override
public String getId() {
return region.getId();
}
@Override @Override
public Map<String, Object> getFlags() { public Map<String, Object> getFlags() {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
@ -78,14 +79,16 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
} }
@Override @Override
public Object getFlag(String name) { public Optional<Object> getFlag(String name) {
return region.getFlag(flagRegistry.get(name)); return Optional.ofNullable(flagRegistry.get(name))
.map(region::getFlag);
} }
@Override @Override
public int getPriority() { public int getPriority() {
return region.getPriority(); return region.getPriority();
} }
}; };
} }
@ -130,7 +133,7 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
} }
@Override @Override
public <T> boolean registerFlag(AbstractFlag<T> flag) { public <T> boolean registerFlag(AbstractWrappedFlag<T> flag) {
Flag<T> wgFlag = new Flag<T>(flag.getName()) { Flag<T> wgFlag = new Flag<T>(flag.getName()) {
@Override @Override
public T getDefault() { public T getDefault() {
@ -149,7 +152,7 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
@Override @Override
public T parseInput(FlagContext context) throws InvalidFlagFormat { public T parseInput(FlagContext context) throws InvalidFlagFormat {
return flag.parse(getPlayer(context.getPlayerSender()).get(), context.getUserInput()); return flag.parse(getPlayer(context.getPlayerSender()).orElse(null), context.getUserInput());
} }
}; };
@ -162,31 +165,34 @@ public class WorldGuardImplementation extends AbstractWorldGuardImplementation {
} }
@Override @Override
public Optional<AbstractRegion> getRegion(World world, String id) { public Optional<WrappedRegion> getRegion(World world, String id) {
return getWorldManager(world).map(regionManager -> toRegion(regionManager.getRegion(id))); return getWorldManager(world)
.map(regionManager -> regionManager.getRegion(id))
.map(this::toRegion);
} }
@Override @Override
public Map<String, AbstractRegion> getRegions(World world) { public Map<String, WrappedRegion> getRegions(World world) {
RegionManager regionManager = core.getPlatform().getRegionContainer().get(new BukkitWorld(world)); RegionManager regionManager = core.getPlatform().getRegionContainer().get(new BukkitWorld(world));
if (regionManager == null) {
return Collections.emptyMap();
}
Map<String, ProtectedRegion> regions = regionManager.getRegions(); Map<String, ProtectedRegion> regions = regionManager.getRegions();
Map<String, WrappedRegion> map = new HashMap<>();
Map<String, AbstractRegion> map = new HashMap<>();
regions.forEach((name, region) -> map.put(name, toRegion(region))); regions.forEach((name, region) -> map.put(name, toRegion(region)));
return map; return map;
} }
@Override @Override
public Set<AbstractRegion> getRegions(Location location) { public Set<WrappedRegion> getRegions(Location location) {
ApplicableRegionSet regionSet = getApplicableRegions(location).orElse(null); ApplicableRegionSet regionSet = getApplicableRegions(location).orElse(null);
Set<AbstractRegion> set = new HashSet<>();
if (regionSet == null) { if (regionSet == null) {
return set; return Collections.emptySet();
} }
regionSet.forEach(region -> set.add(toRegion(region))); return regionSet.getRegions().stream()
return set; .map(this::toRegion)
.collect(Collectors.toSet());
} }
} }

48
library/pom.xml Normal file
View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper-parent</artifactId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<artifactId>worldguardwrapper</artifactId>
<name>WorldGuardWrapper-Library</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>worldguardwrapper-implementation-v6</artifactId>
<version>1.0.1-SNAPSHOT</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>worldguardwrapper-implementation-v7</artifactId>
<version>1.0.1-SNAPSHOT</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,19 +1,20 @@
package org.codemc.worldguardwrapper; package org.codemc.worldguardwrapper;
import lombok.experimental.Delegate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.codemc.worldguardwrapper.event.DamageEntityEvent;
import org.codemc.worldguardwrapper.event.UseBlockEvent;
import org.codemc.worldguardwrapper.event.UseEntityEvent;
import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation; import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation;
import lombok.experimental.Delegate;
public class WorldGuardWrapper implements IWorldGuardImplementation { public class WorldGuardWrapper implements IWorldGuardImplementation {
private static WorldGuardWrapper instance; private static WorldGuardWrapper instance;
/**
* Returns the wrapper singleton instance.
*
* @return the wrapper singleton
*/
public static WorldGuardWrapper getInstance() { public static WorldGuardWrapper getInstance() {
if (instance == null) { if (instance == null) {
instance = new WorldGuardWrapper(); instance = new WorldGuardWrapper();
@ -26,24 +27,21 @@ public class WorldGuardWrapper implements IWorldGuardImplementation {
private Listener eventListener; private Listener eventListener;
private WorldGuardWrapper() { private WorldGuardWrapper() {
// TODO: better way to detect version
try { try {
Class.forName("com.sk89q.worldguard.WorldGuard"); Class.forName("com.sk89q.worldguard.WorldGuard");
delegate = new org.codemc.worldguardwrapper.implementation.v7.WorldGuardImplementation(); delegate = new org.codemc.worldguardwrapper.implementation.v7.WorldGuardImplementation();
eventListener = new org.codemc.worldguardwrapper.implementation.v7.EventListener( eventListener = new org.codemc.worldguardwrapper.implementation.v7.EventListener();
UseBlockEvent.class, UseEntityEvent.class, DamageEntityEvent.class);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
delegate = new org.codemc.worldguardwrapper.implementation.v6.WorldGuardImplementation(); delegate = new org.codemc.worldguardwrapper.implementation.v6.WorldGuardImplementation();
eventListener = new org.codemc.worldguardwrapper.implementation.v6.EventListener( eventListener = new org.codemc.worldguardwrapper.implementation.v6.EventListener();
UseBlockEvent.class, UseEntityEvent.class, DamageEntityEvent.class);
} }
} }
/** /**
* Forward WorldGuard event calls to wrapped events to allow listening to them * Forward WorldGuard event calls to wrapped events to allow listening to them
* without having to use WorldGuard's events. * without having to use WorldGuard's events. This is optional.
* *
* @param plugin The plugin * @param plugin the plugin instance
*/ */
public void registerEvents(JavaPlugin plugin) { public void registerEvents(JavaPlugin plugin) {
Bukkit.getPluginManager().registerEvents(eventListener, plugin); Bukkit.getPluginManager().registerEvents(eventListener, plugin);

View File

@ -6,11 +6,12 @@
<groupId>org.codemc.worldguardwrapper</groupId> <groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper-parent</artifactId> <artifactId>worldguardwrapper-parent</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.1-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>api</module> <module>api</module>
<module>library</module>
<module>implementation</module> <module>implementation</module>
</modules> </modules>