mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Removed all warnings in the main file -> updated to new copyright format (please do this for any file you edit)
This commit is contained in:
parent
4bfe5f6453
commit
a39d50843e
@ -1,13 +1,50 @@
|
|||||||
/*
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
* and/or monetize any of our intellectual property. IntellectualCrafters is not
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
// /
|
||||||
*
|
// This program is free software; you can redistribute it and/or modify /
|
||||||
* >> File = Main.java >> Generated by: Citymonstret at 2014-08-09 01:43
|
// it under the terms of the GNU General Public License as published by /
|
||||||
*/
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
|
// (at your option) any later version. /
|
||||||
|
// /
|
||||||
|
// This program is distributed in the hope that it will be useful, /
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
|
// GNU General Public License for more details. /
|
||||||
|
// /
|
||||||
|
// You should have received a copy of the GNU General Public License /
|
||||||
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
|
// /
|
||||||
|
// You can contact us via: support@intellectualsites.com /
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.Logger.LogLevel;
|
||||||
|
import com.intellectualcrafters.plot.commands.Auto;
|
||||||
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
|
import com.intellectualcrafters.plot.database.*;
|
||||||
|
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
||||||
|
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||||
|
import com.intellectualcrafters.plot.generator.DefaultPlotManager;
|
||||||
|
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.generator.WorldGenerator;
|
||||||
|
import com.intellectualcrafters.plot.listeners.*;
|
||||||
|
import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
|
||||||
|
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import me.confuser.barapi.BarAPI;
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -15,62 +52,10 @@ import java.sql.Connection;
|
|||||||
import java.sql.DatabaseMetaData;
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import me.confuser.barapi.BarAPI;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.Logger.LogLevel;
|
|
||||||
import com.intellectualcrafters.plot.commands.Auto;
|
|
||||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
|
||||||
import com.intellectualcrafters.plot.database.MySQL;
|
|
||||||
import com.intellectualcrafters.plot.database.PlotMeConverter;
|
|
||||||
import com.intellectualcrafters.plot.database.SQLManager;
|
|
||||||
import com.intellectualcrafters.plot.database.SQLite;
|
|
||||||
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
|
||||||
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
|
||||||
import com.intellectualcrafters.plot.generator.DefaultPlotManager;
|
|
||||||
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
|
|
||||||
import com.intellectualcrafters.plot.generator.WorldGenerator;
|
|
||||||
import com.intellectualcrafters.plot.listeners.EntityListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
|
||||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.WorldEditListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.WorldGuardListener;
|
|
||||||
import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
|
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotMain class.
|
* PlotMain class.
|
||||||
*
|
*
|
||||||
@ -315,7 +300,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
public static Set<Plot> getPlots(final World world, final Player player) {
|
public static Set<Plot> getPlots(final World world, final Player player) {
|
||||||
final UUID uuid = player.getUniqueId();
|
final UUID uuid = player.getUniqueId();
|
||||||
final ArrayList<Plot> myplots = new ArrayList<Plot>();
|
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||||
for (final Plot plot : getPlots(world).values()) {
|
for (final Plot plot : getPlots(world).values()) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
if (plot.getOwner().equals(uuid)) {
|
if (plot.getOwner().equals(uuid)) {
|
||||||
@ -323,14 +308,14 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new HashSet<Plot>(myplots);
|
return new HashSet<>(myplots);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<PlotId, Plot> getPlots(final String world) {
|
public static HashMap<PlotId, Plot> getPlots(final String world) {
|
||||||
if (plots.containsKey(world)) {
|
if (plots.containsKey(world)) {
|
||||||
return plots.get(world);
|
return plots.get(world);
|
||||||
}
|
}
|
||||||
return new HashMap<PlotId, Plot>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,21 +327,23 @@ public class PlotMain extends JavaPlugin {
|
|||||||
if (plots.containsKey(world.getName())) {
|
if (plots.containsKey(world.getName())) {
|
||||||
return plots.get(world.getName());
|
return plots.get(world.getName());
|
||||||
}
|
}
|
||||||
return new HashMap<PlotId, Plot>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all plot worlds
|
* get all plot worlds
|
||||||
*/
|
*/
|
||||||
public static String[] getPlotWorlds() {
|
public static String[] getPlotWorlds() {
|
||||||
return (worlds.keySet().toArray(new String[0]));
|
Set<String> strings = worlds.keySet();
|
||||||
|
return (strings.toArray(new String[strings.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return plots worlds
|
* @return plots worlds
|
||||||
*/
|
*/
|
||||||
public static String[] getPlotWorldsString() {
|
public static String[] getPlotWorldsString() {
|
||||||
return plots.keySet().toArray(new String[0]);
|
Set<String> strings = plots.keySet();
|
||||||
|
return strings.toArray(new String[strings.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -390,8 +377,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world world
|
||||||
* @return
|
* @return PlotManager
|
||||||
*/
|
*/
|
||||||
public static PlotManager getPlotManager(final String world) {
|
public static PlotManager getPlotManager(final String world) {
|
||||||
if (managers.containsKey(world)) {
|
if (managers.containsKey(world)) {
|
||||||
@ -401,8 +388,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world to search
|
||||||
* @return
|
* @return PlotWorld object
|
||||||
*/
|
*/
|
||||||
public static PlotWorld getWorldSettings(final World world) {
|
public static PlotWorld getWorldSettings(final World world) {
|
||||||
if (worlds.containsKey(world.getName())) {
|
if (worlds.containsKey(world.getName())) {
|
||||||
@ -412,8 +399,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world to search
|
||||||
* @return
|
* @return PlotWorld object
|
||||||
*/
|
*/
|
||||||
public static PlotWorld getWorldSettings(final String world) {
|
public static PlotWorld getWorldSettings(final String world) {
|
||||||
if (worlds.containsKey(world)) {
|
if (worlds.containsKey(world)) {
|
||||||
@ -423,11 +410,12 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world world to search
|
||||||
* @return set containing the plots for a world
|
* @return set containing the plots for a world
|
||||||
*/
|
*/
|
||||||
public static Plot[] getWorldPlots(final World world) {
|
public static Plot[] getWorldPlots(final World world) {
|
||||||
return (plots.get(world.getName()).values().toArray(new Plot[0]));
|
Collection<Plot> values = plots.get(world.getName()).values();
|
||||||
|
return (values.toArray(new Plot[values.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) {
|
public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) {
|
||||||
@ -492,7 +480,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
for (final String world : getPlotWorldsString()) {
|
for (final String world : getPlotWorldsString()) {
|
||||||
if (plots.containsKey(world)) {
|
if (plots.containsKey(world)) {
|
||||||
|
|
||||||
final ArrayList<Plot> toDeletePlot = new ArrayList<Plot>();
|
final ArrayList<Plot> toDeletePlot = new ArrayList<>();
|
||||||
|
|
||||||
for (final Plot plot : plots.get(world).values()) {
|
for (final Plot plot : plots.get(world).values()) {
|
||||||
if (plot.owner == null) {
|
if (plot.owner == null) {
|
||||||
@ -915,7 +903,9 @@ public class PlotMain extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
configFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "settings.yml");
|
configFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "settings.yml");
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
configFile.createNewFile();
|
if (!configFile.createNewFile()) {
|
||||||
|
sendConsoleSenderMessage("Could not create the settings file, please create \"settings.yml\" manually.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
setupConfig();
|
setupConfig();
|
||||||
@ -927,7 +917,9 @@ public class PlotMain extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
storageFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "storage.yml");
|
storageFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "storage.yml");
|
||||||
if (!storageFile.exists()) {
|
if (!storageFile.exists()) {
|
||||||
storageFile.createNewFile();
|
if (!storageFile.createNewFile()) {
|
||||||
|
sendConsoleSenderMessage("Could not the storage settings file, please create \"storage.yml\" manually.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
storage = YamlConfiguration.loadConfiguration(storageFile);
|
storage = YamlConfiguration.loadConfiguration(storageFile);
|
||||||
setupStorage();
|
setupStorage();
|
||||||
@ -939,7 +931,9 @@ public class PlotMain extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
translationsFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "translations.yml");
|
translationsFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "translations.yml");
|
||||||
if (!translationsFile.exists()) {
|
if (!translationsFile.exists()) {
|
||||||
translationsFile.createNewFile();
|
if (!translationsFile.createNewFile()) {
|
||||||
|
sendConsoleSenderMessage("Could not create the translations file, please create \"translations.yml\" manually.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
translations = YamlConfiguration.loadConfiguration(translationsFile);
|
translations = YamlConfiguration.loadConfiguration(translationsFile);
|
||||||
setupTranslations();
|
setupTranslations();
|
||||||
@ -1113,7 +1107,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
private static void setupConfig() {
|
private static void setupConfig() {
|
||||||
final int config_ver = 1;
|
final int config_ver = 1;
|
||||||
config.set("version", config_ver);
|
config.set("version", config_ver);
|
||||||
final Map<String, Object> options = new HashMap<String, Object>();
|
final Map<String, Object> options = new HashMap<>();
|
||||||
options.put("auto_update", false);
|
options.put("auto_update", false);
|
||||||
options.put("worldguard.enabled", Settings.WORLDGUARD);
|
options.put("worldguard.enabled", Settings.WORLDGUARD);
|
||||||
options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT);
|
options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT);
|
||||||
@ -1154,12 +1148,13 @@ public class PlotMain extends JavaPlugin {
|
|||||||
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
|
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static void createConfiguration(final PlotWorld plotworld) {
|
public static void createConfiguration(final PlotWorld plotworld) {
|
||||||
final Map<String, Object> options = new HashMap<String, Object>();
|
final Map<String, Object> options = new HashMap<>();
|
||||||
|
|
||||||
for (final ConfigurationNode setting : plotworld.getSettingNodes()) {
|
for (final ConfigurationNode setting : plotworld.getSettingNodes()) {
|
||||||
setting.getConstant();
|
options.put(setting.getConstant(), setting.getValue());
|
||||||
setting.getValue();
|
//TODO: Make jesse expalain wth was going on here
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Entry<String, Object> node : options.entrySet()) {
|
for (final Entry<String, Object> node : options.entrySet()) {
|
||||||
@ -1185,7 +1180,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
worlds = config.getConfigurationSection("worlds").getKeys(false);
|
worlds = config.getConfigurationSection("worlds").getKeys(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
worlds = new HashSet<String>();
|
worlds = new HashSet<>();
|
||||||
}
|
}
|
||||||
if ((generator != null) && (generator instanceof PlotGenerator)) {
|
if ((generator != null) && (generator instanceof PlotGenerator)) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'");
|
sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'");
|
||||||
@ -1245,7 +1240,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* use this method unless the required world is preconfigured in the
|
* use this method unless the required world is preconfigured in the
|
||||||
* settings.yml
|
* settings.yml
|
||||||
*
|
*
|
||||||
* @param world
|
* @param world to load
|
||||||
*/
|
*/
|
||||||
public static void loadWorld(final World world) {
|
public static void loadWorld(final World world) {
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
@ -1260,7 +1255,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
private static void setupStorage() {
|
private static void setupStorage() {
|
||||||
storage.set("version", storage_ver);
|
storage.set("version", storage_ver);
|
||||||
final Map<String, Object> options = new HashMap<String, Object>();
|
final Map<String, Object> options = new HashMap<>();
|
||||||
options.put("mysql.use", true);
|
options.put("mysql.use", true);
|
||||||
options.put("sqlite.use", false);
|
options.put("sqlite.use", false);
|
||||||
options.put("sqlite.db", "storage");
|
options.put("sqlite.db", "storage");
|
||||||
@ -1562,8 +1557,9 @@ public class PlotMain extends JavaPlugin {
|
|||||||
PlotMain.plots = plots;
|
PlotMain.plots = plots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> plots) {
|
public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||||
PlotMain.plots = new LinkedHashMap<String, HashMap<PlotId, Plot>>();
|
PlotMain.plots = new LinkedHashMap<>();
|
||||||
PlotMain.plots.putAll(plots);
|
PlotMain.plots.putAll(plots);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user