Update to 1.13

This commit is contained in:
BuildTools 2018-08-07 20:45:40 +02:00
parent 807f3e4b5f
commit 69313f7799
15 changed files with 155 additions and 190 deletions

View File

@ -4,6 +4,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="C:/Programmieren/FastAsyncWorldEdit.jar"/>
<classpathentry kind="lib" path="C:/Programmieren/worldedit-bukkit-6.1.7.2.jar"/>
<classpathentry kind="lib" path="C:/Programmieren/spigot-1.12.jar" sourcepath="C:/Users/jubek/Documents/Development/JavaLibraries/Bukkit_Spigot/BuildTools/Spigot"/>
<classpathentry kind="lib" path="C:/Programmieren/spigot-1.13-pre7.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -2,6 +2,9 @@ name: WorldSystem
version: 2.2.0.6
author: Butzlabben
main: de.butzlabben.world.WorldSystem
api-version: 1.13
loadbefore: [FastAsyncWorldEdit, WorldEdit]
commands:

View File

@ -4,26 +4,21 @@
#
options:
# How the enabled item should look like
enabled:
# ItemID, for seeing them press F3 + H
material: 351
# Data, how it should look like eg. blue, red, green
data: 10
# Material name in the Material enum
material: LIME_DYE
# Displayname
display: '&aEnabled'
# How the disabled item should look like
disabled:
material: 351
data: 1
material: ROSE_RED
display: '&cDisabled'
# How the comming-soon item should look like
coming_soon:
material: 351
data: 14
material: ORANGE_DYE
display: '&6Coming soon...'
# WorldoptionsGUI
@ -37,7 +32,7 @@ options:
slot:
row: 1
col: 8
material: 293
material: DIAMOND_HOE
data: 0
display: '&eReset World'
@ -51,8 +46,7 @@ options:
state:
row: 2
col: 2
material: 259
data: 0
material: FLINT_AND_STEEL
display: '&eToggle Fire'
# TNT button
@ -64,35 +58,35 @@ options:
state:
row: 2
col: 5
material: 46
data: 0
material: TNT
display: '&eToggle TNT-Explosion'
players:
skull_item:
material: PLAYER_HEAD
rows: 6
nextpage:
enabled: true
slot:
row: 6
col: 9
material: 175
data: 0
material: PAPER
display: '&eNext Page'
pagebefore:
enabled: true
slot:
row: 6
col: 1
material: 175
data: 0
material: PAPER
display: '&ePage before'
currentpage:
enabled: true
slot:
row: 6
col: 5
material: 339
data: 0
material: DOUBLE_PLANT
display: '&eCurrent page: %page'
player_list_to_row: 4
playerhead:
@ -109,8 +103,7 @@ options:
state:
row: 2
col: 1
material: 286
data: 0
material: GOLDEN_AXE
display: '&eToggle Build-Permission'
lore:
- '&7Toggles the permission for a player'
@ -123,8 +116,7 @@ options:
state:
row: 2
col: 2
material: 426
data: 0
material: END_CRYSTAL
display: '&eToggle GameMode-Permission'
lore:
- '&7Toggles the permission for a player'
@ -137,8 +129,7 @@ options:
state:
row: 2
col: 3
material: 345
data: 0
material: COMPASS
display: '&eToggle Teleport-Permission'
lore:
- '&7Toggles the permission for a player'
@ -152,25 +143,10 @@ options:
row: 2
col: 4
material: 347
data: 0
display: '&eToggle Time-Permission'
lore:
- '&7Toggles the permission for a player'
- '&7To change the time on this world'
worldborder:
enabled: false
slot:
row: 1
col: 5
state:
row: 2
col: 5
material: 345
data: 0
display: '&eToggle Worldborder-Permission'
lore:
- '&7Toggles the permission for a player'
- '&7To change the worldborder on this world'
addmember:
enabled: false
slot:
@ -180,7 +156,6 @@ options:
row: 2
col: 6
material: 399
data: 0
display: '&eToggle Addmember-Permission'
lore:
- '&7Toggles the permission for a player'
@ -194,25 +169,10 @@ options:
row: 2
col: 6
material: 286
data: 0
display: '&eToggle Delmember-Permission'
lore:
- '&7Toggles the permission for a player'
- '&7To remove a member from this world'
addmember:
enabled: false
slot:
row: 1
col: 7
state:
row: 2
col: 7
material: 399
data: 0
display: '&eToggle Addmember-Permission'
lore:
- '&7Toggles the permission for a player'
- '&7To add a member to this world'
setpermissions:
enabled: false
slot:
@ -222,7 +182,6 @@ options:
row: 2
col: 8
material: 331
data: 0
display: '&eToggle Setpermissions-Permission'
lore:
- '&7Toggles the permission for a player'
@ -236,7 +195,6 @@ options:
row: 2
col: 9
material: 421
data: 0
display: '&eToggle Addmember-Permission'
lore:
- '&7Toggles the permission for a player'
@ -250,14 +208,12 @@ worldsystem:
slot:
row: 1
col: 4
material: 298
data: 0
material: LEATHER_HELMET
display: '&ePlayer Options'
worldoptions:
enabled: true
slot:
row: 1
col: 6
material: 2
data: 0
material: GRASS_BLOCK
display: '&eWorld Options'

