From 9d5338ad3df2ab9d6b53404e8914558f68fb8774 Mon Sep 17 00:00:00 2001 From: Benkralex Date: Tue, 25 Jul 2023 14:37:48 +0200 Subject: [PATCH] Start Plugin + Workspace uploded --- Pvptoggle-1.4-FINAL.jar | Bin 0 -> 8118 bytes pvptogglepluginworkspace/.idea/.gitignore | 3 + pvptogglepluginworkspace/.idea/compiler.xml | 13 +++ pvptogglepluginworkspace/.idea/encodings.xml | 7 ++ .../.idea/jarRepositories.xml | 30 +++++++ pvptogglepluginworkspace/.idea/misc.xml | 19 ++++ pvptogglepluginworkspace/.idea/modules.xml | 8 ++ pvptogglepluginworkspace/Pvptoggle.iml | 12 +++ pvptogglepluginworkspace/pom.xml | 80 +++++++++++++++++ .../main/java/benkralex/pvptoggle/Config.java | 20 +++++ .../java/benkralex/pvptoggle/PvpCommand.java | 35 ++++++++ .../java/benkralex/pvptoggle/PvpEvent.java | 83 ++++++++++++++++++ .../java/benkralex/pvptoggle/Pvptoggle.java | 26 ++++++ .../src/main/resources/plugin.yml | 7 ++ 14 files changed, 343 insertions(+) create mode 100644 Pvptoggle-1.4-FINAL.jar create mode 100644 pvptogglepluginworkspace/.idea/.gitignore create mode 100644 pvptogglepluginworkspace/.idea/compiler.xml create mode 100644 pvptogglepluginworkspace/.idea/encodings.xml create mode 100644 pvptogglepluginworkspace/.idea/jarRepositories.xml create mode 100644 pvptogglepluginworkspace/.idea/misc.xml create mode 100644 pvptogglepluginworkspace/.idea/modules.xml create mode 100644 pvptogglepluginworkspace/Pvptoggle.iml create mode 100644 pvptogglepluginworkspace/pom.xml create mode 100644 pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/Config.java create mode 100644 pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/PvpCommand.java create mode 100644 pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/PvpEvent.java create mode 100644 pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/Pvptoggle.java create mode 100644 pvptogglepluginworkspace/src/main/resources/plugin.yml diff --git a/Pvptoggle-1.4-FINAL.jar b/Pvptoggle-1.4-FINAL.jar new file mode 100644 index 0000000000000000000000000000000000000000..7bd0ed14ebac2931c239ffb4f9c1a3c4c1a4b636 GIT binary patch literal 8118 zcmb7J1yqz<*QSRU5EurBRzh;s(hb8xLPJuL(zp+m zQl8 z*vNP-oc%S|%7zn*{MZ1C0#qCmu%4%tK+OD#)}tvs3Jy|$tGi?{l@pQU5XN)C!9Jj2 z_#sjBG0PFqvngGk%US+T4P#S^Cw?H&gUSS(Y>G`U46n^rgI0t8#44fty~6r3l7P$W z_pxGMJ~cM8d*p<$G4o*i|NhHsPX{*#7kdi}8?*lx#+|>-evKhvZ)a|0!D?cIaCXj6 zSF)cL!}p!9b6jh-CA18fQXSG>6SJ1j5d(QKibqyq!qwtd>fHD$(q6}=yP{o0;Ear(DuUJdjO^L`$H3lf?ZxB^$^ZQb?=#<77m*9 zAJ9>w2H=_W>xPgzpC^b?(|3q{>dS!kKFwC0@KLcNvjvj_rmm)K zELyU$;!`)7zRji$8CUhd$e_@8V3~5oIeV-@PAB|XN7*XOHpdHYWPNMfN6emh zG5S-=7wxKXQ$S`Px+h(cZX?h;f& z|8j#tNHj1nCJwSuI$+U(e07K|L=VQ5E>Ceh+RcNJ^h*Yy{ms@?b#sugx3xvsnf|do z%eA-NL7GGtZTDQJT(a@qOi8q+Q7FXFxmnzhBlDs#BB4y}v`<{#4JxLmBoGsv_%5TL zB&zt~3qaA29b%V-e=5y>=fv73&J!OS92xdKSz2y8S=`vD^so4dykhu+NE(cS9mKSm zor>@irCM(uERSAF*}cv9B**Isf@BF6DpuF7e?J_dt_R#XucuKIF|(*$kUvb%X*eA& zsOaw1#6%Dd;cj-RX3GaO0i#}g=9KJm1~P+6_wjOK1B8X*Ii!Mt`q|V$A+&qz(9p%n zv(xA}W7)hfnR|_1$%A1b>S!=k+J4#tW3WP10wQyq#ULwj)%56svD`?(+0W?Jfe&jY zw-ih81`y%YF?pgu>YN;zs3X;v&fD6~x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zstU*`L`Z+{(*48_MO1 z{-5#u()PHCc%@3+tjw-dscS2|T&Uk5-q5Ii#kNM^yp+QUXOn!n^$ZxJ+<) IWLMw*2gYw0!2kdN literal 0 HcmV?d00001 diff --git a/pvptogglepluginworkspace/.idea/.gitignore b/pvptogglepluginworkspace/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/pvptogglepluginworkspace/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/pvptogglepluginworkspace/.idea/compiler.xml b/pvptogglepluginworkspace/.idea/compiler.xml new file mode 100644 index 0000000..435944c --- /dev/null +++ b/pvptogglepluginworkspace/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/pvptogglepluginworkspace/.idea/encodings.xml b/pvptogglepluginworkspace/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/pvptogglepluginworkspace/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/pvptogglepluginworkspace/.idea/jarRepositories.xml b/pvptogglepluginworkspace/.idea/jarRepositories.xml new file mode 100644 index 0000000..861936a --- /dev/null +++ b/pvptogglepluginworkspace/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pvptogglepluginworkspace/.idea/misc.xml b/pvptogglepluginworkspace/.idea/misc.xml new file mode 100644 index 0000000..40f5889 --- /dev/null +++ b/pvptogglepluginworkspace/.idea/misc.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pvptogglepluginworkspace/.idea/modules.xml b/pvptogglepluginworkspace/.idea/modules.xml new file mode 100644 index 0000000..01daa2d --- /dev/null +++ b/pvptogglepluginworkspace/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pvptogglepluginworkspace/Pvptoggle.iml b/pvptogglepluginworkspace/Pvptoggle.iml new file mode 100644 index 0000000..fa63d4b --- /dev/null +++ b/pvptogglepluginworkspace/Pvptoggle.iml @@ -0,0 +1,12 @@ + + + + + + + SPIGOT + + + + + \ No newline at end of file diff --git a/pvptogglepluginworkspace/pom.xml b/pvptogglepluginworkspace/pom.xml new file mode 100644 index 0000000..4a47c27 --- /dev/null +++ b/pvptogglepluginworkspace/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + + benkralex + Pvptoggle + 1.4-FINAL + jar + + Pvptoggle + + + 1.8 + UTF-8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + + + + + + src/main/resources + true + + + + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + + + + org.spigotmc + spigot-api + 1.20.1-R0.1-SNAPSHOT + provided + + + dev.jorel + commandapi-bukkit-core + 9.0.3 + provided + + + diff --git a/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/Config.java b/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/Config.java new file mode 100644 index 0000000..d7bff1a --- /dev/null +++ b/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/Config.java @@ -0,0 +1,20 @@ +package benkralex.pvptoggle; + +import org.bukkit.configuration.file.FileConfiguration; + +import java.io.File; +import java.time.Instant; + +public class Config { + public static void createConfig() { + FileConfiguration config = Pvptoggle.pvptoggle.getConfig(); + config.options().copyDefaults(); + config.addDefault("pvp-time-hit-back", 60); + Pvptoggle.pvptoggle.saveConfig(); + } + + public static int getpvptime() { + FileConfiguration config = Pvptoggle.pvptoggle.getConfig(); + return config.getInt("pvp-time-hit-back"); + } +} diff --git a/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/PvpCommand.java b/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/PvpCommand.java new file mode 100644 index 0000000..4266553 --- /dev/null +++ b/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/PvpCommand.java @@ -0,0 +1,35 @@ +package benkralex.pvptoggle; + +import dev.jorel.commandapi.CommandAPI; +import dev.jorel.commandapi.CommandAPICommand; +import dev.jorel.commandapi.executors.CommandArguments; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; + +public class PvpCommand { + public static void createPvpCommand() { + //Create PVP-Command with Command-API + new CommandAPICommand("pvp"). + withSubcommand(new CommandAPICommand("toggle"). + executesPlayer((sender, args)->{ + pvpToggle(sender, args); + }). + withPermission("pvp.toggle"). + withUsage("/pvp toggle"). + withHelp("PvP damage für sich an/auschalten.", "Du kannst damit an/ausschalten, ob du geschlagen werden kannst.")). + register(); + } + + public static void pvpToggle(Player sender, CommandArguments args) { + PersistentDataContainer pdc = sender.getPersistentDataContainer(); + if (pdc.has(new NamespacedKey(Pvptoggle.pvptoggle, "pvptoggle"), PersistentDataType.BOOLEAN)) { + pdc.set(new NamespacedKey(Pvptoggle.pvptoggle, "pvptoggle"), PersistentDataType.BOOLEAN, + !pdc.get(new NamespacedKey(Pvptoggle.pvptoggle, "pvptoggle"), PersistentDataType.BOOLEAN)); + sender.sendMessage("Dein PvP-Schutz ist jetzt " + (pdc.get(new NamespacedKey(Pvptoggle.pvptoggle, "pvptoggle"), PersistentDataType.BOOLEAN)?"an":"aus")); + } else { + pdc.set(new NamespacedKey(Pvptoggle.pvptoggle, "pvptoggle"), PersistentDataType.BOOLEAN, true); + } + } +} diff --git a/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/PvpEvent.java b/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/PvpEvent.java new file mode 100644 index 0000000..c915bf1 --- /dev/null +++ b/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/PvpEvent.java @@ -0,0 +1,83 @@ +package benkralex.pvptoggle; + + +import org.bukkit.NamespacedKey; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.persistence.PersistentDataAdapterContext; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; +import sun.reflect.generics.tree.ArrayTypeSignature; + +import java.sql.Array; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +public class PvpEvent implements Listener { + + @EventHandler + public static void pvpListener(EntityDamageByEntityEvent event) { + Entity damager = event.getDamager(); + Entity victim = event.getEntity(); + + if (damager instanceof Player && victim instanceof Player) { + List pvpvictimsList; + List pvpvictimsListdamager; + PersistentDataContainer pdc = victim.getPersistentDataContainer(); + PersistentDataContainer pdcdamager = damager.getPersistentDataContainer(); + PersistentDataContainer[] pvpvictims = pdc.get(new NamespacedKey(Pvptoggle.pvptoggle, "pvpvictims"), PersistentDataType.TAG_CONTAINER_ARRAY); + PersistentDataContainer[] pvpvictimsdamager = pdcdamager.get(new NamespacedKey(Pvptoggle.pvptoggle, "pvpvictims"), PersistentDataType.TAG_CONTAINER_ARRAY); + boolean canpvp = false; + String victimuuid = victim.getUniqueId().toString(); + + if (pvpvictims != null) { + pvpvictimsList = new ArrayList(Arrays.asList(pvpvictims)); + } else { + pvpvictimsList = new ArrayList(); + } + + if (pvpvictimsdamager != null) { + pvpvictimsListdamager = new ArrayList(Arrays.asList(pvpvictimsdamager)); + } else { + pvpvictimsListdamager = new ArrayList(); + } + + for (int i = 0; i= Instant.now().getEpochSecond() - Config.getpvptime()) { + if (pdcfor.get(new NamespacedKey(Pvptoggle.pvptoggle, "uuid"), PersistentDataType.STRING).equals(victimuuid)) { + canpvp = true; + } + } else { + pvpvictimsListdamager.remove(i); + i--; + } + } + + if (pdc.has(new NamespacedKey(Pvptoggle.pvptoggle, "pvptoggle"), PersistentDataType.BOOLEAN) && + pdc.get(new NamespacedKey(Pvptoggle.pvptoggle, "pvptoggle"), PersistentDataType.BOOLEAN) && + !canpvp) { + + event.setCancelled(true); + + } else { + PersistentDataContainer pdcupdated = pdc.getAdapterContext().newPersistentDataContainer(); + String uuid = damager.getUniqueId().toString(); + pdcupdated.set(new NamespacedKey(Pvptoggle.pvptoggle, "uuid"), PersistentDataType.STRING, uuid); + pdcupdated.set(new NamespacedKey(Pvptoggle.pvptoggle, "time"), PersistentDataType.LONG, Instant.now().getEpochSecond()); + pvpvictimsList.add(pdcupdated); + pvpvictims = pvpvictimsList.toArray(new PersistentDataContainer[pvpvictimsList.size()]); + pdc.set(new NamespacedKey(Pvptoggle.pvptoggle, "pvpvictims"), PersistentDataType.TAG_CONTAINER_ARRAY, pvpvictims); + } + } + } + +} +//pdc.getAdapterContext().newPersistentDataContainer() \ No newline at end of file diff --git a/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/Pvptoggle.java b/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/Pvptoggle.java new file mode 100644 index 0000000..d349af0 --- /dev/null +++ b/pvptogglepluginworkspace/src/main/java/benkralex/pvptoggle/Pvptoggle.java @@ -0,0 +1,26 @@ +package benkralex.pvptoggle; + +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +public final class Pvptoggle extends JavaPlugin { + + public static Pvptoggle pvptoggle; + + @Override + public void onEnable() { + // Plugin enable logic + pvptoggle = this; + Bukkit.getPluginManager().registerEvents(new PvpEvent(), this); + PvpCommand.createPvpCommand(); + Config.createConfig(); + } + + @Override + public void onDisable() { + // Plugin shutdown logic + } +} \ No newline at end of file diff --git a/pvptogglepluginworkspace/src/main/resources/plugin.yml b/pvptogglepluginworkspace/src/main/resources/plugin.yml new file mode 100644 index 0000000..b1b10c3 --- /dev/null +++ b/pvptogglepluginworkspace/src/main/resources/plugin.yml @@ -0,0 +1,7 @@ +name: Pvptoggle +version: '${project.version}' +main: benkralex.pvptoggle.Pvptoggle +api-version: 1.20 +permissions: + pvp.toggle: + default: true \ No newline at end of file