|
@@ -1,5 +1,13 @@
|
|
package de.Linus122.customoregen;
|
|
package de.Linus122.customoregen;
|
|
|
|
|
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
+import org.bukkit.Location;
|
|
|
|
+import org.bukkit.World;
|
|
|
|
+import org.bukkit.command.ConsoleCommandSender;
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.plugin.PluginManager;
|
|
|
|
+import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
+
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -10,148 +18,139 @@ import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
-import org.bukkit.Bukkit;
|
|
|
|
-import org.bukkit.Location;
|
|
|
|
-import org.bukkit.World;
|
|
|
|
-import org.bukkit.command.ConsoleCommandSender;
|
|
|
|
-import org.bukkit.entity.Player;
|
|
|
|
-import org.bukkit.plugin.PluginManager;
|
|
|
|
-import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
-
|
|
|
|
|
|
|
|
public class Main extends JavaPlugin {
|
|
public class Main extends JavaPlugin {
|
|
public static List<GeneratorConfig> generatorConfigs = new ArrayList<GeneratorConfig>();
|
|
public static List<GeneratorConfig> generatorConfigs = new ArrayList<GeneratorConfig>();
|
|
public static List<String> disabledWorlds = new ArrayList<String>();
|
|
public static List<String> disabledWorlds = new ArrayList<String>();
|
|
-
|
|
+
|
|
public static World activeInWorld;
|
|
public static World activeInWorld;
|
|
-
|
|
+
|
|
public static ConsoleCommandSender clogger;
|
|
public static ConsoleCommandSender clogger;
|
|
-
|
|
+
|
|
public void onEnable() {
|
|
public void onEnable() {
|
|
clogger = getServer().getConsoleSender();
|
|
clogger = getServer().getConsoleSender();
|
|
PluginManager pm = Bukkit.getPluginManager();
|
|
PluginManager pm = Bukkit.getPluginManager();
|
|
pm.registerEvents(new Events(), this);
|
|
pm.registerEvents(new Events(), this);
|
|
Bukkit.getPluginCommand("customoregen").setExecutor(new Cmd(this));
|
|
Bukkit.getPluginCommand("customoregen").setExecutor(new Cmd(this));
|
|
- try{
|
|
+ try {
|
|
loadConfig();
|
|
loadConfig();
|
|
- }catch(IOException e) {
|
|
+ } catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
disabledWorlds = getConfig().getStringList("disabled-worlds");
|
|
disabledWorlds = getConfig().getStringList("disabled-worlds");
|
|
- if(Bukkit.getServer().getPluginManager().isPluginEnabled("ASkyBlock")) {
|
|
+ if (Bukkit.getServer().getPluginManager().isPluginEnabled("ASkyBlock")) {
|
|
activeInWorld = com.wasteofplastic.askyblock.ASkyBlock.getIslandWorld();
|
|
activeInWorld = com.wasteofplastic.askyblock.ASkyBlock.getIslandWorld();
|
|
clogger.sendMessage("§6[CustomOreGen] §aUsing ASkyBlock as SkyBlock-Plugin");
|
|
clogger.sendMessage("§6[CustomOreGen] §aUsing ASkyBlock as SkyBlock-Plugin");
|
|
- }else if(Bukkit.getServer().getPluginManager().isPluginEnabled("AcidIsland")) {
|
|
+ } else if (Bukkit.getServer().getPluginManager().isPluginEnabled("AcidIsland")) {
|
|
activeInWorld = com.wasteofplastic.acidisland.ASkyBlock.getIslandWorld();
|
|
activeInWorld = com.wasteofplastic.acidisland.ASkyBlock.getIslandWorld();
|
|
clogger.sendMessage("§6[CustomOreGen] §aUsing AcidIsland as SkyBlock-Plugin");
|
|
clogger.sendMessage("§6[CustomOreGen] §aUsing AcidIsland as SkyBlock-Plugin");
|
|
- }else if(Bukkit.getServer().getPluginManager().isPluginEnabled("uSkyBlock")) {
|
|
+ } else if (Bukkit.getServer().getPluginManager().isPluginEnabled("uSkyBlock")) {
|
|
us.talabrek.ultimateskyblock.api.uSkyBlockAPI api = (us.talabrek.ultimateskyblock.api.uSkyBlockAPI) Bukkit.getPluginManager().getPlugin("uSkyBlock");
|
|
us.talabrek.ultimateskyblock.api.uSkyBlockAPI api = (us.talabrek.ultimateskyblock.api.uSkyBlockAPI) Bukkit.getPluginManager().getPlugin("uSkyBlock");
|
|
api.getConfig().getString("options.general.worldName");
|
|
api.getConfig().getString("options.general.worldName");
|
|
activeInWorld = Bukkit.getWorld(api.getConfig().getString("options.general.worldName"));
|
|
activeInWorld = Bukkit.getWorld(api.getConfig().getString("options.general.worldName"));
|
|
-
|
|
+
|
|
clogger.sendMessage("§6[CustomOreGen] §aUsing uSkyBlock as SkyBlock-Plugin");
|
|
clogger.sendMessage("§6[CustomOreGen] §aUsing uSkyBlock as SkyBlock-Plugin");
|
|
}
|
|
}
|
|
new Metrics(this);
|
|
new Metrics(this);
|
|
}
|
|
}
|
|
-
|
|
+
|
|
public void onDisable() {
|
|
public void onDisable() {
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
+
|
|
public static int getLevel(Player p) {
|
|
public static int getLevel(Player p) {
|
|
- if(Bukkit.getServer().getPluginManager().isPluginEnabled("ASkyBlock")) {
|
|
+ if (Bukkit.getServer().getPluginManager().isPluginEnabled("ASkyBlock")) {
|
|
return com.wasteofplastic.askyblock.ASkyBlockAPI.getInstance().getIslandLevel(p.getUniqueId());
|
|
return com.wasteofplastic.askyblock.ASkyBlockAPI.getInstance().getIslandLevel(p.getUniqueId());
|
|
}
|
|
}
|
|
- if(Bukkit.getServer().getPluginManager().isPluginEnabled("AcidIsland")) {
|
|
+ if (Bukkit.getServer().getPluginManager().isPluginEnabled("AcidIsland")) {
|
|
return com.wasteofplastic.acidisland.ASkyBlockAPI.getInstance().getIslandLevel(p.getUniqueId());
|
|
return com.wasteofplastic.acidisland.ASkyBlockAPI.getInstance().getIslandLevel(p.getUniqueId());
|
|
}
|
|
}
|
|
- if(Bukkit.getServer().getPluginManager().isPluginEnabled("uSkyBlock")) {
|
|
+ if (Bukkit.getServer().getPluginManager().isPluginEnabled("uSkyBlock")) {
|
|
- return (int) Math.floor(us.talabrek.ultimateskyblock.uSkyBlock.getAPI().getIslandLevel(p));
|
|
+ return (int) Math.floor(((us.talabrek.ultimateskyblock.api.uSkyBlockAPI) Bukkit.getPluginManager().getPlugin("uSkyBlock")).getIslandLevel(p));
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
static HashMap<UUID, Player> map = new HashMap<UUID, Player>();
|
|
static HashMap<UUID, Player> map = new HashMap<UUID, Player>();
|
|
-
|
|
+
|
|
public static Player getOwner(Location loc) {
|
|
public static Player getOwner(Location loc) {
|
|
Set<Location> set = new HashSet<Location>();
|
|
Set<Location> set = new HashSet<Location>();
|
|
set.add(loc);
|
|
set.add(loc);
|
|
-
|
|
+
|
|
UUID uuid = null;
|
|
UUID uuid = null;
|
|
- if(Bukkit.getServer().getPluginManager().isPluginEnabled("ASkyBlock")) {
|
|
+ if (Bukkit.getServer().getPluginManager().isPluginEnabled("ASkyBlock")) {
|
|
uuid = com.wasteofplastic.askyblock.ASkyBlockAPI.getInstance()
|
|
uuid = com.wasteofplastic.askyblock.ASkyBlockAPI.getInstance()
|
|
.getOwner(com.wasteofplastic.askyblock.ASkyBlockAPI.getInstance().locationIsOnIsland(set, loc));
|
|
.getOwner(com.wasteofplastic.askyblock.ASkyBlockAPI.getInstance().locationIsOnIsland(set, loc));
|
|
- }else if(Bukkit.getServer().getPluginManager().isPluginEnabled("AcidIsland")) {
|
|
+ } else if (Bukkit.getServer().getPluginManager().isPluginEnabled("AcidIsland")) {
|
|
uuid = com.wasteofplastic.acidisland.ASkyBlockAPI.getInstance()
|
|
uuid = com.wasteofplastic.acidisland.ASkyBlockAPI.getInstance()
|
|
.getOwner(com.wasteofplastic.acidisland.ASkyBlockAPI.getInstance().locationIsOnIsland(set, loc));
|
|
.getOwner(com.wasteofplastic.acidisland.ASkyBlockAPI.getInstance().locationIsOnIsland(set, loc));
|
|
- }else if(Bukkit.getServer().getPluginManager().isPluginEnabled("uSkyBlock")) {
|
|
+ } else if (Bukkit.getServer().getPluginManager().isPluginEnabled("uSkyBlock")) {
|
|
- String player = us.talabrek.ultimateskyblock.uSkyBlock.getInstance().getIslandInfo(loc).getLeader();
|
|
+ String player = ((us.talabrek.ultimateskyblock.api.uSkyBlockAPI) Bukkit.getPluginManager().getPlugin("uSkyBlock")).getIslandInfo(loc).getLeader();
|
|
- if((Bukkit.getPlayer(player) != null) && (Bukkit.getPlayer(player).getUniqueId() != null)) {
|
|
+ if ((Bukkit.getPlayer(player) != null) && (Bukkit.getPlayer(player).getUniqueId() != null)) {
|
|
uuid = Bukkit.getPlayer(player).getUniqueId();
|
|
uuid = Bukkit.getPlayer(player).getUniqueId();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
+
|
|
Player p = Bukkit.getPlayer(uuid);
|
|
Player p = Bukkit.getPlayer(uuid);
|
|
-
|
|
+
|
|
- if(p != null) {
|
|
+ if (p != null) {
|
|
map.put(uuid, p);
|
|
map.put(uuid, p);
|
|
- if(p.isOnline()) {
|
|
+ if (p.isOnline()) {
|
|
activeInWorld = p.getWorld();
|
|
activeInWorld = p.getWorld();
|
|
}
|
|
}
|
|
- }else if(map.containsKey(uuid)) {
|
|
+ } else if (map.containsKey(uuid)) {
|
|
p = (Player) map.get(uuid);
|
|
p = (Player) map.get(uuid);
|
|
}
|
|
}
|
|
-
|
|
+
|
|
return p;
|
|
return p;
|
|
}
|
|
}
|
|
-
|
|
+
|
|
public void reload() throws IOException {
|
|
public void reload() throws IOException {
|
|
reloadConfig();
|
|
reloadConfig();
|
|
loadConfig();
|
|
loadConfig();
|
|
}
|
|
}
|
|
-
|
|
+
|
|
public void loadConfig() throws IOException {
|
|
public void loadConfig() throws IOException {
|
|
File cfg = new File("plugins/CustomOreGen/config.yml");
|
|
File cfg = new File("plugins/CustomOreGen/config.yml");
|
|
File dir = new File("plugins/CustomOreGen/");
|
|
File dir = new File("plugins/CustomOreGen/");
|
|
- if(!dir.exists()) dir.mkdirs();
|
|
+ if (!dir.exists()) dir.mkdirs();
|
|
- if(!cfg.exists()){
|
|
+ if (!cfg.exists()) {
|
|
FileOutputStream writer = new FileOutputStream(new File(getDataFolder() + "/config.yml"));
|
|
FileOutputStream writer = new FileOutputStream(new File(getDataFolder() + "/config.yml"));
|
|
InputStream out = this.getClassLoader().getResourceAsStream("config.yml");
|
|
InputStream out = this.getClassLoader().getResourceAsStream("config.yml");
|
|
byte[] linebuffer = new byte[4096];
|
|
byte[] linebuffer = new byte[4096];
|
|
int lineLength = 0;
|
|
int lineLength = 0;
|
|
- while((lineLength = out.read(linebuffer)) > 0)
|
|
+ while ((lineLength = out.read(linebuffer)) > 0) {
|
|
- {
|
|
+ writer.write(linebuffer, 0, lineLength);
|
|
- writer.write(linebuffer, 0, lineLength);
|
|
|
|
}
|
|
}
|
|
- writer.close();
|
|
+ writer.close();
|
|
}
|
|
}
|
|
-
|
|
+
|
|
-
|
|
+
|
|
generatorConfigs = new ArrayList<GeneratorConfig>();
|
|
generatorConfigs = new ArrayList<GeneratorConfig>();
|
|
int i = 0;
|
|
int i = 0;
|
|
- while(true){
|
|
+ while (true) {
|
|
i++;
|
|
i++;
|
|
- if(this.getConfig().contains("generators.generator" + i)){
|
|
+ if (this.getConfig().contains("generators.generator" + i)) {
|
|
GeneratorConfig gc = new GeneratorConfig();
|
|
GeneratorConfig gc = new GeneratorConfig();
|
|
gc.permission = this.getConfig().getString("generators.generator" + i + ".permission");
|
|
gc.permission = this.getConfig().getString("generators.generator" + i + ".permission");
|
|
gc.unlock_islandLevel = this.getConfig().getInt("generators.generator" + i + ".unlock_islandLevel");
|
|
gc.unlock_islandLevel = this.getConfig().getInt("generators.generator" + i + ".unlock_islandLevel");
|
|
- for(String raw : this.getConfig().getStringList("generators.generator" + i + ".blocks")){
|
|
+ for (String raw : this.getConfig().getStringList("generators.generator" + i + ".blocks")) {
|
|
- try{
|
|
+ try {
|
|
- if(!raw.contains("!")){
|
|
+ if (!raw.contains("!")) {
|
|
String material = raw.split(":")[0];
|
|
String material = raw.split(":")[0];
|
|
double percent = Double.parseDouble(raw.split(":")[1]);
|
|
double percent = Double.parseDouble(raw.split(":")[1]);
|
|
gc.itemList.add(new GeneratorItem(material, (byte) 0, percent));
|
|
gc.itemList.add(new GeneratorItem(material, (byte) 0, percent));
|
|
- }else{
|
|
+ } else {
|
|
String material = raw.split("!")[0];
|
|
String material = raw.split("!")[0];
|
|
double percent = Double.parseDouble(raw.split(":")[1]);
|
|
double percent = Double.parseDouble(raw.split(":")[1]);
|
|
int damage = Integer.parseInt(raw.split("!")[1].split(":")[0]);
|
|
int damage = Integer.parseInt(raw.split("!")[1].split(":")[0]);
|
|
gc.itemList.add(new GeneratorItem(material, (byte) damage, percent));
|
|
gc.itemList.add(new GeneratorItem(material, (byte) damage, percent));
|
|
}
|
|
}
|
|
- }catch(Exception e){
|
|
+ } catch (Exception e) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
generatorConfigs.add(gc);
|
|
generatorConfigs.add(gc);
|
|
- }else{
|
|
+ } else {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|