mirror of
https://github.com/SunNetservers/MiniGames.git
synced 2025-09-17 11:27:55 +02:00
Fixes a bug in killBlockNames, and reduces writes
This commit is contained in:
@@ -21,6 +21,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static net.knarcraft.minigames.util.InputValidationHelper.isInvalid;
|
||||
|
||||
@@ -167,13 +168,13 @@ public class DropperArena implements Arena {
|
||||
public void addReward(@NotNull RewardCondition rewardCondition, @NotNull Reward reward) {
|
||||
this.rewards.computeIfAbsent(rewardCondition, k -> new HashSet<>());
|
||||
this.rewards.get(rewardCondition).add(reward);
|
||||
this.dropperArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRewards(@NotNull RewardCondition rewardCondition) {
|
||||
this.rewards.remove(rewardCondition);
|
||||
this.dropperArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -267,7 +268,7 @@ public class DropperArena implements Arena {
|
||||
return false;
|
||||
} else {
|
||||
this.spawnLocation = newLocation;
|
||||
this.dropperArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -283,7 +284,7 @@ public class DropperArena implements Arena {
|
||||
return false;
|
||||
} else {
|
||||
this.exitLocation = newLocation;
|
||||
this.dropperArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -300,7 +301,7 @@ public class DropperArena implements Arena {
|
||||
this.arenaName = arenaName;
|
||||
// Update the arena lookup map to make sure the new name can be used immediately
|
||||
this.dropperArenaHandler.updateLookupName(oldName, this.getArenaNameSanitized());
|
||||
this.dropperArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -320,7 +321,7 @@ public class DropperArena implements Arena {
|
||||
return false;
|
||||
} else {
|
||||
this.winBlockType = material;
|
||||
this.dropperArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -338,7 +339,7 @@ public class DropperArena implements Arena {
|
||||
return false;
|
||||
} else {
|
||||
this.playerHorizontalVelocity = horizontalVelocity;
|
||||
this.dropperArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -354,11 +355,24 @@ public class DropperArena implements Arena {
|
||||
return false;
|
||||
} else {
|
||||
this.playerVerticalVelocity = verticalVelocity;
|
||||
this.dropperArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves this arena to disk
|
||||
*/
|
||||
public void saveArena() {
|
||||
try {
|
||||
DropperArenaStorageHelper.saveSingleDropperArena(this);
|
||||
} catch (IOException exception) {
|
||||
MiniGames.log(Level.SEVERE, "Unable to save arena! " +
|
||||
"Data loss can occur!");
|
||||
MiniGames.log(Level.SEVERE, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof DropperArena otherArena)) {
|
||||
|
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static net.knarcraft.minigames.util.InputValidationHelper.isInvalid;
|
||||
|
||||
@@ -180,13 +181,13 @@ public class ParkourArena implements Arena {
|
||||
public void addReward(@NotNull RewardCondition rewardCondition, @NotNull Reward reward) {
|
||||
this.rewards.computeIfAbsent(rewardCondition, k -> new HashSet<>());
|
||||
this.rewards.get(rewardCondition).add(reward);
|
||||
this.parkourArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRewards(@NotNull RewardCondition rewardCondition) {
|
||||
this.rewards.remove(rewardCondition);
|
||||
this.parkourArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -314,7 +315,7 @@ public class ParkourArena implements Arena {
|
||||
return false;
|
||||
} else {
|
||||
this.spawnLocation = newLocation;
|
||||
this.parkourArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -330,7 +331,7 @@ public class ParkourArena implements Arena {
|
||||
return false;
|
||||
} else {
|
||||
this.exitLocation = newLocation;
|
||||
this.parkourArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -347,7 +348,7 @@ public class ParkourArena implements Arena {
|
||||
this.arenaName = arenaName;
|
||||
// Update the arena lookup map to make sure the new name can be used immediately
|
||||
this.parkourArenaHandler.updateLookupName(oldName, this.getArenaNameSanitized());
|
||||
this.parkourArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -367,7 +368,7 @@ public class ParkourArena implements Arena {
|
||||
return false;
|
||||
} else {
|
||||
this.winBlockType = material;
|
||||
this.parkourArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -383,7 +384,7 @@ public class ParkourArena implements Arena {
|
||||
return false;
|
||||
} else {
|
||||
this.winLocation = newLocation.clone();
|
||||
this.parkourArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -406,7 +407,7 @@ public class ParkourArena implements Arena {
|
||||
this.killPlaneBlockNames = killPlaneBlockNames;
|
||||
this.killPlaneBlocks = parsed;
|
||||
}
|
||||
this.parkourArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -422,7 +423,7 @@ public class ParkourArena implements Arena {
|
||||
}
|
||||
|
||||
this.checkpoints.add(checkpoint.clone());
|
||||
this.parkourArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -437,10 +438,23 @@ public class ParkourArena implements Arena {
|
||||
}
|
||||
|
||||
this.checkpoints.clear();
|
||||
this.parkourArenaHandler.saveArenas();
|
||||
this.saveArena();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves this arena to disk
|
||||
*/
|
||||
public void saveArena() {
|
||||
try {
|
||||
ParkourArenaStorageHelper.saveSingleParkourArena(this);
|
||||
} catch (IOException exception) {
|
||||
MiniGames.log(Level.SEVERE, "Unable to save arena! " +
|
||||
"Data loss can occur!");
|
||||
MiniGames.log(Level.SEVERE, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof ParkourArena otherArena)) {
|
||||
|
Reference in New Issue
Block a user