Overhaul group signs

This commit is contained in:
Daniel Saukel 2018-05-24 20:41:17 +02:00
parent e7abc8649c
commit 6194b7ac54
6 changed files with 194 additions and 342 deletions

View File

@ -32,6 +32,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
*/ */
public abstract class GlobalProtection { public abstract class GlobalProtection {
public static final String SIGN_TAG = "[DXL]";
FileConfiguration config = DungeonsXL.getInstance().getGlobalData().getConfig(); FileConfiguration config = DungeonsXL.getInstance().getGlobalData().getConfig();
GlobalProtectionCache protections = DungeonsXL.getInstance().getGlobalProtections(); GlobalProtectionCache protections = DungeonsXL.getInstance().getGlobalProtections();

View File

@ -18,6 +18,7 @@ package de.erethon.dungeonsxl.global;
import de.erethon.caliburn.item.ExItem; import de.erethon.caliburn.item.ExItem;
import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.player.DGroup;
import java.io.File; import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -159,6 +160,18 @@ public class GlobalProtectionCache {
return false; return false;
} }
public void updateGroupSigns(DGroup dGroupSearch) {
for (GlobalProtection protection : getProtections(GroupSign.class)) {
GroupSign groupSign = (GroupSign) protection;
if (dGroupSearch != null && groupSign.getGroup() == dGroupSearch) {
if (dGroupSearch.isEmpty()) {
groupSign.setGroup(null);
}
groupSign.update();
}
}
}
/* SUBJECT TO CHANGE */ /* SUBJECT TO CHANGE */
@Deprecated @Deprecated
public void loadAll() { public void loadAll() {
@ -195,11 +208,11 @@ public class GlobalProtectionCache {
preString = "protections.groupSigns." + world.getName() + "." + id + "."; preString = "protections.groupSigns." + world.getName() + "." + id + ".";
if (data.contains(preString)) { if (data.contains(preString)) {
String mapName = data.getString(preString + ".dungeon"); String mapName = data.getString(preString + ".dungeon");
int maxGroups = data.getInt(preString + ".maxGroups"); String groupName = data.getString(preString + ".groupName");
int maxPlayersPerGroup = data.getInt(preString + ".maxPlayersPerGroup"); int maxPlayersPerGroup = data.getInt(preString + ".maxPlayersPerGroup");
Block startSign = world.getBlockAt(data.getInt(preString + ".x"), data.getInt(preString + ".y"), data.getInt(preString + ".z")); Block startSign = world.getBlockAt(data.getInt(preString + ".x"), data.getInt(preString + ".y"), data.getInt(preString + ".z"));
new GroupSign(id, startSign, mapName, maxGroups, maxPlayersPerGroup); new GroupSign(id, startSign, mapName, maxPlayersPerGroup, groupName);
} }
} while (data.contains(preString)); } while (data.contains(preString));
} }

View File

