Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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>

<groupId>com.github.aasmus</groupId>
<artifactId>PVPToggle</artifactId>
<version>1.8</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>nametagedit-repo</id>
<url>http://ci.nametagedit.com/plugin/repository/everything/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.sgtcaze</groupId>
<artifactId>NametagEdit</artifactId>
<version>master-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.aasmus.pvptoggle;

import com.github.aasmus.pvptoggle.events.PVPToggleEvent;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand Down Expand Up @@ -32,6 +33,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
} else if(args[0].equals("toggle")) {
if(current == true) {
if (Util.setPlayerState(other, false, console)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(other, true));
Chat.send(other, "PVP_STATE_ENABLED");
if (PvPToggle.instance.getConfig().getBoolean("SETTINGS.PARTICLES")) {
Util.particleEffect(other.getPlayer());
Expand All @@ -42,11 +44,13 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}
} else {
if (Util.setPlayerState(other, true, console)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(other, false));
Chat.send(other, "PVP_STATE_DISABLED");
}
}
} else if(args[0].equalsIgnoreCase("on")) {
if (Util.setPlayerState(other, false, console)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(other, true));
Chat.send(other, "PVP_STATE_ENABLED");
if (current == true) {
if(PvPToggle.instance.getConfig().getBoolean("SETTINGS.PARTICLES")) {
Expand All @@ -59,6 +63,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}
} else if(args[0].equalsIgnoreCase("off")) {
if (Util.setPlayerState(other, true, console)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(other, false));
Chat.send(other, "PVP_STATE_DISABLED");
if(PvPToggle.instance.getConfig().getBoolean("SETTINGS.NAMETAG")) {
Util.ChangeNametag(other.getPlayer(), "reset");
Expand Down Expand Up @@ -96,6 +101,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if(current == true) {
Util.setCooldownTime(p);
if (Util.setPlayerState(p, false, p)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(p, true));
Chat.send(p, "PVP_STATE_ENABLED");
if (PvPToggle.instance.getConfig().getBoolean("SETTINGS.PARTICLES")) {
Util.particleEffect(p.getPlayer());
Expand All @@ -105,12 +111,14 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}
} else {
if (Util.setPlayerState(p, true, p)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(p, false));
Chat.send(p, "PVP_STATE_DISABLED");
}
}
} else if(args[0].equalsIgnoreCase("on")) {
Util.setCooldownTime(p);
if (Util.setPlayerState(p, false, p)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(p, true));
Chat.send(p, "PVP_STATE_ENABLED");
if (current == true) {
if(PvPToggle.instance.getConfig().getBoolean("SETTINGS.PARTICLES")) {
Expand All @@ -123,6 +131,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}
} else if(args[0].equalsIgnoreCase("off")) {
if (Util.setPlayerState(p, true, p)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(p, false));
Chat.send(p, "PVP_STATE_DISABLED");
if(PvPToggle.instance.getConfig().getBoolean("SETTINGS.NAMETAG")) {
Util.ChangeNametag(p.getPlayer(), "reset");
Expand Down Expand Up @@ -158,6 +167,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if(args[0].equals("toggle")) {
if(current == true) {
if (Util.setPlayerState(other, false, sender)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(other, true));
Chat.send(other, "PVP_STATE_ENABLED");
if (PvPToggle.instance.getConfig().getBoolean("SETTINGS.PARTICLES")) {
Util.particleEffect(other.getPlayer());
Expand All @@ -168,11 +178,13 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}
} else {
if (Util.setPlayerState(other, true, sender)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(other, false));
Chat.send(other, "PVP_STATE_DISABLED");
}
}
} else if(args[0].equalsIgnoreCase("on")) {
if (Util.setPlayerState(other, false, sender)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(other, true));
if (current == true) {
if(PvPToggle.instance.getConfig().getBoolean("SETTINGS.PARTICLES")) {
Util.particleEffect(other.getPlayer());
Expand All @@ -185,6 +197,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
}
} else if(args[0].equalsIgnoreCase("off")) {
if (Util.setPlayerState(other, true, sender)) {
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(other, false));
Chat.send(other, "PVP_STATE_DISABLED");
if(PvPToggle.instance.getConfig().getBoolean("SETTINGS.NAMETAG")) {
Util.ChangeNametag(other.getPlayer(), "reset");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

import com.github.aasmus.pvptoggle.events.PVPToggleEvent;
import com.github.aasmus.pvptoggle.listeners.PlayerJoin;
import com.github.aasmus.pvptoggle.listeners.PlayerLeave;
import com.github.aasmus.pvptoggle.listeners.PvP;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.github.aasmus.pvptoggle.events;

import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.entity.Player;

public class PVPToggleEvent extends Event {

private final Player player;
private final boolean pvp;

public PVPToggleEvent(Player player, boolean pvp) {
this.player = player;
this.pvp = pvp;
}

private static final HandlerList HANDLERS = new HandlerList();

public HandlerList getHandlers() {
return HANDLERS;
}

public static HandlerList getHandlerList() {
return HANDLERS;
}

public Player getPlayer() {
return this.player;
}

public boolean getPVP() {
return this.pvp;
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.github.aasmus.pvptoggle.listeners;

import com.github.aasmus.pvptoggle.PvPToggle;
import com.github.aasmus.pvptoggle.events.PVPToggleEvent;
import com.github.aasmus.pvptoggle.utils.Chat;
import com.github.aasmus.pvptoggle.utils.Util;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -19,6 +21,7 @@ public void onChangeWorld(PlayerChangedWorldEvent event) {
// If PVP isn't enabled in the world but the player has it enabled, disable it.
if (!world.getPVP() && playerPvpEnabled) {
Util.setPlayerState(player.getUniqueId(), true);
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(player, false));
Chat.send(player, "PVP_WORLD_CHANGE_DISABLED");
/*if (PvPToggle.instance.getConfig().getBoolean("SETTINGS.PARTICLES")) {
Util.particleEffect(player);
Expand All @@ -32,6 +35,7 @@ public void onChangeWorld(PlayerChangedWorldEvent event) {
// If PVP is required (i.e. the world has PVP enabled and it is in the blocked worlds) and the player has it disabled, enable it.
if (player.getWorld().getPVP() && PvPToggle.blockedWorlds.contains(world.getName()) && !playerPvpEnabled) {
Util.setPlayerState(player.getUniqueId(), false);
Bukkit.getPluginManager().callEvent(new PVPToggleEvent(player, true));
Chat.send(player, "PVP_WORLD_CHANGE_REQUIRED");
if (PvPToggle.instance.getConfig().getBoolean("SETTINGS.PARTICLES")) {
Util.particleEffect(player);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/resources/plugin.yml → src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
main: com.github.aasmus.pvptoggle.PvPToggle
softdepend: [PlaceholderAPI, NametagEdit]
name: PvPToggle
version: 1.7
version: 1.8
api-version: 1.13
author: aasmus (with modifications by the Red Fusion Team)
description: Plugin that allows players to toggle PvP state
Expand Down