Skip to content

Commit

Permalink
chore: Update deprecated methods and such
Browse files Browse the repository at this point in the history
  • Loading branch information
PainOchoco committed Apr 2, 2024
1 parent 90d762c commit d769ce3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.scoreboard.Criteria;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
Expand All @@ -17,7 +18,8 @@ public static void setPlayerScore(OfflinePlayer player) {
if (board.getObjective("ability_used_count") != null) {
objective = board.getObjective("ability_used_count");
} else {
objective = board.registerNewObjective("ability_used_count", "dummy", Component.text("Ability used coint"));
objective = board.registerNewObjective("ability_used_count", Criteria.DUMMY,
Component.text("Ability used count"));
}
useObjectives(objective, player, board);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String alias, String
List<Map<?, ?>> confCrystals = LaBoulangerieCore.PLUGIN.getConfig().getMapList("crystals");

for (Map<?, ?> map : confCrystals) {
@SuppressWarnings("unchecked")
Map<String, Double> crystal = (Map<String, Double>) map;
crystalLocs.add(new Location(world, crystal.get("x"), crystal.get("y"), crystal.get("z")));
}
Expand Down Expand Up @@ -136,28 +137,29 @@ public boolean onCommand(CommandSender sender, Command cmd, String alias, String
PlayerNameTag tag = PlayerNameTag.get(target);

if (args.length == 2) {
sender.sendMessage("Debugging "+target.getName()+"'s nametag");
sender.sendMessage("* Number of viewers: §e"+tag.getViewers().size());
sender.sendMessage("Debugging " + target.getName() + "'s nametag");
sender.sendMessage("* Number of viewers: §e" + tag.getViewers().size());
sender.sendMessage("* Viewers:");
for (Player p : tag.getViewers()) {
sender.sendMessage(" - §e"+p.getName());
sender.sendMessage(" - §e" + p.getName());
}
return true;
}else {
} else {
Player secondPlayer = null;
switch (args[2].toLowerCase()) {
case "hide":

break;

default:
if (args.length >= 4) {
secondPlayer = Bukkit.getPlayer(args[3]);
if (secondPlayer == null || !secondPlayer.isOnline()) {
sender.sendMessage("§4Player isn't online");
return true;
}
}else return false;
} else
return false;
case "addViewer":
tag.addViewer(secondPlayer);
return true;
Expand All @@ -179,11 +181,10 @@ public boolean onCommand(CommandSender sender, Command cmd, String alias, String
List<String> suggestions = Arrays.asList("");
if (args.length == 1)
suggestions = Arrays.asList("reload", "rl", "conversion", "nick", "unnick", "spawnDragon", "nametag");
if (args.length == 2 && (
args[0].equalsIgnoreCase("nick") ||
args[0].equalsIgnoreCase("unnick") ||
args[0].equalsIgnoreCase("nametag")
)) return null;
if (args.length == 2 && (args[0].equalsIgnoreCase("nick") ||
args[0].equalsIgnoreCase("unnick") ||
args[0].equalsIgnoreCase("nametag")))
return null;
if (args.length == 3 && args[0].equalsIgnoreCase("nametag"))
suggestions = Arrays.asList("addViewer", "removeViewer", "sendNametag");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public static void innit() {
EventState eventState = new EventState(key);

for (Map<?, ?> step : section.getMapList("steps")) {
@SuppressWarnings("unchecked")
Map<String, ?> castStep = (Map<String, ?>) step;
EventStep eventStep =
new EventStep(key, (String) castStep.get("name"), (ArrayList<String>) castStep.get("actions"));
@SuppressWarnings("unchecked")
EventStep eventStep = new EventStep(key, (String) castStep.get("name"),
(ArrayList<String>) castStep.get("actions"));
eventState.addStep(eventStep);
}
events.put(key, eventState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
public class HouseShop implements Listener {
public static void displayShop(Player player, short page) {
int invSize = 27;
Inventory inv =
Bukkit.createInventory(null, invSize, Component.text("§2Maisons de nation - page " + (page + 1)));
Inventory inv = Bukkit.createInventory(null, invSize,
Component.text("§2Maisons de nation - page " + (page + 1)));
List<UUID> freeHouses = LaBoulangerieCore.nationHouseHolder.getFreeHouses();

for (int i = page * (invSize - 2); i < Math.min(freeHouses.size(), (page + 1) * (invSize - 2)); i++) {
Expand Down Expand Up @@ -77,11 +77,13 @@ public static void displayShop(Player player, short page) {
public void onClick(InventoryClickEvent event) {
InventoryView view = event.getView();
String title = PlainTextComponentSerializer.plainText().serialize(view.title());
if (!title.contains("Maisons de nation")) return;
if (!title.contains("Maisons de nation"))
return;

event.setCancelled(true);

if (event.getClick() != ClickType.LEFT || event.getCurrentItem() == null) return;
if (event.getClick() != ClickType.LEFT || event.getCurrentItem() == null)
return;

ItemStack item = event.getCurrentItem();
short page = Short.parseShort(title.split("page ")[1]);
Expand All @@ -98,7 +100,8 @@ public void onClick(InventoryClickEvent event) {
return;
}

if (item.getType() != Material.BRICKS) return;
if (item.getType() != Material.BRICKS)
return;

double price = 0;
try {
Expand Down Expand Up @@ -130,8 +133,8 @@ public void onClick(InventoryClickEvent event) {
return;
}

String name =
PlainTextComponentSerializer.plainText().serialize(item.getItemMeta().displayName()).split("§6")[1];
String name = PlainTextComponentSerializer.plainText().serialize(item.getItemMeta().displayName())
.split("§6")[1];
House house = LaBoulangerieCore.housesManager.getHouseByName(name).get();

LaBoulangerieCore.nationHouseHolder.assignNationHouse(house.getUUID(), nation.getUUID());
Expand Down Expand Up @@ -194,7 +197,7 @@ public void onLeaveNation(NationRemoveTownEvent event) {

@EventHandler
public void onDeleteNation(DeleteNationEvent event) {
if (LaBoulangerieCore.nationHouseHolder.hasHouse(event.getNationKing())) {
if (LaBoulangerieCore.nationHouseHolder.hasHouse(event.getLeaderUUID())) {
LaBoulangerieCore.nationHouseHolder
.freeHouse(LaBoulangerieCore.nationHouseHolder.getHouseOfNation(event.getNationUUID()));
}
Expand Down

0 comments on commit d769ce3

Please sign in to comment.