fixing bugs

This commit is contained in:
NK 2022-11-17 21:58:19 +00:00
parent 9979c9de23
commit 63a1d5e4ae
2 changed files with 36 additions and 47 deletions

View file

@ -26,13 +26,12 @@ public class CustomItemManager {
public static HashMap<String, NamespacedKey> keys = new HashMap<>();
private static Main main;
public CustomItemManager(Main main) {
this.main = main;
CustomItemManager.main = main;
main.getConfig().options().copyDefaults();
main.saveDefaultConfig();
if(!main.getDataFolder().exists()) {
main.getDataFolder().mkdir();
}
createDirectoryInPluginFolder("ItemData");
createFilesFromConfig(main.getConfig());
register();
@ -151,17 +150,18 @@ public class CustomItemManager {
return YamlConfiguration.loadConfiguration(f);
}
public static File loadFile(String path) {
File f = new File(main.getDataFolder(), path);
if(!f.exists()) {
File file = new File(main.getDataFolder(), path);
if(!file.exists()) {
try {
f.createNewFile();
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
return f;
return file;
}
public static void createDirectoryInPluginFolder(String path) {
File f = new File(main.getDataFolder(), path);
if(!f.exists()) {
@ -219,4 +219,10 @@ public class CustomItemManager {
public static ItemStack getItem(String name){
return weapons.get(name);
}
public static void updateYamlFilesToPlugin(String path) {
File file = new File(main.getDataFolder(), path); //xxx.yml
if (!file.exists()) main.saveResource(path, true);
else main.saveResource(path, true);
}
}

View file

@ -1,6 +1,7 @@
package me.night.nullvalkyrie.rank;
import me.night.nullvalkyrie.Main;
import me.night.nullvalkyrie.util.Util;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -13,7 +14,7 @@ import java.util.UUID;
public class SideBarManager {
private final HashMap<UUID, Integer> deaths = new HashMap<>();
private int taskID;
private Main main;
private final Main main;
public SideBarManager(Main main) {
this.main = main;
@ -47,7 +48,7 @@ public class SideBarManager {
Score website = obj.getScore(ChatColor.YELLOW + "cath.js.org");
website.setScore(1);
Team playersOnline;
if(board.getTeam("deathsTotal") != null) {
if (board.getTeam("deathsTotal") != null) {
playersOnline = board.getTeam("deathsTotal");
} else playersOnline = board.registerNewTeam("deathsTotal");
playersOnline.addEntry(ChatColor.BOLD.toString());
@ -63,6 +64,12 @@ public class SideBarManager {
int count = 0;
final AnimatedSideBar board = new AnimatedSideBar(player.getUniqueId());
public void animate(String str) {
Objective objective = player.getScoreboard().getObjective("Vanadium");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName(Util.color(str));
}
@Override
public void run() {
if (!board.hasID())
@ -70,46 +77,22 @@ public class SideBarManager {
if (count == 13)
count = 0;
switch (count) {
case 0:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &e&lVanadium&1&l <<"));
break;
case 1:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&b&l>&1&l> &e&lVanadium &1&l<<")); //>
break;
case 2:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>&b&l> &e&lVanadium &1&l<<")); //>>
break;
case 3:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &b&lV&e&lanadium&1&l <<"));//V
break;
case 4:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &e&lV&b&la&e&lnadium&1&l <<")); //Va
break;
case 5:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &e&lVa&b&ln&e&ladium&1&l <<")); //Van
break;
case 6:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &e&lVan&b&la&e&ldium&1&l <<")); //Vana
break;
case 7:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &e&lVana&b&ld&e&lium&1&l <<")); //Vanad
break;
case 8:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &e&lVanad&b&li&e&lum&1&l <<")); //Vanadi
break;
case 9:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &e&lVanadi&b&lu&e&lm&1&l <<")); // Vanadiu
break;
case 10:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &e&lVanadiu&b&lm&1&l <<")); //Vanadium
break;
case 11:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &e&lVanadium &b&l<&1&l<")); // <
break;
case 12:
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(ChatColor.translateAlternateColorCodes('&', "&1&l>> &e&lVanadium &1&l<&b&l<")); // <<
case 0 -> animate("&1&l>> &e&lVanadium&1&l <<");
case 1 -> animate("&b&l>&1&l> &e&lVanadium &1&l<<");
case 2 -> animate("&1&l>&b&l> &e&lVanadium &1&l<<");
case 3 -> animate("&1&l>> &b&lV&e&lanadium&1&l <<");
case 4 -> animate("&1&l>> &e&lV&b&la&e&lnadium&1&l <<");
case 5 -> animate("&1&l>> &e&lVa&b&ln&e&ladium&1&l <<");
case 6 -> animate("&1&l>> &e&lVan&b&la&e&ldium&1&l <<");
case 7 -> animate("&1&l>> &e&lVana&b&ld&e&lium&1&l <<");
case 8 -> animate("&1&l>> &e&lVanad&b&li&e&lum&1&l <<");
case 9 -> animate("&1&l>> &e&lVanadi&b&lu&e&lm&1&l <<");
case 10 -> animate("&1&l>> &e&lVanadiu&b&lm&1&l <<");
case 11 -> animate("&1&l>> &e&lVanadium &b&l<&1&l<");
case 12 -> {
animate("&1&l>> &e&lVanadium &1&l<&b&l<");
setSideBar(player);
break;
}
}
count++;
}