mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2025-03-21 14:59:54 +01:00
Added MOVE_BOX flag to enable lower rank players to move the box.
This commit is contained in:
parent
1032f4078d
commit
af4cc022bb
@ -1,5 +1,8 @@
|
||||
package world.bentobox.boxed;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
@ -15,6 +18,10 @@ import world.bentobox.bentobox.api.commands.admin.DefaultAdminCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.DefaultPlayerCommand;
|
||||
import world.bentobox.bentobox.api.configuration.Config;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.api.flags.Flag;
|
||||
import world.bentobox.bentobox.api.flags.Flag.Mode;
|
||||
import world.bentobox.bentobox.api.flags.Flag.Type;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
import world.bentobox.boxed.generators.BasicWorldGenerator;
|
||||
import world.bentobox.boxed.generators.BoxedBiomeGenerator;
|
||||
import world.bentobox.boxed.generators.DeleteGen;
|
||||
@ -22,12 +29,17 @@ import world.bentobox.boxed.listeners.AdvancementListener;
|
||||
import world.bentobox.boxed.listeners.EnderPearlListener;
|
||||
|
||||
/**
|
||||
* Main BSkyBlock class - provides an island minigame in the sky
|
||||
* Main Boxed class - provides an survival game inside a box
|
||||
* @author tastybento
|
||||
* @author Poslovitch
|
||||
*/
|
||||
public class Boxed extends GameModeAddon {
|
||||
|
||||
public static final Flag MOVE_BOX = new Flag.Builder("MOVE_BOX", Material.COMPOSTER)
|
||||
.mode(Mode.BASIC)
|
||||
.type(Type.PROTECTION)
|
||||
.defaultRank(RanksManager.OWNER_RANK)
|
||||
.build();
|
||||
|
||||
private static final String NETHER = "_nether";
|
||||
private static final String THE_END = "_the_end";
|
||||
|
||||
@ -72,7 +84,6 @@ public class Boxed extends GameModeAddon {
|
||||
// Register listeners
|
||||
this.registerListener(new AdvancementListener(this));
|
||||
this.registerListener(new EnderPearlListener(this));
|
||||
//this.registerListener(new JoinListener(this));
|
||||
}
|
||||
|
||||
private boolean loadSettings() {
|
||||
@ -95,6 +106,11 @@ public class Boxed extends GameModeAddon {
|
||||
advManager = new AdvancementsManager(this);
|
||||
// Get delete chunk generator
|
||||
delChunks = new DeleteGen(this);
|
||||
// Make flag only applicable to this game mode
|
||||
MOVE_BOX.setGameModes(Collections.singleton(this));
|
||||
// Register protection flag with BentoBox
|
||||
getPlugin().getFlagsManager().registerFlag(this, MOVE_BOX);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
import world.bentobox.boxed.Boxed;
|
||||
|
||||
/**
|
||||
@ -47,9 +46,8 @@ public class EnderPearlListener implements Listener {
|
||||
if (ep.getShooter() instanceof Player) {
|
||||
User u = User.getInstance((Player)ep.getShooter());
|
||||
addon.getIslands().getIslandAt(l).ifPresent(i -> {
|
||||
// TODO make this a flag
|
||||
if (i.getMemberSet(RanksManager.OWNER_RANK).contains(u.getUniqueId())
|
||||
&& addon.getIslands().isSafeLocation(l)) {
|
||||
// Check flag
|
||||
if (i.isAllowed(u, Boxed.MOVE_BOX) && addon.getIslands().isSafeLocation(l)) {
|
||||
// Reset home locations
|
||||
i.getMemberSet().forEach(uuid -> {
|
||||
addon.getPlayers().getPlayer(uuid).clearHomeLocations(l.getWorld());
|
||||
@ -59,8 +57,7 @@ public class EnderPearlListener implements Listener {
|
||||
i.setProtectionCenter(l);
|
||||
u.getPlayer().playSound(l, Sound.ENTITY_GENERIC_EXPLODE, 2F, 2F);
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
addon.logError("Could not move box " + e1.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,47 +0,0 @@
|
||||
package world.bentobox.boxed.listeners;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.advancement.Advancement;
|
||||
import org.bukkit.advancement.AdvancementProgress;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.boxed.Boxed;
|
||||
|
||||
/**
|
||||
* Just used for development right now
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class JoinListener implements Listener {
|
||||
|
||||
private Boxed addon;
|
||||
|
||||
public JoinListener(Boxed addon) {
|
||||
this.addon = addon;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onJoinEvent(PlayerJoinEvent e) {
|
||||
Iterator<Advancement> it = Bukkit.advancementIterator();
|
||||
while (it.hasNext()) {
|
||||
Advancement a = it.next();
|
||||
//if (!a.getKey().getKey().startsWith("recipe")) {
|
||||
AdvancementProgress progress = e.getPlayer().getAdvancementProgress(a);
|
||||
BentoBox.getInstance().logDebug(a.getKey().toString());
|
||||
//BentoBox.getInstance().logDebug(a.getKey() + " " + progress.isDone());
|
||||
//BentoBox.getInstance().logDebug("Awarded criteria");
|
||||
//progress.getAwardedCriteria().forEach(s -> BentoBox.getInstance().logDebug(s + " " + progress.getDateAwarded(s)));
|
||||
|
||||
//BentoBox.getInstance().logDebug("Remaining criteria " + progress.getRemainingCriteria());
|
||||
//progress.getAwardedCriteria().forEach(progress::revokeCriteria);
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,15 @@
|
||||
#
|
||||
# This is a YML file. Be careful when editing. Check your edits in a YAML checker like #
|
||||
# the one at http://yaml-online-parser.appspot.com #
|
||||
protection:
|
||||
flags:
|
||||
MOVE_BOX:
|
||||
name: Move Box
|
||||
description: |
|
||||
&b Toggle who can
|
||||
&b move the box with
|
||||
&b EnderPearls
|
||||
|
||||
boxed:
|
||||
completed: '&a [name] completed!'
|
||||
size-changed: '&a Box size increased by [number]!'
|
||||
|
Loading…
Reference in New Issue
Block a user