mirror of
https://github.com/CodeMC/WorldGuardWrapper.git
synced 2024-11-10 13:15:19 +01:00
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.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 com.sk89q.worldguard.bukkit.protection.events.DisallowedPVPEvent;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event.Result;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.Event.Result;
|
|
||||||
import org.codemc.worldguardwrapper.event.AbstractWrappedEvent;
|
import org.codemc.worldguardwrapper.event.AbstractWrappedEvent;
|
||||||
|
|
||||||
@NoArgsConstructor
|
@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.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<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>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.0</version>
|
<version>1.18.2</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -149,7 +149,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.2.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<minimizeJar>false</minimizeJar>
|
<minimizeJar>false</minimizeJar>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user