mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2025-02-19 01:41:30 +01:00
Debug to view advancements
This commit is contained in:
parent
ec48419961
commit
553a44cd07
2
pom.xml
2
pom.xml
@ -58,7 +58,7 @@
|
|||||||
<!-- Non-minecraft related dependencies -->
|
<!-- Non-minecraft related dependencies -->
|
||||||
<powermock.version>2.0.9</powermock.version>
|
<powermock.version>2.0.9</powermock.version>
|
||||||
<!-- More visible way how to change dependency versions -->
|
<!-- More visible way how to change dependency versions -->
|
||||||
<spigot.version>1.20.1-R0.1-SNAPSHOT</spigot.version>
|
<spigot.version>1.20.2-R0.1-SNAPSHOT</spigot.version>
|
||||||
<bentobox.version>1.24.0</bentobox.version>
|
<bentobox.version>1.24.0</bentobox.version>
|
||||||
<!-- Revision variable removes warning about dynamic version -->
|
<!-- Revision variable removes warning about dynamic version -->
|
||||||
<revision>${build.version}-SNAPSHOT</revision>
|
<revision>${build.version}-SNAPSHOT</revision>
|
||||||
|
@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
import world.bentobox.bentobox.database.Database;
|
import world.bentobox.bentobox.database.Database;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
@ -183,10 +184,12 @@ public class AdvancementsManager {
|
|||||||
*/
|
*/
|
||||||
public int addAdvancement(Player p, Advancement advancement) {
|
public int addAdvancement(Player p, Advancement advancement) {
|
||||||
if (!addon.inWorld(p.getWorld())) {
|
if (!addon.inWorld(p.getWorld())) {
|
||||||
|
BentoBox.getInstance().logDebug("Wrong world");
|
||||||
// Wrong world
|
// Wrong world
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int score = getScore(advancement);
|
int score = getScore(advancement);
|
||||||
|
BentoBox.getInstance().logDebug("score is " + score);
|
||||||
if (score == 0) {
|
if (score == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -197,9 +200,11 @@ public class AdvancementsManager {
|
|||||||
&& addAdvancement(island, advancement.getKey().toString())) {
|
&& addAdvancement(island, advancement.getKey().toString())) {
|
||||||
int oldSize = island.getProtectionRange();
|
int oldSize = island.getProtectionRange();
|
||||||
int newSize = Math.max(1, oldSize + score);
|
int newSize = Math.max(1, oldSize + score);
|
||||||
|
BentoBox.getInstance().logDebug("Changing size old = " + oldSize + " new = " + newSize);
|
||||||
setProtectionSize(island, newSize, p.getUniqueId());
|
setProtectionSize(island, newSize, p.getUniqueId());
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
BentoBox.getInstance().logDebug("No island");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -240,6 +245,7 @@ public class AdvancementsManager {
|
|||||||
* @return score of advancement, or 0 if it cannot be worked out
|
* @return score of advancement, or 0 if it cannot be worked out
|
||||||
*/
|
*/
|
||||||
public int getScore(Advancement a) {
|
public int getScore(Advancement a) {
|
||||||
|
BentoBox.getInstance().logDebug("get score");
|
||||||
String adv = "advancements." + a.getKey().getKey();
|
String adv = "advancements." + a.getKey().getKey();
|
||||||
// Unknowns
|
// Unknowns
|
||||||
if (adv.endsWith("/root")) {
|
if (adv.endsWith("/root")) {
|
||||||
@ -257,7 +263,9 @@ public class AdvancementsManager {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
BentoBox.getInstance().logDebug("Checking yaml for " + adv);
|
||||||
if (advConfig.contains(adv)) {
|
if (advConfig.contains(adv)) {
|
||||||
|
BentoBox.getInstance().logDebug("It's there");
|
||||||
return advConfig.getInt(adv, this.unknownAdvChange);
|
return advConfig.getInt(adv, this.unknownAdvChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import org.bukkit.event.player.PlayerPortalEvent;
|
import org.bukkit.event.player.PlayerPortalEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.events.island.IslandNewIslandEvent;
|
import world.bentobox.bentobox.api.events.island.IslandNewIslandEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamJoinedEvent;
|
import world.bentobox.bentobox.api.events.team.TeamJoinedEvent;
|
||||||
import world.bentobox.bentobox.api.events.team.TeamLeaveEvent;
|
import world.bentobox.bentobox.api.events.team.TeamLeaveEvent;
|
||||||
@ -84,14 +85,17 @@ public class AdvancementListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onAdvancement(PlayerAdvancementDoneEvent e) {
|
public void onAdvancement(PlayerAdvancementDoneEvent e) {
|
||||||
|
BentoBox.getInstance().logDebug(e.getAdvancement().getKey());
|
||||||
// Ignore if player is not in survival or if advancements are being ignored
|
// Ignore if player is not in survival or if advancements are being ignored
|
||||||
if (!e.getPlayer().getGameMode().equals(GameMode.SURVIVAL) || addon.getSettings().isIgnoreAdvancements()) {
|
if (!e.getPlayer().getGameMode().equals(GameMode.SURVIVAL) || addon.getSettings().isIgnoreAdvancements()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check if player is in the Boxed worlds
|
// Check if player is in the Boxed worlds
|
||||||
if (addon.inWorld(e.getPlayer().getWorld())) {
|
if (addon.inWorld(e.getPlayer().getWorld())) {
|
||||||
|
BentoBox.getInstance().logDebug("in world");
|
||||||
// Only allow members or higher to get advancements in a box
|
// Only allow members or higher to get advancements in a box
|
||||||
if (addon.getSettings().isDenyVisitorAdvancements() && !addon.getIslands().getIslandAt(e.getPlayer().getLocation()).map(i -> i.getMemberSet().contains(e.getPlayer().getUniqueId())).orElse(false)) {
|
if (addon.getSettings().isDenyVisitorAdvancements() && !addon.getIslands().getIslandAt(e.getPlayer().getLocation()).map(i -> i.getMemberSet().contains(e.getPlayer().getUniqueId())).orElse(false)) {
|
||||||
|
BentoBox.getInstance().logDebug("not on island");
|
||||||
// Remove advancement from player
|
// Remove advancement from player
|
||||||
e.getAdvancement().getCriteria().forEach(c ->
|
e.getAdvancement().getCriteria().forEach(c ->
|
||||||
e.getPlayer().getAdvancementProgress(e.getAdvancement()).revokeCriteria(c));
|
e.getPlayer().getAdvancementProgress(e.getAdvancement()).revokeCriteria(c));
|
||||||
@ -103,6 +107,7 @@ public class AdvancementListener implements Listener {
|
|||||||
}
|
}
|
||||||
// Add the advancement to the island
|
// Add the advancement to the island
|
||||||
int score = addon.getAdvManager().addAdvancement(e.getPlayer(), e.getAdvancement());
|
int score = addon.getAdvManager().addAdvancement(e.getPlayer(), e.getAdvancement());
|
||||||
|
BentoBox.getInstance().logDebug("Score for this advancement is " + score);
|
||||||
// Tell other team players one tick after it occurs if it is something that has a score
|
// Tell other team players one tick after it occurs if it is something that has a score
|
||||||
if (score != 0) {
|
if (score != 0) {
|
||||||
User user = User.getInstance(e.getPlayer());
|
User user = User.getInstance(e.getPlayer());
|
||||||
|
@ -20,7 +20,7 @@ import org.bukkit.block.structure.Mirror;
|
|||||||
import org.bukkit.block.structure.StructureRotation;
|
import org.bukkit.block.structure.StructureRotation;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
Loading…
Reference in New Issue
Block a user