mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-04-10 19:16:23 +02:00
Moved some Utility to Util Class
This commit is contained in:
parent
9567feed81
commit
930d4a2028
@ -181,7 +181,7 @@ public class BCauldron {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void save(ConfigurationSection config, ConfigurationSection oldData) {
|
public static void save(ConfigurationSection config, ConfigurationSection oldData) {
|
||||||
P.p.createWorldSections(config);
|
Util.createWorldSections(config);
|
||||||
|
|
||||||
if (!bcauldrons.isEmpty()) {
|
if (!bcauldrons.isEmpty()) {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
@ -190,7 +190,7 @@ public class BCauldron {
|
|||||||
String prefix;
|
String prefix;
|
||||||
|
|
||||||
if (worldName.startsWith("DXL_")) {
|
if (worldName.startsWith("DXL_")) {
|
||||||
prefix = P.p.getDxlName(worldName) + "." + id;
|
prefix = Util.getDxlName(worldName) + "." + id;
|
||||||
} else {
|
} else {
|
||||||
prefix = cauldron.block.getWorld().getUID().toString() + "." + id;
|
prefix = cauldron.block.getWorld().getUID().toString() + "." + id;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class BPlayer {
|
|||||||
|
|
||||||
public static BPlayer get(Player player) {
|
public static BPlayer get(Player player) {
|
||||||
if (!players.isEmpty()) {
|
if (!players.isEmpty()) {
|
||||||
return players.get(P.playerString(player));
|
return players.get(Util.playerString(player));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -105,18 +105,18 @@ public class BPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPlayer(Player player) {
|
public static boolean hasPlayer(Player player) {
|
||||||
return players.containsKey(P.playerString(player));
|
return players.containsKey(Util.playerString(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new BPlayer and add it to the list
|
// Create a new BPlayer and add it to the list
|
||||||
public static BPlayer addPlayer(Player player) {
|
public static BPlayer addPlayer(Player player) {
|
||||||
BPlayer bPlayer = new BPlayer();
|
BPlayer bPlayer = new BPlayer();
|
||||||
players.put(P.playerString(player), bPlayer);
|
players.put(Util.playerString(player), bPlayer);
|
||||||
return bPlayer;
|
return bPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove(Player player) {
|
public static void remove(Player player) {
|
||||||
players.remove(P.playerString(player));
|
players.remove(Util.playerString(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int numDrunkPlayers() {
|
public static int numDrunkPlayers() {
|
||||||
@ -319,7 +319,7 @@ public class BPlayer {
|
|||||||
}
|
}
|
||||||
hangoverEffects(player);
|
hangoverEffects(player);
|
||||||
// wird der spieler noch gebraucht?
|
// wird der spieler noch gebraucht?
|
||||||
players.remove(P.playerString(player));
|
players.remove(Util.playerString(player));
|
||||||
|
|
||||||
} else if (offlineDrunk - drunkeness >= 30) {
|
} else if (offlineDrunk - drunkeness >= 30) {
|
||||||
Location randomLoc = Wakeup.getRandom(player.getLocation());
|
Location randomLoc = Wakeup.getRandom(player.getLocation());
|
||||||
@ -545,7 +545,7 @@ public class BPlayer {
|
|||||||
|
|
||||||
if (bplayer.drunkeness > 30) {
|
if (bplayer.drunkeness > 30) {
|
||||||
if (bplayer.offlineDrunk == 0) {
|
if (bplayer.offlineDrunk == 0) {
|
||||||
Player player = P.getPlayerfromString(name);
|
Player player = Util.getPlayerfromString(name);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
|
||||||
bplayer.drunkEffects(player);
|
bplayer.drunkEffects(player);
|
||||||
@ -573,7 +573,7 @@ public class BPlayer {
|
|||||||
// Prevent 0 drunkeness
|
// Prevent 0 drunkeness
|
||||||
soberPerMin++;
|
soberPerMin++;
|
||||||
}
|
}
|
||||||
if (bplayer.drain(P.getPlayerfromString(name), soberPerMin)) {
|
if (bplayer.drain(Util.getPlayerfromString(name), soberPerMin)) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
|
|
||||||
// Saves all data
|
// Saves all data
|
||||||
public static void save(ConfigurationSection config, ConfigurationSection oldData) {
|
public static void save(ConfigurationSection config, ConfigurationSection oldData) {
|
||||||
P.p.createWorldSections(config);
|
Util.createWorldSections(config);
|
||||||
|
|
||||||
if (!barrels.isEmpty()) {
|
if (!barrels.isEmpty()) {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
@ -536,7 +536,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
String prefix;
|
String prefix;
|
||||||
|
|
||||||
if (worldName.startsWith("DXL_")) {
|
if (worldName.startsWith("DXL_")) {
|
||||||
prefix = P.p.getDxlName(worldName) + "." + id;
|
prefix = Util.getDxlName(worldName) + "." + id;
|
||||||
} else {
|
} else {
|
||||||
prefix = barrel.spigot.getWorld().getUID().toString() + "." + id;
|
prefix = barrel.spigot.getWorld().getUID().toString() + "." + id;
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,16 @@
|
|||||||
package com.dre.brewery;
|
package com.dre.brewery;
|
||||||
|
|
||||||
import com.dre.brewery.filedata.*;
|
import com.dre.brewery.filedata.ConfigUpdater;
|
||||||
|
import com.dre.brewery.filedata.DataSave;
|
||||||
|
import com.dre.brewery.filedata.DataUpdater;
|
||||||
|
import com.dre.brewery.filedata.LanguageReader;
|
||||||
|
import com.dre.brewery.filedata.UpdateChecker;
|
||||||
import com.dre.brewery.integration.LogBlockBarrel;
|
import com.dre.brewery.integration.LogBlockBarrel;
|
||||||
import com.dre.brewery.integration.WGBarrel;
|
import com.dre.brewery.integration.WGBarrel;
|
||||||
import com.dre.brewery.integration.WGBarrel7;
|
import com.dre.brewery.integration.WGBarrel7;
|
||||||
import com.dre.brewery.integration.WGBarrelNew;
|
import com.dre.brewery.integration.WGBarrelNew;
|
||||||
import com.dre.brewery.integration.WGBarrelOld;
|
import com.dre.brewery.integration.WGBarrelOld;
|
||||||
import com.dre.brewery.listeners.*;
|
import com.dre.brewery.listeners.*;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -36,6 +29,15 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class P extends JavaPlugin {
|
public class P extends JavaPlugin {
|
||||||
public static P p;
|
public static P p;
|
||||||
public static final String configVersion = "1.8";
|
public static final String configVersion = "1.8";
|
||||||
@ -535,7 +537,7 @@ public class P extends JavaPlugin {
|
|||||||
|
|
||||||
for (World world : p.getServer().getWorlds()) {
|
for (World world : p.getServer().getWorlds()) {
|
||||||
if (world.getName().startsWith("DXL_")) {
|
if (world.getName().startsWith("DXL_")) {
|
||||||
loadWorldData(getDxlName(world.getName()), world);
|
loadWorldData(Util.getDxlName(world.getName()), world);
|
||||||
} else {
|
} else {
|
||||||
loadWorldData(world.getUID().toString(), world);
|
loadWorldData(world.getUID().toString(), world);
|
||||||
}
|
}
|
||||||
@ -696,7 +698,7 @@ public class P extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
saveFile(defconf, getDataFolder(), "config.yml", false);
|
Util.saveFile(defconf, getDataFolder(), "config.yml", false);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
@ -717,8 +719,8 @@ public class P extends JavaPlugin {
|
|||||||
for (String l : new String[] {"de", "en", "fr", "it"}) {
|
for (String l : new String[] {"de", "en", "fr", "it"}) {
|
||||||
File lfold = new File(configs, l);
|
File lfold = new File(configs, l);
|
||||||
try {
|
try {
|
||||||
saveFile(getResource("config/" + (use1_13 ? "v13/" : "v12/") + l + "/config.yml"), lfold, "config.yml", overwrite);
|
Util.saveFile(getResource("config/" + (use1_13 ? "v13/" : "v12/") + l + "/config.yml"), lfold, "config.yml", overwrite);
|
||||||
saveFile(getResource("languages/" + l + ".yml"), languages, l + ".yml", false); // Never overwrite languages for now
|
Util.saveFile(getResource("languages/" + l + ".yml"), languages, l + ".yml", false); // Never overwrite languages for now
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -731,53 +733,6 @@ public class P extends JavaPlugin {
|
|||||||
return NumberUtils.toInt(string, 0);
|
return NumberUtils.toInt(string, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// gets the Name of a DXL World
|
|
||||||
public String getDxlName(String worldName) {
|
|
||||||
File dungeonFolder = new File(worldName);
|
|
||||||
if (dungeonFolder.isDirectory()) {
|
|
||||||
for (File file : dungeonFolder.listFiles()) {
|
|
||||||
if (!file.isDirectory()) {
|
|
||||||
if (file.getName().startsWith(".id_")) {
|
|
||||||
return file.getName().substring(1).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return worldName;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create empty World save Sections
|
|
||||||
public void createWorldSections(ConfigurationSection section) {
|
|
||||||
for (World world : p.getServer().getWorlds()) {
|
|
||||||
String worldName = world.getName();
|
|
||||||
if (worldName.startsWith("DXL_")) {
|
|
||||||
worldName = getDxlName(worldName);
|
|
||||||
} else {
|
|
||||||
worldName = world.getUID().toString();
|
|
||||||
}
|
|
||||||
section.createSection(worldName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// prints a list of Strings at the specified page
|
|
||||||
public void list(CommandSender sender, ArrayList<String> strings, int page) {
|
|
||||||
int pages = (int) Math.ceil(strings.size() / 7F);
|
|
||||||
if (page > pages || page < 1) {
|
|
||||||
page = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(color("&7-------------- &f" + languageReader.get("Etc_Page") + " &6" + page + "&f/&6" + pages + " &7--------------"));
|
|
||||||
|
|
||||||
ListIterator<String> iter = strings.listIterator((page - 1) * 7);
|
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) {
|
|
||||||
if (iter.hasNext()) {
|
|
||||||
sender.sendMessage(color(iter.next()));
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the Block can be destroyed by the Player or something else (null)
|
// Returns true if the Block can be destroyed by the Player or something else (null)
|
||||||
public boolean blockDestroy(Block block, Player player) {
|
public boolean blockDestroy(Block block, Player player) {
|
||||||
@ -831,60 +786,9 @@ public class P extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String color(String msg) {
|
public String color(String msg) {
|
||||||
if (msg != null) {
|
return Util.color(msg);
|
||||||
msg = ChatColor.translateAlternateColorCodes('&', msg);
|
|
||||||
}
|
|
||||||
return msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
|
||||||
public static void saveFile(InputStream in, File dest, String name, boolean overwrite) throws IOException {
|
|
||||||
if (in == null) return;
|
|
||||||
if (!dest.exists()) {
|
|
||||||
dest.mkdirs();
|
|
||||||
}
|
|
||||||
File result = new File(dest, name);
|
|
||||||
if (result.exists()) {
|
|
||||||
if (overwrite) {
|
|
||||||
result.delete();
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OutputStream out = new FileOutputStream(result);
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
|
|
||||||
int length;
|
|
||||||
//copy the file content in bytes
|
|
||||||
while ((length = in.read(buffer)) > 0){
|
|
||||||
out.write(buffer, 0, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
in.close();
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns either uuid or Name of player, depending on bukkit version
|
|
||||||
public static String playerString(Player player) {
|
|
||||||
if (useUUID) {
|
|
||||||
return player.getUniqueId().toString();
|
|
||||||
} else {
|
|
||||||
return player.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns the Player if online
|
|
||||||
public static Player getPlayerfromString(String name) {
|
|
||||||
if (useUUID) {
|
|
||||||
try {
|
|
||||||
return Bukkit.getPlayer(UUID.fromString(name));
|
|
||||||
} catch (Exception e) {
|
|
||||||
return Bukkit.getPlayerExact(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Bukkit.getPlayerExact(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Runnables
|
// Runnables
|
||||||
|
|
||||||
|
@ -1,12 +1,135 @@
|
|||||||
package com.dre.brewery;
|
package com.dre.brewery;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
|
|
||||||
|
/********** Bukkit Utils **********/
|
||||||
|
|
||||||
// Check if the Chunk of a Block is loaded !without loading it in the process!
|
// Check if the Chunk of a Block is loaded !without loading it in the process!
|
||||||
public static boolean isChunkLoaded(Block block) {
|
public static boolean isChunkLoaded(Block block) {
|
||||||
return block.getWorld().isChunkLoaded(block.getX() >> 4, block.getZ() >> 4);
|
return block.getWorld().isChunkLoaded(block.getX() >> 4, block.getZ() >> 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String color(String msg) {
|
||||||
|
if (msg != null) {
|
||||||
|
msg = ChatColor.translateAlternateColorCodes('&', msg);
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns either uuid or Name of player, depending on bukkit version
|
||||||
|
public static String playerString(Player player) {
|
||||||
|
if (P.useUUID) {
|
||||||
|
return player.getUniqueId().toString();
|
||||||
|
} else {
|
||||||
|
return player.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the Player if online
|
||||||
|
public static Player getPlayerfromString(String name) {
|
||||||
|
if (P.useUUID) {
|
||||||
|
try {
|
||||||
|
return Bukkit.getPlayer(UUID.fromString(name));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return Bukkit.getPlayerExact(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Bukkit.getPlayerExact(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/********** Other Utils **********/
|
||||||
|
|
||||||
|
// prints a list of Strings at the specified page
|
||||||
|
public static void list(CommandSender sender, ArrayList<String> strings, int page) {
|
||||||
|
int pages = (int) Math.ceil(strings.size() / 7F);
|
||||||
|
if (page > pages || page < 1) {
|
||||||
|
page = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(color("&7-------------- &f" + P.p.languageReader.get("Etc_Page") + " &6" + page + "&f/&6" + pages + " &7--------------"));
|
||||||
|
|
||||||
|
ListIterator<String> iter = strings.listIterator((page - 1) * 7);
|
||||||
|
|
||||||
|
for (int i = 0; i < 7; i++) {
|
||||||
|
if (iter.hasNext()) {
|
||||||
|
sender.sendMessage(color(iter.next()));
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// gets the Name of a DXL World
|
||||||
|
public static String getDxlName(String worldName) {
|
||||||
|
File dungeonFolder = new File(worldName);
|
||||||
|
if (dungeonFolder.isDirectory()) {
|
||||||
|
for (File file : dungeonFolder.listFiles()) {
|
||||||
|
if (!file.isDirectory()) {
|
||||||
|
if (file.getName().startsWith(".id_")) {
|
||||||
|
return file.getName().substring(1).toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return worldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create empty World save Sections
|
||||||
|
public static void createWorldSections(ConfigurationSection section) {
|
||||||
|
for (World world : P.p.getServer().getWorlds()) {
|
||||||
|
String worldName = world.getName();
|
||||||
|
if (worldName.startsWith("DXL_")) {
|
||||||
|
worldName = getDxlName(worldName);
|
||||||
|
} else {
|
||||||
|
worldName = world.getUID().toString();
|
||||||
|
}
|
||||||
|
section.createSection(worldName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
public static void saveFile(InputStream in, File dest, String name, boolean overwrite) throws IOException {
|
||||||
|
if (in == null) return;
|
||||||
|
if (!dest.exists()) {
|
||||||
|
dest.mkdirs();
|
||||||
|
}
|
||||||
|
File result = new File(dest, name);
|
||||||
|
if (result.exists()) {
|
||||||
|
if (overwrite) {
|
||||||
|
result.delete();
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputStream out = new FileOutputStream(result);
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
|
||||||
|
int length;
|
||||||
|
//copy the file content in bytes
|
||||||
|
while ((length = in.read(buffer)) > 0){
|
||||||
|
out.write(buffer, 0, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
in.close();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public class Wakeup {
|
|||||||
locs.add("&6" + s + id + "&f" + s + ": " + world + " " + x + "," + y + "," + z);
|
locs.add("&6" + s + id + "&f" + s + ": " + world + " " + x + "," + y + "," + z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.list(sender, locs, page);
|
Util.list(sender, locs, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void check(CommandSender sender, int id, boolean all) {
|
public static void check(CommandSender sender, int id, boolean all) {
|
||||||
@ -211,7 +211,7 @@ public class Wakeup {
|
|||||||
checkPlayer.teleport(wakeup.loc);
|
checkPlayer.teleport(wakeup.loc);
|
||||||
} else {
|
} else {
|
||||||
p.msg(checkPlayer, p.languageReader.get("Player_WakeFilled", "" + checkId, world, "" + x , "" + y, "" + z));
|
p.msg(checkPlayer, p.languageReader.get("Player_WakeFilled", "" + checkId, world, "" + x , "" + y, "" + z));
|
||||||
}
|
}
|
||||||
p.msg(checkPlayer, p.languageReader.get("Player_WakeHint1"));
|
p.msg(checkPlayer, p.languageReader.get("Player_WakeHint1"));
|
||||||
p.msg(checkPlayer, p.languageReader.get("Player_WakeHint2"));
|
p.msg(checkPlayer, p.languageReader.get("Player_WakeHint2"));
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ public class Wakeup {
|
|||||||
|
|
||||||
|
|
||||||
public static void save(ConfigurationSection section, ConfigurationSection oldData) {
|
public static void save(ConfigurationSection section, ConfigurationSection oldData) {
|
||||||
p.createWorldSections(section);
|
Util.createWorldSections(section);
|
||||||
|
|
||||||
// loc is saved as a String in world sections with format x/y/z/pitch/yaw
|
// loc is saved as a String in world sections with format x/y/z/pitch/yaw
|
||||||
if (!wakeups.isEmpty()) {
|
if (!wakeups.isEmpty()) {
|
||||||
@ -245,7 +245,7 @@ public class Wakeup {
|
|||||||
String prefix;
|
String prefix;
|
||||||
|
|
||||||
if (worldName.startsWith("DXL_")) {
|
if (worldName.startsWith("DXL_")) {
|
||||||
prefix = p.getDxlName(worldName) + "." + id;
|
prefix = Util.getDxlName(worldName) + "." + id;
|
||||||
} else {
|
} else {
|
||||||
prefix = wakeup.loc.getWorld().getUID().toString() + "." + id;
|
prefix = wakeup.loc.getWorld().getUID().toString() + "." + id;
|
||||||
}
|
}
|
||||||
@ -264,4 +264,4 @@ public class Wakeup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package com.dre.brewery.filedata;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import com.dre.brewery.MCBarrel;
|
import com.dre.brewery.MCBarrel;
|
||||||
|
import com.dre.brewery.Util;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@ -153,7 +154,7 @@ public class DataSave extends BukkitRunnable {
|
|||||||
for (World world : P.p.getServer().getWorlds()) {
|
for (World world : P.p.getServer().getWorlds()) {
|
||||||
String worldName = world.getName();
|
String worldName = world.getName();
|
||||||
if (worldName.startsWith("DXL_")) {
|
if (worldName.startsWith("DXL_")) {
|
||||||
worldName = P.p.getDxlName(worldName);
|
worldName = Util.getDxlName(worldName);
|
||||||
root.set("Worlds." + worldName, 0);
|
root.set("Worlds." + worldName, 0);
|
||||||
} else {
|
} else {
|
||||||
worldName = world.getUID().toString();
|
worldName = world.getUID().toString();
|
||||||
|
@ -2,6 +2,7 @@ package com.dre.brewery.listeners;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.dre.brewery.Util;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -154,10 +155,10 @@ public class CommandListener implements CommandExecutor {
|
|||||||
ArrayList<String> commands = getCommands(sender);
|
ArrayList<String> commands = getCommands(sender);
|
||||||
|
|
||||||
if (page == 1) {
|
if (page == 1) {
|
||||||
p.msg(sender, "&6" + p.getDescription().getName() + " v" + p.getDescription().getVersion());
|
p.msg(sender, "&6" + p.getDescription().getName() + " v" + p.getDescription().getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
p.list(sender, commands, page);
|
Util.list(sender, commands, page);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,6 +201,7 @@ public class CommandListener implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("brewery.cmd.reload")) {
|
if (sender.hasPermission("brewery.cmd.reload")) {
|
||||||
|
cmds.add(p.languageReader.get("Help_Configname"));
|
||||||
cmds.add(p.languageReader.get("Help_Reload"));
|
cmds.add(p.languageReader.get("Help_Reload"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package com.dre.brewery.listeners;
|
package com.dre.brewery.listeners;
|
||||||
|
|
||||||
|
import com.dre.brewery.BCauldron;
|
||||||
|
import com.dre.brewery.Barrel;
|
||||||
|
import com.dre.brewery.P;
|
||||||
|
import com.dre.brewery.Util;
|
||||||
|
import com.dre.brewery.filedata.DataSave;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.event.world.WorldUnloadEvent;
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import com.dre.brewery.P;
|
|
||||||
import com.dre.brewery.BCauldron;
|
|
||||||
import com.dre.brewery.Barrel;
|
|
||||||
import com.dre.brewery.filedata.DataSave;
|
|
||||||
|
|
||||||
public class WorldListener implements Listener {
|
public class WorldListener implements Listener {
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ public class WorldListener implements Listener {
|
|||||||
World world = event.getWorld();
|
World world = event.getWorld();
|
||||||
|
|
||||||
if (world.getName().startsWith("DXL_")) {
|
if (world.getName().startsWith("DXL_")) {
|
||||||
P.p.loadWorldData(P.p.getDxlName(world.getName()), world);
|
P.p.loadWorldData(Util.getDxlName(world.getName()), world);
|
||||||
} else {
|
} else {
|
||||||
P.p.loadWorldData(world.getUID().toString(), world);
|
P.p.loadWorldData(world.getUID().toString(), world);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user