mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Merge branch 'maxDungeons' of git://github.com/Sn0wStorm/DungeonsXL into 0.12
This commit is contained in:
commit
df562765ee
@ -83,10 +83,12 @@ public enum DMessages implements Messages {
|
||||
ERROR_NOT_IN_GROUP("Error_NotInGroup", "&4The player &6&v1&4 is not member of the group &6&v2&v4."),
|
||||
ERROR_NOT_INVITED("Error_NotInvited", "&4You are not invited to the group &6&v1&4."),
|
||||
ERROR_NOT_SAVED("Error_NotSaved", "&4The map &6&v1&4 has not been saved to the &6DungeonsXL/maps/ &4folder yet!"),
|
||||
ERROR_TUTORIAL_NOT_EXIST("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!"),
|
||||
ERROR_READY("Error_Ready", "&4Choose your class first!"),
|
||||
ERROR_REQUIREMENTS("Error_Requirements", "&4You don't fulfill the requirements for this dungeon!"),
|
||||
ERROR_SIGN_WRONG_FORMAT("Error_SignWrongFormat", "&4The sign is not written correctly!"),
|
||||
ERROR_TOO_MANY_INSTANCES("Error_TooManyInstances", "&4There are currently too many maps instantiated. Try it again in a few minutes!"),
|
||||
ERROR_TOO_MANY_TUTORIALS("Error_TooManyTutorials", "&4There are currently too many tutorials running. Try it again in a few minutes!"),
|
||||
ERROR_TUTORIAL_NOT_EXIST("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!"),
|
||||
HELP_CMD_BREAK("Help_Cmd_Break", "/dxl break - Break a block protected by DungeonsXL"),
|
||||
HELP_CMD_CHAT("Help_Cmd_Chat", "/dxl chat - Change the chat mode"),
|
||||
HELP_CMD_CHATSPY("Help_Cmd_Chatspy", "/dxl chatspy - Dis/enables the spymode"),
|
||||
|
@ -30,7 +30,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
*/
|
||||
public class MainConfig extends BRConfig {
|
||||
|
||||
public static final int CONFIG_VERSION = 7;
|
||||
public static final int CONFIG_VERSION = 8;
|
||||
|
||||
private String language = "english";
|
||||
private boolean enableEconomy = false;
|
||||
@ -45,6 +45,7 @@ public class MainConfig extends BRConfig {
|
||||
private boolean sendFloorTitle = true;
|
||||
private Map<String, Object> externalMobProviders = new HashMap<>();
|
||||
private List<Short> groupColorPriority = new ArrayList<>(Arrays.asList((short) 11, (short) 14, (short) 4, (short) 5, (short) 10, (short) 1, (short) 0, (short) 15));
|
||||
private int maxInstances = 10;
|
||||
|
||||
/* Secure Mode */
|
||||
private boolean secureModeEnabled = false;
|
||||
@ -136,6 +137,8 @@ public class MainConfig extends BRConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* <<<<<<< HEAD
|
||||
*
|
||||
* @param group
|
||||
* the group the player gets when he plays the tutorial
|
||||
*/
|
||||
@ -195,6 +198,21 @@ public class MainConfig extends BRConfig {
|
||||
groupColorPriority = dataValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum amount of worlds to instantiate at once
|
||||
*/
|
||||
public int getMaxInstances() {
|
||||
return maxInstances;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxInstances
|
||||
* the maximum amount of worlds to instantiate at once
|
||||
*/
|
||||
public void setMaxInstances(int maxInstances) {
|
||||
this.maxInstances = maxInstances;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the secure mode is enabled
|
||||
*/
|
||||
@ -254,7 +272,7 @@ public class MainConfig extends BRConfig {
|
||||
public void setSecureModeCheckInterval(double interval) {
|
||||
secureModeCheckInterval = interval;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the editCommandWhitelist
|
||||
*/
|
||||
@ -315,6 +333,10 @@ public class MainConfig extends BRConfig {
|
||||
config.set("groupColorPriority", groupColorPriority);
|
||||
}
|
||||
|
||||
if (!config.contains("maxInstances")) {
|
||||
config.set("maxInstances", maxInstances);
|
||||
}
|
||||
|
||||
if (!config.contains("secureMode.enabled")) {
|
||||
config.set("secureMode.enabled", secureModeEnabled);
|
||||
}
|
||||
@ -386,6 +408,10 @@ public class MainConfig extends BRConfig {
|
||||
groupColorPriority = config.getShortList("groupColorPriority");
|
||||
}
|
||||
|
||||
if (config.contains("maxInstances")) {
|
||||
maxInstances = config.getInt("maxInstances");
|
||||
}
|
||||
|
||||
if (config.contains("secureMode.enabled")) {
|
||||
secureModeEnabled = config.getBoolean("secureMode.enabled");
|
||||
}
|
||||
|
@ -469,6 +469,11 @@ public class GameSign extends GlobalProtection {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plugin.getGameWorlds().size() >= plugin.getMainConfig().getMaxInstances()) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_INSTANCES.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
|
||||
if (dGroup == null) {
|
||||
|
@ -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.event.dgroup.DGroupCreateEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerDeathEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
||||
@ -65,6 +66,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -570,6 +572,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.getMaxInstances()) {
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
|
||||
event.setKickMessage(DMessages.ERROR_TOO_MANY_TUTORIALS.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user