Skip to content

Commit

Permalink
Update to 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
nickstuaw committed Jun 11, 2022
1 parent 3d015f6 commit 350bc5d
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 76 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions .idea/artifacts/PersonalPVP_jar3.xml

This file was deleted.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/runConfigurations.xml

This file was deleted.

22 changes: 16 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>xyz.nsgw.personalpvp</groupId>
<artifactId>PersonalPVP</artifactId>
<version>1.5.0-SNAPSHOT-1</version>
<version>1.5.0</version>
<packaging>jar</packaging>

<name>PersonalPVP</name>
Expand Down Expand Up @@ -89,9 +89,9 @@
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository> <!-- for development builds -->
<id>sonatype-oss</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<repository>
<id>sonatype-oss-snapshots1</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>aikar</id>
Expand Down Expand Up @@ -124,17 +124,27 @@
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-paper</artifactId>
<version>0.5.0-SNAPSHOT</version>
<version>0.5.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.9.1</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.1.0-SNAPSHOT</version>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>ch.jalu</groupId>
Expand Down
21 changes: 17 additions & 4 deletions src/main/java/xyz/nsgw/personalpvp/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
import me.clip.placeholderapi.PlaceholderAPI;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import xyz.nsgw.personalpvp.config.GeneralConfig;

