Update to 1.13

This commit is contained in:
Bradley Hilton 2019-04-15 11:00:17 -05:00
parent 72ab3dae5d
commit 36f515864f
14 changed files with 15 additions and 912 deletions

14
pom.xml
View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.graywolf336</groupId>
@ -56,14 +57,14 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<version>1.13.2-R0.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<version>1.13.2-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
@ -71,7 +72,7 @@
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>6.1</version>
<version>7.0.0-SNAPSHOT</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
@ -167,7 +168,6 @@
<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<!-- <sourceDirectory>${basedir}/src</sourceDirectory> -->
<defaultGoal>clean install test</defaultGoal>
<resources>
@ -324,12 +324,12 @@
<repository>
<id>repo-release</id>
<name>Jail Releases</name>
<url>https://repo2.craftyn.com/repository/internal/</url>
<url>https://repo.craftyn.com/repository/internal/</url>
</repository>
<snapshotRepository>
<id>repo-snapshot</id>
<name>Jail Snapshots</name>
<url>https://repo2.craftyn.com/repository/snapshots/</url>
<url>https://repo.craftyn.com/repository/snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>

View File

@ -19,7 +19,6 @@ import com.graywolf336.jail.enums.Settings;
import com.graywolf336.jail.events.JailPluginReloadedEvent;
import com.graywolf336.jail.interfaces.IJailPayManager;
import com.graywolf336.jail.interfaces.IJailStickManager;
import com.graywolf336.jail.legacy.LegacyManager;
import com.graywolf336.jail.listeners.CacheListener;
import com.graywolf336.jail.listeners.CellSignListener;
import com.graywolf336.jail.listeners.EntityListener;
@ -63,14 +62,6 @@ public class JailMain extends JavaPlugin {
hcm = new HandCuffManager();
jm = new JailManager(this);
//Try to load the old stuff before we load anything, esp the storage stuff
LegacyManager lm = new LegacyManager(this);
if(lm.doWeNeedToConvert()) {
lm.convertOldData();
if(!lm.wasAnythingConverted()) getLogger().severe("We was unable to convert some, or all, of the old data.");
}
io = new JailIO(this);
io.loadLanguage();
@ -83,11 +74,6 @@ public class JailMain extends JavaPlugin {
io.loadJails();
//If we converted something, let's save EVERYTHING including the cells
if(lm.wasAnythingConverted()) {
io.saveEverything();
}
cmdHand = new CommandHandler(this);
jh = new JailHandler(this);
pm = new PrisonerManager(this);

View File

@ -7,7 +7,6 @@ import java.util.UUID;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@ -233,14 +232,6 @@ public class PrisonerManager {
//only eject them if they're inside a vehicle and also eject anyone else on top of them
if(player.isInsideVehicle()) {
player.getVehicle().eject();
if (Util.doesClassHaveThisMethod(Entity.class, "getPassengers")) {
player.getPassengers().forEach(e -> e.eject());
} else {
//Ideally we should @SurpressWarnings due to the handling this, but leaving this here for now
player.getPassenger().eject();
}
player.eject();
}
@ -460,18 +451,10 @@ public class PrisonerManager {
//the *future* move checkers won't be canceling our moving.
prisoner.setTeleporting(true);
//In case they have somehow got on a vehicle, let's unmount
//In case they have somehow got in a vehicle, let's unmount
//them so we can possibly teleport them
if(player.isInsideVehicle()) {
player.getVehicle().eject();
if (Util.doesClassHaveThisMethod(Entity.class, "getPassengers")) {
player.getPassengers().forEach(e -> e.eject());
} else {
//Ideally we should @SurpressWarnings due to the handling this, but leaving this here for now
player.getPassenger().eject();
}
player.eject();
}

View File

@ -205,7 +205,7 @@ public class Util {
* @return The {@link ItemStack} to use for creation
*/
public static ItemStack getWand() {
ItemStack wand = new ItemStack(Material.CLAY_BRICK);
ItemStack wand = new ItemStack(Material.BRICK);
ItemMeta meta = wand.getItemMeta();
meta.setDisplayName(ChatColor.AQUA + "Jail Wand");
LinkedList<String> lore = new LinkedList<String>();

View File

@ -1,448 +0,0 @@
package com.graywolf336.jail.legacy;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.google.common.io.Files;
import com.graywolf336.jail.JailMain;
import com.graywolf336.jail.enums.Settings;
/**
* Manages the old data from Jail 2.
*
* @author graywolf336
* @since 3.0.0
* @version 1.0.0
*/
public class LegacyManager {
private JailMain pl;
private YamlConfiguration global;
private boolean wasConverted;
public LegacyManager(JailMain plugin) {
this.pl = plugin;
this.wasConverted = false;
}
/** Returns true/false if the old config, global.yml, exists and needs to be converted. */
public boolean doWeNeedToConvert() {
return new File(pl.getDataFolder(), "global.yml").exists();
}
/**
* Returns true if we converted anything and it was successful.
*
* @return true if everything converted successfully, was if not.
*/
public boolean wasAnythingConverted() {
return this.wasConverted;
}
public boolean convertOldData() {
File f = new File(pl.getDataFolder(), "global.yml");
if(f.exists()) {
global = new YamlConfiguration();
try {
global.load(f);
} catch (FileNotFoundException e) {
//e.printStackTrace();
pl.getLogger().severe("Unable to load the old global config, file not found.");
} catch (IOException e) {
//e.printStackTrace();
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
} catch (InvalidConfigurationException e) {
//e.printStackTrace();
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
}
}else {
pl.debug("The old config file, global.yml, was not found so not loading anything.");
return false;
}
try {
pl.getLogger().info("Starting to convert Jail 2.x data to Jail 3.0, this does use a blocking call (getOfflinePlayer) so expect the server to be held up until we are finished...");
loadOldConfig();
loadOldData();
moveOldConfigs();
this.wasConverted = true;
pl.getLogger().info("...finished converting configs and data.");
return true;
}catch (Exception e) {
if(pl.inDebug()) {
e.printStackTrace();
}
pl.debug(e.getMessage());
pl.getLogger().severe("Failed to load the old configuration for some reason.");
return false;
}
}
@SuppressWarnings("deprecation")
private void loadOldConfig() {
FileConfiguration c = pl.getConfig();
int count = 0;
for(OldSetting s : OldSetting.values()) {
switch(s) {
case Debug:
if(global.contains(s.getString())) {
c.set(Settings.DEBUG.getPath(), OldSettings.getGlobalBoolean(global, s));
//Only set it true if the old config had true, this way we can still hold the debuggin over
//if the old config had it set to false but the new one has it set to true (until a restart/reload)
if(c.getBoolean(Settings.DEBUG.getPath())) pl.setDebugging(true);
pl.debug(Settings.DEBUG.getPath() + " <-- " + s.getString());
count++;
}
break;
case BroadcastJailMessage:
if(global.contains(s.getString())) {
c.set(Settings.BROADCASTJAILING.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.BROADCASTJAILING.getPath() + " <-- " + s.getString());
count++;
}
break;
case AllowUpdateNotifications:
if(global.contains(s.getString())) {
c.set(Settings.UPDATENOTIFICATIONS.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.UPDATENOTIFICATIONS.getPath() + " <-- " + s.getString());
count++;
}
break;
case ExecutedCommandsOnJail:
if(global.contains(s.getString())) {
c.set(Settings.COMMANDSONJAIL.getPath(), OldSettings.getGlobalList(global, s));
pl.debug(Settings.COMMANDSONJAIL.getPath() + " <-- " + s.getString());
count++;
}
break;
case ExecutedCommandsOnRelease:
if(global.contains(s.getString())) {
c.set(Settings.COMMANDSONRELEASE.getPath(), OldSettings.getGlobalList(global, s));
pl.debug(Settings.COMMANDSONRELEASE.getPath() + " <-- " + s.getString());
count++;
}
break;
case AutomaticMute:
if(global.contains(s.getString())) {
c.set(Settings.AUTOMATICMUTE.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.AUTOMATICMUTE.getPath() + " <-- " + s.getString());
count++;
}
break;
case StoreInventory:
if(global.contains(s.getString())) {
c.set(Settings.JAILEDSTOREINVENTORY.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.JAILEDSTOREINVENTORY.getPath() + " <-- " + s.getString());
count++;
}
break;
case CanPrisonerOpenHisChest:
if(global.contains(s.getString())) {
c.set(Settings.PRISONEROPENCHEST.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.PRISONEROPENCHEST.getPath() + " <-- " + s.getString());
count++;
}
break;
case LogJailingIntoConsole:
if(global.contains(s.getString())) {
c.set(Settings.LOGJAILINGTOCONSOLE.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.LOGJAILINGTOCONSOLE.getPath() + " <-- " + s.getString());
count++;
}
break;
case CountdownTimeWhenOffline:
if(global.contains(s.getString())) {
c.set(Settings.COUNTDOWNTIMEOFFLINE.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.COUNTDOWNTIMEOFFLINE.getPath() + " <-- " + s.getString());
count++;
}
break;
case ReleaseBackToPreviousPosition:
if(global.contains(s.getString())) {
c.set(Settings.RELEASETOPREVIOUSPOSITION.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.RELEASETOPREVIOUSPOSITION.getPath() + " <-- " + s.getString());
count++;
}
break;
case IgnorePrisonersSleepingState:
if(global.contains(s.getString())) {
c.set(Settings.IGNORESLEEPINGSTATE.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.IGNORESLEEPINGSTATE.getPath() + " <-- " + s.getString());
count++;
}
break;
case TeleportPrisonerOnRelease:
if(global.contains(s.getString())) {
c.set(Settings.TELEPORTONRELEASE.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.TELEPORTONRELEASE.getPath() + " <-- " + s.getString());
count++;
}
break;
case DefaultJailTime:
if(global.contains(s.getString())) {
c.set(Settings.DEFAULTTIME.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.DEFAULTTIME.getPath() + " <-- " + s.getString());
count++;
}
break;
case UseBukkitSchedulerTimer:
if(global.contains(s.getString())) {
c.set(Settings.USEBUKKITTIMER.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.USEBUKKITTIMER.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnableJailStick:
if(global.contains(s.getString())) {
c.set(Settings.JAILSTICKENABLED.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.JAILSTICKENABLED.getPath() + " <-- " + s.getString());
count++;
}
break;
case JailStickParameters:
if(global.contains(s.getString())) {
LinkedList<String> sticks = new LinkedList<String>();
for (String i : OldSettings.getGlobalString(global, s).split(";")) {
String[] info = i.split(",");
//item id,range,time,jail name,reason
Material m = Material.getMaterial(Integer.valueOf(info[0]).intValue());
//item name,time,jail name,reason
sticks.push(m.toString().toLowerCase() + "," + info[2] + "," + info[3] + "," + info[4]);
}
c.set(Settings.JAILSTICKSTICKS.getPath(), sticks);
pl.debug(Settings.JAILSTICKSTICKS.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnableBlockDestroyProtection:
if(global.contains(s.getString())) {
c.set(Settings.BLOCKBREAKPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.BLOCKBREAKPROTECTION.getPath() + " <-- " + s.getString());
count++;
}
break;
case BlockDestroyPenalty:
if(global.contains(s.getString())) {
c.set(Settings.BLOCKBREAKPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.BLOCKBREAKPENALTY.getPath() + " <-- " + s.getString());
count++;
}
break;
case BlockDestroyProtectionExceptions:
if(global.contains(s.getString())) {
@SuppressWarnings("unchecked")
List<String> exceptions = (List<String>) OldSettings.getGlobalList(global, s);
LinkedList<String> whitelist = new LinkedList<String>();
for(String e : exceptions) {
whitelist.add(Material.getMaterial(Integer.valueOf(e).intValue()).toString().toLowerCase());
}
c.set(Settings.BLOCKBREAKWHITELIST.getPath(), whitelist);
pl.debug(Settings.BLOCKBREAKWHITELIST.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnableBlockPlaceProtection:
if(global.contains(s.getString())) {
c.set(Settings.BLOCKPLACEPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.BLOCKPLACEPROTECTION.getPath() + " <-- " + s.getString());
count++;
}
break;
case BlockPlacePenalty:
if(global.contains(s.getString())) {
c.set(Settings.BLOCKPLACEPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.BLOCKPLACEPENALTY.getPath() + " <-- " + s.getString());
count++;
}
break;
case BlockPlaceProtectionExceptions:
if(global.contains(s.getString())) {
@SuppressWarnings("unchecked")
List<String> exceptions = (List<String>) OldSettings.getGlobalList(global, s);
LinkedList<String> whitelist = new LinkedList<String>();
for(String e : exceptions) {
whitelist.add(Material.getMaterial(Integer.valueOf(e).intValue()).toString().toLowerCase());
}
c.set(Settings.BLOCKPLACEWHITELIST.getPath(), whitelist);
pl.debug(Settings.BLOCKPLACEWHITELIST.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnablePlayerMoveProtection:
if(global.contains(s.getString())) {
c.set(Settings.MOVEPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.MOVEPROTECTION.getPath() + " <-- " + s.getString());
count++;
}
break;
case PlayerMoveProtectionPenalty:
if(global.contains(s.getString())) {
c.set(Settings.MOVEPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.MOVEPENALTY.getPath() + " <-- " + s.getString());
count++;
}
break;
case WhitelistedCommands:
if(global.contains(s.getString())) {
c.set(Settings.COMMANDWHITELIST.getPath(), OldSettings.getGlobalList(global, s));
pl.debug(Settings.COMMANDWHITELIST.getPath() + " <-- " + s.getString());
count++;
}
break;
case CommandProtectionPenalty:
if(global.contains(s.getString())) {
c.set(Settings.COMMANDPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.COMMANDPENALTY.getPath() + " <-- " + s.getString());
count++;
}
break;
case InteractionPenalty:
if(global.contains(s.getString())) {
c.set(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnableExplosionProtection:
if(global.contains(s.getString())) {
c.set(Settings.EXPLOSIONPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.EXPLOSIONPROTECTION.getPath() + " <-- " + s.getString());
count++;
}
break;
case EnableFoodControl:
if(global.contains(s.getString())) {
c.set(Settings.FOODCONTROL.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.FOODCONTROL.getPath() + " <-- " + s.getString());
count++;
}
break;
case FoodControlMinimumFood:
if(global.contains(s.getString())) {
c.set(Settings.FOODCONTROLMIN.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.FOODCONTROLMIN.getPath() + " <-- " + s.getString());
count++;
}
break;
case FoodControlMaximumFood:
if(global.contains(s.getString())) {
c.set(Settings.FOODCONTROLMAX.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.FOODCONTROLMAX.getPath() + " <-- " + s.getString());
count++;
}
break;
case PrisonersRecieveMessages:
if(global.contains(s.getString())) {
c.set(Settings.RECIEVEMESSAGES.getPath(), OldSettings.getGlobalBoolean(global, s));
pl.debug(Settings.RECIEVEMESSAGES.getPath() + " <-- " + s.getString());
count++;
}
break;
case UseMySQL:
if(global.contains(s.getString())) {
c.set("storage.type", OldSettings.getGlobalBoolean(global, s) ? "mysql" : "sqlite");
pl.debug(Settings.RECIEVEMESSAGES.getPath() + " <-- " + s.getString());
count++;
}
break;
case MySQLConn:
if(global.contains(s.getString())) {
//jdbc:mysql://localhost:3306/minecraft
String con = OldSettings.getGlobalString(global, s);
String a = con.split("//")[1];
//localhost 3306/minecraft
String[] b1 = a.split(":");
//3306 minecraft
String[] b2 = b1[1].split("/");
c.set("storage.mysql.host", b1[0]);
c.set("storage.mysql.port", b2[0]);
c.set("storage.mysql.database", b2[1]);
pl.debug("storage.mysql <-- " + s.getString());
count++;
}
break;
case MySQLUsername:
if(global.contains(s.getString())) {
c.set("storage.mysql.username", OldSettings.getGlobalString(global, s));
pl.debug("storage.mysql.username <-- " + s.getString());
count++;
}
break;
case MySQLPassword:
if(global.contains(s.getString())) {
c.set("storage.mysql.password", OldSettings.getGlobalString(global, s));
pl.debug("storage.mysql.password <-- " + s.getString());
count++;
}
break;
case PricePerMinute:
if(global.contains(s.getString())) {
c.set(Settings.JAILPAYPRICEPERMINUTE.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.JAILPAYPRICEPERMINUTE.getPath() + " <-- " + s.getString());
count++;
}
break;
case PriceForInfiniteJail:
if(global.contains(s.getString())) {
c.set(Settings.JAILPAYPRICEINFINITE.getPath(), OldSettings.getGlobalInt(global, s));
pl.debug(Settings.JAILPAYPRICEINFINITE.getPath() + " <-- " + s.getString());
count++;
}
break;
case JailPayCurrency:
if(global.contains(s.getString())) {
Material mat = Material.getMaterial(OldSettings.getGlobalInt(global, s));
if(mat != null) {
c.set(Settings.JAILPAYITEM.getPath(), mat.toString().toLowerCase());
pl.debug(Settings.JAILPAYPRICEINFINITE.getPath() + " <-- " + s.getString());
count++;
}
}
break;
default:
break;
}
}
pl.saveConfig();
pl.getLogger().info("Converted " + count + " old config value" + (count == 1 ? "" : "s") + ".");
}
private void loadOldData() throws SQLException {
OldInputOutput o = new OldInputOutput(pl, global);
o.LoadJails();
o.LoadPrisoners();
o.LoadCells();
o.freeConnection();
}
private void moveOldConfigs() throws IOException {
File to = new File(pl.getDataFolder() + File.separator + "preJail3Data");
Files.move(new File(pl.getDataFolder(), "global.yml"), to);
Files.move(new File(pl.getDataFolder(), "jails.yml"), to);
Files.move(new File(pl.getDataFolder(), "jailLog.txt"), to);
File sqlite = new File(pl.getDataFolder(), "jail.sqlite");
if(sqlite.exists()) {
Files.move(sqlite, to);
}
}
}

View File

@ -1,248 +0,0 @@
package com.graywolf336.jail.legacy;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.TimeUnit;
import org.bukkit.Location;
import org.bukkit.configuration.file.YamlConfiguration;
import com.graywolf336.jail.JailMain;
import com.graywolf336.jail.beans.Cell;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.beans.SimpleLocation;
public class OldInputOutput {
private JailMain pl;
private Connection connection;
private YamlConfiguration global;
public OldInputOutput(JailMain plugin, YamlConfiguration global) {
this.pl = plugin;
this.global = global;
}
public synchronized Connection getConnection() throws SQLException {
if (connection == null) connection = createConnection();
if(OldSettings.getGlobalBoolean(global, OldSetting.UseMySQL)) {
if(!connection.isValid(10)) connection = createConnection();
}
return connection;
}
private Connection createConnection() {
try {
if (OldSettings.getGlobalBoolean(global, OldSetting.UseMySQL)) {
Class.forName("com.mysql.jdbc.Driver");
Connection ret = DriverManager.getConnection(OldSettings.getGlobalString(global, OldSetting.MySQLConn), OldSettings.getGlobalString(global, OldSetting.MySQLUsername), OldSettings.getGlobalString(global, OldSetting.MySQLPassword));
ret.setAutoCommit(false);
return ret;
} else {
Class.forName("org.sqlite.JDBC");
Connection ret = DriverManager.getConnection("jdbc:sqlite:" + new File(pl.getDataFolder().getPath(), "jail.sqlite").getPath());
ret.setAutoCommit(false);
return ret;
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
public synchronized void freeConnection() throws SQLException {
Connection conn = getConnection();
if(conn != null) {
try {
conn.close();
conn = null;
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public void LoadJails() throws SQLException {
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM jail_zones");
ResultSet set = ps.executeQuery();
while (set.next()) {
String name = set.getString("name").toLowerCase();
double X1 = set.getDouble("X1");
double Y1 = set.getDouble("Y1");
double Z1 = set.getDouble("Z1");
double X2 = set.getDouble("X2");
double Y2 = set.getDouble("Y2");
double Z2 = set.getDouble("Z2");
double teleX = set.getDouble("teleX");
double teleY = set.getDouble("teleY");
double teleZ = set.getDouble("teleZ");
double freeX = set.getDouble("freeX");
double freeY = set.getDouble("freeY");
double freeZ = set.getDouble("freeZ");
String teleWorld = set.getString("teleWorld");
String freeWorld = set.getString("freeWorld");
Jail j = new Jail(pl, name);
j.setWorld(teleWorld);
j.setMaxPoint(new Location(pl.getServer().getWorld(teleWorld), X1, Y1, Z1));
j.setMinPoint(new Location(pl.getServer().getWorld(teleWorld), X2, Y2, Z2));
j.setTeleportIn(new Location(pl.getServer().getWorld(teleWorld), teleX, teleY, teleZ));
j.setTeleportFree(new Location(pl.getServer().getWorld(freeWorld), freeX, freeY, freeZ));
pl.getJailManager().addJail(j, false);
}
set.close();
ps.close();
}
@SuppressWarnings("deprecation")
public void LoadPrisoners() throws SQLException {
if(pl.getJailManager().getJails().size() != 0) {
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM jail_prisoners");
ResultSet set = ps.executeQuery();
while (set.next()) {
Jail j = pl.getJailManager().getJail(set.getString("JailName"));
String name = set.getString("PlayerName").toLowerCase();
String transferDest = set.getString("TransferDest");
boolean transfer = false;
if(!transferDest.isEmpty()) {
j = pl.getJailManager().getJail(transferDest);
transfer = true;
}
//In the event the jail is null (jail didn't transfer or the prisoner was jailed offline and no jail specified)
//set their jail to the first one we have
if(j == null) {
j = pl.getJailManager().getJails().iterator().next();
}
Prisoner p = new Prisoner(pl.getServer().getOfflinePlayer(name).getUniqueId().toString(), name, set.getBoolean("muted"), TimeUnit.MILLISECONDS.convert(set.getInt("RemainTime") / 6, TimeUnit.MINUTES), set.getString("Jailer"), set.getString("reason"));
p.setOfflinePending(set.getBoolean("Offline"));
p.setToBeTransferred(transfer);
String previousLoc = set.getString("PreviousPosition");
if(!previousLoc.isEmpty()) {
String[] l = previousLoc.split(",");
p.setPreviousPosition(new Location(pl.getServer().getWorld(l[0]), Integer.parseInt(l[1]), Integer.parseInt(l[2]), Integer.parseInt(l[3])));
}
j.addPrisoner(p);
//String permissions = set.getString("Permissions"); TODO
}
set.close();
ps.close();
}else {
pl.getLogger().warning("No prisoners were transferred from the old database since there aren't any jails defined.");
}
}
public void LoadCells() throws SQLException {
Connection conn;
PreparedStatement ps = null;
ResultSet set = null;
conn = getConnection();
ps = conn.prepareStatement("SELECT * FROM jail_cells");
set = ps.executeQuery();
while (set.next()) {
String jailname = set.getString("JailName");
String teleport = set.getString("Teleport");
String sign = set.getString("Sign");
String chest = set.getString("Chest");
String player = set.getString("Player");
String name = set.getString("Name");
if(name.isEmpty()) {
pl.getLogger().warning("We need a cell name in Jail 3.0, refusing to load a cell due to this.");
}else if(jailname.isEmpty()) {
pl.getLogger().warning("Refusing to load a cell (" + name + ") as it does not contain a reference to a valid Jail.");
}else {
Jail j = pl.getJailManager().getJail(jailname);
if(j == null) {
pl.getLogger().warning("Refusing to load a cell (" + name + ") as it references a Jail which doesn't exist.");
}else if(j.isValidCell(name)) {
pl.getLogger().warning("Refusing to load a duplicate named cell, " + name + ", as another one exists with that same name.");
} else {
Cell c = new Cell(name);
if(!teleport.isEmpty()) {
String[] l = teleport.split(",");
c.setTeleport(new SimpleLocation(j.getWorldName(), l[0], l[1], l[2]));
}else {
pl.getLogger().warning("Cell " + c.getName() + " in " + j.getName() + " has an empty teleport spot, might be buggy.");
}
if(!chest.isEmpty()) {
String[] ch = chest.split(",");
c.setChestLocation(new SimpleLocation(j.getWorldName(), Double.valueOf(ch[0]), Double.valueOf(ch[1]), Double.valueOf(ch[2])));
}else {
pl.getLogger().warning("Cell " + c.getName() + " in " + j.getName() + " has no chest.");
}
if(!sign.isEmpty()) {
for(String s : sign.split(";")) {
pl.debug(s);
String[] si = s.split(",");
c.addSign(new SimpleLocation(j.getWorldName(), si[0], si[1], si[2]));
}
}
//Load the prisoner if he is a valid prisoner
if(!player.isEmpty()) {
Prisoner p = j.getPrisonerByLastKnownName(player);
if(p != null) {
j.removePrisoner(p);
c.setPrisoner(p);
}
}
j.addCell(c, false);
}
}
}
set.close();
ps.close();
}
public void DeleteZone(String z) throws SQLException {
Connection conn = getConnection();
PreparedStatement ps = conn.prepareStatement("DELETE FROM jail_zones WHERE name = ?");
ps.setString(1, z);
ps.executeUpdate();
conn.commit();
ps.close();
}
public void DeleteCell(int x, int y, int z) throws SQLException {
Connection conn = getConnection();
PreparedStatement ps = conn.prepareStatement("DELETE FROM jail_cells WHERE Teleport = ?");
ps.setString(1, String.valueOf(x) + "," + String.valueOf(y) + "," + String.valueOf(z));
ps.executeUpdate();
conn.commit();
ps.close();
}
public void DeletePrisoner(String p) throws SQLException {
Connection conn = getConnection();
PreparedStatement ps = conn.prepareStatement("DELETE FROM jail_prisoners WHERE PlayerName = ?");
ps.setString(1, p);
ps.executeUpdate();
conn.commit();
ps.close();
}
}

View File

@ -1,102 +0,0 @@
package com.graywolf336.jail.legacy;
import java.util.ArrayList;
import java.util.Arrays;
public enum OldSetting {
Debug("Debug", false),//done
BroadcastJailMessage("Broadcast Jail Message", false),//done
AllowUpdateNotifications("AllowUpdateNotifications", true),//done
ExecutedCommandsOnJail("ExecutedCommandsOnJail", new ArrayList<String>()),//done
ExecutedCommandsOnRelease("ExecutedCommandsOnRelease", new ArrayList<String>()),//done
AutomaticMute("AutomaticMute", false),//done
StoreInventory("StoreInventory", true),//done
CanPrisonerOpenHisChest("CanPrisonerOpenHisChest", true),//done
LogJailingIntoConsole("LogJailingIntoConsole", false),//done
CountdownTimeWhenOffline("CountdownTimeWhenOffline", false),//done
ReleaseBackToPreviousPosition("ReleaseBackToPreviousPosition", false),//done
IgnorePrisonersSleepingState("IgnorePrisonersSleepingState", true),//done
TeleportPrisonerOnRelease("TeleportPrisonerOnRelease", true),//done
DefaultJailTime("DefaultJailTime", -1),//done
UseBukkitSchedulerTimer("UseBukkitSchedulerTimer", true),//done
JailCheckPrisonersPerPage("JailCheckPrisonersPerPage", 15),//TODO
//JailStick
EnableJailStick("EnableJailStick", false),//done
JailStickParameters("JailStickParameters", "280,5,10,,police;50,5,20,,admin"),//done
//Protections
EnableBlockDestroyProtection("Protections.EnableBlockDestroyProtection", true),//done
BlockDestroyPenalty("Protections.BlockDestroyPenalty", 15),//done
BlockDestroyProtectionExceptions("Protections.BlockDestroyProtectionExceptions", Arrays.asList(new String[]{"59"})),//done
EnableBlockPlaceProtection("Protections.EnableBlockPlaceProtection", true),//done
BlockPlacePenalty("Protections.BlockPlacePenalty", 10),//done
BlockPlaceProtectionExceptions("Protections.BlockPlaceProtectionExceptions", Arrays.asList(new String[]{"59"})),//done
EnablePlayerMoveProtection("Protections.EnablePlayerMoveProtection", true),//done
PlayerMoveProtectionPenalty("Protections.PlayerMoveProtectionPenalty", 30),//done
PlayerMoveProtectionAction("Protections.PlayerMoveProtectionAction", "teleport"),//TODO
WhitelistedCommands("Protections.WhitelistedCommands", new ArrayList<String>()),//done
CommandProtectionPenalty("Protections.CommandProtectionPenalty", 10),//done
InteractionPenalty("Protections.InteractionPenalty", 10),//done
EnableExplosionProtection("Protections.EnableExplosionProtection", true),//done
EnablePVPProtection("Protections.EnablePVPProtection", true),//TODO: ??? I haven't even tested this out!!!!
EnableChangingPermissions("Protections.EnableChangingPermissions", false),//TODO
PrisonersPermissionsGroups("Protections.PrisonersPermissionsGroups", Arrays.asList("prisoners")),//TODO
RestorePermissionsToEscapedPrisoners("Protections.RestorePermissionsToEscapedPrisoners", true),//TODO
EnableFoodControl("Protections.EnableFoodControl", true),//done
FoodControlMinimumFood("Protections.FoodControlMinimumFood", 10),//done
FoodControlMaximumFood("Protections.FoodControlMaximumFood", 20),//done
PrisonersRecieveMessages("Protections.PlayerRecievesMessages", true), //done
//JailPay
PricePerMinute("JailPay.PricePerMinute", 10),//done
PriceForInfiniteJail("JailPay.PriceForInfiniteJail", 9999),//done
JailPayCurrency("JailPay.Currency", 0),//done
//Guards
GuardHealth("Guards.GuardHealth", 8),//TODO
GuardArmor("Guards.GuardArmor", 0),//TODO
GuardDamage("Guards.GuardDamage", 2),//TODO
NumbefOfGuards("Guards.NumberOfGuards", 3),//TODO
GuardInvincibility("Guards.GuardInvincibility", false),//TODO
GuardAttackSpeedPercent("Guards.GuardAttackSpeedPercent", 100),//TODO
RespawnGuards("Guards.RespawnGuards", true),//TODO
GuardTeleportDistance("Guards.GuardTeleportDistance", 10),//TODO
GuardTypes("Guards.GuardTypes", Arrays.asList(new String[] { "Zombie", "Silverfish" })),//TODO
//Database
UseMySQL("Database.UseMySQL", false),//done
MySQLConn("Database.MySQLConn", "jdbc:mysql://localhost:3306/minecraft"),//done
MySQLUsername("Database.MySQLUSername", "root"),//done
MySQLPassword("Database.MySQLPassword", "password"),//done
//Jail Vote
VoteJailEnabled("Jail Vote.Enabled", true),//TODO
VoteJailTime("Jail Vote.Time", 5),//TODO
VoteJailReason("Jail Vote.Reason", "Jailed by players"),//TODO
VoteJailVoteTime("Jail Vote.Vote Time", 60),//TODO
//Jail swearing
EnableJailSwear("Jail Swear.Enabled", false),//TODO
JailSwearTime("Jail Swear.Time", 10),//TODO
BannedWords("Jail Swear.Banned Words", Arrays.asList(new String[] {"shit", "crap", "fuck", "cunt"}));//TODO
private String name;
private Object def;
private OldSetting(String Name, Object Def) {
name = Name;
def = Def;
}
/** The string of the node the value is stored at in the config. */
public String getString() {
return name;
}
/** The default value for this config. */
public Object getDefault() {
return def;
}
}

View File

@ -1,33 +0,0 @@
package com.graywolf336.jail.legacy;
import java.util.List;
import org.bukkit.configuration.file.YamlConfiguration;
public class OldSettings {
public static Object getGlobalProperty(YamlConfiguration config, OldSetting setting) {
Object property = config.get(setting.getString());
if (property == null) {
property = setting.getDefault();
}
return property;
}
public static Boolean getGlobalBoolean(YamlConfiguration config, OldSetting setting) {
return (Boolean) getGlobalProperty(config, setting);
}
public static Integer getGlobalInt(YamlConfiguration config, OldSetting setting) {
return (Integer) getGlobalProperty(config, setting);
}
public static String getGlobalString(YamlConfiguration config, OldSetting setting) {
return (String) getGlobalProperty(config, setting);
}
public static List<?> getGlobalList(YamlConfiguration config, OldSetting setting) {
return (List<?>) getGlobalProperty(config, setting);
}
}

View File

@ -223,7 +223,7 @@ public class ProtectionListener implements Listener {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
//Next, check if crap trampling protection is enabled
if(pl.getConfig().getBoolean(Settings.CROPTRAMPLINGPROTECTION.getPath())) {
if(event.getAction() == Action.PHYSICAL && event.getClickedBlock().getType() == Material.SOIL) {
if(event.getAction() == Action.PHYSICAL && event.getClickedBlock().getType() == Material.FARMLAND) {
if(pl.getJailManager().getJailFromLocation(event.getClickedBlock().getLocation()) != null) {
try {
long add = Util.getTime(pl.getConfig().getString(Settings.CROPTRAMPLINGPENALTY.getPath()));

View File

@ -93,7 +93,7 @@ public class CellCreationSteps {
/** Applies the second step, which is adding signs to the cell. */
private void secondStep(CreationPlayer cp, Player player, Block block) {
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) {
if (block.getType() == Material.SIGN || block.getType() == Material.WALL_SIGN) {
cp.addSign(new SimpleLocation(block.getLocation()));
//Set the sign's first text

View File

@ -24,7 +24,7 @@ public class TestUtilClass {
@BeforeClass
public static void setUp() throws Exception {
list = new ArrayList<String>();
list.add(Material.SEEDS.toString());
list.add(Material.WHEAT_SEEDS.toString());
list.add("coal_ore");
list.add("torch");
bottomCorner = new Vector(-10.50, 50.25, 100.00);
@ -58,7 +58,7 @@ public class TestUtilClass {
@Test
public void testInList() {
assertTrue(Util.isStringInsideList("seeds", list));
assertTrue(Util.isStringInsideList("wheat_seeds", list));
assertTrue(Util.isStringInsideList(Material.COAL_ORE.toString(), list));
assertTrue(Util.isStringInsideList("tOrCh", list));
}

View File

@ -83,11 +83,6 @@ public class MockPlayerInventory implements PlayerInventory {
return 0;
}
@Override
public int clear(int i, int i2) {
return 0;
}
@Override
public HumanEntity getHolder() {
return null;
@ -147,11 +142,6 @@ public class MockPlayerInventory implements PlayerInventory {
this.inventoryContents = itemStacks;
}
@Override
public boolean contains(int i) {
return false;
}
@Override
public boolean contains(Material material) {
return false;
@ -162,11 +152,6 @@ public class MockPlayerInventory implements PlayerInventory {
return false;
}
@Override
public boolean contains(int i, int i1) {
return false;
}
@Override
public boolean contains(Material material, int i) {
return false;
@ -177,11 +162,6 @@ public class MockPlayerInventory implements PlayerInventory {
return false;
}
@Override
public HashMap<Integer, ? extends ItemStack> all(int i) {
return null;
}
@Override
public HashMap<Integer, ? extends ItemStack> all(Material material) {
return null;
@ -192,11 +172,6 @@ public class MockPlayerInventory implements PlayerInventory {
return null;
}
@Override
public int first(int i) {
return 0;
}
@Override
public int first(Material material) {
return 0;
@ -212,11 +187,6 @@ public class MockPlayerInventory implements PlayerInventory {
return 0;
}
@Override
public void remove(int i) {
}
@Override
public void remove(Material material) {
@ -277,12 +247,11 @@ public class MockPlayerInventory implements PlayerInventory {
return false;
}
@SuppressWarnings("deprecation")
private static Map<String, Object> makeMap(ItemStack[] items) {
Map<String, Object> contents = new LinkedHashMap<String, Object>(
items.length);
for (int i = 0; i < items.length; i++) {
if (items[i] != null && items[i].getTypeId() != 0) {
if (items[i] != null && items[i].getType() != Material.AIR) {
contents.put(Integer.valueOf(i).toString(), items[i]);
}
}

View File

@ -100,7 +100,6 @@ public class MockWorldFactory {
}
});
when(mockWorld.getBlockAt(any(Location.class))).thenAnswer(new Answer<Block>() {
@SuppressWarnings("deprecation")
public Block answer(InvocationOnMock invocation) throws Throwable {
Location loc;
try {
@ -115,7 +114,6 @@ public class MockWorldFactory {
}
when(mockBlock.getType()).thenReturn(blockType);
when(mockBlock.getTypeId()).thenReturn(blockType.getId());
when(mockBlock.getWorld()).thenReturn(loc.getWorld());
when(mockBlock.getX()).thenReturn(loc.getBlockX());
when(mockBlock.getY()).thenReturn(loc.getBlockY());
@ -145,7 +143,6 @@ public class MockWorldFactory {
}
});
when(mockWorld.getBlockAt(any(Location.class))).thenAnswer(new Answer<Block>() {
@SuppressWarnings("deprecation")
public Block answer(InvocationOnMock invocation) throws Throwable {
Location loc;
try {
@ -158,7 +155,6 @@ public class MockWorldFactory {
Material blockType = Material.AIR;
when(mockBlock.getType()).thenReturn(blockType);
when(mockBlock.getTypeId()).thenReturn(blockType.getId());
when(mockBlock.getWorld()).thenReturn(loc.getWorld());
when(mockBlock.getX()).thenReturn(loc.getBlockX());
when(mockBlock.getY()).thenReturn(loc.getBlockY());

View File

@ -30,7 +30,7 @@ import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemFactory;
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemFactory;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.Plugin;