mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-25 03:55:22 +01:00
#40 Basic game announcements
This commit is contained in:
parent
70b4d16be5
commit
a227d8628d
@ -4,6 +4,7 @@
|
|||||||
[![Wiki](http://feuerstern.bplaced.net/ressourcen/buttons/Wiki.png)](../../wiki/)
|
[![Wiki](http://feuerstern.bplaced.net/ressourcen/buttons/Wiki.png)](../../wiki/)
|
||||||
[![Issues](http://feuerstern.bplaced.net/ressourcen/buttons/Issues.png)](../../issues/)
|
[![Issues](http://feuerstern.bplaced.net/ressourcen/buttons/Issues.png)](../../issues/)
|
||||||
[![JavaDocs](http://feuerstern.bplaced.net/ressourcen/buttons/JavaDocs.png)](http://feuerstern.bplaced.net/javadocs/dxl/)
|
[![JavaDocs](http://feuerstern.bplaced.net/ressourcen/buttons/JavaDocs.png)](http://feuerstern.bplaced.net/javadocs/dxl/)
|
||||||
|
[![MCStats](http://feuerstern.bplaced.net/ressourcen/buttons/MCStats.png)](http://mcstats.org/plugin/DungeonsXL/)
|
||||||
|
|
||||||
![Doge](https://i.imgflip.com/vtpyi.jpg)
|
![Doge](https://i.imgflip.com/vtpyi.jpg)
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ DungeonsXL also provides custom game mechanics to make these worlds interesting.
|
|||||||
* A built-in custom mob system and support for MythicMobs. [Read more...](../../wiki/signs#mob)
|
* A built-in custom mob system and support for MythicMobs. [Read more...](../../wiki/signs#mob)
|
||||||
* A powerful API: [Read more...](../../wiki/api-tutorial)
|
* A powerful API: [Read more...](../../wiki/api-tutorial)
|
||||||
* Different game types allow you to use your maps dynamically for different purposes. [Read more...](../../wiki/game-types)
|
* Different game types allow you to use your maps dynamically for different purposes. [Read more...](../../wiki/game-types)
|
||||||
|
* Announcements sothat users can join the next match easily. [Read more...](../../wiki/announcements)
|
||||||
* ...and many more!
|
* ...and many more!
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +69,7 @@ Instead of referencing the internals of the implementation directly, DungeonsXL
|
|||||||
The shaded version of DXL (standard version) contains this library, while the original version needs it as an external plugin.
|
The shaded version of DXL (standard version) contains this library, while the original version needs it as an external plugin.
|
||||||
Have a look at the [installation instructions](../../wiki/getting-started#installation) for detailed information.
|
Have a look at the [installation instructions](../../wiki/getting-started#installation) for detailed information.
|
||||||
|
|
||||||
DungeonsXL currently uses BRCommons 0.5.2.
|
DungeonsXL currently uses BRCommons 0.6.2.
|
||||||
|
|
||||||
### Java
|
### Java
|
||||||
7 and higher
|
7 and higher
|
||||||
|
6
pom.xml
6
pom.xml
@ -53,8 +53,8 @@
|
|||||||
</build>
|
</build>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
<version>1.9.4-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -67,7 +67,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.dre2n</groupId>
|
<groupId>io.github.dre2n</groupId>
|
||||||
<artifactId>commons</artifactId>
|
<artifactId>commons</artifactId>
|
||||||
<version>0.5.2</version>
|
<version>0.6.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.dre2n</groupId>
|
<groupId>io.github.dre2n</groupId>
|
||||||
|
@ -22,6 +22,7 @@ import io.github.dre2n.commons.config.MessageConfig;
|
|||||||
import io.github.dre2n.commons.javaplugin.BRPlugin;
|
import io.github.dre2n.commons.javaplugin.BRPlugin;
|
||||||
import io.github.dre2n.commons.javaplugin.BRPluginSettings;
|
import io.github.dre2n.commons.javaplugin.BRPluginSettings;
|
||||||
import io.github.dre2n.commons.util.FileUtil;
|
import io.github.dre2n.commons.util.FileUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.announcer.Announcers;
|
||||||
import io.github.dre2n.dungeonsxl.command.*;
|
import io.github.dre2n.dungeonsxl.command.*;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.config.DataConfig;
|
import io.github.dre2n.dungeonsxl.config.DataConfig;
|
||||||
@ -62,6 +63,11 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
private static DungeonsXL instance;
|
private static DungeonsXL instance;
|
||||||
|
|
||||||
public static final String[] EXCLUDED_FILES = {"config.yml", "uid.dat", "DXLData.data"};
|
public static final String[] EXCLUDED_FILES = {"config.yml", "uid.dat", "DXLData.data"};
|
||||||
|
public static File DUNGEONS;
|
||||||
|
public static File LANGUAGES;
|
||||||
|
public static File MAPS;
|
||||||
|
public static File SCRIPTS;
|
||||||
|
public static File ANNOUNCERS;
|
||||||
|
|
||||||
private DataConfig dataConfig;
|
private DataConfig dataConfig;
|
||||||
private MainConfig mainConfig;
|
private MainConfig mainConfig;
|
||||||
@ -77,6 +83,7 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
private GlobalProtections protections;
|
private GlobalProtections protections;
|
||||||
private ExternalMobProviders dMobProviders;
|
private ExternalMobProviders dMobProviders;
|
||||||
private DPlayers dPlayers;
|
private DPlayers dPlayers;
|
||||||
|
private Announcers announcers;
|
||||||
|
|
||||||
private BukkitTask worldUnloadTask;
|
private BukkitTask worldUnloadTask;
|
||||||
private BukkitTask lazyUpdateTask;
|
private BukkitTask lazyUpdateTask;
|
||||||
@ -95,7 +102,7 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
* ####~BRPluginSettings~####
|
* ####~BRPluginSettings~####
|
||||||
* ##########################
|
* ##########################
|
||||||
* #~Internals~##~~v1_7_R3+~#
|
* #~Internals~##~~v1_7_R3+~#
|
||||||
* #~SpigotAPI~##~~~false~~~#
|
* #~SpigotAPI~##~~~~true~~~#
|
||||||
* #~~~~UUID~~~##~~~~true~~~#
|
* #~~~~UUID~~~##~~~~true~~~#
|
||||||
* #~~Economy~~##~~~~true~~~#
|
* #~~Economy~~##~~~~true~~~#
|
||||||
* #Permissions##~~~~true~~~#
|
* #Permissions##~~~~true~~~#
|
||||||
@ -103,7 +110,7 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
* ##########################
|
* ##########################
|
||||||
*/
|
*/
|
||||||
|
|
||||||
settings = new BRPluginSettings(false, true, true, true, true, Internals.andHigher(Internals.v1_7_R3));
|
settings = new BRPluginSettings(true, true, true, true, true, Internals.andHigher(Internals.v1_7_R3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,7 +119,6 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
// InitFolders
|
|
||||||
initFolders();
|
initFolders();
|
||||||
|
|
||||||
// Load Language
|
// Load Language
|
||||||
@ -121,7 +127,7 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
loadDataConfig(new File(getDataFolder(), "data.yml"));
|
loadDataConfig(new File(getDataFolder(), "data.yml"));
|
||||||
loadMainConfig(new File(getDataFolder(), "config.yml"));
|
loadMainConfig(new File(getDataFolder(), "config.yml"));
|
||||||
// Load Language 2
|
// Load Language 2
|
||||||
loadMessageConfig(new File(getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
|
loadMessageConfig(new File(LANGUAGES, mainConfig.getLanguage() + ".yml"));
|
||||||
loadDCommands();
|
loadDCommands();
|
||||||
DPermissions.register();
|
DPermissions.register();
|
||||||
loadGameTypes();
|
loadGameTypes();
|
||||||
@ -133,8 +139,10 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
loadGlobalProtections();
|
loadGlobalProtections();
|
||||||
loadExternalMobProviders();
|
loadExternalMobProviders();
|
||||||
loadDPlayers();
|
loadDPlayers();
|
||||||
|
loadAnnouncers(ANNOUNCERS);
|
||||||
|
|
||||||
manager.registerEvents(new EntityListener(), this);
|
manager.registerEvents(new EntityListener(), this);
|
||||||
|
manager.registerEvents(new GUIListener(), this);
|
||||||
manager.registerEvents(new PlayerListener(), this);
|
manager.registerEvents(new PlayerListener(), this);
|
||||||
manager.registerEvents(new BlockListener(), this);
|
manager.registerEvents(new BlockListener(), this);
|
||||||
manager.registerEvents(new WorldListener(), this);
|
manager.registerEvents(new WorldListener(), this);
|
||||||
@ -189,19 +197,29 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
getDataFolder().mkdir();
|
getDataFolder().mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
File dungeons = new File(getDataFolder() + "/dungeons");
|
DUNGEONS = new File(getDataFolder(), "dungeons");
|
||||||
if (!dungeons.exists()) {
|
if (!DUNGEONS.exists()) {
|
||||||
dungeons.mkdir();
|
DUNGEONS.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
File languages = new File(getDataFolder() + "/languages");
|
LANGUAGES = new File(getDataFolder(), "languages");
|
||||||
if (!languages.exists()) {
|
if (!LANGUAGES.exists()) {
|
||||||
languages.mkdir();
|
LANGUAGES.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
File maps = new File(getDataFolder() + "/maps");
|
MAPS = new File(getDataFolder(), "maps");
|
||||||
if (!maps.exists()) {
|
if (!MAPS.exists()) {
|
||||||
maps.mkdir();
|
MAPS.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
SCRIPTS = new File(getDataFolder(), "scripts");
|
||||||
|
if (!SCRIPTS.exists()) {
|
||||||
|
SCRIPTS.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
ANNOUNCERS = new File(SCRIPTS, "announcers");
|
||||||
|
if (!ANNOUNCERS.exists()) {
|
||||||
|
ANNOUNCERS.mkdir();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,6 +335,7 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
new GameCommand(),
|
new GameCommand(),
|
||||||
new GroupCommand(),
|
new GroupCommand(),
|
||||||
new InviteCommand(),
|
new InviteCommand(),
|
||||||
|
new JoinCommand(),
|
||||||
new EnterCommand(),
|
new EnterCommand(),
|
||||||
new LeaveCommand(),
|
new LeaveCommand(),
|
||||||
new ListCommand(),
|
new ListCommand(),
|
||||||
@ -461,6 +480,20 @@ public class DungeonsXL extends BRPlugin {
|
|||||||
dPlayers = new DPlayers();
|
dPlayers = new DPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the loaded instance of Announcers
|
||||||
|
*/
|
||||||
|
public Announcers getAnnouncers() {
|
||||||
|
return announcers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load / reload a new instance of Announcers
|
||||||
|
*/
|
||||||
|
public void loadAnnouncers(File file) {
|
||||||
|
announcers = new Announcers(file);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the worldUnloadTask
|
* @return the worldUnloadTask
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,313 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Daniel Saukel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package io.github.dre2n.dungeonsxl.announcer;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||||
|
import io.github.dre2n.commons.util.guiutil.GUIUtil;
|
||||||
|
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.dungeon.Dungeon;
|
||||||
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class Announcer {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private List<String> description;
|
||||||
|
private List<String> worlds;
|
||||||
|
|
||||||
|
private String dungeonName;
|
||||||
|
private String mapName;
|
||||||
|
|
||||||
|
private short maxGroupsPerGame;
|
||||||
|
private int maxPlayersPerGroup;
|
||||||
|
|
||||||
|
private List<DGroup> dGroups;
|
||||||
|
private List<ItemStack> buttons;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* the name of the Announcer
|
||||||
|
* @param description
|
||||||
|
* the description messages
|
||||||
|
* @param worlds
|
||||||
|
* the names of the worlds where the announcement will be seen or null to broadcast it to all worlds
|
||||||
|
* @param identifier
|
||||||
|
* the dungeon identifier
|
||||||
|
* @param multiFloor
|
||||||
|
* if the identifier refers to an MFD (true) or an SFD (false)
|
||||||
|
* @param maxGroupsPerGame
|
||||||
|
* the amount of groups in one game
|
||||||
|
* @param maxPlayersPerGame
|
||||||
|
* the amount of players in one group
|
||||||
|
*/
|
||||||
|
public Announcer(String name, List<String> description, List<String> worlds, String identifier, boolean multiFloor, short maxGroupsPerGame, int maxPlayersPerGroup) {
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.worlds = worlds;
|
||||||
|
|
||||||
|
if (multiFloor) {
|
||||||
|
dungeonName = identifier;
|
||||||
|
|
||||||
|
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
|
||||||
|
if (dungeon != null) {
|
||||||
|
mapName = dungeon.getConfig().getStartFloor();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
mapName = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.maxGroupsPerGame = maxGroupsPerGame;
|
||||||
|
this.dGroups = new ArrayList<>(Collections.nCopies(maxGroupsPerGame + 1, (DGroup) null));
|
||||||
|
this.maxPlayersPerGroup = maxPlayersPerGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the announcer
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the description messages
|
||||||
|
*/
|
||||||
|
public List<String> getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param description
|
||||||
|
* the description to set
|
||||||
|
*/
|
||||||
|
public void setDescription(List<String> description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the names of the worlds where the announcement will be seen or null to broadcast it to all worlds
|
||||||
|
*/
|
||||||
|
public List<String> getWorlds() {
|
||||||
|
return worlds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param worlds
|
||||||
|
* the worlds to set
|
||||||
|
*/
|
||||||
|
public void setWorlds(List<String> worlds) {
|
||||||
|
this.worlds = worlds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the dungeon
|
||||||
|
*/
|
||||||
|
public String getDungeonName() {
|
||||||
|
return dungeonName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dungeonName
|
||||||
|
* the name of the dungeon to set
|
||||||
|
*/
|
||||||
|
public void setDungeonName(String dungeonName) {
|
||||||
|
this.dungeonName = dungeonName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the first or only floor
|
||||||
|
*/
|
||||||
|
public String getMapName() {
|
||||||
|
return mapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mapName
|
||||||
|
* the name of the map to set
|
||||||
|
*/
|
||||||
|
public void setMapName(String mapName) {
|
||||||
|
this.mapName = mapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the maximum amount of groups per game
|
||||||
|
*/
|
||||||
|
public short getMaxGroupsPerGame() {
|
||||||
|
return maxGroupsPerGame;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param amount
|
||||||
|
* the amount to set
|
||||||
|
*/
|
||||||
|
public void setMaxGroupsPerGame(short amount) {
|
||||||
|
maxGroupsPerGame = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the maximum amount of players per group
|
||||||
|
*/
|
||||||
|
public int getMaxPlayersPerGroup() {
|
||||||
|
return maxPlayersPerGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param amount
|
||||||
|
* the amount to set
|
||||||
|
*/
|
||||||
|
public void setMaxPlayersPerGroup(int amount) {
|
||||||
|
maxPlayersPerGroup = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the announcement
|
||||||
|
*/
|
||||||
|
public void send(Player player) {
|
||||||
|
for (String message : description) {
|
||||||
|
MessageUtil.broadcastCenteredMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CompatibilityHandler.getInstance().isSpigot()) {
|
||||||
|
ClickEvent onClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl join " + name);
|
||||||
|
|
||||||
|
BaseComponent[] message = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', DMessages.ANNOUNCER_CLICK.getMessage()));
|
||||||
|
for (BaseComponent slice : message) {
|
||||||
|
slice.setClickEvent(onClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.spigot().sendMessage(message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
MessageUtil.sendCenteredMessage(player, DMessages.ANNOUNCER_CMD.getMessage(getName().toUpperCase()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the group selection GUI
|
||||||
|
*/
|
||||||
|
public void showGUI(Player player) {
|
||||||
|
updateButtons();
|
||||||
|
Inventory gui = GUIUtil.createGUI(plugin, ChatColor.DARK_RED + name, buttons);
|
||||||
|
plugin.addGUI(gui);
|
||||||
|
player.closeInventory();
|
||||||
|
player.openInventory(gui);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param button
|
||||||
|
* the clicked button
|
||||||
|
*/
|
||||||
|
public void clickGroupButton(Player player, ItemStack button) {
|
||||||
|
DGroup dGroup = getDGroupByButton(button);
|
||||||
|
DGroup pGroup = DGroup.getByPlayer(player);
|
||||||
|
|
||||||
|
for (DGroup group : dGroups) {
|
||||||
|
if (dGroups.contains(pGroup) && pGroup != null && pGroup.isCustom() && pGroup.getCaptain() == player) {
|
||||||
|
dGroups.set(dGroups.indexOf(pGroup), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (group != null && group.getPlayers().contains(player)) {
|
||||||
|
group.removePlayer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dGroup != null && pGroup == null) {
|
||||||
|
if (dGroup.getPlayers().size() < maxPlayersPerGroup) {
|
||||||
|
dGroup.addPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (dGroup == null && pGroup == null) {
|
||||||
|
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.ANNOUNCER);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
dGroups.set(buttons.indexOf(button), new DGroup(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (dGroup == null && pGroup != null) {
|
||||||
|
dGroups.set(buttons.indexOf(button), pGroup);
|
||||||
|
|
||||||
|
} else if (pGroup != null && dGroups.contains(pGroup) && pGroup != dGroup) {
|
||||||
|
dGroups.set(dGroups.indexOf(pGroup), null);
|
||||||
|
dGroups.set(buttons.indexOf(button), pGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
showGUI(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the buttons to group changes.
|
||||||
|
*/
|
||||||
|
public void updateButtons() {
|
||||||
|
int groupCount = 0;
|
||||||
|
|
||||||
|
buttons = new ArrayList<>(dGroups.size());
|
||||||
|
do {
|
||||||
|
String name = ChatColor.DARK_GRAY + "EMPTY GROUP";
|
||||||
|
int playerCount = 0;
|
||||||
|
|
||||||
|
DGroup dGroup = dGroups.get(groupCount);
|
||||||
|
if (!plugin.getDGroups().contains(dGroup)) {
|
||||||
|
dGroups.set(groupCount, null);
|
||||||
|
|
||||||
|
} else if (dGroup != null) {
|
||||||
|
name = ChatColor.AQUA + dGroup.getName();
|
||||||
|
playerCount = dGroup.getPlayers().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean full = playerCount >= maxPlayersPerGroup;
|
||||||
|
|
||||||
|
ItemStack button = new ItemStack(Material.WOOL, playerCount, plugin.getMainConfig().getGroupColorPriority().get(groupCount));
|
||||||
|
ItemMeta meta = button.getItemMeta();
|
||||||
|
meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]");
|
||||||
|
button.setItemMeta(meta);
|
||||||
|
buttons.add(button);
|
||||||
|
|
||||||
|
groupCount++;
|
||||||
|
} while (groupCount != maxGroupsPerGame);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param button
|
||||||
|
* the button
|
||||||
|
* @return the matching DGroup
|
||||||
|
*/
|
||||||
|
public DGroup getDGroupByButton(ItemStack button) {
|
||||||
|
int index = buttons.indexOf(button);
|
||||||
|
return dGroups.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Daniel Saukel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package io.github.dre2n.dungeonsxl.announcer;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.util.FileUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.task.AnnouncerTask;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class Announcers {
|
||||||
|
|
||||||
|
private List<Announcer> announcers = new ArrayList<>();
|
||||||
|
|
||||||
|
public Announcers(File file) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
for (File script : FileUtil.getFilesForFolder(file)) {
|
||||||
|
FileConfiguration config = YamlConfiguration.loadConfiguration(script);
|
||||||
|
|
||||||
|
String name = script.getName().substring(0, script.getName().length() - 4);
|
||||||
|
String identifier = config.getString("identifier");
|
||||||
|
List<String> description = config.getStringList("description");
|
||||||
|
List<String> worlds = null;
|
||||||
|
if (config.contains("worlds")) {
|
||||||
|
worlds = config.getStringList("worlds");
|
||||||
|
}
|
||||||
|
boolean multiFloor = config.getBoolean("multiFloor");
|
||||||
|
short maxGroupsPerGame = (short) config.getInt("maxGroupsPerGame");
|
||||||
|
int maxPlayersPerGroup = config.getInt("maxPlayersPerGroup");
|
||||||
|
|
||||||
|
announcers.add(new Announcer(name, description, worlds, identifier, multiFloor, maxGroupsPerGame, maxPlayersPerGroup));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new AnnouncerTask(this).runTaskTimer(DungeonsXL.getInstance(), 0, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the announcer that has the name
|
||||||
|
*/
|
||||||
|
public Announcer getByName(String name) {
|
||||||
|
for (Announcer announcer : announcers) {
|
||||||
|
if (announcer.getName().equals(name)) {
|
||||||
|
return announcer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the announcer that has the GUI
|
||||||
|
*/
|
||||||
|
public Announcer getByGUI(Inventory gui) {
|
||||||
|
for (Announcer announcer : announcers) {
|
||||||
|
if ((ChatColor.DARK_RED + announcer.getName()).equals(gui.getTitle())) {
|
||||||
|
return announcer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the announcers
|
||||||
|
*/
|
||||||
|
public List<Announcer> getAnnouncers() {
|
||||||
|
return announcers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param announcer
|
||||||
|
* the Announcer to add
|
||||||
|
*/
|
||||||
|
public void addAnnouncer(Announcer announcer) {
|
||||||
|
announcers.add(announcer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param announcer
|
||||||
|
* the Announcer to remove
|
||||||
|
*/
|
||||||
|
public void removeAnnouncer(Announcer announcer) {
|
||||||
|
announcers.remove(announcer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Daniel Saukel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package io.github.dre2n.dungeonsxl.command;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.command.BRCommand;
|
||||||
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.announcer.Announcer;
|
||||||
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class JoinCommand extends BRCommand {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
|
public JoinCommand() {
|
||||||
|
setCommand("join");
|
||||||
|
setMinArgs(1);
|
||||||
|
setMaxArgs(1);
|
||||||
|
setHelp(DMessages.HELP_CMD_JOIN.getMessage());
|
||||||
|
setPermission(DPermissions.JOIN.getNode());
|
||||||
|
setPlayerCommand(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
|
DGlobalPlayer player = plugin.getDPlayers().getByPlayer((Player) sender);
|
||||||
|
if (player instanceof DInstancePlayer) {
|
||||||
|
MessageUtil.sendMessage(sender, DMessages.ERROR_LEAVE_GAME.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Announcer announcer = plugin.getAnnouncers().getByName(args[1]);
|
||||||
|
if (announcer != null) {
|
||||||
|
announcer.showGUI((Player) sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -82,6 +82,7 @@ public class ReloadCommand extends BRCommand {
|
|||||||
plugin.loadTriggers();
|
plugin.loadTriggers();
|
||||||
plugin.loadDSigns();
|
plugin.loadDSigns();
|
||||||
plugin.loadDungeons();
|
plugin.loadDungeons();
|
||||||
|
plugin.loadAnnouncers(DungeonsXL.ANNOUNCERS);
|
||||||
|
|
||||||
MessageUtil.sendPluginTag(sender, plugin);
|
MessageUtil.sendPluginTag(sender, plugin);
|
||||||
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_RELOAD_DONE.getMessage());
|
MessageUtil.sendCenteredMessage(sender, DMessages.CMD_RELOAD_DONE.getMessage());
|
||||||
|
@ -26,6 +26,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
*/
|
*/
|
||||||
public enum DMessages implements Messages {
|
public enum DMessages implements Messages {
|
||||||
|
|
||||||
|
ANNOUNCER_CMD("Announcer_Cmd", "&4&l=> &6USE &4/DXL JOIN &v1 &6TO JOIN &4&l<="),
|
||||||
|
ANNOUNCER_CLICK("Announcer_Click", "&4&l=> &6CLICK HERE TO JOIN &4&l<="),
|
||||||
CMD_BREAK_PROTECTED_MODE("Cmd_Break_ProtectedMode", "&6You may not break blocks protected by DungeonsXL anymore."),
|
CMD_BREAK_PROTECTED_MODE("Cmd_Break_ProtectedMode", "&6You may not break blocks protected by DungeonsXL anymore."),
|
||||||
CMD_BREAK_BREAK_MODE("Cmd_Break_BreakMode", "&6You may break a block protected by DungeonsXL."),
|
CMD_BREAK_BREAK_MODE("Cmd_Break_BreakMode", "&6You may break a block protected by DungeonsXL."),
|
||||||
CMD_CHAT_DUNGEON_CHAT("Cmd_Chat_DungeonChat", "&6You have entered the Dungeon-chat"),
|
CMD_CHAT_DUNGEON_CHAT("Cmd_Chat_DungeonChat", "&6You have entered the Dungeon-chat"),
|
||||||
@ -101,6 +103,7 @@ public enum DMessages implements Messages {
|
|||||||
HELP_CMD_GROUP_SHOW("Help_Cmd_GroupShow", "/dxl group show [group] - Shows a group"),
|
HELP_CMD_GROUP_SHOW("Help_Cmd_GroupShow", "/dxl group show [group] - Shows a group"),
|
||||||
HELP_CMD_HELP("Help_Cmd_Help", "/dxl help <page> - Shows the help page"),
|
HELP_CMD_HELP("Help_Cmd_Help", "/dxl help <page> - Shows the help page"),
|
||||||
HELP_CMD_INVITE("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon"),
|
HELP_CMD_INVITE("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon"),
|
||||||
|
HELP_CMD_JOIN("Help_Cmd_Join", "/dxl join [announcement] - Opens the GUI to join a group in an upcoming game"),
|
||||||
HELP_CMD_ENTER("Help_Cmd_Enter", "/dxl enter ([joining group]) [target group] - Let the joining group enter the game of the target group"),
|
HELP_CMD_ENTER("Help_Cmd_Enter", "/dxl enter ([joining group]) [target group] - Let the joining group enter the game of the target group"),
|
||||||
HELP_CMD_LEAVE("Help_Cmd_Leave", "/dxl leave - Leaves the current dungeon"),
|
HELP_CMD_LEAVE("Help_Cmd_Leave", "/dxl leave - Leaves the current dungeon"),
|
||||||
HELP_CMD_LIST("Help_Cmd_List", "/dxl list ([dungeon|map|loaded]) ([dungeon]) - Lists all dungeons"),
|
HELP_CMD_LIST("Help_Cmd_List", "/dxl list ([dungeon|map|loaded]) ([dungeon]) - Lists all dungeons"),
|
||||||
|
@ -19,6 +19,7 @@ package io.github.dre2n.dungeonsxl.config;
|
|||||||
import io.github.dre2n.commons.config.BRConfig;
|
import io.github.dre2n.commons.config.BRConfig;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -29,7 +30,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
*/
|
*/
|
||||||
public class MainConfig extends BRConfig {
|
public class MainConfig extends BRConfig {
|
||||||
|
|
||||||
public static final int CONFIG_VERSION = 6;
|
public static final int CONFIG_VERSION = 7;
|
||||||
|
|
||||||
private String language = "en";
|
private String language = "en";
|
||||||
private boolean enableEconomy = false;
|
private boolean enableEconomy = false;
|
||||||
@ -43,6 +44,7 @@ public class MainConfig extends BRConfig {
|
|||||||
/* Misc */
|
/* Misc */
|
||||||
private boolean sendFloorTitle = true;
|
private boolean sendFloorTitle = true;
|
||||||
private Map<String, Object> externalMobProviders = new HashMap<>();
|
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));
|
||||||
|
|
||||||
/* Secure Mode */
|
/* Secure Mode */
|
||||||
private boolean secureModeEnabled = false;
|
private boolean secureModeEnabled = false;
|
||||||
@ -115,6 +117,13 @@ public class MainConfig extends BRConfig {
|
|||||||
return externalMobProviders;
|
return externalMobProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the group colors
|
||||||
|
*/
|
||||||
|
public List<Short> getGroupColorPriority() {
|
||||||
|
return groupColorPriority;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the tutorialEndGroup
|
* @return the tutorialEndGroup
|
||||||
*/
|
*/
|
||||||
@ -206,6 +215,10 @@ public class MainConfig extends BRConfig {
|
|||||||
config.createSection("externalMobProviders");
|
config.createSection("externalMobProviders");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!config.contains("groupColorPriority")) {
|
||||||
|
config.set("groupColorPriority", groupColorPriority);
|
||||||
|
}
|
||||||
|
|
||||||
if (!config.contains("secureMode.enabled")) {
|
if (!config.contains("secureMode.enabled")) {
|
||||||
config.set("secureMode.enabled", secureModeEnabled);
|
config.set("secureMode.enabled", secureModeEnabled);
|
||||||
}
|
}
|
||||||
@ -273,6 +286,10 @@ public class MainConfig extends BRConfig {
|
|||||||
externalMobProviders = config.getConfigurationSection("externalMobProviders").getValues(false);
|
externalMobProviders = config.getConfigurationSection("externalMobProviders").getValues(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.contains("groupColorPriority")) {
|
||||||
|
groupColorPriority = config.getShortList("groupColorPriority");
|
||||||
|
}
|
||||||
|
|
||||||
if (config.contains("secureMode.enabled")) {
|
if (config.contains("secureMode.enabled")) {
|
||||||
secureModeEnabled = config.getBoolean("secureMode.enabled");
|
secureModeEnabled = config.getBoolean("secureMode.enabled");
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ public class DGroupCreateEvent extends DGroupEvent implements Cancellable {
|
|||||||
|
|
||||||
public enum Cause {
|
public enum Cause {
|
||||||
|
|
||||||
|
ANNOUNCER,
|
||||||
COMMAND,
|
COMMAND,
|
||||||
GROUP_SIGN,
|
GROUP_SIGN,
|
||||||
CUSTOM
|
CUSTOM
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Daniel Saukel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package io.github.dre2n.dungeonsxl.listener;
|
||||||
|
|
||||||
|
import io.github.dre2n.commons.util.guiutil.ButtonClickEvent;
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.announcer.Announcer;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class GUIListener implements Listener {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onButtonClick(ButtonClickEvent event) {
|
||||||
|
Inventory gui = event.getGUI();
|
||||||
|
if (!plugin.getGUIs().contains(gui)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack button = event.getGUI().getItem(event.getSlot());
|
||||||
|
Announcer announcer = plugin.getAnnouncers().getByGUI(gui);
|
||||||
|
if (announcer != null) {
|
||||||
|
announcer.clickGroupButton(event.getPlayer(), button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -63,6 +63,10 @@ public class DGroup {
|
|||||||
private List<Reward> rewards = new ArrayList<>();
|
private List<Reward> rewards = new ArrayList<>();
|
||||||
private BukkitTask timeIsRunningTask;
|
private BukkitTask timeIsRunningTask;
|
||||||
|
|
||||||
|
public DGroup(Player player) {
|
||||||
|
this("Group_" + plugin.getDGroups().size(), player);
|
||||||
|
}
|
||||||
|
|
||||||
public DGroup(String name, Player player) {
|
public DGroup(String name, Player player) {
|
||||||
plugin.getDGroups().add(this);
|
plugin.getDGroups().add(this);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -440,6 +444,13 @@ public class DGroup {
|
|||||||
return players.isEmpty();
|
return players.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the group has been customized with a command
|
||||||
|
*/
|
||||||
|
public boolean isCustom() {
|
||||||
|
return !name.matches("Group_[0-9]{1,}");
|
||||||
|
}
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
/**
|
/**
|
||||||
* Remove the group from the List
|
* Remove the group from the List
|
||||||
|
@ -49,6 +49,7 @@ public enum DPermissions {
|
|||||||
IGNORE_TIME_LIMIT("ignoretimelimit", OP),
|
IGNORE_TIME_LIMIT("ignoretimelimit", OP),
|
||||||
INVITE("invite", OP),
|
INVITE("invite", OP),
|
||||||
INSECURE("insecure", OP),
|
INSECURE("insecure", OP),
|
||||||
|
JOIN("join", TRUE),
|
||||||
LEAVE("leave", TRUE),
|
LEAVE("leave", TRUE),
|
||||||
LIST("list", OP),
|
LIST("list", OP),
|
||||||
LIVES("lives", TRUE),
|
LIVES("lives", TRUE),
|
||||||
@ -65,7 +66,7 @@ public enum DPermissions {
|
|||||||
ADMINISTRATOR("*", OP),
|
ADMINISTRATOR("*", OP),
|
||||||
HALF_EDITOR("halfeditor", OP, ESCAPE, LIST, MESSAGE, SAVE),
|
HALF_EDITOR("halfeditor", OP, ESCAPE, LIST, MESSAGE, SAVE),
|
||||||
FULL_EDITOR("fulleditor", OP, HALF_EDITOR, EDIT, PLAY, SIGN, TEST),
|
FULL_EDITOR("fulleditor", OP, HALF_EDITOR, EDIT, PLAY, SIGN, TEST),
|
||||||
HALF_PLAYER("halfplayer", TRUE, CHAT, ESCAPE, GAME, HELP, LEAVE, LIVES, MAIN),
|
HALF_PLAYER("halfplayer", TRUE, CHAT, ESCAPE, GAME, HELP, JOIN, LEAVE, LIVES, MAIN),
|
||||||
FULL_PLAYER("fullplayer", OP, HALF_PLAYER, GROUP);
|
FULL_PLAYER("fullplayer", OP, HALF_PLAYER, GROUP);
|
||||||
|
|
||||||
public static final String PREFIX = "dxl.";
|
public static final String PREFIX = "dxl.";
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Daniel Saukel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package io.github.dre2n.dungeonsxl.task;
|
||||||
|
|
||||||
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
|
import io.github.dre2n.dungeonsxl.announcer.Announcer;
|
||||||
|
import io.github.dre2n.dungeonsxl.announcer.Announcers;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Daniel Saukel
|
||||||
|
*/
|
||||||
|
public class AnnouncerTask extends BukkitRunnable {
|
||||||
|
|
||||||
|
private List<Announcer> announcers;
|
||||||
|
int index;
|
||||||
|
|
||||||
|
public AnnouncerTask(Announcers announcers) {
|
||||||
|
this.announcers = announcers.getAnnouncers();
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (!(DungeonsXL.getInstance().getDPlayers().getByPlayer(player) instanceof DInstancePlayer)) {
|
||||||
|
announcers.get(index).send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
if (index == announcers.size()) {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user