mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-25 03:55:22 +01:00
parent
5f8170e494
commit
a97b345b30
17
pom.xml
17
pom.xml
@ -48,10 +48,15 @@
|
||||
<pattern>io.github.dre2n.commons</pattern>
|
||||
<shadedPattern>io.github.dre2n.dungeonsxl</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>io.github.dre2n.caliburn</pattern>
|
||||
<shadedPattern>io.github.dre2n.dungeonsxl.util.caliburn</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>io.github.dre2n:commons</include>
|
||||
<include>io.github.dre2n:caliburn</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
@ -78,6 +83,16 @@
|
||||
<artifactId>commons</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>caliburn</artifactId>
|
||||
<version>0.1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>itemsxl</artifactId>
|
||||
<version>0.1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>commandsxl</artifactId>
|
||||
@ -86,7 +101,7 @@
|
||||
<dependency>
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
<artifactId>citizensapi</artifactId>
|
||||
<version>2.0.17-SNAPSHOT</version>
|
||||
<version>2.0.18-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl;
|
||||
|
||||
import io.github.dre2n.caliburn.CaliburnAPI;
|
||||
import io.github.dre2n.commons.command.BRCommands;
|
||||
import io.github.dre2n.commons.compatibility.Internals;
|
||||
import io.github.dre2n.commons.config.MessageConfig;
|
||||
@ -53,6 +54,7 @@ import io.github.dre2n.dungeonsxl.task.WorldUnloadTask;
|
||||
import io.github.dre2n.dungeonsxl.trigger.TriggerTypes;
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import io.github.dre2n.itemsxl.ItemsXL;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@ -77,6 +79,8 @@ public class DungeonsXL extends BRPlugin {
|
||||
public static File MOBS;
|
||||
public static File SIGNS;
|
||||
|
||||
private CaliburnAPI caliburn;
|
||||
|
||||
private GlobalData globalData;
|
||||
private MainConfig mainConfig;
|
||||
private MessageConfig messageConfig;
|
||||
@ -304,6 +308,24 @@ public class DungeonsXL extends BRPlugin {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of CaliburnAPI
|
||||
*/
|
||||
public CaliburnAPI getCaliburnAPI() {
|
||||
return caliburn;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of CaliburnAPI
|
||||
*/
|
||||
public void loadCaliburnAPI() {
|
||||
if (manager.isPluginEnabled("ItemsXL")) {
|
||||
this.caliburn = ItemsXL.getInstance().getAPI();
|
||||
} else {
|
||||
this.caliburn = new CaliburnAPI(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of GlobalData
|
||||
*/
|
||||
|
@ -23,8 +23,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
|
@ -16,6 +16,8 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.config;
|
||||
|
||||
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||
import io.github.dre2n.commons.compatibility.Version;
|
||||
import io.github.dre2n.commons.util.EnumUtil;
|
||||
import io.github.dre2n.commons.util.NumberUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
@ -25,6 +27,7 @@ import io.github.dre2n.dungeonsxl.requirement.FeeLevelRequirement;
|
||||
import io.github.dre2n.dungeonsxl.requirement.FeeMoneyRequirement;
|
||||
import io.github.dre2n.dungeonsxl.requirement.GroupSizeRequirement;
|
||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||
import io.github.dre2n.dungeonsxl.util.DeserialisazionUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -32,10 +35,10 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||
@ -43,6 +46,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
public class WorldConfig extends GameRules {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
CompatibilityHandler compat = CompatibilityHandler.getInstance();
|
||||
|
||||
private File file;
|
||||
|
||||
@ -79,13 +83,10 @@ public class WorldConfig extends GameRules {
|
||||
/* Secure Objects */
|
||||
if (configFile.contains("secureObjects")) {
|
||||
List<String> secureObjectList = configFile.getStringList("secureObjects");
|
||||
for (String id : secureObjectList) {
|
||||
if (Material.getMaterial(NumberUtil.parseInt(id)) != null) {
|
||||
secureObjects.add(Material.getMaterial(NumberUtil.parseInt(id)));
|
||||
|
||||
} else if (Material.getMaterial(id) != null) {
|
||||
secureObjects.add(Material.getMaterial(id));
|
||||
}
|
||||
if (Version.andHigher(Version.MC1_9).contains(compat.getVersion())) {
|
||||
secureObjects = plugin.getCaliburnAPI().getItems().deserializeStackList(secureObjectList);
|
||||
} else {
|
||||
secureObjects = DeserialisazionUtil.deserializeStackList(secureObjectList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,14 +245,13 @@ public class WorldConfig extends GameRules {
|
||||
configFile.set("message." + msgs, this.msgs.get(msgs));
|
||||
}
|
||||
|
||||
// Secure Objects
|
||||
CopyOnWriteArrayList<Integer> secureObjectsids = new CopyOnWriteArrayList<>();
|
||||
List<String> secureObjectIds = new ArrayList<>();
|
||||
|
||||
for (Material mat : secureObjects) {
|
||||
secureObjectsids.add(mat.getId());
|
||||
for (ItemStack item : secureObjects) {
|
||||
secureObjectIds.add(plugin.getCaliburnAPI().getItems().getCustomItemId(item));
|
||||
}
|
||||
|
||||
configFile.set("secureObjects", secureObjectsids);
|
||||
configFile.set("secureObjects", secureObjectIds);
|
||||
|
||||
// Invited Players
|
||||
configFile.set("invitedPlayers", invitedPlayers);
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.game;
|
||||
|
||||
import io.github.dre2n.caliburn.item.UniversalItem;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||
@ -24,7 +25,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
@ -109,7 +110,7 @@ public class GameRules {
|
||||
|
||||
/* Misc */
|
||||
protected Map<Integer, String> msgs;
|
||||
protected List<Material> secureObjects;
|
||||
protected List<ItemStack> secureObjects;
|
||||
|
||||
/* Getters and setters */
|
||||
// keepInventory
|
||||
@ -315,7 +316,7 @@ public class GameRules {
|
||||
/**
|
||||
* @return the objects to get passed to another player of the group when this player leaves
|
||||
*/
|
||||
public List<Material> getSecureObjects() {
|
||||
public List<ItemStack> getSecureObjects() {
|
||||
return secureObjects;
|
||||
}
|
||||
|
||||
|
@ -350,8 +350,8 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Game game = Game.getByWorld(gamePlayer.getWorld());
|
||||
|
||||
for (Material material : game.getRules().getSecureObjects()) {
|
||||
if (material == event.getItemDrop().getItemStack().getType()) {
|
||||
for (ItemStack item : game.getRules().getSecureObjects()) {
|
||||
if (event.getItemDrop().getItemStack().isSimilar(item)) {
|
||||
event.setCancelled(true);
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_DROP.getMessage());
|
||||
return;
|
||||
|
@ -18,7 +18,6 @@ package io.github.dre2n.dungeonsxl.listener;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.world.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
@ -19,7 +19,6 @@ package io.github.dre2n.dungeonsxl.mob;
|
||||
import io.github.dre2n.commons.util.EnumUtil;
|
||||
import io.github.dre2n.commons.util.NumberUtil;
|
||||
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.world.GameWorld;
|
||||
import java.io.File;
|
||||
@ -46,8 +45,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
*/
|
||||
public class DMobType {
|
||||
|
||||
static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
private String name;
|
||||
private EntityType type;
|
||||
|
||||
@ -75,7 +72,7 @@ public class DMobType {
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name of the Announcer
|
||||
* the name of the DMobType
|
||||
* @param config
|
||||
* the config that stores the information
|
||||
*/
|
||||
@ -178,7 +175,7 @@ public class DMobType {
|
||||
|
||||
/* Add Item to the drops map */
|
||||
item.setItemMeta(itemMeta);
|
||||
getDrops().put(item, chance);
|
||||
drops.put(item, chance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,10 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.player;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.util.ItemUtil;
|
||||
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||
import io.github.dre2n.commons.compatibility.Version;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.util.DeserialisazionUtil;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -29,6 +32,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class DClass {
|
||||
|
||||
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
CompatibilityHandler compat = CompatibilityHandler.getInstance();
|
||||
|
||||
private String name;
|
||||
|
||||
private List<ItemStack> items = new ArrayList<>();
|
||||
@ -42,7 +48,13 @@ public class DClass {
|
||||
this.name = name;
|
||||
|
||||
if (config.contains("items")) {
|
||||
items = ItemUtil.fromConfig(config);
|
||||
List<String> itemList = config.getStringList("items");
|
||||
|
||||
if (Version.andHigher(Version.MC1_9).contains(compat.getVersion())) {
|
||||
items = plugin.getCaliburnAPI().getItems().deserializeStackList(itemList);
|
||||
} else {
|
||||
items = DeserialisazionUtil.deserializeStackList(itemList);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.contains("dog")) {
|
||||
|
@ -19,7 +19,6 @@ package io.github.dre2n.dungeonsxl.sign;
|
||||
import io.github.dre2n.dungeonsxl.player.DClass;
|
||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
/**
|
||||
|
@ -17,21 +17,21 @@
|
||||
package io.github.dre2n.dungeonsxl.util;
|
||||
|
||||
import io.github.dre2n.commons.util.NumberUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Deprecated deserialization methods for compatibility with 1.7.8-1.8.x
|
||||
*
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
@Deprecated
|
||||
public class ItemUtil {
|
||||
public class DeserialisazionUtil {
|
||||
|
||||
public static List<ItemStack> fromConfig(ConfigurationSection configSectionClasses) {
|
||||
List<String> items = configSectionClasses.getStringList("items");
|
||||
CopyOnWriteArrayList<ItemStack> itemStacks = new CopyOnWriteArrayList<>();
|
||||
public static List<ItemStack> deserializeStackList(List<String> items) {
|
||||
List<ItemStack> itemStacks = new ArrayList<>();
|
||||
|
||||
for (String item : items) {
|
||||
String[] itemSplit = item.split(",");
|
@ -44,7 +44,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.block.Block;
|
||||
@ -53,6 +52,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||
@ -71,7 +71,7 @@ public class GameWorld {
|
||||
private Location locStart;
|
||||
private boolean isPlaying = false;
|
||||
private int id;
|
||||
private List<Material> secureObjects = new ArrayList<>();
|
||||
private List<ItemStack> secureObjects = new ArrayList<>();
|
||||
private CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<>();
|
||||
|
||||
private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<>();
|
||||
@ -244,7 +244,7 @@ public class GameWorld {
|
||||
/**
|
||||
* @return the secureObjects
|
||||
*/
|
||||
public List<Material> getSecureObjects() {
|
||||
public List<ItemStack> getSecureObjects() {
|
||||
return secureObjects;
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ public class GameWorld {
|
||||
* @param secureObjects
|
||||
* the secureObjects to set
|
||||
*/
|
||||
public void setSecureObjects(List<Material> secureObjects) {
|
||||
public void setSecureObjects(List<ItemStack> secureObjects) {
|
||||
this.secureObjects = secureObjects;
|
||||
}
|
||||
|
||||
@ -539,10 +539,7 @@ public class GameWorld {
|
||||
/* Statics */
|
||||
public static GameWorld getByWorld(World world) {
|
||||
for (GameWorld gameWorld : plugin.getGameWorlds()) {
|
||||
if (gameWorld.getWorld() == null) {
|
||||
continue;
|
||||
|
||||
} else if (gameWorld.getWorld().equals(world)) {
|
||||
if (gameWorld.getWorld() != null && gameWorld.getWorld().equals(world)) {
|
||||
return gameWorld;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ version: ${project.version}
|
||||
authors: [Frank Baumann, Milan Albrecht, Tobias Schmitz, Daniel Saukel]
|
||||
description: ${project.description}
|
||||
website: ${project.url}
|
||||
softdepend: [BlueRoseCommons, CommandsXL, Vault, CustomMobs, InsaneMobs, MythicMobs]
|
||||
softdepend: [BlueRoseCommons, CommandsXL, ItemsXL, Vault, CustomMobs, InsaneMobs, MythicMobs]
|
||||
commands:
|
||||
dungeonsxl:
|
||||
description: Reference command for DungeonsXL.
|
||||
|
Loading…
Reference in New Issue
Block a user