import java.io.*;
Expand All @@ -36,6 +39,7 @@ public class Utils {

private static PPVPPlugin pl;

private static MiniMessage mm = MiniMessage.miniMessage();
private static List<List<UUID>> loaded = new ArrayList<>(Arrays.asList(new ArrayList<>(),new ArrayList<>(),new ArrayList<>()));

public static void setPlugin(final PPVPPlugin plugin) {
Expand All @@ -47,7 +51,7 @@ public static void send(final CommandSender sender, final Component component, f
sender.sendMessage(component);
}
if (actionbar && sender instanceof Player) {
((Player)sender).sendActionBar(component);
sender.sendActionBar(component);
}
}
public static void sendText(final Player player, final Component component) {
Expand All @@ -62,11 +66,20 @@ public static Component parse(Player p, String text, final String... placeholder
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
PlaceholderAPI.setPlaceholders(p, text);
}
return MiniMessage.get().parse(text, placeholders);
return getComponent(text, placeholders);
}

@NotNull
public static Component getComponent(String text, String... placeholders) {
TagResolver.Builder builder = TagResolver.builder();
for(int i = 0; i < placeholders.length; i += 2) {
builder.tag(placeholders[i], Tag.inserting(mm.deserialize(placeholders[i + 1])));
}
return mm.deserialize(text, builder.build());
}

public static Component parse(String text, final String... placeholders) {
return MiniMessage.get().parse(text, placeholders);
return getComponent(text, placeholders);
}

public static void loadObjects() throws IOException, ClassNotFoundException {
Expand Down Expand Up @@ -113,7 +126,7 @@ public static boolean togglePersonal(final Player p) {
return false;
}
pl.pvp().coolDown(p);
Utils.sendText(p, pl.pvp().toggle(p.getUniqueId()) ? MiniMessage.get().parse("<aqua>PVP enabled.") : MiniMessage.get().parse("<green>PVP disabled."));
Utils.sendText(p, pl.pvp().toggle(p.getUniqueId()) ? mm.deserialize("<aqua>PVP enabled.") : mm.deserialize("<green>PVP disabled."));
return true;
}
public static class Tameables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ public void onControl(final CommandSender s) {
@Subcommand("resetglobal")
@CommandPermission("personalpvp.pvpcontrol.resetglobal")
public void onGlobalReset(final CommandSender s) {
PPVPPlugin.inst().pvp().players().forEach(PPVPPlugin.inst().pvp()::remove);
List<UUID> uuids = PPVPPlugin.inst().pvp().players();
int size = uuids.size();
for(int i = 0; i < size; i++) {
PPVPPlugin.inst().pvp().remove(uuids.get(i));
}
Utils.send(s, Utils.parse(
"<yellow>You <hover:show_text:'"
+ (PPVPPlugin.inst().conf().get().getProperty(GeneralConfig.DEFAULT_PVP_STATUS) ?
Expand Down Expand Up @@ -156,7 +160,7 @@ public class onOther extends BaseCommand {
@CommandPermission("personalpvp.pvpcontrol.other.status")
public void onStatus(final CommandSender s, final OnlinePlayer t) {
Player target = t.getPlayer();
Utils.send(s, Utils.parse("<yellow>"+target.getDisplayName()+" has PVP "
Utils.send(s, Utils.parse("<yellow>"+target.getName()+" has PVP "
+ (PPVPPlugin.inst().pvp().pvpPositive(target.getUniqueId()) ?
"<aqua>ENABLED." : "<green>DISABLED.")), true, false);
}
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/xyz/nsgw/personalpvp/config/GeneralConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,13 @@ public class GeneralConfig implements SettingsHolder {
public static final Property<Boolean> ABAR_RESET_ON_Q =
newProperty(PFX_ACTIONBAR + "reset-actionbar-status-on-quit", true);
public static final Property<String> ABAR_MESSAGE =
newProperty(PFX_ACTIONBAR + "message", "<pvpprefix>PVP: <pvpstatus></gradient> <gray>-</gray> <gold><worldtime>");
newProperty(PFX_ACTIONBAR + "message", "<pvpprefix> <gray>-</gray> <gold><worldtime>");
public static final Property<String> ABAR_TIME_WORLD =
newProperty(PFX_ACTIONBAR + "worldtime-in-world", "world");
public static final Property<String> ABAR_PVP_ENABLED =
newProperty(PFX_ACTIONBAR + "pvpstatus-enabled", "<aqua>Enabled");
public static final Property<String> ABAR_PVP_DISABLED =
newProperty(PFX_ACTIONBAR + "pvpstatus-disabled", "<green>Disabled");
public static final Property<String> ABAR_PVP_ENABLED_PFX =
newProperty(PFX_ACTIONBAR + "pvp-enabled-color-prefix","<gradient:#b82a11:#d41c43>");
newProperty(PFX_ACTIONBAR + "pvp-enabled-color-prefix","<gradient:#b82a11:#d41c43>PVP: <aqua>Enabled</aqua></gradient>");
public static final Property<String> ABAR_PVP_DISABLED_PFX =
newProperty(PFX_ACTIONBAR + "pvp-disabled-color-prefix","<gradient:#d41c43:#b82a11>");
newProperty(PFX_ACTIONBAR + "pvp-disabled-color-prefix","<gradient:#d41c43:#b82a11>PVP: <green>Disabled</green></gradient>");

public static final Property<Integer> CMD_PVPTOGGLE_COOLDOWN =
newProperty(PFX_CMD_SETTINGS + PFX_PVP_TOGGLE + "cooldown", 3);
Expand Down Expand Up @@ -97,7 +93,7 @@ public class GeneralConfig implements SettingsHolder {
));
public static final Property<List<String>> CMD_PVPCTRL_LINES =
newListProperty(PFX_CMD_SETTINGS + PFX_PVP_CONTROL + "lines", List.of(
"<green>[<click:suggest_command:/pvp ontrol resetglobal><hover:show_text:'<aqua>Reset offline players as well as online players.'><gradient:green:aqua><bold>FULL</gradient> <gradient:aqua:green>RESET</gradient></bold></hover></click><green>]"));
"<green>[<click:suggest_command:/pvp control resetglobal><hover:show_text:'<aqua>Reset offline players as well as online players.'><gradient:green:aqua><bold>FULL</bold></gradient> <gradient:aqua:green><bold>RESET</bold></gradient></hover></click><green>]"));

public static final Property<Boolean> ENABLE_PVP_ALERT =
newProperty("notifications.enable-pvp-alert", true);
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/xyz/nsgw/personalpvp/managers/TaskManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,15 @@ public static void sendInstantUpdate(final UUID u) {
pl.pvp().pvpPositive(u) ?
pl.conf().get().getProperty(GeneralConfig.ABAR_PVP_ENABLED_PFX) :
pl.conf().get().getProperty(GeneralConfig.ABAR_PVP_DISABLED_PFX),
"pvpstatus",
pl.pvp().pvpPositive(u) ?
pl.conf().get().getProperty(GeneralConfig.ABAR_PVP_ENABLED) :
pl.conf().get().getProperty(GeneralConfig.ABAR_PVP_DISABLED),
"worldtime", (hours<10?"0":"")+hours+":"+(minutes<10?"0":"")+minutes+suffix),
false, true);
}
public static void sendInstantUpdate(final UUID u, final String msg) {
PPVPPlugin pl = PPVPPlugin.inst();
Utils.sendText(Bukkit.getPlayer(u), MiniMessage.get().parse(msg, "pvpprefix",
Utils.sendText(Bukkit.getPlayer(u), Utils.parse(msg, "pvpprefix",
pl.pvp().pvpPositive(u) ?
pl.conf().get().getProperty(GeneralConfig.ABAR_PVP_ENABLED_PFX) :
pl.conf().get().getProperty(GeneralConfig.ABAR_PVP_DISABLED_PFX),
"pvpstatus", pl.pvp().pvpPositive(u) ?
pl.conf().get().getProperty(GeneralConfig.ABAR_PVP_ENABLED) :
pl.conf().get().getProperty(GeneralConfig.ABAR_PVP_DISABLED),
"worldtime", (hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + suffix));
}

Expand Down

0 comments on commit 350bc5d

Please sign in to comment.