mirror of
https://github.com/devLukaDev/PureKitPvP.git
synced 2026-11-05 01:00:08 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e6144fcea | ||
|
|
440d43ed09 |
No files matched your search
+20
-6
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.lifelessnerd.purekitpvp</groupId>
|
||||
<artifactId>PureKitPvP</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.3.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>PureKitPvP</name>
|
||||
@@ -24,8 +24,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@@ -49,7 +49,7 @@
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<outputDirectory>/run/media/luka/250GB SATA SSD/Minecraft/Servers/1.21.11/plugins/</outputDirectory>
|
||||
<outputDirectory>F:\Minecraft\Servers\MC 1.20.6 Server\plugins</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
@@ -74,21 +74,35 @@
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.21.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://github.com/CatCoderr/ProtocolSidebar -->
|
||||
<dependency>
|
||||
<groupId>me.catcoder</groupId>
|
||||
<artifactId>bukkit-sidebar</artifactId>
|
||||
<version>6.2.7-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.j256.ormlite/ormlite-jdbc -->
|
||||
<dependency>
|
||||
<groupId>com.j256.ormlite</groupId>
|
||||
<artifactId>ormlite-jdbc</artifactId>
|
||||
<version>6.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.steveice10/opennbt -->
|
||||
<dependency>
|
||||
<groupId>com.github.steveice10</groupId>
|
||||
<artifactId>opennbt</artifactId>
|
||||
<version>1.6</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -38,7 +38,7 @@ public class InfoCommand extends Subcommand{
|
||||
|
||||
String message =
|
||||
"""
|
||||
&bPureKitPvP - version 1.4
|
||||
&bPureKitPvP - version 1.3.1
|
||||
&6Discord Support: &ohttps://discord.com/invite/8n65jSEkVf
|
||||
&6SpigotMC: &ohttps://bit.ly/PureKitPvPSpigotMC
|
||||
&6Github: &ohttps://github.com/LifelessNerd/PureKitPvP
|
||||
|
||||
@@ -7,6 +7,7 @@ import me.lifelessnerd.purekitpvp.combathandlers.killhandler.DeathHandler;
|
||||
import me.lifelessnerd.purekitpvp.database.KitDatabase;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageConfig;
|
||||
import me.lifelessnerd.purekitpvp.globalevents.events.DoubleHealthListeners;
|
||||
import me.lifelessnerd.purekitpvp.scoreboards.SidebarScoreboard;
|
||||
import me.lifelessnerd.purekitpvp.cosmetics.cosmeticsCommand.CosmeticsCommand;
|
||||
import me.lifelessnerd.purekitpvp.cosmetics.cosmeticsCommand.CosmeticsGUIListener;
|
||||
import me.lifelessnerd.purekitpvp.cosmetics.cosmeticsCommand.inventories.KillEffectInventory;
|
||||
@@ -93,6 +94,9 @@ public final class PureKitPvP extends JavaPlugin {
|
||||
LanguageConfig.save();
|
||||
LanguageConfig.loadLanguage();
|
||||
|
||||
|
||||
SidebarScoreboard scoreboard = new SidebarScoreboard(this);
|
||||
|
||||
getCommand("getkit").setExecutor(new GetKit(this));
|
||||
getCommand("kit").setExecutor(new KitsGUI(this));
|
||||
getCommand("perk").setExecutor(new PerkCommand(this));
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.lifelessnerd.purekitpvp;
|
||||
|
||||
import me.lifelessnerd.purekitpvp.files.*;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageConfig;
|
||||
import me.lifelessnerd.purekitpvp.scoreboards.SidebarScoreboard;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -72,6 +73,8 @@ public class ReloadPlugin extends Subcommand {
|
||||
plugin.saveConfig();
|
||||
plugin.saveDefaultConfig();
|
||||
|
||||
SidebarScoreboard scoreboard = new SidebarScoreboard(plugin); // Make new Scoreboard instance
|
||||
|
||||
sender.sendMessage(Component.text("Plugin configs were reloaded!"));
|
||||
sender.sendMessage(Component.text("Please note that settings relating to events are not reloaded." +
|
||||
"\nIf you have made such changes, a server reload/restart is required.").color(NamedTextColor.GRAY));
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDismountEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.spigotmc.event.entity.EntityDismountEvent;
|
||||
|
||||
public class PearlListener implements Listener {
|
||||
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public class DeathHandler implements Listener {
|
||||
player.setExp(0f);
|
||||
player.setLevel(0);
|
||||
player.setArrowsInBody(0);
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP_BOOST, 5, 254)); //Kinda jank, works tho
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 5, 254)); //Kinda jank, works tho
|
||||
player.setFireTicks(0);
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 5, 1));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 10 , 1));
|
||||
|
||||
+14
-16
@@ -33,7 +33,7 @@ public class OnPlayerSpawnMob implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerUseSpawnEgg(PlayerInteractEvent e) {
|
||||
public void playerUseSpawnEgg(PlayerInteractEvent e){
|
||||
|
||||
Player player = e.getPlayer();
|
||||
|
||||
@@ -41,25 +41,26 @@ public class OnPlayerSpawnMob implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
|
||||
if (!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!(player.getInventory().getItemInMainHand().getType().toString().contains("_SPAWN_EGG"))) {
|
||||
if (!(player.getInventory().getItemInMainHand().getType().toString().contains("_SPAWN_EGG"))){
|
||||
return;
|
||||
}
|
||||
|
||||
EntityType entityTypeTBS;
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
boolean customMob = false;
|
||||
if (item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(plugin, "custom_mob_id"), PersistentDataType.STRING)) {
|
||||
if (item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(plugin, "custom_mob_id"), PersistentDataType.STRING)){
|
||||
// Custom Mob has been attempted to spawn
|
||||
String customMobId = item.getItemMeta().getPersistentDataContainer().get(new NamespacedKey(plugin, "custom_mob_id"), PersistentDataType.STRING);
|
||||
String mobType = MobSpawnConfig.get().getString(customMobId + ".type");
|
||||
entityTypeTBS = EntityType.valueOf(mobType);
|
||||
customMob = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
String[] entityToBeSpawnedList = item.getType().toString().split("_SPAWN_EGG");
|
||||
String entityToBeSpawned = entityToBeSpawnedList[0];
|
||||
|
||||
@@ -70,8 +71,8 @@ public class OnPlayerSpawnMob implements Listener {
|
||||
Location lookPlace = e.getInteractionPoint();
|
||||
Entity spawnedEntity = player.getWorld().spawnEntity(lookPlace, entityTypeTBS);
|
||||
|
||||
if (spawnedEntity instanceof Chicken) {
|
||||
if (plugin.getConfig().getBoolean("chicken-prevention")) {
|
||||
if (spawnedEntity instanceof Chicken){
|
||||
if (plugin.getConfig().getBoolean("chicken-prevention")){
|
||||
player.sendMessage(Component.text("ChickenPrevention prevented your chicken from spawning.").color(NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
@@ -93,7 +94,7 @@ public class OnPlayerSpawnMob implements Listener {
|
||||
if (customMob) {
|
||||
String customModId = item.getItemMeta().getPersistentDataContainer().get(new NamespacedKey(plugin, "custom_mob_id"), PersistentDataType.STRING);
|
||||
// System.out.println(customModId);
|
||||
if (spawnedEntity instanceof Mob) {
|
||||
if (spawnedEntity instanceof Mob){
|
||||
ItemStack mainHand = MobSpawnConfig.get().getItemStack(customModId + ".mainhand");
|
||||
((Mob) spawnedEntity).getEquipment().setItemInMainHand(mainHand);
|
||||
ItemStack offHand = MobSpawnConfig.get().getItemStack(customModId + ".offhand");
|
||||
@@ -140,13 +141,12 @@ public class OnPlayerSpawnMob implements Listener {
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Stolen from https://www.spigotmc.org/threads/how-do-i-get-the-nearest-player.506654/
|
||||
public static @Nullable Player getNearestPlayer(Player player) {
|
||||
World world = player.getWorld();
|
||||
Location location = player.getLocation();
|
||||
ArrayList<Player> playersInWorld = new ArrayList<>(world.getEntitiesByClass(Player.class));
|
||||
if (playersInWorld.size() == 1) return null;
|
||||
if(playersInWorld.size()==1) return null;
|
||||
playersInWorld.remove(player); //Removes player itself
|
||||
playersInWorld.sort(Comparator.comparingDouble(o -> o.getLocation().distanceSquared(location)));
|
||||
return playersInWorld.get(0);
|
||||
@@ -160,13 +160,13 @@ public class OnPlayerSpawnMob implements Listener {
|
||||
if (!(entity.getWorld().getName().equalsIgnoreCase(plugin.getConfig().getString("world")))) {
|
||||
return;
|
||||
}
|
||||
if (toBeCancelled) {
|
||||
if(toBeCancelled){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void mobTargetEvent(EntityTargetEvent e) {
|
||||
public void mobTargetEvent(EntityTargetEvent e){
|
||||
|
||||
Entity entity = e.getEntity();
|
||||
Entity target = e.getTarget();
|
||||
@@ -180,11 +180,9 @@ public class OnPlayerSpawnMob implements Listener {
|
||||
String entityName = entity.getName();
|
||||
String playerName = entityName.split("'s")[0]; // Gets name of player who spawned it
|
||||
Player player = Bukkit.getPlayerExact(playerName); // TODOX: This is quite janky, requires testing: seems to work!
|
||||
if (player != null) {
|
||||
Player closestPlayer = getNearestPlayer(player); // NPE has no effect it seems; target becomes null and zombie is fine with that
|
||||
((Monster) entity).setTarget(closestPlayer);
|
||||
Player closestPlayer = getNearestPlayer(player); // NPE has no effect it seems; target becomes null and zombie is fine with that
|
||||
((Monster) entity).setTarget(closestPlayer);
|
||||
// System.out.println(entity + "'s target set to " + closestPlayer);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public CosmeticsCommand(Plugin plugin) {
|
||||
// Kill cosmetics button
|
||||
ItemStack killEffectButton = new ItemStack(Material.DIAMOND_SWORD);
|
||||
ItemMeta killEffectButtonMeta = killEffectButton.getItemMeta();
|
||||
killEffectButtonMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
killEffectButtonMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
killEffectButtonMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
killEffectButtonMeta.displayName(Component.text("Kill Effect").color(TextColor.color(200, 152, 0)).decoration(TextDecoration.ITALIC, false));
|
||||
List<Component> loreList2 = new ArrayList<>();
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ public class KillEffectInventory implements Listener {
|
||||
for (String killEffect : lib.killEffects.keySet()) {
|
||||
ItemStack effectItem = new ItemStack(lib.killEffects.get(killEffect), 1);
|
||||
ItemMeta itemMeta = effectItem.getItemMeta();
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
Component displayName = Component.text(MyStringUtils.cosmeticIdToItemName(killEffect));
|
||||
@@ -59,7 +59,7 @@ public class KillEffectInventory implements Listener {
|
||||
if (configValue.equalsIgnoreCase(killEffect)){
|
||||
displayName = displayName.color(NamedTextColor.GREEN).decoration(TextDecoration.ITALIC, false);
|
||||
displayName = displayName.decoration(TextDecoration.BOLD, true);
|
||||
itemMeta.addEnchant(Enchantment.SHARPNESS, 1, true);
|
||||
itemMeta.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
|
||||
} else {
|
||||
displayName = displayName.color(NamedTextColor.RED).decoration(TextDecoration.ITALIC, false);;
|
||||
}
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ public class KillMessageInventory implements Listener {
|
||||
for (String messageEffect : lib.messageEffects.keySet()) {
|
||||
ItemStack effectItem = new ItemStack(lib.messageEffects.get(messageEffect), 1);
|
||||
ItemMeta itemMeta = effectItem.getItemMeta();
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
Component displayName = Component.text(MyStringUtils.cosmeticIdToItemName(messageEffect));
|
||||
@@ -58,7 +58,7 @@ public class KillMessageInventory implements Listener {
|
||||
if (configValue.equalsIgnoreCase(messageEffect)){
|
||||
displayName = displayName.color(NamedTextColor.GREEN).decoration(TextDecoration.ITALIC, false);
|
||||
displayName = displayName.decoration(TextDecoration.BOLD, true);
|
||||
itemMeta.addEnchant(Enchantment.SHARPNESS, 1, true);
|
||||
itemMeta.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
|
||||
} else {
|
||||
displayName = displayName.color(NamedTextColor.RED).decoration(TextDecoration.ITALIC, false);;
|
||||
}
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ public class ProjectileTrailInventory implements Listener {
|
||||
for (String projectileTrail : lib.trailEffects.keySet()) {
|
||||
ItemStack effectItem = new ItemStack(lib.trailEffects.get(projectileTrail), 1);
|
||||
ItemMeta itemMeta = effectItem.getItemMeta();
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
Component displayName = Component.text(MyStringUtils.cosmeticIdToItemName(projectileTrail));
|
||||
@@ -58,7 +58,7 @@ public class ProjectileTrailInventory implements Listener {
|
||||
if (configValue.equalsIgnoreCase(projectileTrail)){
|
||||
displayName = displayName.color(NamedTextColor.GREEN).decoration(TextDecoration.ITALIC, false);
|
||||
displayName = displayName.decoration(TextDecoration.BOLD, true);
|
||||
itemMeta.addEnchant(Enchantment.SHARPNESS, 1, true);
|
||||
itemMeta.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
|
||||
} else {
|
||||
displayName = displayName.color(NamedTextColor.RED).decoration(TextDecoration.ITALIC, false);;
|
||||
}
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ public class KillEffect implements Listener {
|
||||
|
||||
public static void firework(Location location) {
|
||||
location = location.add(0,1.4,0);
|
||||
Firework fw = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK_ROCKET);
|
||||
Firework fw = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
|
||||
FireworkMeta fwm = fw.getFireworkMeta();
|
||||
fwm.addEffect(FireworkEffect.builder().withColor(Color.RED).withColor(Color.WHITE).flicker(true).build());
|
||||
fw.setMetadata("nodamage", new FixedMetadataValue(plugin, true));
|
||||
@@ -104,7 +104,7 @@ public class KillEffect implements Listener {
|
||||
for (float i = 0.5f; i < 1.8f; i += 0.1) {
|
||||
float rndFloat = rnd.nextFloat() / 10;
|
||||
location.getWorld().spawnParticle(
|
||||
Particle.BLOCK,
|
||||
Particle.BLOCK_CRACK,
|
||||
location.add(rndFloat,i,rndFloat),
|
||||
20,
|
||||
Material.REDSTONE_BLOCK.createBlockData()
|
||||
|
||||
+3
-3
@@ -106,16 +106,16 @@ public class ProjectileTrail implements Listener {
|
||||
location.getWorld().spawnParticle(Particle.END_ROD, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
break;
|
||||
case "water_drip":
|
||||
location.getWorld().spawnParticle(Particle.DRIPPING_WATER, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
location.getWorld().spawnParticle(Particle.DRIP_WATER, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
break;
|
||||
case "heart":
|
||||
location.getWorld().spawnParticle(Particle.HEART, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
break;
|
||||
case "firework":
|
||||
location.getWorld().spawnParticle(Particle.ELECTRIC_SPARK, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
break;
|
||||
case "totem":
|
||||
location.getWorld().spawnParticle(Particle.TOTEM_OF_UNDYING, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
location.getWorld().spawnParticle(Particle.TOTEM, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
break;
|
||||
case "smoke":
|
||||
location.getWorld().spawnParticle(Particle.CAMPFIRE_COSY_SMOKE, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
|
||||
@@ -186,7 +186,6 @@ public class LanguageConfig {
|
||||
defaults.put(LanguageKey.SCOREBOARD_GLOBAL_KILLS, " &dKills");
|
||||
defaults.put(LanguageKey.SCOREBOARD_GLOBAL_KD, " &dK/D Ratio");
|
||||
defaults.put(LanguageKey.SCOREBOARD_GLOBAL_LEVEL, "&dLevel");
|
||||
|
||||
defaults.put(LanguageKey.STATS_NO_STATS, "That player has no stats attached to them!");
|
||||
defaults.put(LanguageKey.STATS_TITLE, "%PLAYER% &bStatistics");
|
||||
defaults.put(LanguageKey.STATS_LEVEL_UP, "&6You leveled up to LEVEL %VALUE%!");
|
||||
|
||||
@@ -102,7 +102,7 @@ public class KitsGUI implements TabExecutor {
|
||||
|
||||
ItemStack itemStack = new ItemStack(Material.BARRIER);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
|
||||
// Set gui item
|
||||
@@ -160,14 +160,14 @@ public class KitsGUI implements TabExecutor {
|
||||
String amount = String.valueOf(item.getAmount());
|
||||
lore.add(Component.text(amount + "x ", NamedTextColor.GRAY).decoration(TextDecoration.ITALIC, false).append(
|
||||
Component.text(MyStringUtils.itemCamelCase(item.getType().toString()), NamedTextColor.YELLOW)));
|
||||
lore.add(Component.text(" " + MyStringUtils.potionMetaToEffects(item.getItemMeta()), NamedTextColor.GRAY));
|
||||
lore.add(Component.text(" " + MyStringUtils.itemMetaToEffects(item.getItemMeta().toString()), NamedTextColor.GRAY));
|
||||
|
||||
} else if (item.getType().toString().equalsIgnoreCase("POTION")){
|
||||
//Do stuff with potions
|
||||
String amount = String.valueOf(item.getAmount());
|
||||
lore.add(Component.text(amount + "x ", NamedTextColor.GRAY).decoration(TextDecoration.ITALIC, false).append(
|
||||
Component.text(MyStringUtils.itemCamelCase(item.getType().toString()), NamedTextColor.YELLOW)));
|
||||
lore.add(Component.text(" " + MyStringUtils.potionMetaToEffects(item.getItemMeta()), NamedTextColor.GRAY));
|
||||
lore.add(Component.text(" " + MyStringUtils.itemMetaToEffects(item.getItemMeta().toString()), NamedTextColor.GRAY));
|
||||
|
||||
} else if (item.getType().toString().equalsIgnoreCase("PLAYER_HEAD")){
|
||||
|
||||
@@ -189,7 +189,7 @@ public class KitsGUI implements TabExecutor {
|
||||
Component.text(MyStringUtils.itemCamelCase(item.getType().toString()), NamedTextColor.YELLOW)));
|
||||
//If it has enchants, view them
|
||||
if (!(item.getEnchantments().isEmpty())){
|
||||
lore.add(Component.text(" " + MyStringUtils.mapEnchantmentsToString(item.getEnchantments()), NamedTextColor.GRAY));
|
||||
lore.add(Component.text(" " + MyStringUtils.mapStringToEnchantment(item.getEnchantments().toString()), NamedTextColor.GRAY));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -74,7 +74,7 @@ public class PerkGUIListener implements Listener {
|
||||
|
||||
ItemStack icon = new ItemStack(perkLib.perkIcons.get(perk));
|
||||
ItemMeta itemMeta = icon.getItemMeta();
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
itemMeta.displayName(Component.text(perk).color(TextColor.color(200, 0, 0)).decoration(TextDecoration.ITALIC, false));
|
||||
|
||||
@@ -82,7 +82,7 @@ public class PerkGUIListener implements Listener {
|
||||
for(String selectedPerkKey : PerkData.get().getConfigurationSection(player.getName()).getKeys(false)){
|
||||
String selectedPerk = PerkData.get().getString(player.getName() + "." + selectedPerkKey);
|
||||
if (perk.equals(selectedPerk)){
|
||||
itemMeta.addEnchant(Enchantment.SHARPNESS, 1, true);
|
||||
itemMeta.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
itemMeta.displayName(Component.text(perk).color(TextColor.color(50, 200, 0)).decoration(TextDecoration.BOLD, true).decoration(TextDecoration.ITALIC, false));
|
||||
}
|
||||
|
||||
+8
-8
@@ -60,7 +60,7 @@ public class PerkFireHandler {
|
||||
break;
|
||||
case "BULLDOZER":
|
||||
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.STRENGTH, 60, 1));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 60, 1));
|
||||
break;
|
||||
case "KNOWLEDGE":
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PerkFireHandler {
|
||||
ItemMeta weaponMeta = weapon.getItemMeta();
|
||||
if (weaponMeta == null){continue;} // If weapon is hand TODO maybe - check if it is a weapon?
|
||||
if (weapon.getType() == Material.BOW){continue;} // meh
|
||||
int sharpnessLevel = weaponMeta.getEnchantLevel(Enchantment.SHARPNESS);
|
||||
int sharpnessLevel = weaponMeta.getEnchantLevel(Enchantment.DAMAGE_ALL);
|
||||
|
||||
double rnd = Math.random();
|
||||
if(rnd * 100 <= (100 - plugin.getConfig().getInt("notoriety-chance-decrease") * sharpnessLevel)) {
|
||||
@@ -84,8 +84,8 @@ public class PerkFireHandler {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
weaponMeta.removeEnchant(Enchantment.SHARPNESS);
|
||||
weaponMeta.addEnchant(Enchantment.SHARPNESS, sharpnessLevel + 1, true);
|
||||
weaponMeta.removeEnchant(Enchantment.DAMAGE_ALL);
|
||||
weaponMeta.addEnchant(Enchantment.DAMAGE_ALL, sharpnessLevel + 1, true);
|
||||
weapon.setItemMeta(weaponMeta);
|
||||
player.sendMessage(LanguageConfig.lang.get("PERKS_PERK_NOTORIETY_UPGRADE").
|
||||
replaceText(ComponentUtils.replaceConfig("%CHANCE%",
|
||||
@@ -110,7 +110,7 @@ public class PerkFireHandler {
|
||||
ItemMeta weaponMarksmanMeta = weaponMarksman.getItemMeta();
|
||||
if (weaponMarksman.getType() != Material.BOW){continue;}
|
||||
if (weaponMarksmanMeta == null){continue;} // If weapon is hand
|
||||
int powerLevel = weaponMarksmanMeta.getEnchantLevel(Enchantment.POWER);
|
||||
int powerLevel = weaponMarksmanMeta.getEnchantLevel(Enchantment.ARROW_DAMAGE);
|
||||
|
||||
double rnd2 = Math.random();
|
||||
if(rnd2 * 100 <= (100 - plugin.getConfig().getInt("notoriety-chance-decrease") * powerLevel)) {
|
||||
@@ -123,8 +123,8 @@ public class PerkFireHandler {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
weaponMarksmanMeta.removeEnchant(Enchantment.POWER);
|
||||
weaponMarksmanMeta.addEnchant(Enchantment.POWER, powerLevel + 1, true);
|
||||
weaponMarksmanMeta.removeEnchant(Enchantment.ARROW_DAMAGE);
|
||||
weaponMarksmanMeta.addEnchant(Enchantment.ARROW_DAMAGE, powerLevel + 1, true);
|
||||
weaponMarksman.setItemMeta(weaponMarksmanMeta);
|
||||
player.sendMessage(LanguageConfig.lang.get("PERKS_PERK_MARKSMAN_UPGRADE").
|
||||
replaceText(ComponentUtils.replaceConfig("%CHANCE%",
|
||||
@@ -245,7 +245,7 @@ public class PerkFireHandler {
|
||||
switch(perk){
|
||||
case "SNOWMAN":
|
||||
if (event.getEntity() instanceof Snowball) {
|
||||
damaged.addPotionEffect(new PotionEffect(PotionEffectType.SLOWNESS, 60, 0));
|
||||
damaged.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 0));
|
||||
}
|
||||
break;
|
||||
case "DISRUPTOR":
|
||||
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
package me.lifelessnerd.purekitpvp.scoreboards;
|
||||
import me.catcoder.sidebar.ProtocolSidebar;
|
||||
import me.catcoder.sidebar.Sidebar;
|
||||
import me.catcoder.sidebar.pager.SidebarPager;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageConfig;
|
||||
import me.lifelessnerd.purekitpvp.files.PlayerStatsConfig;
|
||||
import me.lifelessnerd.purekitpvp.utils.ComponentUtils;
|
||||
import me.lifelessnerd.purekitpvp.utils.DoubleUtils;
|
||||
import me.lifelessnerd.purekitpvp.utils.PlayerUtils;
|
||||
|
||||
import me.lifelessnerd.purekitpvp.versioning.MinecraftVersion;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SidebarScoreboard implements Listener {
|
||||
Plugin plugin;
|
||||
|
||||
|
||||
public SidebarScoreboard(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
|
||||
if (plugin.getConfig().getBoolean("scoreboard-enabled")){
|
||||
refreshLeaderboard();
|
||||
}
|
||||
System.out.println(MinecraftVersion.getVersion());
|
||||
|
||||
}
|
||||
|
||||
public void refreshLeaderboard() {
|
||||
Set<Player> players = PlayerUtils.getPlayersInWorld(plugin.getConfig().getString("world"));
|
||||
|
||||
List<String> enabled = plugin.getConfig().getStringList("enabled-slides");
|
||||
|
||||
ArrayList<Sidebar<Component>> enabledSidebars = new ArrayList<>();
|
||||
|
||||
Component titleComponent = LanguageConfig.lang.get("SCOREBOARD_MAIN_TITLE");
|
||||
|
||||
for (String panel : enabled) {
|
||||
|
||||
switch(panel){
|
||||
case "GlobalStats":
|
||||
Sidebar<Component> globalStatsSidebar = ProtocolSidebar.newAdventureSidebar(titleComponent, plugin);
|
||||
globalStatsSidebar.getObjective().scoreNumberFormatBlank();
|
||||
fillGlobalSidebar(globalStatsSidebar);
|
||||
enabledSidebars.add(globalStatsSidebar);
|
||||
break;
|
||||
case "PersonalStats":
|
||||
Sidebar<Component> personalStatsSidebar = ProtocolSidebar.newAdventureSidebar(titleComponent, plugin);
|
||||
personalStatsSidebar.getObjective().scoreNumberFormatBlank();
|
||||
fillPersonalSidebar(personalStatsSidebar);
|
||||
enabledSidebars.add(personalStatsSidebar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
long period = plugin.getConfig().getInt("scoreboard-period") * 20L;
|
||||
SidebarPager<Component> pager = new SidebarPager<>(
|
||||
enabledSidebars, period, plugin);
|
||||
|
||||
// add page status line to all sidebars in pager
|
||||
pager.addPageLine((page, maxPage, sidebar) ->
|
||||
sidebar.addLine(Component.text("Page " + page + "/" + maxPage).color(NamedTextColor.GREEN)));
|
||||
|
||||
|
||||
for (Player player : players){
|
||||
pager.show(player);
|
||||
if (!(plugin.getConfig().getBoolean("scoreboard-enabled"))){
|
||||
pager.hide(player);
|
||||
}
|
||||
}
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.getConfig().getBoolean("scoreboard-enabled")){
|
||||
refreshLeaderboard();
|
||||
}
|
||||
pager.destroy();
|
||||
}
|
||||
}.runTaskLater(plugin, period * 2);
|
||||
}
|
||||
|
||||
|
||||
private void fillGlobalSidebar(Sidebar<Component> sidebar) {
|
||||
|
||||
int places = plugin.getConfig().getInt("global-stats-place-amount");
|
||||
List<String> enabled = plugin.getConfig().getStringList("global-stats-components");
|
||||
|
||||
sidebar.addLine(LanguageConfig.lang.get("SCOREBOARD_GLOBAL_TITLE"));
|
||||
|
||||
for (String component : enabled){
|
||||
ArrayList<Component> createdLeaderboard = null;
|
||||
switch(component) {
|
||||
case "Killstreak":
|
||||
sidebar.addLine(LanguageConfig.lang.get("SCOREBOARD_GLOBAL_KILLSTREAK"));
|
||||
|
||||
createdLeaderboard = createLeaderboard(".killstreak", places);
|
||||
|
||||
break;
|
||||
case "Level":
|
||||
sidebar.addLine(LanguageConfig.lang.get("SCOREBOARD_GLOBAL_LEVEL"));
|
||||
createdLeaderboard = createLeaderboard(".level", places);
|
||||
|
||||
break;
|
||||
case "Kills":
|
||||
sidebar.addLine(LanguageConfig.lang.get("SCOREBOARD_GLOBAL_KILLS"));
|
||||
createdLeaderboard = createLeaderboard(".kills", places);
|
||||
|
||||
break;
|
||||
case "KD":
|
||||
sidebar.addLine(LanguageConfig.lang.get("SCOREBOARD_GLOBAL_KD"));
|
||||
createdLeaderboard = createLeaderboard(".kdratio", places);
|
||||
|
||||
break;
|
||||
default:
|
||||
plugin.getLogger().warning("Global leaderboard components are wrongly defined! " +
|
||||
"If you do not want a global scoreboard, change this in the enabled-slides value.");
|
||||
createdLeaderboard = new ArrayList<>(); // This is empty; only happens when there are no/faulty values defined
|
||||
break;
|
||||
}
|
||||
|
||||
for (Component line : createdLeaderboard){
|
||||
sidebar.addUpdatableLine(
|
||||
(player) -> {
|
||||
return line;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sidebar.updateLinesPeriodically(0, 20);
|
||||
}
|
||||
|
||||
|
||||
private ArrayList<Component> createLeaderboard(String statKey, int places) {
|
||||
HashMap<String, Double> leaderboard = new HashMap<>();
|
||||
|
||||
Set<String> players = PlayerStatsConfig.get().getKeys(false);
|
||||
|
||||
for (String player : players){
|
||||
double statValue = PlayerStatsConfig.get().getDouble(player + statKey);
|
||||
leaderboard.put(player, statValue);
|
||||
}
|
||||
|
||||
ArrayList<Component> toBeReturned = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < places; i++) {
|
||||
double highestScore = 0;
|
||||
String highestPlayer = null;
|
||||
for (String player : leaderboard.keySet()) {
|
||||
if (leaderboard.get(player) > highestScore) {
|
||||
highestScore = leaderboard.get(player);
|
||||
highestPlayer = player;
|
||||
}
|
||||
}
|
||||
if (highestPlayer != null) {
|
||||
highestScore = DoubleUtils.round(highestScore, 2);
|
||||
if (highestScore % 1 == 0){
|
||||
int highestScoreInt = (int) highestScore;
|
||||
toBeReturned.add(Component.text(" " + highestPlayer + " - ", NamedTextColor.GRAY).append(Component.text(highestScoreInt, NamedTextColor.AQUA)));
|
||||
} else {
|
||||
toBeReturned.add(Component.text(" " + highestPlayer + " - ", NamedTextColor.GRAY).append(Component.text(highestScore, NamedTextColor.AQUA)));
|
||||
}
|
||||
leaderboard.remove(highestPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
return toBeReturned;
|
||||
}
|
||||
|
||||
private void fillPersonalSidebar(Sidebar<Component> sidebar){
|
||||
|
||||
sidebar.addLine(LanguageConfig.lang.get("SCOREBOARD_PERSONAL_TITLE"));
|
||||
|
||||
List<String> enabled = plugin.getConfig().getStringList("personal-stats-components");
|
||||
|
||||
for (String component : enabled){
|
||||
switch(component){
|
||||
case "Killstreak":
|
||||
sidebar.addUpdatableLine(
|
||||
(player) -> LanguageConfig.lang.get("SCOREBOARD_PERSONAL_KILLSTREAK").
|
||||
replaceText(ComponentUtils.replaceConfig("%VALUE%",
|
||||
PlayerStatsConfig.get().getString(player.getName() + ".killstreak")))
|
||||
);
|
||||
break;
|
||||
case "Kills":
|
||||
sidebar.addUpdatableLine(
|
||||
(player) -> LanguageConfig.lang.get("SCOREBOARD_PERSONAL_KILLS").
|
||||
replaceText(ComponentUtils.replaceConfig("%VALUE%",
|
||||
PlayerStatsConfig.get().getString(player.getName() + ".kills")))
|
||||
);
|
||||
break;
|
||||
case "Deaths":
|
||||
sidebar.addUpdatableLine(
|
||||
(player) -> LanguageConfig.lang.get("SCOREBOARD_PERSONAL_DEATHS").
|
||||
replaceText(ComponentUtils.replaceConfig("%VALUE%",
|
||||
PlayerStatsConfig.get().getString(player.getName() + ".deaths")))
|
||||
);
|
||||
break;
|
||||
case "KD":
|
||||
sidebar.addUpdatableLine(
|
||||
(player) -> LanguageConfig.lang.get("SCOREBOARD_PERSONAL_KD").
|
||||
replaceText(ComponentUtils.replaceConfig("%VALUE%",
|
||||
String.valueOf(DoubleUtils.round(
|
||||
PlayerStatsConfig.get().getDouble(player.getName() + ".kdratio"), 2)
|
||||
)))
|
||||
);
|
||||
break;
|
||||
case "Level":
|
||||
sidebar.addUpdatableLine(
|
||||
(player) -> LanguageConfig.lang.get("SCOREBOARD_PERSONAL_LEVEL").
|
||||
replaceText(ComponentUtils.replaceConfig("%VALUE%",
|
||||
PlayerStatsConfig.get().getString(player.getName() + ".level")))
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sidebar.updateLinesPeriodically(0, 20);
|
||||
}
|
||||
|
||||
private HashMap<String, Integer> orderLeaderboard(HashMap<String, Integer> unordered){
|
||||
HashMap<String, Integer> sortedMap = new HashMap<>();
|
||||
ArrayList<Integer> list = new ArrayList<>();
|
||||
for (Map.Entry<String, Integer> entry : unordered.entrySet()) {
|
||||
list.add(entry.getValue());
|
||||
}
|
||||
Collections.sort(list, new Comparator<Integer>() {
|
||||
public int compare(Integer int1, Integer int2) {
|
||||
return (int1).compareTo(int2);
|
||||
}
|
||||
});
|
||||
for (Integer integer : list) {
|
||||
for (Map.Entry<String, Integer> entry : unordered.entrySet()) {
|
||||
if (entry.getValue().equals(integer)) {
|
||||
sortedMap.put(entry.getKey(), integer);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sortedMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
//package me.lifelessnerd.purekitpvp.scoreboards;
|
||||
//
|
||||
//
|
||||
//import me.lifelessnerd.purekitpvp.utils.ComponentUtils;
|
||||
//import me.lifelessnerd.purekitpvp.utils.PlayerUtils;
|
||||
//import net.kyori.adventure.text.Component;
|
||||
//import net.minecraft.network.protocol.game.ClientboundTabListPacket;
|
||||
//import net.minecraft.server.level.ServerPlayer;
|
||||
//import org.bukkit.Bukkit;
|
||||
//import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.plugin.Plugin;
|
||||
//
|
||||
//import java.util.Set;
|
||||
//
|
||||
//
|
||||
//public class TabManager {
|
||||
//
|
||||
// private Plugin plugin;
|
||||
// private Component header = Component.text("");
|
||||
// private Component footer = Component.text("");
|
||||
//
|
||||
// public TabManager(Plugin plugin) {
|
||||
// this.plugin = plugin;
|
||||
// }
|
||||
// // CURRENTLY NOT IN USE
|
||||
// public void showTab(){
|
||||
// if(header == null && footer == null) return;
|
||||
//
|
||||
// Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void run() {
|
||||
//
|
||||
// // CURRENTLY NOT IN USE
|
||||
//
|
||||
// net.minecraft.network.chat.Component headerTBS = ComponentUtils.toMojangComponent(header);
|
||||
// net.minecraft.network.chat.Component footerTBS = ComponentUtils.toMojangComponent(footer);
|
||||
//
|
||||
// ClientboundTabListPacket packet = new ClientboundTabListPacket(headerTBS, footerTBS);
|
||||
//
|
||||
// Set<Player> inWorld = PlayerUtils.getPlayersInWorld(plugin.getConfig().getString("world"));
|
||||
// if (inWorld.size() != 0){
|
||||
// for (Player player : inWorld){
|
||||
// CraftPlayer cPlayer = (CraftPlayer) player; // frick nms
|
||||
// ServerPlayer serverPlayer = cPlayer.getHandle();
|
||||
// serverPlayer.connection.send(packet);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
// }, 10, plugin.getConfig().getLong("tab-refresh-period"));
|
||||
//
|
||||
// }
|
||||
// // CURRENTLY NOT IN USE
|
||||
// public void addHeader(Component header){
|
||||
// this.header = this.header.append(header).appendNewline();
|
||||
// }
|
||||
// public void addFooter(Component footer){
|
||||
// this.footer = this.footer.append(footer).appendNewline();
|
||||
// }
|
||||
//}
|
||||
@@ -2,25 +2,14 @@ package me.lifelessnerd.purekitpvp.utils;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MyStringUtils {
|
||||
|
||||
public static String itemCamelCase(String string) {
|
||||
public static String itemCamelCase(String string){
|
||||
//Input: IRON_SWORD
|
||||
String[] split = string.split("_");
|
||||
StringBuilder processedSentence = new StringBuilder();
|
||||
for (String word : split) {
|
||||
for (String word : split){
|
||||
String processedWord = camelCaseWord(word);
|
||||
processedSentence.append(processedWord).append(" ");
|
||||
}
|
||||
@@ -29,16 +18,15 @@ public class MyStringUtils {
|
||||
//Output: Iron Sword
|
||||
}
|
||||
|
||||
public static String camelCaseWord(String string) {
|
||||
public static String camelCaseWord(String string){
|
||||
//Input: SAMPLE
|
||||
string = string.toLowerCase();
|
||||
return string.substring(0, 1).toUpperCase() + string.substring(1);
|
||||
//Output: Sample
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String mapStringToEnchantment(String string) {
|
||||
System.out.println(string);
|
||||
public static String mapStringToEnchantment(String string){
|
||||
|
||||
//{CraftEnchantment[minecraft:knockback]=11, CraftEnchantment[minecraft:fire_aspect]=2}
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
@@ -48,7 +36,7 @@ public class MyStringUtils {
|
||||
string = builder.toString();
|
||||
|
||||
String[] split = string.split(",");
|
||||
for (String substring : split) {
|
||||
for(String substring : split){
|
||||
substring = substring.trim();
|
||||
substring = substring.substring(16);
|
||||
String level = substring.split("=")[1];
|
||||
@@ -62,58 +50,7 @@ public class MyStringUtils {
|
||||
//Output: Knockback 11, Fire Aspect 2
|
||||
}
|
||||
|
||||
public static String mapEnchantmentsToString(Map<Enchantment, Integer> map) {
|
||||
if (map == null || map.isEmpty()) return "0";
|
||||
|
||||
return map.entrySet().stream()
|
||||
.map(e -> formatEnchantmentName(e.getKey()) + " " + romanize(e.getValue()))
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
private static String formatEnchantmentName(Enchantment enchantment) {
|
||||
String raw = enchantment.getKey().getKey(); // e.g. "sharpness", "blast_protection"
|
||||
return Arrays.stream(raw.split("_"))
|
||||
.map(word -> Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase())
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
public static String potionMetaToEffects(ItemMeta potionItemMeta) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
PotionMeta potionMeta = (PotionMeta) potionItemMeta;
|
||||
|
||||
// Add information about base effect
|
||||
if (potionMeta.getBasePotionType() == null) return "";
|
||||
if (!potionMeta.getBasePotionType().name().equals("WATER")) {
|
||||
for (PotionEffect potionEffect : potionMeta.getBasePotionType().getPotionEffects()) {
|
||||
String translationKey = potionEffect.getType().translationKey();
|
||||
String[] split = translationKey.split("\\.");
|
||||
sb.append(itemCamelCase(split[split.length - 1]));
|
||||
sb.append(romanize(potionEffect.getAmplifier() + 1));
|
||||
if (potionEffect.getDuration() > 1) sb.append(" (").append(potionEffect.getDuration()).append("s)");
|
||||
}
|
||||
}
|
||||
|
||||
List<PotionEffect> customEffects = potionMeta.getCustomEffects();
|
||||
if (!customEffects.isEmpty()) {
|
||||
// Add information about each custom effect
|
||||
if (!potionMeta.getBasePotionType().name().equals("WATER")) sb.append(", ");
|
||||
for (PotionEffect customEffect : customEffects) {
|
||||
String customEffectName = customEffect.getType().translationKey();
|
||||
String[] split = customEffectName.split("\\.");
|
||||
int amplifier = customEffect.getAmplifier() + 1;
|
||||
int duration = customEffect.getDuration();
|
||||
|
||||
sb.append(itemCamelCase(split[split.length - 1]));
|
||||
sb.append(romanize(amplifier));
|
||||
if (duration > 1) sb.append(" (").append(duration).append("s)");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String itemMetaToEffects(String string) {
|
||||
public static String itemMetaToEffects(String string){
|
||||
|
||||
//I: POTION_META:meta-type=POTION, potion-type=minecraft:strong_healing)
|
||||
//OR
|
||||
@@ -121,30 +58,30 @@ public class MyStringUtils {
|
||||
|
||||
StringBuilder result = new StringBuilder("");
|
||||
|
||||
if (string.contains("custom-effects")) {
|
||||
if (string.contains("custom-effects")){
|
||||
|
||||
String[] split = string.split("custom-effects=");
|
||||
StringBuilder builder = new StringBuilder(split[1]);
|
||||
builder.deleteCharAt(0);
|
||||
builder.deleteCharAt(split[1].length() - 2);
|
||||
builder.deleteCharAt(split[1].length() - 3);
|
||||
builder.deleteCharAt(split[1].length() - 2 );
|
||||
builder.deleteCharAt(split[1].length() - 3 );
|
||||
String[] splitAgain = builder.toString().split(":");
|
||||
|
||||
result.append(itemCamelCase(splitAgain[0]));
|
||||
String meta = splitAgain[1];
|
||||
String[] splitOnceMore = meta.split("-");
|
||||
|
||||
StringBuilder time = new StringBuilder(splitOnceMore[0]);
|
||||
StringBuilder time = new StringBuilder(splitOnceMore[0]);
|
||||
time.deleteCharAt(splitOnceMore[0].length() - 1);
|
||||
int timeSec = Integer.parseInt(time.toString()) / 20;
|
||||
|
||||
|
||||
StringBuilder potency = new StringBuilder(splitOnceMore[1]);
|
||||
StringBuilder potency = new StringBuilder(splitOnceMore[1]);
|
||||
potency.deleteCharAt(0);
|
||||
int potencyInt = Integer.parseInt(potency.toString()) + 1;
|
||||
|
||||
StringBuilder lvlAndTime = new StringBuilder("");
|
||||
if (timeSec > 100000000) {
|
||||
if (timeSec > 100000000){
|
||||
lvlAndTime.append(potencyInt + " (Infinite)");
|
||||
} else {
|
||||
lvlAndTime.append(potencyInt + " (" + timeSec + "s)");
|
||||
@@ -159,11 +96,11 @@ public class MyStringUtils {
|
||||
StringBuilder effectB = new StringBuilder(split[1]);
|
||||
String effect = effectB.deleteCharAt(split[1].length() - 1).toString();
|
||||
|
||||
if (effect.contains("strong")) {
|
||||
if (effect.contains("strong")){
|
||||
String[] splitAgain = effect.split("strong_");
|
||||
result.append(itemCamelCase(splitAgain[1]));
|
||||
result.append("II ");
|
||||
} else if (effect.contains("long")) {
|
||||
} else if (effect.contains("long")){
|
||||
String[] splitAgain = effect.split("long_");
|
||||
result.append(itemCamelCase(splitAgain[1]));
|
||||
result.append("(Long) ");
|
||||
@@ -175,12 +112,12 @@ public class MyStringUtils {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String[] perkLoreDecoder(String string) {
|
||||
public static String[] perkLoreDecoder(String string){
|
||||
String[] output = string.split("\n");
|
||||
return output;
|
||||
}
|
||||
|
||||
public static String itemNameToCosmeticId(String input) {
|
||||
public static String itemNameToCosmeticId(String input){
|
||||
String processed = input.toLowerCase();
|
||||
processed = processed.replace(' ', '_');
|
||||
|
||||
@@ -188,30 +125,16 @@ public class MyStringUtils {
|
||||
}
|
||||
|
||||
// Opposite of function above
|
||||
public static String cosmeticIdToItemName(String input) {
|
||||
public static String cosmeticIdToItemName(String input){
|
||||
// Input: blood_explosion -> Blood Explosion
|
||||
return itemCamelCase(input).trim();
|
||||
}
|
||||
|
||||
public static String componentToString(Component singleLineComponent) {
|
||||
public static String componentToString(Component singleLineComponent){
|
||||
PlainTextComponentSerializer serializer = PlainTextComponentSerializer.plainText();
|
||||
String processed = serializer.serialize(singleLineComponent);
|
||||
processed = processed.substring(1, processed.length() - 1);
|
||||
return processed;
|
||||
}
|
||||
|
||||
public static String romanize(int input) {
|
||||
int[] values = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
|
||||
String[] symbols = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
while (input >= values[i]) {
|
||||
result.append(symbols[i]);
|
||||
input -= values[i];
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package me.lifelessnerd.purekitpvp.versioning;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MinecraftVersion {
|
||||
|
||||
public static String getVersion(){
|
||||
return extractVersion(Bukkit.getVersion());
|
||||
}
|
||||
|
||||
public static String extractVersion(String input) {
|
||||
// Define a regular expression pattern to match the version number
|
||||
Pattern pattern = Pattern.compile("\\b(\\d+\\.\\d+\\.\\d+)\\b");
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1);
|
||||
} else {
|
||||
throw new IllegalArgumentException("No version number found in the input string");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package me.lifelessnerd.purekitpvp.versioning;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static java.lang.Integer.parseInt;
|
||||
|
||||
public class Version implements Comparable<Version> {
|
||||
|
||||
int major;
|
||||
int minor;
|
||||
int build;
|
||||
|
||||
public Version(int major, int minor, int build) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
public Version(String versionString){
|
||||
// versionString: 1.20.6
|
||||
String[] split = versionString.split("\\.");
|
||||
this.major = parseInt(split[0]);
|
||||
this.minor = parseInt(split[1]);
|
||||
this.build = parseInt(split[2]);
|
||||
}
|
||||
|
||||
public int getVersionNumber(){
|
||||
String versionNumber = major + String.valueOf(minor) + build; // hacky
|
||||
return parseInt(versionNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull Version o) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -118,7 +118,7 @@ If you have any questions please reach out via Discord (see #Support).
|
||||
## How to create a kit
|
||||
*Also see the video that covers this topic below.*
|
||||
|
||||
Have all the items you want to be in your kit in your inventory, and type the command /purekitpvp kit create \<name> . A kit will be created with the arguments and automatically added to the kit menu (/kit). You either provide a kill item in the base command, or, if you want the kill item to be a special item (i.e. a golden head or a random loot chest), use the /purekitpvp getcustomitem command to get that item, and run the command /purekitpvp kit setkillitem \<kitName> while holding that item.
|
||||
Have all the items you want to be in your kit in your inventory, and type the command /purekitpvp createkit \<name> . A kit will be created with the arguments and automatically added to the kit menu (/kit). You either provide a kill item in the base command, or, if you want the kill item to be a special item (i.e. a golden head or a random loot chest), use the /purekitpvp getcustomitem command to get that item, and run the command /purekitpvp setkillitem \<kitName> while holding that item.
|
||||
The contents of the kit will be shown in a clean hoverbox when choosing the kit, which will categorize the first 3 items in your hotbar as weapons, the rest of the inventory as items, the armor as armor and the offhand as offhand. If the kit has no armor, it will tell you aswell. A piece of lore can be set in the kits.yml.
|
||||
Basic potions that can be found in the inventory are translated as well, although they do not show their potency and lenght, due to how these items work in spigot. Custom potions created with commands however do work perfectly and show potency and lenght, so I recommend to create your own potions with commands when working with them.
|
||||
|
||||
|
||||
Reference in new issue
Block a user