mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2024-11-14 10:16:03 +01:00
Some work around trying to reset advancements
only when a player starts an island.
This commit is contained in:
parent
8dd34a32e6
commit
5e536dfa63
@ -293,6 +293,14 @@ public class Settings implements WorldSettings {
|
|||||||
@ConfigEntry(path = "area.reset.on-join.ender-chest")
|
@ConfigEntry(path = "area.reset.on-join.ender-chest")
|
||||||
private boolean onJoinResetEnderChest = false;
|
private boolean onJoinResetEnderChest = false;
|
||||||
|
|
||||||
|
@ConfigComment("Reset advancements.")
|
||||||
|
@ConfigEntry(path = "area.reset.on-join.reset-advancements")
|
||||||
|
private boolean onJoinResetAdvancements = true;
|
||||||
|
|
||||||
|
@ConfigComment("Grant these advancements")
|
||||||
|
@ConfigEntry(path = "area.reset.on-join.grant-advancements")
|
||||||
|
private List<String> onJoinGrantAdvancements = new ArrayList<>();
|
||||||
|
|
||||||
@ConfigComment("What the plugin should reset when the player leaves or is kicked from an area")
|
@ConfigComment("What the plugin should reset when the player leaves or is kicked from an area")
|
||||||
@ConfigComment("Reset Money - if this is true, will reset the player's money to the starting money")
|
@ConfigComment("Reset Money - if this is true, will reset the player's money to the starting money")
|
||||||
@ConfigComment("Recommendation is that this is set to true, but if you run multi-worlds")
|
@ConfigComment("Recommendation is that this is set to true, but if you run multi-worlds")
|
||||||
@ -322,6 +330,14 @@ public class Settings implements WorldSettings {
|
|||||||
@ConfigEntry(path = "area.reset.on-leave.ender-chest")
|
@ConfigEntry(path = "area.reset.on-leave.ender-chest")
|
||||||
private boolean onLeaveResetEnderChest = false;
|
private boolean onLeaveResetEnderChest = false;
|
||||||
|
|
||||||
|
@ConfigComment("Reset advancements.")
|
||||||
|
@ConfigEntry(path = "area.reset.on-leave.reset-advancements")
|
||||||
|
private boolean oLeaveResetAdvancements = false;
|
||||||
|
|
||||||
|
@ConfigComment("Grant these advancements")
|
||||||
|
@ConfigEntry(path = "area.reset.on-leave.grant-advancements")
|
||||||
|
private List<String> onLeaveGrantAdvancements = new ArrayList<>();
|
||||||
|
|
||||||
@ConfigComment("Toggles the automatic area creation upon the player's first login on your server.")
|
@ConfigComment("Toggles the automatic area creation upon the player's first login on your server.")
|
||||||
@ConfigComment("If set to true,")
|
@ConfigComment("If set to true,")
|
||||||
@ConfigComment(" * Upon connecting to your server for the first time, the player will be told that")
|
@ConfigComment(" * Upon connecting to your server for the first time, the player will be told that")
|
||||||
@ -1662,4 +1678,60 @@ public class Settings implements WorldSettings {
|
|||||||
public void setAllowStrongholds(boolean allowStrongholds) {
|
public void setAllowStrongholds(boolean allowStrongholds) {
|
||||||
this.allowStrongholds = allowStrongholds;
|
this.allowStrongholds = allowStrongholds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the onJoinResetAdvancements
|
||||||
|
*/
|
||||||
|
public boolean isOnJoinResetAdvancements() {
|
||||||
|
return onJoinResetAdvancements;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param onJoinResetAdvancements the onJoinResetAdvancements to set
|
||||||
|
*/
|
||||||
|
public void setOnJoinResetAdvancements(boolean onJoinResetAdvancements) {
|
||||||
|
this.onJoinResetAdvancements = onJoinResetAdvancements;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the onJoinGrantAdvancements
|
||||||
|
*/
|
||||||
|
public List<String> getOnJoinGrantAdvancements() {
|
||||||
|
return onJoinGrantAdvancements;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param onJoinGrantAdvancements the onJoinGrantAdvancements to set
|
||||||
|
*/
|
||||||
|
public void setOnJoinGrantAdvancements(List<String> onJoinGrantAdvancements) {
|
||||||
|
this.onJoinGrantAdvancements = onJoinGrantAdvancements;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the oLeaveResetAdvancements
|
||||||
|
*/
|
||||||
|
public boolean isoLeaveResetAdvancements() {
|
||||||
|
return oLeaveResetAdvancements;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param oLeaveResetAdvancements the oLeaveResetAdvancements to set
|
||||||
|
*/
|
||||||
|
public void setoLeaveResetAdvancements(boolean oLeaveResetAdvancements) {
|
||||||
|
this.oLeaveResetAdvancements = oLeaveResetAdvancements;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the onLeaveGrantAdvancements
|
||||||
|
*/
|
||||||
|
public List<String> getOnLeaveGrantAdvancements() {
|
||||||
|
return onLeaveGrantAdvancements;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param onLeaveGrantAdvancements the onLeaveGrantAdvancements to set
|
||||||
|
*/
|
||||||
|
public void setOnLeaveGrantAdvancements(List<String> onLeaveGrantAdvancements) {
|
||||||
|
this.onLeaveGrantAdvancements = onLeaveGrantAdvancements;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,11 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerAdvancementDoneEvent;
|
import org.bukkit.event.player.PlayerAdvancementDoneEvent;
|
||||||
import org.bukkit.event.player.PlayerPortalEvent;
|
import org.bukkit.event.player.PlayerPortalEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
|
import world.bentobox.bentobox.api.metadata.MetaDataValue;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
import world.bentobox.boxed.Boxed;
|
import world.bentobox.boxed.Boxed;
|
||||||
@ -93,5 +95,24 @@ public class AdvancementListener implements Listener {
|
|||||||
adv.getCriteria().forEach(player.getAdvancementProgress(adv)::awardCriteria);
|
adv.getCriteria().forEach(player.getAdvancementProgress(adv)::awardCriteria);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onFirstTime(PlayerTeleportEvent e) {
|
||||||
|
User user = User.getInstance(e.getPlayer());
|
||||||
|
boolean firstTime = user.getMetaData("Boxed-first-time").map(MetaDataValue::asBoolean).orElse(true);
|
||||||
|
if (firstTime
|
||||||
|
&& e.getTo() != null
|
||||||
|
&& e.getTo().getWorld() != null
|
||||||
|
&& addon.getOverWorld().equals(Util.getWorld(e.getTo().getWorld()))
|
||||||
|
&& addon.getIslands().hasIsland(addon.getOverWorld(), user) // Owner of island
|
||||||
|
) {
|
||||||
|
// Clear advancements
|
||||||
|
addon.getPlugin().logDebug("Clear advancements");
|
||||||
|
// Add meta data
|
||||||
|
user.putMetaData("Boxed-first-time", new MetaDataValue(false));
|
||||||
|
addon.getPlayers().save(user.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -348,6 +348,11 @@ area:
|
|||||||
exp: true
|
exp: true
|
||||||
# Reset Ender Chest - if true, the player's Ender Chest will be cleared.
|
# Reset Ender Chest - if true, the player's Ender Chest will be cleared.
|
||||||
ender-chest: false
|
ender-chest: false
|
||||||
|
# Reset advancements
|
||||||
|
reset-advancements: true
|
||||||
|
# Grant these advancements
|
||||||
|
grant-advancements:
|
||||||
|
- "minecraft/story:root": true
|
||||||
on-leave:
|
on-leave:
|
||||||
# What the plugin should reset when the player leaves or is kicked from an area
|
# What the plugin should reset when the player leaves or is kicked from an area
|
||||||
# Reset Money - if this is true, will reset the player's money to the starting money
|
# Reset Money - if this is true, will reset the player's money to the starting money
|
||||||
@ -366,6 +371,10 @@ area:
|
|||||||
exp: false
|
exp: false
|
||||||
# Reset Ender Chest - if true, the player's Ender Chest will be cleared.
|
# Reset Ender Chest - if true, the player's Ender Chest will be cleared.
|
||||||
ender-chest: false
|
ender-chest: false
|
||||||
|
# Reset advancements
|
||||||
|
reset-advancements: false
|
||||||
|
# Grant these advancements
|
||||||
|
grant-advancements: []
|
||||||
create-area-on-first-login:
|
create-area-on-first-login:
|
||||||
# Toggles the automatic area creation upon the player's first login on your server.
|
# Toggles the automatic area creation upon the player's first login on your server.
|
||||||
# If set to true,
|
# If set to true,
|
||||||
@ -417,8 +426,7 @@ area:
|
|||||||
# Here are some examples of valid commands to execute:
|
# Here are some examples of valid commands to execute:
|
||||||
# * "[SUDO] bbox version"
|
# * "[SUDO] bbox version"
|
||||||
# * "boxadmin deaths set [player] 0"
|
# * "boxadmin deaths set [player] 0"
|
||||||
on-join:
|
on-join: []
|
||||||
- advancement revoke [player] everything
|
|
||||||
# List of commands to run when a player leaves an area, resets his area or gets kicked from it.
|
# List of commands to run when a player leaves an area, resets his area or gets kicked from it.
|
||||||
# These commands are run by the console, unless otherwise stated using the [SUDO] prefix,
|
# These commands are run by the console, unless otherwise stated using the [SUDO] prefix,
|
||||||
# in which case they are executed by the player.
|
# in which case they are executed by the player.
|
||||||
|
Loading…
Reference in New Issue
Block a user