mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-09 20:31:28 +01:00
Added maxDungeons config option
This commit is contained in:
parent
1b6ed7432a
commit
30d60e9ea2
@ -39,6 +39,7 @@ public class MainConfig extends BRConfig {
|
||||
private String tutorialDungeon = "tutorial";
|
||||
private String tutorialStartGroup = "default";
|
||||
private String tutorialEndGroup = "player";
|
||||
private int maxDungeons = 10;
|
||||
|
||||
/* Misc */
|
||||
private boolean sendFloorTitle = true;
|
||||
@ -98,6 +99,13 @@ public class MainConfig extends BRConfig {
|
||||
return tutorialStartGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maxDungeons
|
||||
*/
|
||||
public int getMaxDungeons() {
|
||||
return maxDungeons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the floor title shall be sent
|
||||
*/
|
||||
@ -188,6 +196,10 @@ public class MainConfig extends BRConfig {
|
||||
config.set("tutorial.endgroup", tutorialEndGroup);
|
||||
}
|
||||
|
||||
if (!config.contains("maxDungeons")) {
|
||||
config.set("maxDungeons", maxDungeons);
|
||||
}
|
||||
|
||||
if (!config.contains("sendFloorTitle")) {
|
||||
config.set("sendFloorTitle", sendFloorTitle);
|
||||
}
|
||||
@ -251,6 +263,10 @@ public class MainConfig extends BRConfig {
|
||||
tutorialEndGroup = config.getString("tutorial.endgroup");
|
||||
}
|
||||
|
||||
if (config.contains("maxDungeons")) {
|
||||
maxDungeons = config.getInt("maxDungeons");
|
||||
}
|
||||
|
||||
if (config.contains("sendFloorTitle")) {
|
||||
sendFloorTitle = config.getBoolean("sendFloorTitle");
|
||||
}
|
||||
|
@ -506,6 +506,11 @@ public class GameSign extends GlobalProtection {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.getGameWorlds().size() >= plugin.getMainConfig().getMaxDungeons()) {
|
||||
MessageUtil.sendMessage(player, "&cEs gibt bereits zu viele laufende Dungeons!");
|
||||
return true;
|
||||
}
|
||||
|
||||
int sx1 = gameSign.startSign.getX(), sy1 = gameSign.startSign.getY(), sz1 = gameSign.startSign.getZ();
|
||||
|
||||
Block topBlock = block.getRelative(0, sy1 - y, 0);
|
||||
|
@ -19,6 +19,7 @@ package io.github.dre2n.dungeonsxl.listener;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.config.MainConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerDeathEvent;
|
||||
@ -68,6 +69,7 @@ import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
@ -556,6 +558,36 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
new DGamePlayer(player, dGroup.getGameWorld());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
MainConfig config = plugin.getMainConfig();
|
||||
if (!config.isTutorialActivated()) {
|
||||
return;
|
||||
}
|
||||
if (DGamePlayer.getByPlayer(player) != null) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getPermissionProvider() == null) {
|
||||
return;
|
||||
}
|
||||
if ((config.getTutorialDungeon() == null || config.getTutorialStartGroup() == null || config.getTutorialEndGroup() == null)) {
|
||||
return;
|
||||
}
|
||||
for (String group : plugin.getPermissionProvider().getPlayerGroups(player)) {
|
||||
if (!config.getTutorialStartGroup().equalsIgnoreCase(group)) {
|
||||
continue;
|
||||
}
|
||||
if (plugin.getGameWorlds().size() >= config.getMaxDungeons()) {
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
|
||||
event.setKickMessage("Es laufen bereits zu viele Tutorials, bitte warte eine Weile!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user