@ -207,12 +207,11 @@ public class GlobalProtectionListener implements Listener {
} }
if (Category.SIGNS.containsBlock(clickedBlock)) { if (Category.SIGNS.containsBlock(clickedBlock)) {
// Check Group Signs GroupSign groupSign = GroupSign.getByBlock(clickedBlock);
if (GroupSign.playerInteract(clickedBlock, player)) { if (groupSign != null && groupSign.onPlayerInteract(clickedBlock, player)) {
event.setCancelled(true); event.setCancelled(true);
} }
// Check Game Signs
if (GameSign.playerInteract(clickedBlock, player)) { if (GameSign.playerInteract(clickedBlock, player)) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -225,7 +224,6 @@ public class GlobalProtectionListener implements Listener {
} }
} }
@Deprecated
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onSignChange(SignChangeEvent event) { public void onSignChange(SignChangeEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -238,11 +236,17 @@ public class GlobalProtectionListener implements Listener {
return; return;
} }
if (!lines[0].equalsIgnoreCase("[DXL]")) { if (!lines[0].equalsIgnoreCase(GlobalProtection.SIGN_TAG)) {
return; return;
} }
if (lines[1].equalsIgnoreCase("Game") || lines[1].equalsIgnoreCase("Group")) { if (lines[1].equalsIgnoreCase(GroupSign.GROUP_SIGN_TAG)) {
if (GroupSign.tryToCreate(event) != null) {
event.setCancelled(true);
}
} else if (lines[1].equalsIgnoreCase("Game")) {
String dungeonName = lines[2]; String dungeonName = lines[2];
String[] data = lines[3].split("\\,"); String[] data = lines[3].split("\\,");
@ -251,20 +255,13 @@ public class GlobalProtectionListener implements Listener {
int maxMembersPerObject = NumberUtil.parseInt(data[1]); int maxMembersPerObject = NumberUtil.parseInt(data[1]);
if (maxObjects > 0 && maxMembersPerObject > 0) { if (maxObjects > 0 && maxMembersPerObject > 0) {
if (lines[1].equalsIgnoreCase("Game")) { if (GameSign.tryToCreate(event.getBlock(), dungeonName, maxObjects, maxMembersPerObject) != null) {
if (GameSign.tryToCreate(event.getBlock(), dungeonName, maxObjects, maxMembersPerObject) != null) { event.setCancelled(true);
event.setCancelled(true);
}
} else if (lines[1].equalsIgnoreCase("Group")) {
if (GroupSign.tryToCreate(event.getBlock(), dungeonName, maxObjects, maxMembersPerObject) != null) {
event.setCancelled(true);
}
} }
} }
} }
} else if (lines[1].equalsIgnoreCase("Leave")) { } else if (lines[1].equalsIgnoreCase(LeaveSign.LEAVE_SIGN_TAG)) {
if (block.getState() instanceof Sign) { if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState(); Sign sign = (Sign) block.getState();

View File

@ -17,8 +17,10 @@
package de.erethon.dungeonsxl.global; package de.erethon.dungeonsxl.global;
import de.erethon.caliburn.category.Category; import de.erethon.caliburn.category.Category;
import de.erethon.caliburn.item.VanillaItem;
import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.chat.MessageUtil;
import de.erethon.commons.misc.BlockUtil; import de.erethon.commons.misc.BlockUtil;
import de.erethon.commons.misc.NumberUtil;
import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.dungeon.Dungeon; import de.erethon.dungeonsxl.dungeon.Dungeon;
@ -26,13 +28,14 @@ import de.erethon.dungeonsxl.player.DGroup;
import de.erethon.dungeonsxl.world.DResourceWorld; import de.erethon.dungeonsxl.world.DResourceWorld;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.material.Attachable;
/** /**
* A sign to form a group and to define its dungeon. * A sign to form a group and to define its dungeon.
@ -41,19 +44,20 @@ import org.bukkit.entity.Player;
*/ */
public class GroupSign extends GlobalProtection { public class GroupSign extends GlobalProtection {
private DGroup[] dGroups; public static final String GROUP_SIGN_TAG = "Group";
private String groupName;
private DGroup group;
private Dungeon dungeon; private Dungeon dungeon;
private int maxPlayersPerGroup; private int maxPlayersPerGroup;
private Block startSign; private Block startSign;
private int directionX = 0, directionZ = 0;
private int verticalSigns; private int verticalSigns;
private Set<Block> blocks; private Set<Block> blocks;
public GroupSign(int id, Block startSign, String identifier, int maxGroups, int maxPlayersPerGroup) { public GroupSign(int id, Block startSign, String identifier, int maxPlayersPerGroup, String groupName) {
super(startSign.getWorld(), id); super(startSign.getWorld(), id);
this.startSign = startSign; this.startSign = startSign;
dGroups = new DGroup[maxGroups];
dungeon = DungeonsXL.getInstance().getDungeons().getByName(identifier); dungeon = DungeonsXL.getInstance().getDungeons().getByName(identifier);
if (dungeon == null) { if (dungeon == null) {
DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(identifier); DResourceWorld resource = DungeonsXL.getInstance().getDWorlds().getResourceByName(identifier);
@ -63,31 +67,30 @@ public class GroupSign extends GlobalProtection {
} }
this.maxPlayersPerGroup = maxPlayersPerGroup; this.maxPlayersPerGroup = maxPlayersPerGroup;
verticalSigns = (int) Math.ceil((float) (1 + maxPlayersPerGroup) / 4); verticalSigns = (int) Math.ceil((float) (1 + maxPlayersPerGroup) / 4);
this.groupName = groupName;
int[] direction = getDirection(this.startSign.getData());
directionX = direction[0];
directionZ = direction[1];
update(); update();
} }
/** /**
* @return the dGroups * @return
* the attached group
*/ */
public DGroup[] getDGroups() { public DGroup getGroup() {
return dGroups; return group;
} }
/** /**
* @param dGroups * @param group
* the dGroups to set * the group to set
*/ */
public void setDGroups(DGroup[] dGroups) { public void setGroup(DGroup group) {
this.dGroups = dGroups; this.group = group;
} }
/** /**
* @return the dungeon * @return
* the dungeon
*/ */
public Dungeon getDungeon() { public Dungeon getDungeon() {
return dungeon; return dungeon;
@ -102,7 +105,8 @@ public class GroupSign extends GlobalProtection {
} }
/** /**
* @return the maximum player count per group * @return
* the maximum player count per group
*/ */
public int getMaxPlayersPerGroup() { public int getMaxPlayersPerGroup() {
return maxPlayersPerGroup; return maxPlayersPerGroup;
@ -112,7 +116,7 @@ public class GroupSign extends GlobalProtection {
* @param maxPlayersPerGroup * @param maxPlayersPerGroup
* the maximum player count per group to set * the maximum player count per group to set
*/ */
public void setMaxPlayerPerGroup(int maxPlayersPerGroup) { public void setMaxPlayersPerGroup(int maxPlayersPerGroup) {
this.maxPlayersPerGroup = maxPlayersPerGroup; this.maxPlayersPerGroup = maxPlayersPerGroup;
} }
@ -120,69 +124,63 @@ public class GroupSign extends GlobalProtection {
* Update this group sign to show the group(s) correctly. * Update this group sign to show the group(s) correctly.
*/ */
public void update() { public void update() {
int i = 0; if (!(startSign.getState() instanceof Sign)) {
for (DGroup dGroup : dGroups) { return;
if (!(startSign.getRelative(i * directionX, 0, i * directionZ).getState() instanceof Sign)) {
i++;
continue;
}
Sign sign = (Sign) startSign.getRelative(i * directionX, 0, i * directionZ).getState();
// Reset Signs
sign.setLine(0, "");
sign.setLine(1, "");
sign.setLine(2, "");
sign.setLine(3, "");
int yy = -1;
while (sign.getBlock().getRelative(0, yy, 0).getState() instanceof Sign) {
Sign subsign = (Sign) sign.getBlock().getRelative(0, yy, 0).getState();
subsign.setLine(0, "");
subsign.setLine(1, "");
subsign.setLine(2, "");
subsign.setLine(3, "");
subsign.update();
yy--;
}
// Set Signs
if (dGroup != null) {
if (dGroup.isPlaying()) {
sign.setLine(0, DMessage.SIGN_GLOBAL_IS_PLAYING.getMessage());
} else if (dGroup.getPlayers().size() >= maxPlayersPerGroup) {
sign.setLine(0, DMessage.SIGN_GLOBAL_FULL.getMessage());
} else {
sign.setLine(0, DMessage.SIGN_GLOBAL_JOIN_GROUP.getMessage());
}
int j = 1;
Sign rowSign = sign;
for (Player player : dGroup.getPlayers().getOnlinePlayers()) {
if (j > 3) {
j = 0;
rowSign = (Sign) sign.getBlock().getRelative(0, -1, 0).getState();
}
if (rowSign != null) {
rowSign.setLine(j, player.getName());
}
j++;
rowSign.update();
}
} else {
sign.setLine(0, DMessage.SIGN_GLOBAL_NEW_GROUP.getMessage());
}
sign.update();
i++;
} }
Sign sign = (Sign) startSign.getState();
sign.setLine(0, "");
sign.setLine(1, "");
sign.setLine(2, "");
sign.setLine(3, "");
int y = -1 * verticalSigns;
while (startSign.getRelative(0, y, 0).getState() instanceof Sign && y != 0) {
Sign subsign = (Sign) sign.getBlock().getRelative(0, y, 0).getState();
subsign.setLine(0, "");
subsign.setLine(1, "");
subsign.setLine(2, "");
subsign.setLine(3, "");
subsign.update();
y++;
}
// Set Signs
if (group == null) {
sign.setLine(0, DMessage.SIGN_GLOBAL_NEW_GROUP.getMessage());
sign.update();
return;
}
if (group.isPlaying()) {
sign.setLine(0, DMessage.SIGN_GLOBAL_IS_PLAYING.getMessage());
} else if (group.getPlayers().size() >= maxPlayersPerGroup) {
sign.setLine(0, DMessage.SIGN_GLOBAL_FULL.getMessage());
} else {
sign.setLine(0, DMessage.SIGN_GLOBAL_JOIN_GROUP.getMessage());
}
int j = 1;
Sign rowSign = sign;
for (Player player : group.getPlayers().getOnlinePlayers()) {
if (j > 3) {
j = 0;
rowSign = (Sign) sign.getBlock().getRelative(0, -1, 0).getState();
}
if (rowSign != null) {
rowSign.setLine(j, player.getName());
}
j++;
rowSign.update();
}
sign.update();
} }
@Override @Override
@ -190,17 +188,15 @@ public class GroupSign extends GlobalProtection {
if (blocks == null) { if (blocks == null) {
blocks = new HashSet<>(); blocks = new HashSet<>();
int i = dGroups.length;
do {
i--;
blocks.add(startSign.getRelative(i * directionX, 0, i * directionZ));
} while (i >= 0);
HashSet<Block> toAdd = new HashSet<>(); HashSet<Block> toAdd = new HashSet<>();
int y = -1 * verticalSigns;
while (y != 1) {
blocks.add(startSign.getRelative(0, y, 0));
y++;
}
for (Block block : blocks) { for (Block block : blocks) {
i = verticalSigns; int i = verticalSigns;
do { do {
i--; i--;
@ -224,10 +220,43 @@ public class GroupSign extends GlobalProtection {
config.set(preString + ".y", startSign.getY()); config.set(preString + ".y", startSign.getY());
config.set(preString + ".z", startSign.getZ()); config.set(preString + ".z", startSign.getZ());
config.set(preString + ".dungeon", dungeon.getName()); config.set(preString + ".dungeon", dungeon.getName());
config.set(preString + ".maxGroups", dGroups.length); config.set(preString + ".groupName", groupName);
config.set(preString + ".maxPlayersPerGroup", maxPlayersPerGroup); config.set(preString + ".maxPlayersPerGroup", maxPlayersPerGroup);
} }
public boolean onPlayerInteract(Block block, Player player) {
int y = block.getY();
if (DGroup.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_GROUP.getMessage());
return true;
}
int sy1 = startSign.getY();
Block topBlock = block.getRelative(0, sy1 - y, 0);
if (!(topBlock.getState() instanceof Sign)) {
return true;
}
Sign topSign = (Sign) topBlock.getState();
if (topSign.getLine(0).equals(DMessage.SIGN_GLOBAL_NEW_GROUP.getMessage())) {
if (groupName != null) {
group = new DGroup(groupName, player, dungeon);
} else {
group = new DGroup(player, dungeon);
}
update();
} else if (topSign.getLine(0).equals(DMessage.SIGN_GLOBAL_JOIN_GROUP.getMessage())) {
group.addPlayer(player);
update();
}
return true;
}
/* Statics */ /* Statics */
/** /**
* @param block * @param block
@ -238,250 +267,60 @@ public class GroupSign extends GlobalProtection {
return null; return null;
} }
int x = block.getX(), y = block.getY(), z = block.getZ();
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections(GroupSign.class)) { for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections(GroupSign.class)) {
GroupSign groupSign = (GroupSign) protection; GroupSign groupSign = (GroupSign) protection;
Block start = groupSign.startSign;
int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ(); if (start == block || (start.getX() == block.getX() && start.getZ() == block.getZ() && (start.getY() >= block.getY() && start.getY() - groupSign.verticalSigns <= block.getY()))) {
int sx2 = sx1 + (groupSign.dGroups.length - 1) * groupSign.directionX; return groupSign;
int sy2 = sy1 - groupSign.verticalSigns + 1;
int sz2 = sz1 + (groupSign.dGroups.length - 1) * groupSign.directionZ;
if (sx1 > sx2) {
if (x < sx2 || x > sx1) {
continue;
}
} else if (sx1 < sx2) {
if (x > sx2 || x < sx1) {
continue;
}
} else if (x != sx1) {
continue;
} }
if (sy1 > sy2) {
if (y < sy2 || y > sy1) {
continue;
}
} else if (y != sy1) {
continue;
}
if (sz1 > sz2) {
if (z < sz2 || z > sz1) {
continue;
}
} else if (sz1 < sz2) {
if (z > sz2 || z < sz1) {
continue;
}
} else if (z != sz1) {
continue;
}
return groupSign;
} }
return null; return null;
} }
/* SUBJECT TO CHANGE */ public static GroupSign tryToCreate(SignChangeEvent event) {
@Deprecated if (!event.getLine(0).equalsIgnoreCase(SIGN_TAG)) {
public static GroupSign tryToCreate(Block startSign, String mapName, int maxGroups, int maxPlayersPerGroup) { return null;
}
if (!event.getLine(1).equalsIgnoreCase(GROUP_SIGN_TAG)) {
return null;
}
String identifier = event.getLine(2);
String[] data = event.getLine(3).split(",");
int maxPlayersPerGroup = 1;
String groupName = null;
if (data.length >= 1) {
maxPlayersPerGroup = NumberUtil.parseInt(data[0], 1);
}
if (data.length == 2) {
groupName = data[1];
}
return tryToCreate(event.getBlock(), identifier, maxPlayersPerGroup, groupName);
}
public static GroupSign tryToCreate(Block startSign, String identifier, int maxPlayersPerGroup, String groupName) {
World world = startSign.getWorld(); World world = startSign.getWorld();
int direction = startSign.getData(); BlockFace facing = ((Attachable) startSign.getState().getData()).getAttachedFace().getOppositeFace();
int x = startSign.getX(), y = startSign.getY(), z = startSign.getZ(); int x = startSign.getX(), y = startSign.getY(), z = startSign.getZ();
int verticalSigns = (int) Math.ceil((float) (1 + maxPlayersPerGroup) / 4); int verticalSigns = (int) Math.ceil((float) (1 + maxPlayersPerGroup) / 4);
while (verticalSigns > 1) {
Block block = world.getBlockAt(x, y - verticalSigns, z);
block.setType(VanillaItem.WALL_SIGN.getMaterial(), false);
org.bukkit.material.Sign signData = new org.bukkit.material.Sign(VanillaItem.WALL_SIGN.getMaterial());
signData.setFacingDirection(facing);
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
sign.setData(signData);
sign.update(true, false);
CopyOnWriteArrayList<Block> changeBlocks = new CopyOnWriteArrayList<>(); verticalSigns--;
int xx, yy, zz;
switch (direction) {
case 2:
zz = z;
for (yy = y; yy > y - verticalSigns; yy--) {
for (xx = x; xx > x - maxGroups; xx--) {
Block block = world.getBlockAt(xx, yy, zz);
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null;
}
if (block.getRelative(0, 0, 1).getType() == Material.AIR) {
return null;
}
changeBlocks.add(block);
}
}
break;
case 3:
zz = z;
for (yy = y; yy > y - verticalSigns; yy--) {
for (xx = x; xx < x + maxGroups; xx++) {
Block block = world.getBlockAt(xx, yy, zz);
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null;
}
if (block.getRelative(0, 0, -1).getType() == Material.AIR) {
return null;
}
changeBlocks.add(block);
}
}
break;
case 4:
xx = x;
for (yy = y; yy > y - verticalSigns; yy--) {
for (zz = z; zz < z + maxGroups; zz++) {
Block block = world.getBlockAt(xx, yy, zz);
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null;
}
if (block.getRelative(1, 0, 0).getType() == Material.AIR) {
return null;
}
changeBlocks.add(block);
}
}
break;
case 5:
xx = x;
for (yy = y; yy > y - verticalSigns; yy--) {
for (zz = z; zz > z - maxGroups; zz--) {
Block block = world.getBlockAt(xx, yy, zz);
if (block.getType() != Material.AIR && block.getType() != Material.WALL_SIGN) {
return null;
}
if (block.getRelative(-1, 0, 0).getType() == Material.AIR) {
return null;
}
changeBlocks.add(block);
}
}
break;
} }
GroupSign sign = new GroupSign(DungeonsXL.getInstance().getGlobalProtections().generateId(GroupSign.class, world), startSign, identifier, maxPlayersPerGroup, groupName);
for (Block block : changeBlocks) {
block.setTypeIdAndData(68, startSign.getData(), true);
}
GroupSign sign = new GroupSign(DungeonsXL.getInstance().getGlobalProtections().generateId(GroupSign.class, world), startSign, mapName, maxGroups, maxPlayersPerGroup);
return sign; return sign;
} }
@Deprecated
public static boolean playerInteract(Block block, Player player) {
int x = block.getX(), y = block.getY(), z = block.getZ();
GroupSign groupSign = getByBlock(block);
if (groupSign == null) {
return false;
}
if (DGroup.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_GROUP.getMessage());
return true;
}
int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ();
Block topBlock = block.getRelative(0, sy1 - y, 0);
int column;
if (groupSign.directionX != 0) {
column = Math.abs(x - sx1);
} else {
column = Math.abs(z - sz1);
}
if (!(topBlock.getState() instanceof Sign)) {
return true;
}
Sign topSign = (Sign) topBlock.getState();
if (topSign.getLine(0).equals(DMessage.SIGN_GLOBAL_NEW_GROUP.getMessage())) {
groupSign.dGroups[column] = new DGroup(player, groupSign.dungeon);
groupSign.update();
} else if (topSign.getLine(0).equals(DMessage.SIGN_GLOBAL_JOIN_GROUP.getMessage())) {
groupSign.dGroups[column].addPlayer(player);
groupSign.update();
}
return true;
}
@Deprecated
public static void updatePerGroup(DGroup dGroupSearch) {
for (GlobalProtection protection : DungeonsXL.getInstance().getGlobalProtections().getProtections(GroupSign.class)) {
GroupSign groupSign = (GroupSign) protection;
int i = 0;
for (DGroup dGroup : groupSign.dGroups) {
if (dGroup == null) {
continue;
}
if (dGroup == dGroupSearch) {
if (dGroupSearch.isEmpty()) {
groupSign.dGroups[i] = null;
}
groupSign.update();
}
i++;
}
}
}
@Deprecated
public static int[] getDirection(byte data) {
int[] direction = new int[2];
switch (data) {
case 2:
direction[0] = -1;
break;
case 3:
direction[0] = 1;
break;
case 4:
direction[1] = 1;
break;
case 5:
direction[1] = -1;
break;
}
return direction;
}
} }

View File

@ -37,6 +37,8 @@ import org.bukkit.entity.Player;
*/ */
public class LeaveSign extends GlobalProtection { public class LeaveSign extends GlobalProtection {
public static final String LEAVE_SIGN_TAG = "Leave";
private Sign sign; private Sign sign;
private Set<Block> blocks; private Set<Block> blocks;

View File

@ -32,7 +32,6 @@ import de.erethon.dungeonsxl.event.requirement.RequirementDemandEvent;
import de.erethon.dungeonsxl.event.reward.RewardAdditionEvent; import de.erethon.dungeonsxl.event.reward.RewardAdditionEvent;
import de.erethon.dungeonsxl.game.Game; import de.erethon.dungeonsxl.game.Game;
import de.erethon.dungeonsxl.game.GameRuleProvider; import de.erethon.dungeonsxl.game.GameRuleProvider;
import de.erethon.dungeonsxl.global.GroupSign;
import de.erethon.dungeonsxl.requirement.Requirement; import de.erethon.dungeonsxl.requirement.Requirement;
import de.erethon.dungeonsxl.reward.Reward; import de.erethon.dungeonsxl.reward.Reward;
import de.erethon.dungeonsxl.util.DColor; import de.erethon.dungeonsxl.util.DColor;
@ -296,7 +295,7 @@ public class DGroup {
*/ */
public void removePlayer(Player player, boolean message) { public void removePlayer(Player player, boolean message) {
players.remove(player.getUniqueId()); players.remove(player.getUniqueId());
GroupSign.updatePerGroup(this); plugin.getGlobalProtections().updateGroupSigns(this);
if (message) { if (message) {
sendMessage(DMessage.PLAYER_LEFT_GROUP.getMessage(player.getName())); sendMessage(DMessage.PLAYER_LEFT_GROUP.getMessage(player.getName()));
@ -758,7 +757,7 @@ public class DGroup {
timeIsRunningTask.cancel(); timeIsRunningTask.cancel();
} }
GroupSign.updatePerGroup(this); plugin.getGlobalProtections().updateGroupSigns(this);
} }
public void startGame(Game game) { public void startGame(Game game) {
@ -871,7 +870,7 @@ public class DGroup {
} }
} }
GroupSign.updatePerGroup(this); plugin.getGlobalProtections().updateGroupSigns(this);
nextFloor = null; nextFloor = null;
initialLives = rules.getInitialGroupLives(); initialLives = rules.getInitialGroupLives();
lives = initialLives; lives = initialLives;