mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Update to CaliburnAPI 0.2
This commit is contained in:
parent
01d7598442
commit
5366e4994a
@ -70,7 +70,7 @@ Maven automatically fetches all dependencies and builds DungeonsXL; just run _bu
|
||||
[BRCommons](https://github.com/DRE2N/BRCommons) is a util library for common tasks. DungeonsXL contains BRCommons 1.0.1.
|
||||
|
||||
#### Caliburn API
|
||||
[Caliburn](https://github.com/DRE2N/CaliburnAPI) is an API to read custom items and mobs from config files. DungeonsXL contains Caliburn Beta 0.1.8.
|
||||
[Caliburn](https://github.com/DRE2N/CaliburnAPI) is an API to read custom items and mobs from config files. DungeonsXL contains Caliburn Beta 0.2.
|
||||
|
||||
### Java
|
||||
Make sure that your server uses Java 7 or higher.
|
||||
|
@ -18,7 +18,6 @@ package io.github.dre2n.dungeonsxl;
|
||||
|
||||
import io.github.dre2n.caliburn.CaliburnAPI;
|
||||
import io.github.dre2n.commons.compatibility.Internals;
|
||||
import io.github.dre2n.commons.compatibility.Version;
|
||||
import io.github.dre2n.commons.config.MessageConfig;
|
||||
import io.github.dre2n.commons.javaplugin.BRPlugin;
|
||||
import io.github.dre2n.commons.javaplugin.BRPluginSettings;
|
||||
@ -52,7 +51,6 @@ import io.github.dre2n.dungeonsxl.task.UpdateTask;
|
||||
import io.github.dre2n.dungeonsxl.task.WorldUnloadTask;
|
||||
import io.github.dre2n.dungeonsxl.trigger.TriggerTypes;
|
||||
import io.github.dre2n.dungeonsxl.world.DWorlds;
|
||||
import io.github.dre2n.itemsxl.ItemsXL;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@ -78,8 +76,6 @@ 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;
|
||||
@ -131,14 +127,10 @@ public class DungeonsXL extends BRPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
|
||||
instance = this;
|
||||
if (Version.andHigher(Version.MC1_9).contains(compat.getVersion())) {
|
||||
loadCaliburnAPI();
|
||||
}
|
||||
|
||||
initFolders();
|
||||
|
||||
loadCaliburnAPI();
|
||||
// Load Language
|
||||
loadMessageConfig(new File(LANGUAGES, "english.yml"));
|
||||
// Load Config
|
||||
@ -295,21 +287,11 @@ public class DungeonsXL extends BRPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of CaliburnAPI
|
||||
* load / reload a new instance of CaliburnAPI if none exists
|
||||
*/
|
||||
public CaliburnAPI getCaliburnAPI() {
|
||||
return caliburn;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of CaliburnAPI
|
||||
*/
|
||||
public void loadCaliburnAPI() {
|
||||
if (manager.isPluginEnabled("ItemsXL")) {
|
||||
caliburn = ItemsXL.getInstance().getAPI();
|
||||
} else {
|
||||
caliburn = new CaliburnAPI(this);
|
||||
caliburn.setupClean();
|
||||
private void loadCaliburnAPI() {
|
||||
if (CaliburnAPI.getInstance() == null) {
|
||||
new CaliburnAPI(this).setupClean();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.config;
|
||||
|
||||
import io.github.dre2n.caliburn.CaliburnAPI;
|
||||
import io.github.dre2n.caliburn.item.UniversalItemStack;
|
||||
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||
import io.github.dre2n.commons.compatibility.Version;
|
||||
import io.github.dre2n.commons.util.EnumUtil;
|
||||
@ -29,7 +31,7 @@ import io.github.dre2n.dungeonsxl.requirement.GroupSizeRequirement;
|
||||
import io.github.dre2n.dungeonsxl.requirement.PermissionRequirement;
|
||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||
import io.github.dre2n.dungeonsxl.requirement.RequirementTypeDefault;
|
||||
import io.github.dre2n.dungeonsxl.util.DeserialisazionUtil;
|
||||
import io.github.dre2n.dungeonsxl.util.DeserializationUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -82,11 +84,10 @@ public class WorldConfig extends GameRules {
|
||||
|
||||
/* Secure Objects */
|
||||
if (configFile.contains("secureObjects")) {
|
||||
List<String> secureObjectList = configFile.getStringList("secureObjects");
|
||||
if (Version.andHigher(Version.MC1_9).contains(compat.getVersion())) {
|
||||
secureObjects = plugin.getCaliburnAPI().getItems().deserializeStackList(secureObjectList);
|
||||
secureObjects = UniversalItemStack.deserializeList(configFile.getList("secureObjects"));
|
||||
} else {
|
||||
secureObjects = DeserialisazionUtil.deserializeStackList(secureObjectList);
|
||||
secureObjects = DeserializationUtil.deserializeStackList(configFile.getStringList("secureObjects"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,7 +252,7 @@ public class WorldConfig extends GameRules {
|
||||
List<String> secureObjectIds = new ArrayList<>();
|
||||
|
||||
for (ItemStack item : getSecureObjects()) {
|
||||
secureObjectIds.add(plugin.getCaliburnAPI().getItems().getCustomItemId(item));
|
||||
secureObjectIds.add(CaliburnAPI.getInstance().getItems().getCustomItemId(item));
|
||||
}
|
||||
|
||||
configFile.set("secureObjects", secureObjects);
|
||||
|
@ -16,10 +16,11 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.player;
|
||||
|
||||
import io.github.dre2n.caliburn.item.UniversalItemStack;
|
||||
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 io.github.dre2n.dungeonsxl.util.DeserializationUtil;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -48,12 +49,10 @@ public class DClass {
|
||||
this.name = name;
|
||||
|
||||
if (config.contains("items")) {
|
||||
List<String> itemList = config.getStringList("items");
|
||||
|
||||
if (Version.andHigher(Version.MC1_9).contains(compat.getVersion())) {
|
||||
items = plugin.getCaliburnAPI().getItems().deserializeStackList(itemList);
|
||||
items = UniversalItemStack.deserializeList(config.getList("items"));
|
||||
} else {
|
||||
items = DeserialisazionUtil.deserializeStackList(itemList);
|
||||
items = DeserializationUtil.deserializeStackList(config.getStringList("items"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.sign;
|
||||
|
||||
import io.github.dre2n.caliburn.CaliburnAPI;
|
||||
import io.github.dre2n.caliburn.item.UniversalItem;
|
||||
import io.github.dre2n.commons.util.NumberUtil;
|
||||
import io.github.dre2n.dungeonsxl.task.DropItemTask;
|
||||
@ -58,12 +59,12 @@ public class DropSign extends DSign {
|
||||
/* Actions */
|
||||
@Override
|
||||
public boolean check() {
|
||||
return plugin.getCaliburnAPI().getItems().getById(lines[1]) != null;
|
||||
return CaliburnAPI.getInstance().getItems().getById(lines[1]) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
UniversalItem item = plugin.getCaliburnAPI().getItems().getById(lines[1]);
|
||||
UniversalItem item = CaliburnAPI.getInstance().getItems().getById(lines[1]);
|
||||
|
||||
String[] attributes = lines[2].split(",");
|
||||
if (attributes.length >= 1) {
|
||||
|
@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.sign;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
import io.github.dre2n.caliburn.CaliburnAPI;
|
||||
import io.github.dre2n.caliburn.item.UniversalItem;
|
||||
import io.github.dre2n.commons.compatibility.CompatibilityHandler;
|
||||
import io.github.dre2n.commons.compatibility.Version;
|
||||
@ -49,7 +50,6 @@ public class HologramSign extends DSign {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onInit() {
|
||||
getSign().getBlock().setType(Material.AIR);
|
||||
|
||||
@ -64,7 +64,7 @@ public class HologramSign extends DSign {
|
||||
ItemStack item = null;
|
||||
|
||||
if (Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) {
|
||||
UniversalItem universalItem = plugin.getCaliburnAPI().getItems().getById(id);
|
||||
UniversalItem universalItem = CaliburnAPI.getInstance().getItems().getById(id);
|
||||
if (universalItem != null) {
|
||||
item = universalItem.toItemStack(1);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
@Deprecated
|
||||
public class DeserialisazionUtil {
|
||||
public class DeserializationUtil {
|
||||
|
||||
public static List<ItemStack> deserializeStackList(List<String> items) {
|
||||
List<ItemStack> itemStacks = new ArrayList<>();
|
7
pom.xml
7
pom.xml
@ -45,12 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>caliburn</artifactId>
|
||||
<version>0.1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>itemsxl</artifactId>
|
||||
<version>0.1.8</version>
|
||||
<version>0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
|
Loading…
Reference in New Issue
Block a user