first commit

This commit is contained in:
Patrick
2026-05-01 19:54:56 +02:00
commit 578661ebe9
15 changed files with 997 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
.gradle
.idea
build
gradle
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 WinniePatGG
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+48
View File
@@ -0,0 +1,48 @@
# PvP Kits Plugin for PaperMC 1.21.4
A customizable PvP kit plugin with GUI selection and player-specific kit layouts.
## Features
- **GUI-based kit selection** - Inventory menu for choosing kits
- **Persistent kit layouts** - Saves each player's item arrangement per kit
- **Hardcoded default kits** - Pre-configured with balanced PvP loadouts
- **Easy customization** - Simple to add new kits or modify existing ones
- **Modern 1.21.4 support** - Includes all new weapons and items
## Included Kits
| Kit Name | Icon Item | Special Features |
|------------|-----------|------------------|
| Warrior | Diamond Sword | Diamond armor, strength effect |
| Archer | Bow | Speed boost, arrows |
| Tank | Shield | Damage resistance |
| Assassin | Netherite Sword | Speed/jump boost, ender pearls |
| Mace | Mace | Wind Burst enchantment, netherite armor |
## Commands
- `/kits` - Open the kit selection GUI
- `/kits save <kitname>` - Save your current inventory as a kit layout
## Installation
1. Download the latest `.jar` from Releases
2. Place in your server's `plugins/` folder
3. Restart your server
## Configuration
Kits are hardcoded in `KitManager.java`. To modify kits:
1. Edit the `initializeKits()` method
2. Rebuild the plugin (`gradlew build`)
3. Replace the JAR file
4. Restart server
Example kit addition:
```java
Kit mage = new Kit("Mage", Material.BLAZE_ROD);
mage.setHelmet(new ItemStack(Material.LEATHER_HELMET));
// ... other armor/items ...
kits.put("mage", mage);
+61
View File
@@ -0,0 +1,61 @@
plugins {
id 'java'
id("xyz.jpenilla.run-paper") version "2.3.1"
}
group = 'de.winniepat'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/"
}
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
}
tasks {
runServer {
minecraftVersion("1.21")
}
}
def targetJavaVersion = 21
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release.set(targetJavaVersion)
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
tasks.register('copyPlugin', Copy) {
dependsOn build
from("$buildDir/libs")
include('*.jar')
into("C:/Users/winnie/Documents/lunaris/server/plugins")
}
build.finalizedBy(copyPlugin)
View File
Vendored
+249
View File
@@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+92
View File
@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+1
View File
@@ -0,0 +1 @@
rootProject.name = 'KitPlugin'
@@ -0,0 +1,39 @@
package de.winniepat.kitPlugin;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import java.util.ArrayList;
import java.util.List;
public class Kit {
private final String name;
private final Material iconMaterial;
private ItemStack helmet;
private ItemStack chestplate;
private ItemStack leggings;
private ItemStack boots;
private final List<ItemStack> items = new ArrayList<>();
private final List<PotionEffect> effects = new ArrayList<>();
public Kit(String name, Material iconMaterial) {
this.name = name;
this.iconMaterial = iconMaterial;
}
public String getName() { return name; }
public Material getIconMaterial() { return iconMaterial; }
public ItemStack getHelmet() { return helmet; }
public void setHelmet(ItemStack helmet) { this.helmet = helmet; }
public ItemStack getChestplate() { return chestplate; }
public void setChestplate(ItemStack chestplate) { this.chestplate = chestplate; }
public ItemStack getLeggings() { return leggings; }
public void setLeggings(ItemStack leggings) { this.leggings = leggings; }
public ItemStack getBoots() { return boots; }
public void setBoots(ItemStack boots) { this.boots = boots; }
public List<ItemStack> getItems() { return items; }
public void addItem(ItemStack item) { this.items.add(item); }
public List<PotionEffect> getEffects() { return effects; }
public void addEffect(PotionEffect effect) { this.effects.add(effect); }
}
@@ -0,0 +1,93 @@
package de.winniepat.kitPlugin;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import org.bukkit.entity.Player;
import java.io.*;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class KitDataStorage {
private final File dataFolder;
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
public KitDataStorage(File dataFolder) {
this.dataFolder = dataFolder;
if (!dataFolder.exists()) {
dataFolder.mkdirs();
}
}
public void savePlayerData(Player player, PlayerKitData data) {
File file = new File(dataFolder, player.getUniqueId() + ".json");
try (FileWriter writer = new FileWriter(file)) {
gson.toJson(data.serialize(), writer);
} catch (IOException e) {
e.printStackTrace();
}
}
public PlayerKitData loadPlayerData(Player player) {
File file = new File(dataFolder, player.getUniqueId() + ".json");
if (!file.exists()) {
return new PlayerKitData();
}
try (FileReader reader = new FileReader(file)) {
Type type = new TypeToken<Map<String, String>>(){}.getType();
Map<String, String> data = gson.fromJson(reader, type);
PlayerKitData playerData = new PlayerKitData();
if (data != null) {
playerData.deserialize(data);
}
return playerData;
} catch (IOException e) {
e.printStackTrace();
return new PlayerKitData();
}
}
public void saveAllData(Map<UUID, PlayerKitData> allData) {
for (Map.Entry<UUID, PlayerKitData> entry : allData.entrySet()) {
File file = new File(dataFolder, entry.getKey() + ".json");
try (FileWriter writer = new FileWriter(file)) {
gson.toJson(entry.getValue().serialize(), writer);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public Map<UUID, PlayerKitData> loadAllData() {
Map<UUID, PlayerKitData> allData = new HashMap<>();
File[] files = dataFolder.listFiles((dir, name) -> name.endsWith(".json"));
if (files != null) {
for (File file : files) {
try {
String fileName = file.getName();
UUID uuid = UUID.fromString(fileName.substring(0, fileName.lastIndexOf('.')));
try (FileReader reader = new FileReader(file)) {
Type type = new TypeToken<Map<String, String>>(){}.getType();
Map<String, String> data = gson.fromJson(reader, type);
PlayerKitData playerData = new PlayerKitData();
if (data != null) {
playerData.deserialize(data);
}
allData.put(uuid, playerData);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return allData;
}
}
@@ -0,0 +1,76 @@
package de.winniepat.kitPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
public class KitGUIListener implements Listener {
private final KitPlugin plugin;
private final Map<Player, String> editingKits = new HashMap<>();
public KitGUIListener(KitPlugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player)) return;
Player player = (Player) event.getWhoClicked();
String inventoryTitle = event.getView().getTitle();
if (inventoryTitle.equals("§6Select Your PvP Kit")) {
event.setCancelled(true);
handleKitSelection(event, player);
} else if (inventoryTitle.startsWith("§6Editing Kit: ")) {
handleKitEditing(event, player);
}
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
Player player = (Player) event.getPlayer();
String inventoryTitle = event.getView().getTitle();
if (inventoryTitle.startsWith("§6Editing Kit: ")) {
String kitName = editingKits.remove(player);
if (kitName != null) {
plugin.getKitManager().savePlayerKitLayout(player, kitName);
player.sendMessage("§aYour " + kitName + " kit layout has been automatically saved!");
}
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
editingKits.remove(event.getPlayer());
}
private void handleKitSelection(InventoryClickEvent event, Player player) {
ItemStack clicked = event.getCurrentItem();
if (clicked == null || !clicked.hasItemMeta()) return;
String kitName = clicked.getItemMeta().getDisplayName().substring(2);
if (event.isShiftClick() && event.isRightClick()) {
player.openInventory(Bukkit.createInventory(player, 36, "§6Editing Kit: " + kitName));
player.getInventory().clear();
plugin.getKitManager().giveKit(player, kitName.toLowerCase());
editingKits.put(player, kitName.toLowerCase());
} else {
plugin.getKitManager().giveKit(player, kitName.toLowerCase());
player.closeInventory();
}
}
private void handleKitEditing(InventoryClickEvent event, Player player) {
}
}
@@ -0,0 +1,177 @@
package de.winniepat.kitPlugin;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class KitManager {
private final Map<String, Kit> kits = new HashMap<>();
private Map<UUID, PlayerKitData> playerData = new HashMap<>();
private final KitDataStorage dataStorage;
public KitManager(File dataFolder) {
this.dataStorage = new KitDataStorage(dataFolder);
this.playerData = dataStorage.loadAllData();
}
public void initializeKits() {
Kit mace = new Kit("Mace", Material.MACE);
ItemStack maceStack = new ItemStack(Material.MACE, 1);
maceStack.addEnchantment(Enchantment.WIND_BURST, 3);
maceStack.addEnchantment(Enchantment.UNBREAKING, 3);
mace.addItem(maceStack);
ItemStack helmetStack = new ItemStack(Material.NETHERITE_HELMET, 1);
helmetStack.addEnchantment(Enchantment.PROTECTION, 3);
helmetStack.addEnchantment(Enchantment.UNBREAKING, 3);
mace.setHelmet(helmetStack);
ItemStack chestplateStack = new ItemStack(Material.NETHERITE_CHESTPLATE, 1);
chestplateStack.addEnchantment(Enchantment.PROTECTION, 3);
chestplateStack.addEnchantment(Enchantment.UNBREAKING, 3);
mace.setChestplate(chestplateStack);
ItemStack leggingsStack = new ItemStack(Material.NETHERITE_LEGGINGS, 1);
leggingsStack.addEnchantment(Enchantment.PROTECTION, 3);
leggingsStack.addEnchantment(Enchantment.UNBREAKING, 3);
mace.setLeggings(leggingsStack);
ItemStack bootsStack = new ItemStack(Material.NETHERITE_BOOTS, 1);
bootsStack.addEnchantment(Enchantment.PROTECTION, 3);
bootsStack.addEnchantment(Enchantment.UNBREAKING, 3);
mace.setBoots(bootsStack);
mace.addItem(new ItemStack(Material.WIND_CHARGE, 64));
mace.addItem(new ItemStack(Material.WIND_CHARGE, 64));
mace.addItem(new ItemStack(Material.ENDER_PEARL, 10));
mace.addItem(new ItemStack(Material.GOLDEN_APPLE, 4));
mace.addItem(new ItemStack(Material.WATER_BUCKET, 1));
mace.addItem(new ItemStack(Material.COOKED_BEEF, 32));
kits.put("mace", mace);
Kit warrior = new Kit("Warrior", Material.DIAMOND_SWORD);
warrior.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
warrior.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
warrior.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
warrior.setBoots(new ItemStack(Material.DIAMOND_BOOTS));
warrior.addItem(new ItemStack(Material.DIAMOND_SWORD));
warrior.addItem(new ItemStack(Material.GOLDEN_APPLE, 5));
warrior.addEffect(new PotionEffect(PotionEffectType.STRENGTH, 20*60, 0));
kits.put("warrior", warrior);
Kit archer = new Kit("Archer", Material.BOW);
archer.setHelmet(new ItemStack(Material.LEATHER_HELMET));
archer.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
archer.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
archer.setBoots(new ItemStack(Material.LEATHER_BOOTS));
archer.addItem(new ItemStack(Material.BOW));
archer.addItem(new ItemStack(Material.ARROW, 64));
archer.addItem(new ItemStack(Material.STONE_SWORD));
archer.addItem(new ItemStack(Material.COOKED_BEEF, 8));
archer.addEffect(new PotionEffect(PotionEffectType.SPEED, 20*60, 1));
kits.put("archer", archer);
Kit tank = new Kit("Tank", Material.SHIELD);
tank.setHelmet(new ItemStack(Material.IRON_HELMET));
tank.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
tank.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
tank.setBoots(new ItemStack(Material.IRON_BOOTS));
tank.addItem(new ItemStack(Material.IRON_SWORD));
tank.addItem(new ItemStack(Material.SHIELD));
tank.addItem(new ItemStack(Material.GOLDEN_CARROT, 3));
tank.addEffect(new PotionEffect(PotionEffectType.RESISTANCE, 20*60, 0));
tank.addEffect(new PotionEffect(PotionEffectType.SLOWNESS, 20*60, 0));
kits.put("tank", tank);
Kit assassin = new Kit("Assassin", Material.NETHERITE_SWORD);
assassin.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
assassin.setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
assassin.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
assassin.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
assassin.addItem(new ItemStack(Material.NETHERITE_SWORD));
assassin.addItem(new ItemStack(Material.ENDER_PEARL, 2));
assassin.addEffect(new PotionEffect(PotionEffectType.SPEED, 20*60, 2));
assassin.addEffect(new PotionEffect(PotionEffectType.JUMP_BOOST, 20*60, 1));
kits.put("assassin", assassin);
}
public void openKitSelectionGUI(Player player) {
Inventory gui = Bukkit.createInventory(null, 9, "§6Select Your PvP Kit");
for (Map.Entry<String, Kit> entry : kits.entrySet()) {
Kit kit = entry.getValue();
ItemStack icon = new ItemStack(kit.getIconMaterial());
ItemMeta meta = icon.getItemMeta();
meta.setDisplayName("§a" + kit.getName());
meta.setLore(Arrays.asList(
"§7Click to select this kit",
"§7Includes armor, weapons, and effects"
));
icon.setItemMeta(meta);
gui.addItem(icon);
}
player.openInventory(gui);
}
public void giveKit(Player player, String kitName) {
Kit kit = kits.get(kitName.toLowerCase());
if (kit == null) return;
PlayerKitData data = getPlayerData(player);
ItemStack[] savedLayout = data.getKitLayout(kitName);
player.getInventory().clear();
for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
if (savedLayout != null && savedLayout.length > 0) {
player.getInventory().setContents(savedLayout);
} else {
if (kit.getHelmet() != null) player.getInventory().setHelmet(kit.getHelmet());
if (kit.getChestplate() != null) player.getInventory().setChestplate(kit.getChestplate());
if (kit.getLeggings() != null) player.getInventory().setLeggings(kit.getLeggings());
if (kit.getBoots() != null) player.getInventory().setBoots(kit.getBoots());
for (ItemStack item : kit.getItems()) {
player.getInventory().addItem(item.clone());
}
}
for (PotionEffect effect : kit.getEffects()) {
player.addPotionEffect(effect);
}
player.sendMessage("§aYou have selected the " + kit.getName() + " kit!");
}
public void savePlayerKitLayout(Player player, String kitName) {
PlayerKitData data = getPlayerData(player);
data.setKitLayout(kitName, player.getInventory().getContents());
dataStorage.savePlayerData(player, data);
player.sendMessage("§aYour " + kitName + " kit layout has been saved!");
}
private PlayerKitData getPlayerData(Player player) {
return playerData.computeIfAbsent(player.getUniqueId(), k -> new PlayerKitData());
}
public void saveAllData() {
dataStorage.saveAllData(playerData);
}
}
@@ -0,0 +1,55 @@
package de.winniepat.kitPlugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public final class KitPlugin extends JavaPlugin {
private KitManager kitManager;
@Override
public void onEnable() {
this.kitManager = new KitManager(getDataFolder());
kitManager.initializeKits();
getCommand("kits").setExecutor(this);
getServer().getPluginManager().registerEvents(new KitGUIListener(this), this);
getLogger().info("PvP Kits plugin enabled!");
}
@Override
public void onDisable() {
getLogger().info("disabled.");
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can use this command!");
return true;
}
Player player = (Player) sender;
if (args.length > 0 && args[0].equalsIgnoreCase("save")) {
if (args.length < 2) {
player.sendMessage("§cUsage: /kits save <kitname>");
return true;
}
kitManager.savePlayerKitLayout(player, args[1].toLowerCase());
return true;
}
kitManager.openKitSelectionGUI(player);
return true;
}
public KitManager getKitManager() {
return kitManager;
}
}
@@ -0,0 +1,70 @@
package de.winniepat.kitPlugin;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class PlayerKitData {
private final Map<String, ItemStack[]> kitLayouts = new HashMap<>();
public void setKitLayout(String kitName, ItemStack[] contents) {
kitLayouts.put(kitName, contents);
}
public ItemStack[] getKitLayout(String kitName) {
return kitLayouts.get(kitName);
}
public Map<String, String> serialize() {
Map<String, String> serialized = new HashMap<>();
for (Map.Entry<String, ItemStack[]> entry : kitLayouts.entrySet()) {
serialized.put(entry.getKey(), itemStackArrayToBase64(entry.getValue()));
}
return serialized;
}
public void deserialize(Map<String, String> data) {
for (Map.Entry<String, String> entry : data.entrySet()) {
kitLayouts.put(entry.getKey(), itemStackArrayFromBase64(entry.getValue()));
}
}
private String itemStackArrayToBase64(ItemStack[] items) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeInt(items.length);
for (ItemStack item : items) {
dataOutput.writeObject(item);
}
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
throw new IllegalStateException("Unable to save item stacks.", e);
}
}
private ItemStack[] itemStackArrayFromBase64(String data) {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] items = new ItemStack[dataInput.readInt()];
for (int i = 0; i < items.length; i++) {
items[i] = (ItemStack) dataInput.readObject();
}
dataInput.close();
return items;
} catch (IOException | ClassNotFoundException e) {
return new ItemStack[0];
}
}
}
+11
View File
@@ -0,0 +1,11 @@
name: KitPlugin
version: '1.0'
main: de.winniepat.kitPlugin.KitPlugin
api-version: '1.21'
authors: [ WinniePatGG ]
description: Kit Plugin
website: https://winniepat.de
commands:
kits:
description: Open Kit Selection
usage: /kits