View File

@ -1,5 +1,6 @@
package de.butzlabben.inventory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@ -32,28 +33,36 @@ public class OrcItem {
setItemStack(mat, display, lore);
}
public OrcItem(int id, byte data, String display, List<String> lore) {
setItemStack(id, data, display, lore);
}
// public OrcItem(int id, byte data, String display, List<String> lore) {
// setItemStack(id, data, display, lore);
// }
@SuppressWarnings("deprecation")
public OrcItem setItemStack(int id, byte data, String display, List<String> lore) {
is = new ItemStack(id, 1, data);
// @SuppressWarnings("deprecation")
// public OrcItem setItemStack(int id, byte data, String display, List<String> lore) {
// is = new ItemStack(id, 1, data);
// ItemMeta meta = is.getItemMeta();
// if (meta != null) {
// meta.setDisplayName(display);
// meta.setLore(lore);
// is.setItemMeta(meta);
// }
// return this;
// }
// public OrcItem(int id, byte data, String display, String... lore) {
// setItemStack(id, data, display, lore);
// }
// public OrcItem setItemStack(int id, byte data, String display, String[] lore) {
// return setItemStack(id, data, display, Arrays.asList(lore));
// }
public OrcItem(Material material, byte data, String display, ArrayList<String> lore) {
is = new ItemStack(material, 1, data);
ItemMeta meta = is.getItemMeta();
if (meta != null) {
meta.setDisplayName(display);
meta.setLore(lore);
is.setItemMeta(meta);
}
return this;
}
public OrcItem(int id, byte data, String display, String... lore) {
setItemStack(id, data, display, lore);
}
public OrcItem setItemStack(int id, byte data, String display, String[] lore) {
return setItemStack(id, data, display, Arrays.asList(lore));
meta.setDisplayName(display);
meta.setLore(lore);
is.setItemMeta(meta);
}
public OrcItem setItemStack(Material mat, String display, List<String> lore) {

View File

@ -62,9 +62,15 @@ public class WorldSystem extends JavaPlugin {
public static OrcInventory mainGUI;
public static CreatorAdapter creator;
private static boolean is1_13 = false;
@Override
public void onEnable() {
//Set right version
if(Bukkit.getVersion().contains("1.13") || Bukkit.getVersion().contains("1_13") )
is1_13 = true;
createConfigs();
PluginManager pm = Bukkit.getPluginManager();
@ -216,4 +222,7 @@ public class WorldSystem extends JavaPlugin {
return JavaPlugin.getPlugin(WorldSystem.class);
}
public static boolean isIs1_13() {
return is1_13;
}
}

View File

@ -11,6 +11,7 @@ import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
@ -31,7 +32,13 @@ public class GuiConfig {
file = f;
if (file.exists() == false) {
try {
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource("gui.yml");
String guiFileResource;
if (WorldSystem.isIs1_13()) {
guiFileResource = "1_13_gui.yml";
} else {
guiFileResource = "old_gui.yml";
}
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource(guiFileResource);
Files.copy(in, file.toPath());
} catch (IOException e) {
System.err.println("Wasn't able to create Config");
@ -45,7 +52,8 @@ public class GuiConfig {
public static YamlConfiguration getConfig() {
try {
return YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8")));
return YamlConfiguration
.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8")));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
@ -83,18 +91,15 @@ public class GuiConfig {
return colored;
}
public static int getId(FileConfiguration cfg, String path) {
return cfg.getInt(path + ".material");
}
public static byte getData(FileConfiguration cfg, String path) {
return (byte) cfg.getInt(path + ".data");
return (byte) cfg.getInt(path + ".data", 0);
}
public static Material getMaterial(FileConfiguration cfg, String path) {
try {
return Material.valueOf(cfg.getString(path + ".material").toUpperCase());
} catch (IllegalArgumentException ex) {
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§cUnknown material: " + path);
return null;
}
}
@ -102,7 +107,7 @@ public class GuiConfig {
public static OrcItem getItem(String path) {
YamlConfiguration cfg = getConfig();
try {
return new OrcItem(getId(cfg, path), getData(cfg, path), getDisplay(cfg, path), getLore(cfg, path));
return new OrcItem(getMaterial(cfg, path), getData(cfg, path), getDisplay(cfg, path), getLore(cfg, path));
} catch (Exception e) {
}
try {
@ -124,4 +129,7 @@ public class GuiConfig {
return getItem("options.coming_soon");
}
public static Material getSkullItem() {
return getMaterial(getConfig(), "options.players.skull_item");
}
}

View File

@ -50,15 +50,10 @@ public class SettingsConfig {
w.getWorldBorder().setSize(size);
System.out.println(cfg.getBoolean("worldborder.center.as_spawn", true));
if (cfg.getBoolean("worldborder.center.as_spawn", true)) {
System.out.println(w.getSpawnLocation());
System.out.println(w.getWorldBorder().getCenter());
if (PluginConfig.useWorldSpawn()) {
System.out.println("s");
w.getWorldBorder().setCenter(PluginConfig.getWorldSpawn(w));
} else {
System.out.println("a");
w.getWorldBorder().setCenter(w.getSpawnLocation());
}
} else {

View File

@ -26,6 +26,7 @@ public class PlayersPageGUI extends OrcInventory {
private final static String path = "options.players.";
private static HashMap<UUID, Pair<Integer, Integer>> pages = new HashMap<>();
@SuppressWarnings("deprecation")
public PlayersPageGUI(int page, UUID ex, HashMap<UUID, String> players, int next, int before) {
super("Players added to this world", GuiConfig.getRows("options.players"), false);
pages.put(ex, Pair.of(next, before));
@ -65,7 +66,7 @@ public class PlayersPageGUI extends OrcInventory {
YamlConfiguration cfg = GuiConfig.getConfig();
OrcItem oi = null;
try {
oi = new OrcItem(GuiConfig.getId(cfg, path), GuiConfig.getData(cfg, path),
oi = new OrcItem(GuiConfig.getMaterial(cfg, path), GuiConfig.getData(cfg, path),
GuiConfig.getDisplay(cfg, path).replaceAll("%page", "" + page), GuiConfig.getLore(cfg, path));
} catch (Exception e) {
}
@ -76,11 +77,12 @@ public class PlayersPageGUI extends OrcInventory {
}
addItem(GuiConfig.getSlot(path), oi);
// Spieler reinladen
// Load players
int i = 0;
for (UUID uuid : players.keySet()) {
String name = players.get(uuid);
ItemStack is = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
Material skullItem = GuiConfig.getSkullItem();
ItemStack is = new ItemStack(skullItem, 1, (short) 3);
SkullMeta sm = (SkullMeta) is.getItemMeta();
sm.setOwner(name);
sm.setDisplayName(

View File

@ -90,6 +90,12 @@ public class SystemWorld {
* w == null
*/
public void directUnload(World w) {
if (!Bukkit.isPrimaryThread()) {
Bukkit.getScheduler().runTask(WorldSystem.getInstance(), () -> {
directUnload(w);
});
return;
}
Preconditions.checkNotNull(w, "world must not be null");
unloading = true;
w.save();
@ -126,6 +132,12 @@ public class SystemWorld {
* w == null
*/
public void unloadLater(World w) {
if (!Bukkit.isPrimaryThread()) {
Bukkit.getScheduler().runTask(WorldSystem.getInstance(), () -> {
unloadLater(w);
});
return;
}
Preconditions.checkNotNull(w, "world must not be null");
WorldUnloadEvent event = new WorldUnloadEvent(this);
Bukkit.getPluginManager().callEvent(event);
@ -177,6 +189,12 @@ public class SystemWorld {
* if player is not online
*/
public void load(Player p) {
if (!Bukkit.isPrimaryThread()) {
Bukkit.getScheduler().runTask(WorldSystem.getInstance(), () -> {
load(p);
});
return;
}
Preconditions.checkNotNull(p, "player must not be null");
Preconditions.checkArgument(p.isOnline(), "player must be online");

View File

@ -10,38 +10,41 @@ import org.bukkit.entity.Player;
import com.google.common.base.Preconditions;
import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.config.WorldConfig;
/**
* This class represents a player, on a systemworld or not
* but be carefull when accesing some methods
* when the player is not on a systemworld like toggleBuild()
* This class represents a player, on a systemworld or not but be carefull when
* accesing some methods when the player is not on a systemworld like
* toggleBuild()
*
* @author Butzlabben
* @since 15.03.2018
*/
public class WorldPlayer {
private OfflinePlayer p;
private String worldname;
/**
* @return the worldname, where the worldplayer object was created for
*/
public String getWorldname() {
return worldname;
}
/**
* toggles building for this player
*
* @return whether can build or not
*/
public boolean toggleBuild() {
Preconditions.checkArgument(isOnSystemWorld(), "player must be for this on a systemworld");
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
if (!wc.isMember(p.getUniqueId()))
if (!wc.isMember(p.getUniqueId()))
return false;
boolean build = wc.canBuild(p.getUniqueId());
build = !build;
wc.setBuild(p.getUniqueId(), build);
@ -52,7 +55,7 @@ public class WorldPlayer {
}
return build;
}
/**
* @return whether can build or not
*/
@ -61,18 +64,19 @@ public class WorldPlayer {
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
return wc.canBuild(p.getUniqueId());
}
/**
* toggles teleporting for this player
*
* @return whether can teleport or not
*/
public boolean toggleTeleport() {
Preconditions.checkArgument(isOnSystemWorld(), "player must be for this on a systemworld");
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
if (!wc.isMember(p.getUniqueId()))
if (!wc.isMember(p.getUniqueId()))
return false;
boolean teleport = wc.canTeleport(p.getUniqueId());
teleport = !teleport;
wc.setTeleport(p.getUniqueId(), teleport);
@ -83,7 +87,7 @@ public class WorldPlayer {
}
return teleport;
}
/**
* @return whether can teleport or not
*/
@ -92,19 +96,19 @@ public class WorldPlayer {
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
return wc.canTeleport(p.getUniqueId());
}
/**
* toggles gamemode changing for this player
*
* @return whether can change his gamemode or not
*/
public boolean toggleGamemode() {
Preconditions.checkArgument(isOnSystemWorld(), "player must be for this on a systemworld");
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
if (!wc.isMember(p.getUniqueId()))
if (!wc.isMember(p.getUniqueId()))
return false;
boolean changeGamemode = wc.canGamemode(p.getUniqueId());
changeGamemode = !changeGamemode;
wc.setGamemode(p.getUniqueId(), changeGamemode);
@ -115,7 +119,7 @@ public class WorldPlayer {
}
return changeGamemode;
}
/**
* @return whether can change his gamemode or not
*/
@ -124,7 +128,7 @@ public class WorldPlayer {
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
return wc.canGamemode(p.getUniqueId());
}
/**
* @return if he is a member
*/
@ -139,7 +143,7 @@ public class WorldPlayer {
this.p = p;
this.worldname = worldname;
}
public WorldPlayer(Player p) {
this(p, p.getWorld().getName());
}
@ -149,9 +153,12 @@ public class WorldPlayer {
*/
public boolean isOnSystemWorld() {
File worldconfig = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
if (!worldconfig.exists()) {
worldconfig = new File(PluginConfig.getWorlddir() + worldname + "/worldconfig.yml");
}
if (worldconfig.exists()) {
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(worldconfig);
if(cfg.getString("Informations.Owner.PlayerUUID") == null) {
if (cfg.getString("Informations.Owner.PlayerUUID") == null) {
return false;
}
return true;
@ -166,19 +173,19 @@ public class WorldPlayer {
return p;
}
/**
* @return if he ist the owner
*/
public boolean isOwnerofWorld() {
if(!isOnSystemWorld())
if (!isOnSystemWorld())
return false;
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
return wc.getOwner().equals(p.getUniqueId());
}
/**
* @param worldname of the world to be tested
* @param worldname
* of the world to be tested
* @return worldname if he is the owner of the specified world
*/
public boolean isMemberofWorld(String worldname) {

View File

@ -22,7 +22,6 @@ public class FlatGenerator extends AbstractGenerator {
setGrass(height);
}
@Override
public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) {
setBiome(biomes, Biome.PLAINS);
return result;

View File

@ -36,7 +36,6 @@ public class GridGenerator extends AbstractGenerator {
}
}
@Override
public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) {
setBiome(biomes, Biome.PLAINS);
if(grid == 16) {

View File

@ -3,15 +3,13 @@ package de.jubeki.generator;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.block.Biome;
public class VoidGenerator extends AbstractGenerator {
private final byte[][] result = new byte[16][];
@Override
public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) {
setBiome(biomes, Biome.VOID);
// setBiome(biomes, Biome.VOID);
return result;
}

View File

@ -4,25 +4,24 @@
#
options:
# How the enabled item should look like
enabled:
# ItemID, for seeing them press F3 + H
material: 351
# Data, how it should look like eg. blue, red, green
# Material name in the Material enum
material: INK_SACK
# Data, how it should look like eg. blue, red, green
data: 10
# Displayname
display: '&aEnabled'
# How the disabled item should look like
disabled:
material: 351
material: INK_SACK
data: 1
display: '&cDisabled'
# How the comming-soon item should look like
coming_soon:
material: 351
material: INK_SACK
data: 14
display: '&6Coming soon...'
@ -37,7 +36,7 @@ options:
slot:
row: 1
col: 8
material: 293
material: DIAMOND_HOE
data: 0
display: '&eReset World'
@ -51,8 +50,7 @@ options:
state:
row: 2
col: 2
material: 259
data: 0
material: FLINT_AND_STEEL
display: '&eToggle Fire'
# TNT button
@ -64,35 +62,34 @@ options:
state:
row: 2
col: 5
material: 46
data: 0
material: TNT
display: '&eToggle TNT-Explosion'
players:
skull_item:
material: SKULL_ITEM
rows: 6
nextpage:
enabled: true
slot:
row: 6
col: 9
material: 175
data: 0
material: PAPER
display: '&eNext Page'
pagebefore:
enabled: true
slot:
row: 6
col: 1
material: 175
data: 0
material: PAPER
display: '&ePage before'
currentpage:
enabled: true
slot:
row: 6
col: 5
material: 339
data: 0
material: DOUBLE_PLANT
display: '&eCurrent page: %page'
player_list_to_row: 4
playerhead:
@ -109,8 +106,7 @@ options:
state:
row: 2
col: 1
material: 286
data: 0
material: GOLD_AXE
display: '&eToggle Build-Permission'
lore:
- '&7Toggles the permission for a player'
@ -123,8 +119,7 @@ options:
state:
row: 2
col: 2
material: 426
data: 0
material: END_CRYSTAL
display: '&eToggle GameMode-Permission'
lore:
- '&7Toggles the permission for a player'
@ -137,8 +132,7 @@ options:
state:
row: 2
col: 3
material: 345
data: 0
material: COMPASS
display: '&eToggle Teleport-Permission'
lore:
- '&7Toggles the permission for a player'
@ -152,25 +146,10 @@ options:
row: 2
col: 4
material: 347
data: 0
display: '&eToggle Time-Permission'
lore:
- '&7Toggles the permission for a player'
- '&7To change the time on this world'
worldborder:
enabled: false
slot:
row: 1
col: 5
state:
row: 2
col: 5
material: 345
data: 0
display: '&eToggle Worldborder-Permission'
lore:
- '&7Toggles the permission for a player'
- '&7To change the worldborder on this world'
addmember:
enabled: false
slot:
@ -180,7 +159,6 @@ options:
row: 2
col: 6
material: 399
data: 0
display: '&eToggle Addmember-Permission'
lore:
- '&7Toggles the permission for a player'
@ -194,25 +172,10 @@ options:
row: 2
col: 6
material: 286
data: 0
display: '&eToggle Delmember-Permission'
lore:
- '&7Toggles the permission for a player'
- '&7To remove a member from this world'
addmember:
enabled: false
slot:
row: 1
col: 7
state:
row: 2
col: 7
material: 399
data: 0
display: '&eToggle Addmember-Permission'
lore:
- '&7Toggles the permission for a player'
- '&7To add a member to this world'
setpermissions:
enabled: false
slot:
@ -222,7 +185,6 @@ options:
row: 2
col: 8
material: 331
data: 0
display: '&eToggle Setpermissions-Permission'
lore:
- '&7Toggles the permission for a player'
@ -236,7 +198,6 @@ options:
row: 2
col: 9
material: 421
data: 0
display: '&eToggle Addmember-Permission'
lore:
- '&7Toggles the permission for a player'
@ -250,14 +211,12 @@ worldsystem:
slot:
row: 1
col: 4
material: 298
data: 0
material: LEATHER_HELMET
display: '&ePlayer Options'
worldoptions:
enabled: true
slot:
row: 1
col: 6
material: 2
data: 0
material: GRASS
display: '&eWorld Options'

View File

@ -2,6 +2,9 @@ name: WorldSystem
version: 2.2.0.6
author: Butzlabben
main: de.butzlabben.world.WorldSystem
api-version: 1.13
loadbefore: [FastAsyncWorldEdit, WorldEdit]
commands: