#I m currently debugging
1 messages · Page 1 of 1 (latest)
private void resetVariables() {
killCount = 0;
spawnedCount = 0;
bossBar.setProgress(0);
currentLevel++;
mythicMob = null;
}
is resetVariables, meant to set the state
sysout something after you set the state
are you setting it to start with
Constructor as true and haven't implementing disabling the game yet
intellij says no usages on set so
Adding some more sysout
I shall inform a infinite loop is happening somewhere
But that's fine no?
I mean
case RESETTING:
Bukkit.getLogger().info("Trying to reset dungeon " + (dungeonGameID) + "...");
ChatManager.sendMessage(player, "The dungeon is resetting!");
currentLevel = 1;
state = State.WAITING;
resetVariables();
Bukkit.getLogger().info("Dungeon " + (dungeonGameID) + " has been reset!");
break;
None of that is ever getting called
state never changes then
force the state to be RESETTING, see if it runs
I made another runtask that's checking the state
It's waiting until I leave
public void removePlayer(Player player) {
DungeonPlayer dungeonPlayer = getDungeonPlayerByPlayer(player);
if (dungeonPlayer == leader) {
players.remove(dungeonPlayer);
if (players.size() == 0) {
state = State.RESETTING;
<-------------------- added sysout here. it works and only once
return;
}
leader = players.get(0);
messagePlayers("&4The leader has left the dungeon!");
messagePlayers("&4The new leader is " + leader.getPlayer().getName() + "!");
}
}
Then goes to resetting
add a sout on all occasions you set the state
I'm legit joining, doesn't change, and leaving changes in that method
its either not getting set to waiting or its getting set the resetting constantly
This isn't even getting called
Not a single time
the state in one case is waiting, so running waiting code, but by the time you sysout state its back to resetting
might crash if you leave it running too long
For science
Kinda desperate at this point
@quiet path yeah no wtf
I made the one that prints it 1tick and the one that's in the actual game 30ticks
is tasktimerAsync?
shouldnt be
what is happening
ive got no idea, im gonna guess somehow its constantly running something
without full source code idk where or what would do that
I'll post this file here
Yeah no there's only 10 times the state gets set to resetting. and none of them are in a loop and none of them can repeat
The fact that it never even reaches the code for resetting anyways is crazy to me
yeah no wtf
there is so much going on in that one class i cant even tell what half of it does or how it even works
Well you guys said to put the gamelogic in 1 place lol but either way
Unless im dumb. That first runnable task is repeating itself forever, correct?
the activateDungeon one will run until isEnable is false
If that's the case then why isn't it even going to the resetting case for the switch
I'll send the start state to resetting and see what happens rq
ive found one of the issues
OK
on case ENDING and PAUSE on activate dungeon, it never breaks if player size doesnt equal 0
.
That would just make the loop run 1 more time
case ENDING:
ChatManager.sendMessage(player, "The dungeon is ending!");
if (players.size() == 0) {
state = State.RESETTING;
break; < -------------
}
getPlayers().forEach(dungeonPlayer -> {
dungeonPlayer.getPlayer().setGameMode(GameMode.SURVIVAL);
dungeonPlayer.getPlayer().teleport(Bukkit.getWorld("spawn").getSpawnLocation());
removePlayer(dungeonPlayer.getPlayer());
TitleManager.sendTitleWithPrefix(dungeonPlayer.getPlayer(), "Resetting, You have been teleported to spawn!");
});
getSpectators().forEach(dungeonSpectator -> {
dungeonSpectator.getPlayer().setGameMode(GameMode.SURVIVAL);
dungeonSpectator.getPlayer().teleport(Bukkit.getWorld("spawn").getSpawnLocation());
removeSpectator(dungeonSpectator.getPlayer());
});
break; < -------------
case PAUSE:
if (players.size() == 0) {
state = State.RESETTING;
break; < -------------
}
titlePlayers("&2&l/dm next &rto continue!", "Waiting for &2&lleader to resume the dungeon!");
break; < -------------
oh lmao
i can barely even tell where half of these methods are ending, others starts
So sort of like this
btw
80% isn't even getting called
Cause I'm just joining and leaving
Not even going through the logic
public void addPlayer(DungeonGame gameHandler, Player player) {
players.add(new DungeonPlayer(player));
if (players.size() == 1) {
gameHandler.setLeader(players.get(0));
}
}
gets called from command to add player
public void removePlayer(Player player) {
DungeonPlayer dungeonPlayer = getDungeonPlayerByPlayer(player);
if (dungeonPlayer == leader) {
players.remove(dungeonPlayer);
if (players.size() == 0) {
state = State.RESETTING;
System.out.println("Leader left, no more players in dungeon, resetting dungeon");
return;
}
leader = players.get(0);
messagePlayers("&4The leader has left the dungeon!");
messagePlayers("&4The new leader is " + leader.getPlayer().getName() + "!");
}
}
``` gets called from command to remove player
omg
I'm gonna kms
Well that's dumb of me
"ending and starting" you're a genius without knowing
EDIT:
Is the correct way around this to initialize the main gamestate in a taskTimer from the constructor itself so that way the function containing the logic will be called over and over?
public void activateDungeon () {
switch (state) {
case WAITING:
messagePlayers("The dungeon is waiting for players!");
setWorldBorder();
break;
case STARTING:
break;
case IN_PROGRESS:
``` etc etc etc etc
new BukkitRunnable() {
@Override
public void run() {
//System.out.println("Dungeon " + (dungeonGameID) + " is " + state.toString() + "!");
if (!isEnabled()) {
return;
}
activateDungeon();
}
}.runTaskTimer(plugin, 0, 10);
In the constructor
I think the timer just got out of scope, if its the only timer consider making it a member variable
Is what I did above bad practice tho?
but im not sure how gc wotks in java
Because before I had it like this
public void activateDungeon(Player player) {
new BukkitRunnable() {
@Override
public void run() {
if (!isEnabled()) {
ChatManager.sendMessage(player, "This dungeon is not enabled!");
cancel();
return;
}
switch (state) {
case WAITING:
ChatManager.sendMessage(player, "The dungeon is waiting for players!");
setWorldBorder();
break;
case RESETTING:
ChatManager.sendMessage(player, "The dungeon is resetting!");
currentLevel = 1;
resetVariables();
state = State.WAITING;
break;
}
}
}.runTaskTimer(plugin, 10, 10);
}