Skip to content

Commit

Permalink
fix kit bug #2 and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
JT122406 committed May 23, 2022
1 parent dead7f7 commit 1a91f9b
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/main/java/tk/shanebee/hg/commands/KitCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public boolean run() {
return false;
}
if (st == Status.WAITING || st == Status.COUNTDOWN) {
player.getInventory().clear();
game.getKitManager().setKit(player, args[1]);
//Bukkit.getScheduler().runTaskLater(plugin, () -> game.getKitManager().setKit(player, args[1]), 10L);
} else {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/tk/shanebee/hg/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ public void startPreGame() {
* Start the free roam state of the game
*/
public void startFreeRoam() {
for (UUID p : gamePlayerData.getPlayers()) {
Objects.requireNonNull(Bukkit.getPlayer(p)).getInventory().clear();
}
gameArenaData.status = Status.BEGINNING;
gameBlockData.updateLobbyBlock();
gameArenaData.bound.removeEntities();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/tk/shanebee/hg/game/GameBarData.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public void addPlayer(Player player) {
*
* @return Associated bossbar
*/

@Deprecated
public BossBar getBossBar() {
return this.bar;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tk/shanebee/hg/game/GameCommandData.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public enum CommandType {
*/
JOIN("join");

String type;
final String type;

CommandType(String type) {
this.type = type;
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/tk/shanebee/hg/game/GamePlayerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public SpectatorGUI getSpectatorGUI() {
// Utility methods

private void kitHelp(Player player) {
// Clear the chat a little bit, making this message easier to see
// Clear the chat a little, making this message easier to see
for (int i = 0; i < 20; ++i)
Util.scm(player, " ");
String kit = game.kitManager.getKitListString();
Expand Down Expand Up @@ -299,16 +299,18 @@ public void join(Player player, boolean command) {
kills.put(player, 0);

if (Config.enableleaveitem){
ItemStack bed = new ItemStack(Material.getMaterial(Config.leaveitemtype), 1);
ItemStack bed = new ItemStack(Objects.requireNonNull(Material.getMaterial(Config.leaveitemtype)), 1);
ItemMeta commeta = bed.getItemMeta();
assert commeta != null;
commeta.setDisplayName(lang.leave_game);
bed.setItemMeta(commeta);
player.getInventory().setItem(8, bed);
}

if (Config.enableforcestartitem && player.hasPermission("hg.forcestart")) {
ItemStack start = new ItemStack(Material.getMaterial(Config.forcestartitem), 1);
ItemStack start = new ItemStack(Objects.requireNonNull(Material.getMaterial(Config.forcestartitem)), 1);
ItemMeta meta = start.getItemMeta();
assert meta != null;
meta.setDisplayName(lang.force_start);
start.setItemMeta(meta);
player.getInventory().setItem(0, start);
Expand Down Expand Up @@ -362,6 +364,7 @@ public void leave(Player player, Boolean death) {
}
heal(player);
PlayerData playerData = playerManager.getPlayerData(uuid);
assert playerData != null;
Location previousLocation = playerData.getPreviousLocation();

playerData.restore(player);
Expand Down Expand Up @@ -440,6 +443,7 @@ public void spectate(Player spectator) {
public void leaveSpectate(Player spectator) {
UUID uuid = spectator.getUniqueId();
PlayerData playerData = playerManager.getSpectatorData(uuid);
assert playerData != null;
Location previousLocation = playerData.getPreviousLocation();

playerData.restore(spectator);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/tk/shanebee/hg/game/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

/**
Expand All @@ -27,6 +28,7 @@ public Team(Player leader, String name, Game game) {
this.leader = leader.getUniqueId();
PlayerData playerData = plugin.getPlayerManager().getPlayerData(leader);
players.add(leader.getUniqueId());
assert playerData != null;
playerData.setTeam(this);
playerData.setPendingTeam(null);

Expand All @@ -49,7 +51,7 @@ public void invite(Player player) {
Util.scm(player, HG.getPlugin().getLang().team_invite_3);
Util.scm(player, HG.getPlugin().getLang().team_invite_4);
pending.add(player.getUniqueId());
HG.getPlugin().getPlayerManager().getData(player).setPendingTeam(this);
Objects.requireNonNull(HG.getPlugin().getPlayerManager().getData(player)).setPendingTeam(this);
}

/**
Expand All @@ -59,6 +61,7 @@ public void invite(Player player) {
*/
public void acceptInvite(Player player) {
PlayerData playerData = HG.getPlugin().getPlayerManager().getPlayerData(player);
assert playerData != null;
playerData.setPendingTeam(null);
playerData.setTeam(this);
pending.remove(player.getUniqueId());
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/tk/shanebee/hg/listeners/GameListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,10 @@ private void onInventoryClick(InventoryClickEvent e) {
Status status = game.getGameArenaData().getStatus();
if (status != Status.RUNNING && status != Status.BEGINNING) {
if (Objects.equals(Objects.requireNonNull(e.getClickedInventory().getItem(e.getSlot())).getType(), Material.getMaterial(Config.leaveitemtype))) {
Util.clearInv(player);
game.getGamePlayerData().leave(player,false);
} else if (Objects.equals(Objects.requireNonNull(e.getClickedInventory().getItem(e.getSlot())).getType(), Material.getMaterial(Config.forcestartitem))) {
Util.clearInv(player);
game.startGame();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tk/shanebee/hg/listeners/McmmoListeners.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
public class McmmoListeners implements Listener {

private HG plugin;
private final HG plugin;
private final PlayerManager playerManager;

public McmmoListeners(HG plugin) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tk/shanebee/hg/managers/KillManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
public class KillManager {

private Language lang = HG.getPlugin().getLang();
private final Language lang = HG.getPlugin().getLang();

/** Get the death message when a player dies of natural causes (non-entity involved deaths)
* @param dc Cause of the damage
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/tk/shanebee/hg/managers/MobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
* Manager for mob spawning in games
Expand Down Expand Up @@ -50,8 +51,8 @@ private void loadMobs() {
if (getSection(key) != null) {
MobEntry entry;
// MYTHIC MOB
if (getString(key, "type").startsWith("MM:") && HG.getPlugin().getMmMobManager() != null) {
String mythicMob = getString(key, "type").replace("MM:", "");
if (Objects.requireNonNull(getString(key, "type")).startsWith("MM:") && HG.getPlugin().getMmMobManager() != null) {
String mythicMob = Objects.requireNonNull(getString(key, "type")).replace("MM:", "");
entry = new MobEntry(mythicMob, getInt(key, "level"));
}
// REGULAR MOB
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/tk/shanebee/hg/managers/Placeholders.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
public class Placeholders extends PlaceholderExpansion {

private HG plugin;
private Leaderboard leaderboard;
private Language lang;
private final HG plugin;
private final Leaderboard leaderboard;
private final Language lang;

public Placeholders(HG plugin) {
this.plugin = plugin;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/tk/shanebee/hg/tasks/StartingTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void run() {
if (timer <= 0) {
//clear inventory on game start

if (Config.enableleaveitem || Config.enableforcestartitem)
if ((Config.enableleaveitem) || Config.enableforcestartitem)
game.getGamePlayerData().getPlayers().forEach(uuid -> {
Player player = Bukkit.getPlayer(uuid);
assert player != null;
Expand All @@ -51,7 +51,6 @@ public void run() {
}
});


stop();
game.startFreeRoam();
} else {
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/tk/shanebee/hg/util/PotionTypeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,6 @@ public static PotionType getByBukkit(String bukkit) {
return PotionType.valueOf(bukkit.toUpperCase());
}

/**
* Get Bukkit key for PotionType
*
* @return Bukkit key
*/
public String getBukkitKey() {
return bukkit;
}

/**
* Get PotionData from a String
* <p><b>Formats:</b>
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/tk/shanebee/hg/util/Vault.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ public class Vault {

public static Economy economy = null;

public static boolean setupEconomy() {
public static void setupEconomy() {
RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
}
return (economy != null);
}

}

0 comments on commit 1a91f9b

Please sign in to comment.