forked from upstream/PureKitPvP
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65517a300d |
No files matched your search
+5
-12
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.lifelessnerd.purekitpvp</groupId>
|
||||
<artifactId>PureKitPvP</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<version>1.4</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>PureKitPvP</name>
|
||||
@@ -24,8 +24,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@@ -49,7 +49,7 @@
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<outputDirectory>F:\Minecraft\Servers\MC 1.20.4 Server\plugins</outputDirectory>
|
||||
<outputDirectory>/run/media/luka/250GB SATA SSD/Minecraft/Servers/1.21.11/plugins/</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
@@ -81,21 +81,14 @@
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.1-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.6-SNAPSHOT</version>
|
||||
</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>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -38,7 +38,7 @@ public class InfoCommand extends Subcommand{
|
||||
|
||||
String message =
|
||||
"""
|
||||
&bPureKitPvP - version 1.3.1
|
||||
&bPureKitPvP - version 1.4
|
||||
&6Discord Support: &ohttps://discord.com/invite/8n65jSEkVf
|
||||
&6SpigotMC: &ohttps://bit.ly/PureKitPvPSpigotMC
|
||||
&6Github: &ohttps://github.com/LifelessNerd/PureKitPvP
|
||||
|
||||
@@ -7,7 +7,6 @@ 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;
|
||||
@@ -94,8 +93,6 @@ 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,7 +2,6 @@ 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;
|
||||
@@ -73,8 +72,6 @@ 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, 5, 254)); //Kinda jank, works tho
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP_BOOST, 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));
|
||||
|
||||
+16
-14
@@ -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,26 +41,25 @@ 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];
|
||||
|
||||
@@ -71,8 +70,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;
|
||||
}
|
||||
@@ -94,7 +93,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");
|
||||
@@ -141,12 +140,13 @@ 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,9 +180,11 @@ 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!
|
||||
Player closestPlayer = getNearestPlayer(player); // NPE has no effect it seems; target becomes null and zombie is fine with that
|
||||
((Monster) entity).setTarget(closestPlayer);
|
||||
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);
|
||||
// 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_POTION_EFFECTS);
|
||||
killEffectButtonMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
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_POTION_EFFECTS);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
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.DAMAGE_ALL, 1, true);
|
||||
itemMeta.addEnchant(Enchantment.SHARPNESS, 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_POTION_EFFECTS);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
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.DAMAGE_ALL, 1, true);
|
||||
itemMeta.addEnchant(Enchantment.SHARPNESS, 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_POTION_EFFECTS);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
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.DAMAGE_ALL, 1, true);
|
||||
itemMeta.addEnchant(Enchantment.SHARPNESS, 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);
|
||||
Firework fw = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK_ROCKET);
|
||||
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_CRACK,
|
||||
Particle.BLOCK,
|
||||
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.DRIP_WATER, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
location.getWorld().spawnParticle(Particle.DRIPPING_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.FIREWORKS_SPARK, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
location.getWorld().spawnParticle(Particle.ELECTRIC_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, location, plugin.getConfig().getInt("projectile-trail-count"), 0.1, 0.1, 0.1, 0.001, null, true);
|
||||
location.getWorld().spawnParticle(Particle.TOTEM_OF_UNDYING, 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,6 +186,7 @@ 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_POTION_EFFECTS);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
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.itemMetaToEffects(item.getItemMeta().toString()), NamedTextColor.GRAY));
|
||||
lore.add(Component.text(" " + MyStringUtils.potionMetaToEffects(item.getItemMeta()), 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.itemMetaToEffects(item.getItemMeta().toString()), NamedTextColor.GRAY));
|
||||
lore.add(Component.text(" " + MyStringUtils.potionMetaToEffects(item.getItemMeta()), 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.mapStringToEnchantment(item.getEnchantments().toString()), NamedTextColor.GRAY));
|
||||
lore.add(Component.text(" " + MyStringUtils.mapEnchantmentsToString(item.getEnchantments()), 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_POTION_EFFECTS);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
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.DAMAGE_ALL, 1, true);
|
||||
itemMeta.addEnchant(Enchantment.SHARPNESS, 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.INCREASE_DAMAGE, 60, 1));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.STRENGTH, 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.DAMAGE_ALL);
|
||||
int sharpnessLevel = weaponMeta.getEnchantLevel(Enchantment.SHARPNESS);
|
||||
|
||||
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.DAMAGE_ALL);
|
||||
weaponMeta.addEnchant(Enchantment.DAMAGE_ALL, sharpnessLevel + 1, true);
|
||||
weaponMeta.removeEnchant(Enchantment.SHARPNESS);
|
||||
weaponMeta.addEnchant(Enchantment.SHARPNESS, 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.ARROW_DAMAGE);
|
||||
int powerLevel = weaponMarksmanMeta.getEnchantLevel(Enchantment.POWER);
|
||||
|
||||
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.ARROW_DAMAGE);
|
||||
weaponMarksmanMeta.addEnchant(Enchantment.ARROW_DAMAGE, powerLevel + 1, true);
|
||||
weaponMarksmanMeta.removeEnchant(Enchantment.POWER);
|
||||
weaponMarksmanMeta.addEnchant(Enchantment.POWER, 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.SLOW, 60, 0));
|
||||
damaged.addPotionEffect(new PotionEffect(PotionEffectType.SLOWNESS, 60, 0));
|
||||
}
|
||||
break;
|
||||
case "DISRUPTOR":
|
||||
|
||||
-247
@@ -1,247 +0,0 @@
|
||||
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 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
//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,14 +2,25 @@ 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(" ");
|
||||
}
|
||||
@@ -18,15 +29,16 @@ 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
|
||||
}
|
||||
|
||||
public static String mapStringToEnchantment(String string){
|
||||
|
||||
@Deprecated
|
||||
public static String mapStringToEnchantment(String string) {
|
||||
System.out.println(string);
|
||||
//{CraftEnchantment[minecraft:knockback]=11, CraftEnchantment[minecraft:fire_aspect]=2}
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
@@ -36,7 +48,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];
|
||||
@@ -50,7 +62,58 @@ public class MyStringUtils {
|
||||
//Output: Knockback 11, Fire Aspect 2
|
||||
}
|
||||
|
||||
public static String itemMetaToEffects(String string){
|
||||
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) {
|
||||
|
||||
//I: POTION_META:meta-type=POTION, potion-type=minecraft:strong_healing)
|
||||
//OR
|
||||
@@ -58,30 +121,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)");
|
||||
@@ -96,11 +159,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) ");
|
||||
@@ -112,12 +175,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(' ', '_');
|
||||
|
||||
@@ -125,16 +188,30 @@ 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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user