Fixed some modifiers

This commit is contained in:
Daniel Saukel 2016-02-24 22:00:30 +01:00
parent b0324f9da8
commit 675492b667
24 changed files with 104 additions and 37 deletions

View File

@ -10,8 +10,8 @@ import org.bukkit.entity.Player;
public abstract class DCommand {
static DungeonsXL plugin = DungeonsXL.getPlugin();
static MessageConfig messageConfig = plugin.getMessageConfig();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static MessageConfig messageConfig = plugin.getMessageConfig();
public boolean costsMoney;
private String command;

View File

@ -30,7 +30,7 @@ import org.bukkit.inventory.ItemStack;
public class WorldConfig {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
@Deprecated
public static WorldConfig defaultConfig = new WorldConfig();

View File

@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack;
public class DLootInventory {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
private Inventory inventory;
private InventoryView inventoryView;

View File

@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
public class EditWorld {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables
private World world;

View File

@ -1,12 +1,17 @@
package io.github.dre2n.dungeonsxl.game;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.player.DGroup;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
public class Game {
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
private List<DGroup> dGroups = new ArrayList<DGroup>();
private GameType type;
@ -58,4 +63,37 @@ public class Game {
this.type = type;
}
/**
* @return if the DGroup list is empty
*/
public boolean isEmpty() {
return dGroups.isEmpty();
}
// Static
public static Game getByDGroup(DGroup dGroup) {
for (Game game : plugin.getGames()) {
if (game.getDGroups().contains(dGroup)) {
return game;
}
}
return null;
}
public static Game getByPlayer(Player player) {
return getByDGroup(DGroup.getByPlayer(player));
}
public static Game getByGameWorld(GameWorld gameWorld) {
for (Game game : plugin.getGames()) {
if (game.getDGroups().get(0).getGameWorld().equals(gameWorld)) {
return game;
}
}
return null;
}
}

View File

@ -22,7 +22,7 @@ import org.bukkit.inventory.ItemStack;
public class GameChest {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables
private boolean used = false;

View File

@ -10,6 +10,7 @@ import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldStartGameEvent;
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldUnloadEvent;
import io.github.dre2n.dungeonsxl.event.requirement.RequirementCheckEvent;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.sign.DSign;
@ -41,7 +42,7 @@ import org.bukkit.entity.Spider;
public class GameWorld {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables
private Game game;
@ -60,7 +61,7 @@ public class GameWorld {
private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<Sign>();
private CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<DMob>();
//TODO: Killed mobs
// TODO: Killed mobs
private CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<GameChest>();
private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<DSign>();
private WorldConfig worldConfig;
@ -512,17 +513,17 @@ public class GameWorld {
}
}
public static boolean canPlayDungeon(String dungeon, Player player) {
public static boolean canPlayDungeon(String map, Player player) {
if (player.hasPermission("dxl.ignoretimelimit")) {
return true;
}
if (new File(plugin.getDataFolder() + "/maps/" + dungeon).isDirectory()) {
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + dungeon, "config.yml"));
if (new File(plugin.getDataFolder() + "/maps/" + map).isDirectory()) {
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + map, "config.yml"));
if (worldConfig.getTimeToNextPlay() != 0) {
// read PlayerConfig
long time = getPlayerTime(dungeon, player);
long time = getPlayerTime(map, player);
if (time != -1) {
if (time + worldConfig.getTimeToNextPlay() * 1000 * 60 * 60 > System.currentTimeMillis()) {
return false;
@ -537,6 +538,20 @@ public class GameWorld {
return true;
}
public static boolean canPlayDungeon(String dungeon, DGroup dGroup) {
if (dGroup.getCaptain().hasPermission("dxl.ignoretimelimit")) {
return true;
}
for (Player player : dGroup.getPlayers()) {
if ( !canPlayDungeon(dungeon, player)) {
return false;
}
}
return true;
}
public static long getPlayerTime(String dungeon, Player player) {
File file = new File(plugin.getDataFolder() + "/maps/" + dungeon, "players.yml");
@ -559,16 +574,16 @@ public class GameWorld {
return -1;
}
public static boolean checkRequirements(String dungeon, Player player) {
public static boolean checkRequirements(String map, Player player) {
if (player.hasPermission("dxl.ignorerequirements")) {
return true;
}
if (new File(plugin.getDataFolder() + "/maps/" + dungeon).isDirectory() == false) {
if (new File(plugin.getDataFolder() + "/maps/" + map).isDirectory() == false) {
return false;
}
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + dungeon, "config.yml"));
WorldConfig worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + map, "config.yml"));
for (Requirement requirement : worldConfig.getRequirements()) {
RequirementCheckEvent event = new RequirementCheckEvent(requirement, player);
@ -634,4 +649,18 @@ public class GameWorld {
return true;
}
public static boolean checkRequirements(String map, DGroup dGroup) {
if (dGroup.getCaptain().hasPermission("dxl.ignorerequirements")) {
return true;
}
for (Player player : dGroup.getPlayers()) {
if ( !checkRequirements(map, player)) {
return false;
}
}
return true;
}
}

View File

@ -16,7 +16,7 @@ import org.bukkit.entity.Player;
public class DPortal {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
private World world;
private Block block1;

View File

@ -21,7 +21,7 @@ import org.bukkit.entity.Player;
public class GroupSign {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
// Sign Labels
public static final String IS_PLAYING = ChatColor.DARK_RED + "Is Playing";
@ -313,7 +313,7 @@ public class GroupSign {
}
public static GroupSign getSign(Block block) {
if (block.getType() != Material.WALL_SIGN) {
if ( !(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
return null;
}
@ -510,7 +510,7 @@ public class GroupSign {
}
public static void load(FileConfiguration configFile) {
for (World world : DungeonsXL.getPlugin().getServer().getWorlds()) {
for (World world : plugin.getServer().getWorlds()) {
if ( !configFile.contains("groupsign." + world.getName())) {
continue;
}

View File

@ -16,7 +16,7 @@ import org.bukkit.entity.Player;
public class LeaveSign {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
private Sign sign;

View File

@ -32,7 +32,7 @@ import org.bukkit.event.block.SignChangeEvent;
public class BlockListener implements Listener {
DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
@EventHandler(priority = EventPriority.HIGH)
public void onPhysics(BlockPhysicsEvent event) {

View File

@ -14,7 +14,7 @@ import org.bukkit.entity.Player;
public class CommandListener implements CommandExecutor {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
@Override
public boolean onCommand(CommandSender sender, Command cmd_notused, String arg, String[] args) {

View File

@ -51,8 +51,8 @@ import org.bukkit.inventory.meta.BookMeta;
public class PlayerListener implements Listener {
static DungeonsXL plugin = DungeonsXL.getPlugin();
static MessageConfig messageConfig = plugin.getMessageConfig();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static MessageConfig messageConfig = plugin.getMessageConfig();
@EventHandler(priority = EventPriority.HIGH)
public void onDeath(PlayerDeathEvent event) {

View File

@ -26,7 +26,7 @@ import org.bukkit.inventory.meta.ItemMeta;
public class DMobType {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
private String name;
private EntityType type;

View File

@ -27,8 +27,8 @@ import org.bukkit.entity.Player;
public class DGroup {
static DungeonsXL plugin = DungeonsXL.getPlugin();
static MessageConfig messageConfig = plugin.getMessageConfig();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static MessageConfig messageConfig = plugin.getMessageConfig();
private String name;
private Player captain;

View File

@ -46,8 +46,8 @@ import org.bukkit.potion.PotionEffect;
public class DPlayer {
static DungeonsXL plugin = DungeonsXL.getPlugin();
static MessageConfig messageConfig = plugin.getMessageConfig();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static MessageConfig messageConfig = plugin.getMessageConfig();
// Variables
private Player player;

View File

@ -21,7 +21,7 @@ import org.bukkit.potion.PotionEffect;
public class DSavePlayer {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
private static CopyOnWriteArrayList<DSavePlayer> savePlayers = new CopyOnWriteArrayList<DSavePlayer>();

View File

@ -10,7 +10,7 @@ import io.github.dre2n.dungeonsxl.event.requirement.RequirementRegistrationEvent
public abstract class Requirement {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
public static Requirement create(RequirementType type) {
Requirement requirement = null;

View File

@ -13,7 +13,7 @@ import io.github.dre2n.dungeonsxl.reward.RewardTypeDefault;
public abstract class Reward {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
public static Reward create(RewardType type) {
Reward reward = null;

View File

@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
public abstract class DSign {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
private Sign sign;
private GameWorld gameWorld;

View File

@ -8,7 +8,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class LazyUpdateTask extends BukkitRunnable {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
@Override
public void run() {

View File

@ -9,7 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class RedstoneEventTask extends BukkitRunnable {
private final Block block;
private Block block;
public RedstoneEventTask(final Block block) {
this.block = block;

View File

@ -9,7 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class WorldUnloadTask extends BukkitRunnable {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
@Override
public void run() {

View File

@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
public abstract class Trigger {
static DungeonsXL plugin = DungeonsXL.getPlugin();
protected static DungeonsXL plugin = DungeonsXL.getPlugin();
private boolean triggered;
private Player player; // Holds Player for Player specific Triggers