mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +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
|
||||
* and/or monetize any of our intellectual property. IntellectualCrafters is not
|
||||
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Main.java >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// 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;
|
||||
|
||||
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.FileWriter;
|
||||
import java.io.IOException;
|
||||
@ -15,62 +52,10 @@ import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
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.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
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.
|
||||
*
|
||||
@ -315,7 +300,7 @@ public class PlotMain extends JavaPlugin {
|
||||
*/
|
||||
public static Set<Plot> getPlots(final World world, final Player player) {
|
||||
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()) {
|
||||
if (plot.hasOwner()) {
|
||||
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) {
|
||||
if (plots.containsKey(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())) {
|
||||
return plots.get(world.getName());
|
||||
}
|
||||
return new HashMap<PlotId, Plot>();
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* get all plot worlds
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
* @return
|
||||
* @param world world
|
||||
* @return PlotManager
|
||||
*/
|
||||
public static PlotManager getPlotManager(final String world) {
|
||||
if (managers.containsKey(world)) {
|
||||
@ -401,8 +388,8 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @return
|
||||
* @param world to search
|
||||
* @return PlotWorld object
|
||||
*/
|
||||
public static PlotWorld getWorldSettings(final World world) {
|
||||
if (worlds.containsKey(world.getName())) {
|
||||
@ -412,8 +399,8 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @return
|
||||
* @param world to search
|
||||
* @return PlotWorld object
|
||||
*/
|
||||
public static PlotWorld getWorldSettings(final String 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
|
||||
*/
|
||||
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) {
|
||||
@ -492,7 +480,7 @@ public class PlotMain extends JavaPlugin {
|
||||
for (final String world : getPlotWorldsString()) {
|
||||
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()) {
|
||||
if (plot.owner == null) {
|
||||
@ -915,7 +903,9 @@ public class PlotMain extends JavaPlugin {
|
||||
try {
|
||||
configFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "settings.yml");
|
||||
if (!configFile.exists()) {
|
||||
configFile.createNewFile();
|
||||
if (!configFile.createNewFile()) {
|
||||
sendConsoleSenderMessage("Could not create the settings file, please create \"settings.yml\" manually.");
|
||||
}
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
setupConfig();
|
||||
@ -927,7 +917,9 @@ public class PlotMain extends JavaPlugin {
|
||||
try {
|
||||
storageFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "storage.yml");
|
||||
if (!storageFile.exists()) {
|
||||
storageFile.createNewFile();
|
||||
if (!storageFile.createNewFile()) {
|
||||
sendConsoleSenderMessage("Could not the storage settings file, please create \"storage.yml\" manually.");
|
||||
}
|
||||
}
|
||||
storage = YamlConfiguration.loadConfiguration(storageFile);
|
||||
setupStorage();
|
||||
@ -939,7 +931,9 @@ public class PlotMain extends JavaPlugin {
|
||||
try {
|
||||
translationsFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "translations.yml");
|
||||
if (!translationsFile.exists()) {
|
||||
translationsFile.createNewFile();
|
||||
if (!translationsFile.createNewFile()) {
|
||||
sendConsoleSenderMessage("Could not create the translations file, please create \"translations.yml\" manually.");
|
||||
}
|
||||
}
|
||||
translations = YamlConfiguration.loadConfiguration(translationsFile);
|
||||
setupTranslations();
|
||||
@ -1113,7 +1107,7 @@ public class PlotMain extends JavaPlugin {
|
||||
private static void setupConfig() {
|
||||
final int config_ver = 1;
|
||||
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("worldguard.enabled", Settings.WORLDGUARD);
|
||||
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");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
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()) {
|
||||
setting.getConstant();
|
||||
setting.getValue();
|
||||
options.put(setting.getConstant(), setting.getValue());
|
||||
//TODO: Make jesse expalain wth was going on here
|
||||
}
|
||||
|
||||
for (final Entry<String, Object> node : options.entrySet()) {
|
||||
@ -1185,7 +1180,7 @@ public class PlotMain extends JavaPlugin {
|
||||
worlds = config.getConfigurationSection("worlds").getKeys(false);
|
||||
}
|
||||
else {
|
||||
worlds = new HashSet<String>();
|
||||
worlds = new HashSet<>();
|
||||
}
|
||||
if ((generator != null) && (generator instanceof PlotGenerator)) {
|
||||
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
|
||||
* settings.yml
|
||||
*
|
||||
* @param world
|
||||
* @param world to load
|
||||
*/
|
||||
public static void loadWorld(final World world) {
|
||||
if (world == null) {
|
||||
@ -1260,7 +1255,7 @@ public class PlotMain extends JavaPlugin {
|
||||
*/
|
||||
private static void setupStorage() {
|
||||
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("sqlite.use", false);
|
||||
options.put("sqlite.db", "storage");
|
||||
@ -1562,8 +1557,9 @@ public class PlotMain extends JavaPlugin {
|
||||
PlotMain.plots = plots;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user