forked from clone/WorldGuardWrapper
Add DisallowedPVPEvent
This commit is contained in:
parent
c24d8cd60f
commit
b038a7b444
|
@ -0,0 +1,27 @@
|
|||
package org.codemc.worldguardwrapper.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public class DisallowedPVPEvent extends AbstractWrappedEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final Player attacker;
|
||||
private final Player defender;
|
||||
private final Event cause;
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
|
@ -3,12 +3,13 @@ package org.codemc.worldguardwrapper.implementation.v7;
|
|||
import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.protection.events.DisallowedPVPEvent;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.codemc.worldguardwrapper.event.AbstractWrappedEvent;
|
||||
|
||||
@NoArgsConstructor
|
||||
|
@ -80,4 +81,19 @@ public class EventListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisallowedPVP(DisallowedPVPEvent worldGuardEvent) {
|
||||
AbstractWrappedEvent event = new org.codemc.worldguardwrapper.event.DisallowedPVPEvent(
|
||||
worldGuardEvent.getAttacker(),
|
||||
worldGuardEvent.getDefender(),
|
||||
worldGuardEvent.getCause());
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.getResult() != Result.DEFAULT) {
|
||||
// DEFAULT = Result probably has not been touched by the handler,
|
||||
// so don't touch the original result either.
|
||||
worldGuardEvent.setCancelled(event.getResult() == Result.DENY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -51,7 +51,7 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spigot-api.version>1.13-R0.1-SNAPSHOT</spigot-api.version>
|
||||
<spigot-api.version>1.13.2-R0.1-SNAPSHOT</spigot-api.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
|
@ -89,7 +89,7 @@
|
|||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.0</version>
|
||||
<version>1.18.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -149,7 +149,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
</configuration>
|
||||
|
|
Loading…
Reference in New Issue
Block a user