mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Fix group signs not loading correctly
...and minor further fixes.
This commit is contained in:
parent
a018664102
commit
0cc9a28f4d
@ -95,6 +95,7 @@ public class DPortal {
|
|||||||
|
|
||||||
if (dgroup.getGameWorld() == null) {
|
if (dgroup.getGameWorld() == null) {
|
||||||
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", DGroup.get(player).getMapName()));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_DungeonNotExist", DGroup.get(player).getMapName()));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dgroup.getGameWorld().getLocLobby() == null) {
|
if (dgroup.getGameWorld().getLocLobby() == null) {
|
||||||
|
@ -43,7 +43,7 @@ public class GroupSign {
|
|||||||
|
|
||||||
this.startSign = startSign;
|
this.startSign = startSign;
|
||||||
dGroups = new DGroup[maxGroups];
|
dGroups = new DGroup[maxGroups];
|
||||||
this.multiFloor = multiFloor;
|
this.setMultiFloor(multiFloor);
|
||||||
if (multiFloor) {
|
if (multiFloor) {
|
||||||
dungeonName = identifier;
|
dungeonName = identifier;
|
||||||
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
|
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
|
||||||
@ -81,6 +81,36 @@ public class GroupSign {
|
|||||||
this.dungeonName = dungeonName;
|
this.dungeonName = dungeonName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the mapName
|
||||||
|
*/
|
||||||
|
public String getMapName() {
|
||||||
|
return mapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mapName
|
||||||
|
* the mapName to set
|
||||||
|
*/
|
||||||
|
public void setMapName(String mapName) {
|
||||||
|
this.mapName = mapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the multiFloor
|
||||||
|
*/
|
||||||
|
public boolean isMultiFloor() {
|
||||||
|
return multiFloor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param multiFloor
|
||||||
|
* the multiFloor to set
|
||||||
|
*/
|
||||||
|
public void setMultiFloor(boolean multiFloor) {
|
||||||
|
this.multiFloor = multiFloor;
|
||||||
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (DGroup dGroup : dGroups) {
|
for (DGroup dGroup : dGroups) {
|
||||||
@ -347,17 +377,20 @@ public class GroupSign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !GameWorld.canPlayDungeon(groupSign.mapName, player)) {
|
if ( !GameWorld.canPlayDungeon(groupSign.mapName, player)) {
|
||||||
File file = new File(DungeonsXL.getPlugin().getDataFolder() + "/maps/" + groupSign.mapName, "config.yml");
|
File file = new File(plugin.getDataFolder() + "/maps/" + groupSign.mapName, "config.yml");
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
WorldConfig confReader = new WorldConfig(file);
|
WorldConfig confReader = new WorldConfig(file);
|
||||||
if (confReader != null) {
|
if (confReader != null) {
|
||||||
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_Cooldown", "" + confReader.getTimeToNextPlay()));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Cooldown", "" + confReader.getTimeToNextPlay()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !GameWorld.checkRequirements(groupSign.mapName, player)) {
|
if ( !GameWorld.checkRequirements(groupSign.mapName, player)) {
|
||||||
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_Requirements"));
|
MessageUtil.sendMessage(player, plugin.getDMessages().get("Error_Requirements"));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ();
|
int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ();
|
||||||
@ -379,7 +412,12 @@ public class GroupSign {
|
|||||||
Sign topSign = (Sign) topBlock.getState();
|
Sign topSign = (Sign) topBlock.getState();
|
||||||
if (topSign.getLine(0).equals(strNewGrp)) {
|
if (topSign.getLine(0).equals(strNewGrp)) {
|
||||||
if (DGroup.get(player) == null) {
|
if (DGroup.get(player) == null) {
|
||||||
groupSign.dGroups[column] = new DGroup(player, groupSign.mapName, groupSign.multiFloor);
|
if (groupSign.isMultiFloor()) {
|
||||||
|
groupSign.dGroups[column] = new DGroup(player, groupSign.dungeonName, groupSign.isMultiFloor());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
groupSign.dGroups[column] = new DGroup(player, groupSign.mapName, groupSign.isMultiFloor());
|
||||||
|
}
|
||||||
groupSign.update();
|
groupSign.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,7 +489,7 @@ public class GroupSign {
|
|||||||
configFile.set(preString + ".z", groupSign.startSign.getZ());
|
configFile.set(preString + ".z", groupSign.startSign.getZ());
|
||||||
|
|
||||||
// Etc.
|
// Etc.
|
||||||
if (groupSign.multiFloor) {
|
if (groupSign.isMultiFloor()) {
|
||||||
configFile.set(preString + ".dungeon", groupSign.dungeonName);
|
configFile.set(preString + ".dungeon", groupSign.dungeonName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -460,7 +498,7 @@ public class GroupSign {
|
|||||||
|
|
||||||
configFile.set(preString + ".maxGroups", groupSign.dGroups.length);
|
configFile.set(preString + ".maxGroups", groupSign.dGroups.length);
|
||||||
configFile.set(preString + ".maxPlayersPerGroup", groupSign.maxPlayersPerGroup);
|
configFile.set(preString + ".maxPlayersPerGroup", groupSign.maxPlayersPerGroup);
|
||||||
configFile.set(preString + ".multiFloor", groupSign.multiFloor);
|
configFile.set(preString + ".multiFloor", groupSign.isMultiFloor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,8 +518,8 @@ public class GroupSign {
|
|||||||
int maxGroups = configFile.getInt(preString + ".maxGroups");
|
int maxGroups = configFile.getInt(preString + ".maxGroups");
|
||||||
int maxPlayersPerGroup = configFile.getInt(preString + ".maxPlayersPerGroup");
|
int maxPlayersPerGroup = configFile.getInt(preString + ".maxPlayersPerGroup");
|
||||||
boolean multiFloor = false;
|
boolean multiFloor = false;
|
||||||
if (configFile.contains("multiFloor")) {
|
if (configFile.contains(preString + ".multiFloor")) {
|
||||||
multiFloor = configFile.getBoolean("multiFloor");
|
multiFloor = configFile.getBoolean(preString + ".multiFloor");
|
||||||
}
|
}
|
||||||
Block startSign = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
|
Block startSign = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
|
||||||
|
|
||||||
|
@ -32,12 +32,14 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
if (event.getBlock().getType() == Material.PORTAL) {
|
if (event.getBlock().getType() != Material.PORTAL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (DPortal.get(event.getBlock()) != null) {
|
if (DPortal.get(event.getBlock()) != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
@ -72,14 +74,14 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Editworld Signs
|
// Editworld Signs
|
||||||
EditWorld eworld = EditWorld.get(block.getWorld());
|
EditWorld editWorld = EditWorld.get(block.getWorld());
|
||||||
if (eworld != null) {
|
if (editWorld != null) {
|
||||||
eworld.getSign().remove(event.getBlock());
|
editWorld.getSign().remove(event.getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deny GameWorld Blocks
|
// Deny GameWorld Blocks
|
||||||
GameWorld gworld = GameWorld.get(block.getWorld());
|
GameWorld gameWorld = GameWorld.get(block.getWorld());
|
||||||
if (gworld != null) {
|
if (gameWorld != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,9 +92,14 @@ public class BlockListener implements Listener {
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
// Deny GameWorld Blocks
|
// Deny GameWorld Blocks
|
||||||
GameWorld gworld = GameWorld.get(block.getWorld());
|
GameWorld gameWorld = GameWorld.get(block.getWorld());
|
||||||
if (gworld != null) {
|
if (gameWorld == null) {
|
||||||
if ( !GamePlaceableBlock.canBuildHere(block, block.getFace(event.getBlockAgainst()), event.getItemInHand().getType(), gworld)) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GamePlaceableBlock.canBuildHere(block, block.getFace(event.getBlockAgainst()), event.getItemInHand().getType(), gameWorld)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Workaround for a bug that would allow 3-Block-high jumping
|
// Workaround for a bug that would allow 3-Block-high jumping
|
||||||
Location loc = event.getPlayer().getLocation();
|
Location loc = event.getPlayer().getLocation();
|
||||||
@ -108,20 +115,24 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onSignChange(SignChangeEvent event) {
|
public void onSignChange(SignChangeEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
String[] lines = event.getLines();
|
String[] lines = event.getLines();
|
||||||
EditWorld eworld = EditWorld.get(player.getWorld());
|
EditWorld editWorld = EditWorld.get(player.getWorld());
|
||||||
|
|
||||||
// Group Signs
|
// Group Signs
|
||||||
if (eworld == null) {
|
if (editWorld == null) {
|
||||||
if (player.isOp() || player.hasPermission("dxl.sign")) {
|
if ( !player.hasPermission("dxl.sign")) {
|
||||||
if (lines[0].equalsIgnoreCase("[DXL]")) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !lines[0].equalsIgnoreCase("[DXL]")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (lines[1].equalsIgnoreCase("Group")) {
|
if (lines[1].equalsIgnoreCase("Group")) {
|
||||||
String dungeonName = lines[2];
|
String dungeonName = lines[2];
|
||||||
|
|
||||||
@ -135,21 +146,23 @@ public class BlockListener implements Listener {
|
|||||||
multiFloor = true;
|
multiFloor = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxGroups > 0 && maxPlayersPerGroup > 0) {
|
if (maxGroups > 0 && maxPlayersPerGroup > 0) {
|
||||||
if (GroupSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup, multiFloor) != null) {
|
if (GroupSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup, multiFloor) != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (lines[1].equalsIgnoreCase("Leave")) {
|
} else if (lines[1].equalsIgnoreCase("Leave")) {
|
||||||
if (block.getState() instanceof Sign) {
|
if (block.getState() instanceof Sign) {
|
||||||
Sign sign = (Sign) block.getState();
|
Sign sign = (Sign) block.getState();
|
||||||
new LeaveSign(sign);
|
new LeaveSign(sign);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // Editworld Signs
|
} else { // Editworld Signs
|
||||||
Sign sign = (Sign) block.getState();
|
Sign sign = (Sign) block.getState();
|
||||||
if (sign != null) {
|
if (sign != null) {
|
||||||
@ -160,21 +173,22 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
DSign dsign = DSign.create(sign, null);
|
DSign dsign = DSign.create(sign, null);
|
||||||
|
|
||||||
if (dsign != null) {
|
if (dsign == null) {
|
||||||
if (player.isOp() || player.hasPermission(dsign.getType().getBuildPermission())) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !player.hasPermission(dsign.getType().getBuildPermission())) {
|
||||||
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_NoPermissions"));
|
||||||
|
}
|
||||||
|
|
||||||
if (dsign.check()) {
|
if (dsign.check()) {
|
||||||
eworld.checkSign(block);
|
editWorld.checkSign(block);
|
||||||
eworld.getSign().add(block);
|
editWorld.getSign().add(block);
|
||||||
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_SignCreated"));
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Player_SignCreated"));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_SignWrongFormat"));
|
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_SignWrongFormat"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().get("Error_NoPermissions"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,19 +197,21 @@ public class BlockListener implements Listener {
|
|||||||
public void onBlockSpread(BlockSpreadEvent event) {
|
public void onBlockSpread(BlockSpreadEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
// Block the Spread off Vines
|
// Block the Spread off Vines
|
||||||
if (block.getType() == Material.VINE) {
|
if (block.getType() != Material.VINE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check GameWorlds
|
// Check GameWorlds
|
||||||
GameWorld gworld = GameWorld.get(event.getBlock().getWorld());
|
GameWorld gameWorld = GameWorld.get(event.getBlock().getWorld());
|
||||||
if (gworld != null) {
|
if (gameWorld != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check EditWorlds
|
// Check EditWorlds
|
||||||
EditWorld eworld = EditWorld.get(event.getBlock().getWorld());
|
EditWorld editWorld = EditWorld.get(event.getBlock().getWorld());
|
||||||
if (eworld != null) {
|
if (editWorld != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,9 +229,9 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (GameWorld gworld : DungeonsXL.getPlugin().getGameWorlds()) {
|
for (GameWorld gameWorld : DungeonsXL.getPlugin().getGameWorlds()) {
|
||||||
if (block.getWorld() == gworld.getWorld()) {
|
if (block.getWorld() == gameWorld.getWorld()) {
|
||||||
RedstoneTrigger.updateAll(gworld);
|
RedstoneTrigger.updateAll(gameWorld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,12 @@ public class DGroup {
|
|||||||
plugin.getDGroups().add(this);
|
plugin.getDGroups().add(this);
|
||||||
|
|
||||||
this.players.add(player);
|
this.players.add(player);
|
||||||
if (multiFloor) {
|
|
||||||
|
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
|
||||||
|
if (multiFloor && dungeon != null) {
|
||||||
this.dungeonName = identifier;
|
this.dungeonName = identifier;
|
||||||
this.mapName = plugin.getDungeons().getDungeon(dungeonName).getConfig().getStartFloor();
|
this.mapName = dungeon.getConfig().getStartFloor();
|
||||||
System.out.println("This one?");
|
this.unplayedFloors = dungeon.getConfig().getFloors();
|
||||||
this.unplayedFloors = plugin.getDungeons().getDungeon(dungeonName).getConfig().getFloors();
|
|
||||||
System.out.println("If this shows p,");
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.mapName = identifier;
|
this.mapName = identifier;
|
||||||
|
Loading…
Reference in New Issue
Block a user