Improves formatting, removes broken comments and updates version to 1.17
This commit is contained in:
parent
820842932a
commit
d5296c4314
141
pom.xml
141
pom.xml
@ -10,22 +10,6 @@
|
||||
<description>Ban too harsh? Mute too weak? Kicking not enough? Jail them!</description>
|
||||
<url>http://dev.bukkit.org/bukkit-plugins/jail/</url>
|
||||
|
||||
<ciManagement>
|
||||
<url>https://ci.craftyn.com/job/Jail/</url>
|
||||
<system>jenkins</system>
|
||||
</ciManagement>
|
||||
|
||||
<issueManagement>
|
||||
<url>https://github.com/graywolf336/Jail/issues</url>
|
||||
<system>GitHub</system>
|
||||
</issueManagement>
|
||||
|
||||
<scm>
|
||||
<url>https://github.com/graywolf336/Jail</url>
|
||||
<connection>scm:git:git://github.com/graywolf336/Jail.git</connection>
|
||||
<developerConnection>scm:git:git:@github.com/graywolf336/Jail.git</developerConnection>
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<project.build.number>0</project.build.number>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -48,40 +32,31 @@
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>gray-snapshot</id>
|
||||
<url>https://repo.craftyn.com/repository/graywolf336-snapshots/</url>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<version>7.2.6</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>Vault</artifactId>
|
||||
<version>1.5.6</version>
|
||||
<type>jar</type>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
@ -96,31 +71,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>1.5.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-easymock</artifactId>
|
||||
<version>1.5.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito</artifactId>
|
||||
<version>1.5.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>3.2</version>
|
||||
<scope>test</scope>
|
||||
<version>4.13.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.carrotsearch</groupId>
|
||||
@ -128,6 +79,12 @@
|
||||
<version>0.7.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- End of Test Dependencies -->
|
||||
</dependencies>
|
||||
|
||||
@ -143,26 +100,6 @@
|
||||
<project.build.number>${env.BUILD_NUMBER}</project.build.number>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>doclint-java8-disable</id>
|
||||
<activation>
|
||||
<jdk>[1.8,)</jdk>
|
||||
</activation>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.3</version>
|
||||
<configuration>
|
||||
<additionalparam>-Xdoclint:none</additionalparam>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
@ -201,10 +138,10 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@ -236,7 +173,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries />
|
||||
@ -247,7 +184,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
@ -294,42 +231,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.11</version>
|
||||
<configuration>
|
||||
<!-- Sets the VM argument line used when unit tests are run. -->
|
||||
<argLine>${surefireArgLine}</argLine>
|
||||
<parallel>methods</parallel>
|
||||
<threadCount>10</threadCount>
|
||||
<excludes>
|
||||
<exclude>**/TestCommandSender.java</exclude>
|
||||
<exclude>**/TestInstanceCreator.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.surefire</groupId>
|
||||
<artifactId>surefire-junit47</artifactId>
|
||||
<version>2.11</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>repo-release</id>
|
||||
<name>Jail Releases</name>
|
||||
<url>https://repo.craftyn.com/repository/internal/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>repo-snapshot</id>
|
||||
<name>Jail Snapshots</name>
|
||||
<url>https://repo.craftyn.com/repository/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
@ -1,15 +1,15 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
* Manages the handcuffing of players.
|
||||
*
|
||||
* <p> </p>
|
||||
*
|
||||
* <p>
|
||||
* Provides easy to use methods for adding,
|
||||
* removing, and checking if someone has
|
||||
* handcuffs.
|
||||
@ -22,17 +22,19 @@ import org.bukkit.Location;
|
||||
* </ul>
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 2.6.3
|
||||
* @version 1.0.2
|
||||
* @since 2.6.3
|
||||
*/
|
||||
public class HandCuffManager {
|
||||
private HashMap<UUID, Long> handcuffed;
|
||||
private HashMap<UUID, Location> locs;
|
||||
private final HashMap<UUID, Long> handcuffed;
|
||||
private final HashMap<UUID, Location> locs;
|
||||
|
||||
/** Constructs a new HandCuff Manager, for handling all the handcuffing. */
|
||||
/**
|
||||
* Constructs a new HandCuff Manager, for handling all the handcuffing.
|
||||
*/
|
||||
protected HandCuffManager() {
|
||||
this.handcuffed = new HashMap<UUID, Long>();
|
||||
this.locs = new HashMap<UUID, Location>();
|
||||
this.handcuffed = new HashMap<>();
|
||||
this.locs = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,18 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.beans.SimpleLocation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
@ -15,27 +25,15 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.beans.SimpleLocation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
/**
|
||||
* Handles all the saving and loading of the plugin's data.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 2.x.x
|
||||
* @version 3.0.0
|
||||
*
|
||||
* @since 2.x.x
|
||||
*/
|
||||
public class JailIO {
|
||||
private JailMain pl;
|
||||
private final JailMain pl;
|
||||
private FileConfiguration flat, records;
|
||||
private Connection con;
|
||||
private int storage = -1; //0 = flatfile, 1 = sqlite, 2 = mysql
|
||||
@ -46,7 +44,9 @@ public class JailIO {
|
||||
this.pl = plugin;
|
||||
}
|
||||
|
||||
/** Loads the language file from disk, if there is none then we save the default one. */
|
||||
/**
|
||||
* Loads the language file from disk, if there is none then we save the default one.
|
||||
*/
|
||||
protected void loadLanguage() {
|
||||
String language = pl.getConfig().getString(Settings.LANGUAGE.getPath());
|
||||
boolean save = false;
|
||||
@ -71,7 +71,8 @@ public class JailIO {
|
||||
}
|
||||
|
||||
//Make sure we have all the new language settings loaded
|
||||
if(!save) save = Lang.writeNewLanguage(YamlConfiguration.loadConfiguration(new InputStreamReader(pl.getResource("locales/en.yml"))));
|
||||
if (!save)
|
||||
save = Lang.writeNewLanguage(YamlConfiguration.loadConfiguration(new InputStreamReader(pl.getResource("locales/en.yml"))));
|
||||
|
||||
//If we have flagged to save the language file, let's save it as en.yml as this flag usually means they didn't have it loaded.
|
||||
if (save) {
|
||||
@ -211,7 +212,9 @@ public class JailIO {
|
||||
}
|
||||
}
|
||||
|
||||
/** Closes the sql connection. */
|
||||
/**
|
||||
* Closes the sql connection.
|
||||
*/
|
||||
protected void closeConnection() {
|
||||
switch (storage) {
|
||||
case 1:
|
||||
@ -455,7 +458,7 @@ public class JailIO {
|
||||
//This list contains an integer which refers to the cellid column in sql
|
||||
//this list only gets populated if there are cells which reference a jail
|
||||
//that doesn't exist anymore
|
||||
List<Integer> cellsToRemove = new LinkedList<Integer>();
|
||||
List<Integer> cellsToRemove = new LinkedList<>();
|
||||
|
||||
try {
|
||||
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM " + prefix + "cells");
|
||||
@ -515,14 +518,14 @@ public class JailIO {
|
||||
if (!cellsToRemove.isEmpty()) {
|
||||
StringBuilder ids = new StringBuilder();
|
||||
for (int c : cellsToRemove) {
|
||||
if(ids.length() == 0) ids.append("'" + c + "'");
|
||||
else ids.append("," + "'" + c + "'");
|
||||
if (ids.length() == 0) ids.append("'").append(c).append("'");
|
||||
else ids.append("," + "'").append(c).append("'");
|
||||
}
|
||||
|
||||
try {
|
||||
PreparedStatement cds = getConnection().prepareStatement("delete from " + prefix + "cells where cellid in (" + ids.toString() + ");");
|
||||
PreparedStatement cds = getConnection().prepareStatement("delete from " + prefix + "cells where cellid in (" + ids + ");");
|
||||
|
||||
pl.debug("Deleting old cells: `delete from " + prefix + "cells where cellid in (" + ids.toString() + ");`");
|
||||
pl.debug("Deleting old cells: `delete from " + prefix + "cells where cellid in (" + ids + ");`");
|
||||
|
||||
int count = cds.executeUpdate();
|
||||
pl.getLogger().info("Deleted " + count + " cells which were invalid, they either referenced a jail which are no longer valid or were duplicates.");
|
||||
@ -537,7 +540,7 @@ public class JailIO {
|
||||
//This list contains a string which refers to the name of the prisoner in sql
|
||||
//this list only gets populated if there are prisoners which reference a jail
|
||||
//that doesn't exist anymore
|
||||
List<String> prisonersToRemove = new LinkedList<String>();
|
||||
List<String> prisonersToRemove = new LinkedList<>();
|
||||
|
||||
try {
|
||||
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM " + prefix + "prisoners");
|
||||
@ -586,10 +589,10 @@ public class JailIO {
|
||||
|
||||
//Remove the invalid prisoners
|
||||
if (!prisonersToRemove.isEmpty()) {
|
||||
String names = "";
|
||||
StringBuilder names = new StringBuilder();
|
||||
for (String s : prisonersToRemove) {
|
||||
if(names.isEmpty()) names = "'" + s + "'";
|
||||
else names += "," + "'" + s + "'";
|
||||
if (names.length() == 0) names = new StringBuilder("'" + s + "'");
|
||||
else names.append("," + "'").append(s).append("'");
|
||||
}
|
||||
|
||||
try {
|
||||
@ -683,11 +686,11 @@ public class JailIO {
|
||||
for (String sign : flat.getStringList(cellNode + "signs")) {
|
||||
String[] arr = sign.split(",");
|
||||
c.addSign(new SimpleLocation(arr[0],
|
||||
Double.valueOf(arr[1]),
|
||||
Double.valueOf(arr[2]),
|
||||
Double.valueOf(arr[3]),
|
||||
Float.valueOf(arr[4]),
|
||||
Float.valueOf(arr[5])));
|
||||
Double.parseDouble(arr[1]),
|
||||
Double.parseDouble(arr[2]),
|
||||
Double.parseDouble(arr[3]),
|
||||
Float.parseFloat(arr[4]),
|
||||
Float.parseFloat(arr[5])));
|
||||
}
|
||||
|
||||
if (flat.contains(cellNode + "prisoner")) {
|
||||
@ -741,7 +744,9 @@ public class JailIO {
|
||||
pl.getLogger().info("Loaded jail " + j.getName() + " with " + j.getAllPrisoners().size() + " prisoners and " + j.getCellCount() + " cells" + (j.isEnabled() ? "." : " but the jail is disabled as the world doesn't exist or isn't loaded."));
|
||||
}
|
||||
|
||||
/** Saves everything about a jail, don't usually call this. */
|
||||
/**
|
||||
* Saves everything about a jail, don't usually call this.
|
||||
*/
|
||||
protected void saveEverything() {
|
||||
long st = System.currentTimeMillis();
|
||||
|
||||
@ -1279,10 +1284,11 @@ public class JailIO {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(records == null) records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
||||
if (records == null)
|
||||
records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
||||
|
||||
List<String> previous = records.getStringList(uuid);
|
||||
previous.add(Lang.RECORDENTRY.get(new String[] { date, username, jailer, String.valueOf(time), reason, uuid }));
|
||||
previous.add(Lang.RECORDENTRY.get(date, username, jailer, String.valueOf(time), reason, uuid));
|
||||
|
||||
records.set(uuid, previous);
|
||||
|
||||
@ -1306,7 +1312,7 @@ public class JailIO {
|
||||
*/
|
||||
public List<String> getRecordEntries(String username) {
|
||||
UUID uuid = pl.getServer().getOfflinePlayer(username).getUniqueId();
|
||||
List<String> entries = new ArrayList<String>();
|
||||
List<String> entries = new ArrayList<>();
|
||||
|
||||
switch (storage) {
|
||||
case 1:
|
||||
@ -1323,7 +1329,7 @@ public class JailIO {
|
||||
ResultSet set = ps.executeQuery();
|
||||
|
||||
while (set.next()) {
|
||||
entries.add(Lang.RECORDENTRY.get(new String[] { set.getString("date"), set.getString("username"), set.getString("jailer"), String.valueOf(set.getLong("time")), set.getString("reason"), set.getString("uuid") }));
|
||||
entries.add(Lang.RECORDENTRY.get(set.getString("date"), set.getString("username"), set.getString("jailer"), String.valueOf(set.getLong("time")), set.getString("reason"), set.getString("uuid")));
|
||||
}
|
||||
|
||||
set.close();
|
||||
@ -1335,7 +1341,8 @@ public class JailIO {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(records == null) records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
||||
if (records == null)
|
||||
records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
||||
|
||||
entries = records.getStringList(uuid.toString());
|
||||
break;
|
||||
|
@ -1,15 +1,5 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.CommandHandler;
|
||||
@ -28,13 +18,22 @@ import com.graywolf336.jail.listeners.MoveProtectionListener;
|
||||
import com.graywolf336.jail.listeners.PlayerListener;
|
||||
import com.graywolf336.jail.listeners.ProtectionListener;
|
||||
import com.graywolf336.jail.listeners.WorldListener;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* The main class for this Jail plugin, holds instances of vital classes.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 1.x.x
|
||||
* @version 3.0.0
|
||||
* @since 1.x.x
|
||||
*/
|
||||
public class JailMain extends JavaPlugin {
|
||||
private CommandHandler cmdHand;
|
||||
@ -231,7 +230,9 @@ public class JailMain extends JavaPlugin {
|
||||
getServer().getPluginManager().callEvent(new JailPluginReloadedEvent(this));
|
||||
}
|
||||
|
||||
/** Reloads/Loads the move protection listener based upon it's previous status and the config. */
|
||||
/**
|
||||
* Reloads/Loads the move protection listener based upon it's previous status and the config.
|
||||
*/
|
||||
private void reloadMoveProtection() {
|
||||
boolean moveProtection = getConfig().getBoolean(Settings.MOVEPROTECTION.getPath());
|
||||
|
||||
@ -251,7 +252,9 @@ public class JailMain extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/** Reloads the scoreboard manager class, useful when something is changed in the config about it. */
|
||||
/**
|
||||
* Reloads the scoreboard manager class, useful when something is changed in the config about it.
|
||||
*/
|
||||
private void reloadScoreBoardManager() {
|
||||
this.sbm.removeAllScoreboards();
|
||||
this.sbm = null;
|
||||
@ -268,7 +271,9 @@ public class JailMain extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/** Reloads the Jail Sticks, so the new ones can be loaded from the config. */
|
||||
/**
|
||||
* Reloads the Jail Sticks, so the new ones can be loaded from the config.
|
||||
*/
|
||||
private void reloadJailSticks() {
|
||||
if (getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||
if (this.jsm != null) {
|
||||
@ -280,7 +285,9 @@ public class JailMain extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/** Reloads the {@link JailPayManager}. */
|
||||
/**
|
||||
* Reloads the {@link JailPayManager}.
|
||||
*/
|
||||
private void reloadJailPayManager() {
|
||||
this.jpm = null;
|
||||
|
||||
@ -294,7 +301,9 @@ public class JailMain extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/** Reloads the {@link JailVoteManager}. */
|
||||
/**
|
||||
* Reloads the {@link JailVoteManager}.
|
||||
*/
|
||||
private void reloadJailVoteManager() throws Exception {
|
||||
if (this.jvm != null) {
|
||||
for (Integer i : this.jvm.getRunningTasks().values()) {
|
||||
@ -309,17 +318,15 @@ public class JailMain extends JavaPlugin {
|
||||
this.jvm = new JailVoteManager(this);
|
||||
}
|
||||
|
||||
/** Reloads the update checker, in case they changed a setting about it. */
|
||||
/**
|
||||
* Reloads the update checker, in case they changed a setting about it.
|
||||
*/
|
||||
private void reloadUpdateCheck() {
|
||||
getServer().getScheduler().cancelTask(updateCheckTask);
|
||||
update = new Update(this);
|
||||
if (getConfig().getBoolean(Settings.UPDATENOTIFICATIONS.getPath())) {
|
||||
try {
|
||||
updateCheckTask = getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
|
||||
public void run() {
|
||||
update.query();
|
||||
}
|
||||
}, 80L, Util.getTime(getConfig().getString(Settings.UPDATETIME.getPath()), TimeUnit.SECONDS) * 20).getTaskId();
|
||||
updateCheckTask = getServer().getScheduler().runTaskTimerAsynchronously(this, () -> update.query(), 80L, Util.getTime(getConfig().getString(Settings.UPDATETIME.getPath()), TimeUnit.SECONDS) * 20).getTaskId();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
getLogger().severe("Was unable to schedule the update checking, please check your time format is correct.");
|
||||
|
@ -1,18 +1,5 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.beans.CachePrisoner;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.ConfirmPlayer;
|
||||
@ -23,12 +10,24 @@ import com.graywolf336.jail.enums.Confirmation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.steps.CellCreationSteps;
|
||||
import com.graywolf336.jail.steps.JailCreationSteps;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Handles all things related to jails.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* Stores the following:
|
||||
* <ul>
|
||||
* <li>The {@link Jail jails}, which contains the prisoners and cells.</li>
|
||||
@ -38,26 +37,26 @@ import com.graywolf336.jail.steps.JailCreationSteps;
|
||||
* </ul>
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.1.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class JailManager {
|
||||
private JailMain plugin;
|
||||
private HashMap<String, Jail> jails;
|
||||
private HashMap<String, CreationPlayer> jailCreators;
|
||||
private HashMap<String, CreationPlayer> cellCreators;
|
||||
private HashMap<String, ConfirmPlayer> confirms;
|
||||
private HashMap<UUID, CachePrisoner> cache;
|
||||
private JailCreationSteps jcs;
|
||||
private CellCreationSteps ccs;
|
||||
private final JailMain plugin;
|
||||
private final HashMap<String, Jail> jails;
|
||||
private final HashMap<String, CreationPlayer> jailCreators;
|
||||
private final HashMap<String, CreationPlayer> cellCreators;
|
||||
private final HashMap<String, ConfirmPlayer> confirms;
|
||||
private final HashMap<UUID, CachePrisoner> cache;
|
||||
private final JailCreationSteps jcs;
|
||||
private final CellCreationSteps ccs;
|
||||
|
||||
protected JailManager(JailMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.jails = new HashMap<String, Jail>();
|
||||
this.jailCreators = new HashMap<String, CreationPlayer>();
|
||||
this.cellCreators = new HashMap<String, CreationPlayer>();
|
||||
this.confirms = new HashMap<String, ConfirmPlayer>();
|
||||
this.cache = new HashMap<UUID, CachePrisoner>();
|
||||
this.jails = new HashMap<>();
|
||||
this.jailCreators = new HashMap<>();
|
||||
this.cellCreators = new HashMap<>();
|
||||
this.confirms = new HashMap<>();
|
||||
this.cache = new HashMap<>();
|
||||
this.jcs = new JailCreationSteps();
|
||||
this.ccs = new CellCreationSteps();
|
||||
}
|
||||
@ -77,7 +76,7 @@ public class JailManager {
|
||||
* @return HashSet of all the jail instances.
|
||||
*/
|
||||
public HashSet<Jail> getJails() {
|
||||
return new HashSet<Jail>(jails.values());
|
||||
return new HashSet<>(jails.values());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,14 +100,14 @@ public class JailManager {
|
||||
* Gets a list of Jail names that start with the provided prefix.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* If the provided prefix is empty, then we add all of the jails.
|
||||
*
|
||||
* @param prefix The start of the jails to get
|
||||
* @return List of jails that matched the prefix
|
||||
*/
|
||||
public List<String> getJailsByPrefix(String prefix) {
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Jail j : this.jails.values())
|
||||
if (prefix.isEmpty() || StringUtil.startsWithIgnoreCase(j.getName(), prefix))
|
||||
@ -231,7 +230,7 @@ public class JailManager {
|
||||
* @return HashSet of all the Cells.
|
||||
*/
|
||||
public HashSet<Cell> getAllCells() {
|
||||
HashSet<Cell> cells = new HashSet<Cell>();
|
||||
HashSet<Cell> cells = new HashSet<>();
|
||||
|
||||
for (Jail j : jails.values())
|
||||
cells.addAll(j.getCells());
|
||||
@ -287,7 +286,7 @@ public class JailManager {
|
||||
* @return HashSet of Prisoners.
|
||||
*/
|
||||
public HashMap<UUID, Prisoner> getAllPrisoners() {
|
||||
HashMap<UUID, Prisoner> prisoners = new HashMap<UUID, Prisoner>();
|
||||
HashMap<UUID, Prisoner> prisoners = new HashMap<>();
|
||||
|
||||
for (Jail j : jails.values())
|
||||
prisoners.putAll(j.getAllPrisoners());
|
||||
@ -310,7 +309,7 @@ public class JailManager {
|
||||
* Gets the {@link Jail jail} the given player is in.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* Checks the cache first.
|
||||
*
|
||||
* @param uuid The uuid of the player who's jail we are getting.
|
||||
@ -439,7 +438,7 @@ public class JailManager {
|
||||
* Forcefully clears all the jails if name provided is null.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This method just clears them from the storage, doesn't release them.
|
||||
*
|
||||
* @param name of the jail to clear, null if all of them.
|
||||
@ -485,14 +484,14 @@ public class JailManager {
|
||||
if (j.getCell(cell).hasPrisoner()) {
|
||||
//The cell has a prisoner, so tell them to first transfer the prisoner
|
||||
//or release the prisoner
|
||||
return Lang.CELLREMOVALUNSUCCESSFUL.get(new String[] { cell, jail });
|
||||
return Lang.CELLREMOVALUNSUCCESSFUL.get(cell, jail);
|
||||
} else {
|
||||
j.removeCell(cell);
|
||||
return Lang.CELLREMOVED.get(new String[] { cell, jail });
|
||||
return Lang.CELLREMOVED.get(cell, jail);
|
||||
}
|
||||
} else {
|
||||
//No cell found by the provided name in the stated jail
|
||||
return Lang.NOCELL.get(new String[] { cell, jail });
|
||||
return Lang.NOCELL.get(cell, jail);
|
||||
}
|
||||
} else {
|
||||
//No jail found by the provided name
|
||||
@ -507,7 +506,7 @@ public class JailManager {
|
||||
* @return An array of strings of messages to send.
|
||||
*/
|
||||
public String[] deleteAllJailCells(String jail) {
|
||||
LinkedList<String> msgs = new LinkedList<String>();
|
||||
LinkedList<String> msgs = new LinkedList<>();
|
||||
|
||||
//Check if the jail name provided is a valid jail
|
||||
if (isValidJail(jail)) {
|
||||
@ -518,16 +517,16 @@ public class JailManager {
|
||||
msgs.add(Lang.NOCELLS.get(j.getName()));
|
||||
} else {
|
||||
//Keep a local copy of the hashset so that we don't get any CMEs.
|
||||
HashSet<Cell> cells = new HashSet<Cell>(j.getCells());
|
||||
HashSet<Cell> cells = new HashSet<>(j.getCells());
|
||||
|
||||
for (Cell c : cells) {
|
||||
if (c.hasPrisoner()) {
|
||||
//The cell has a prisoner, so tell them to first transfer the prisoner
|
||||
//or release the prisoner
|
||||
msgs.add(Lang.CELLREMOVALUNSUCCESSFUL.get(new String[] { c.getName(), j.getName() }));
|
||||
msgs.add(Lang.CELLREMOVALUNSUCCESSFUL.get(c.getName(), j.getName()));
|
||||
} else {
|
||||
j.removeCell(c.getName());
|
||||
msgs.add(Lang.CELLREMOVED.get(new String[] { c.getName(), j.getName() }));
|
||||
msgs.add(Lang.CELLREMOVED.get(c.getName(), j.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -536,7 +535,7 @@ public class JailManager {
|
||||
msgs.add(Lang.NOJAIL.get(jail));
|
||||
}
|
||||
|
||||
return msgs.toArray(new String[msgs.size()]);
|
||||
return msgs.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -567,7 +566,7 @@ public class JailManager {
|
||||
* Returns whether or not the player is creating a jail or a cell.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* If you want to check to see if they're just creating a jail then use {@link #isCreatingAJail(String) isCreatingAJail} or if you want to see if they're creating a cell then use {@link #isCreatingACell(String) isCreatingACell}.
|
||||
*
|
||||
* @param name The name of the player, in any case as we convert it to lowercase.
|
||||
|
@ -1,21 +1,21 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.interfaces.IJailPayManager;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.interfaces.IJailPayManager;
|
||||
|
||||
public class JailPayManager implements IJailPayManager {
|
||||
private Economy economy = null;
|
||||
private double minteCost, infiniteCost;
|
||||
private final double minteCost;
|
||||
private double infiniteCost;
|
||||
private Material item;
|
||||
private boolean infinite, timed;
|
||||
private final boolean infinite;
|
||||
private final boolean timed;
|
||||
|
||||
protected JailPayManager(JailMain plugin) {
|
||||
this.item = Material.getMaterial(plugin.getConfig().getString(Settings.JAILPAYITEM.getPath()).toUpperCase());
|
||||
@ -104,25 +104,25 @@ public class JailPayManager implements IJailPayManager {
|
||||
|
||||
public String getCurrencyName() {
|
||||
if (this.usingItemsForPayment()) {
|
||||
String name = item.toString().replaceAll("_", " ");
|
||||
StringBuilder name = new StringBuilder(item.toString().replaceAll("_", " "));
|
||||
|
||||
if(name.contains(" ")){
|
||||
String[] split = name.split(" ");
|
||||
if (name.toString().contains(" ")) {
|
||||
String[] split = name.toString().split(" ");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
split[i] = split[i].substring(0, 1).toUpperCase() + split[i].substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
name = "";
|
||||
name = new StringBuilder();
|
||||
for (String s : split) {
|
||||
name += " " + s;
|
||||
name.append(" ").append(s);
|
||||
}
|
||||
|
||||
name = name.substring(1);
|
||||
name = new StringBuilder(name.substring(1));
|
||||
} else {
|
||||
name = name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
|
||||
name = new StringBuilder(name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase());
|
||||
}
|
||||
|
||||
return name;
|
||||
return name.toString();
|
||||
} else {
|
||||
return this.economy.currencyNamePlural();
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.graywolf336.jail.beans.Stick;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.interfaces.IJailStickManager;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Manages the jail stick users.
|
||||
@ -16,15 +15,14 @@ import com.graywolf336.jail.interfaces.IJailStickManager;
|
||||
* @author graywolf336
|
||||
* @version 1.0.2
|
||||
* @since 3.0.0
|
||||
*
|
||||
*/
|
||||
public class JailStickManager implements IJailStickManager {
|
||||
private ArrayList<UUID> stickers;
|
||||
private HashMap<Material, Stick> sticks;
|
||||
private final ArrayList<UUID> stickers;
|
||||
private final HashMap<Material, Stick> sticks;
|
||||
|
||||
protected JailStickManager(JailMain plugin) {
|
||||
this.stickers = new ArrayList<UUID>();
|
||||
this.sticks = new HashMap<Material, Stick>();
|
||||
this.stickers = new ArrayList<>();
|
||||
this.sticks = new HashMap<>();
|
||||
|
||||
this.loadJailSticks(plugin);
|
||||
}
|
||||
@ -57,7 +55,7 @@ public class JailStickManager implements IJailStickManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
long time = 5;
|
||||
long time;
|
||||
try {
|
||||
time = Util.getTime(a[1]);
|
||||
} catch (Exception e) {
|
||||
@ -67,12 +65,11 @@ public class JailStickManager implements IJailStickManager {
|
||||
}
|
||||
|
||||
try {
|
||||
this.sticks.put(m, new Stick(jail, a[3], time, a.length >= 5 ? Double.valueOf(a[4]) : -1));
|
||||
this.sticks.put(m, new Stick(jail, a[3], time, a.length >= 5 ? Double.parseDouble(a[4]) : -1));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
pl.getLogger().severe(s);
|
||||
pl.getLogger().severe("Unable to create a new stick for " + a[0] + ", see the exception above for details.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,23 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Timer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.events.PrisonerTimeChangeEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Contains all the logic for counting down the time of the prisoners time.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 2.x.x
|
||||
* @version 3.0.0
|
||||
* @since 2.x.x
|
||||
*/
|
||||
public class JailTimer {
|
||||
private JailMain pl;
|
||||
private final JailMain pl;
|
||||
private Timer timer;
|
||||
private Long lastTime;
|
||||
private Long afkTime = 0L;
|
||||
@ -40,22 +36,16 @@ public class JailTimer {
|
||||
pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, new TimeEvent(), 200, 200);
|
||||
} else {
|
||||
pl.getLogger().info("Using the Java Timer.");
|
||||
timer = new Timer(10000, new ActionListener () {
|
||||
public void actionPerformed (ActionEvent event) {
|
||||
pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new TimeEvent());
|
||||
};
|
||||
});
|
||||
timer = new Timer(10000, event -> pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new TimeEvent()));
|
||||
|
||||
timer.start();
|
||||
}
|
||||
|
||||
//Save all the jail information every minute, not every 10 seconds
|
||||
pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, new Runnable() {
|
||||
public void run() {
|
||||
pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, () -> {
|
||||
for (Jail j : pl.getJailManager().getJails()) {
|
||||
pl.getJailIO().saveJail(j);
|
||||
}
|
||||
}
|
||||
}, 1200L, 1200L);
|
||||
}
|
||||
|
||||
@ -106,11 +96,7 @@ public class JailTimer {
|
||||
//This is so we kick players on the main thread
|
||||
//instead of on the async thread(s), as spigot
|
||||
//has a protection against this enabled.
|
||||
pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new Runnable() {
|
||||
public void run() {
|
||||
player.kickPlayer(Lang.AFKKICKMESSAGE.get());
|
||||
}
|
||||
});
|
||||
pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, () -> player.kickPlayer(Lang.AFKKICKMESSAGE.get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.JailVote;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
@ -12,20 +8,26 @@ import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.events.PrePrisonerJailedEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Manages all the votes to jail players.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class JailVoteManager {
|
||||
private JailMain pl;
|
||||
private HashMap<String, JailVote> votes;
|
||||
private HashMap<String, Integer> tasks;
|
||||
private String timerDesc, reason;
|
||||
private long timerTicks, jailTime;
|
||||
private int minYes;
|
||||
private final JailMain pl;
|
||||
private final HashMap<String, JailVote> votes;
|
||||
private final HashMap<String, Integer> tasks;
|
||||
private final String timerDesc;
|
||||
private final String reason;
|
||||
private final long timerTicks;
|
||||
private final long jailTime;
|
||||
private final int minYes;
|
||||
|
||||
/**
|
||||
* Creates a new instance of this Jail Vote manager.
|
||||
@ -35,8 +37,8 @@ public class JailVoteManager {
|
||||
*/
|
||||
protected JailVoteManager(JailMain plugin) throws Exception {
|
||||
this.pl = plugin;
|
||||
this.votes = new HashMap<String, JailVote>();
|
||||
this.tasks = new HashMap<String, Integer>();
|
||||
this.votes = new HashMap<>();
|
||||
this.tasks = new HashMap<>();
|
||||
this.reason = plugin.getConfig().getString(Settings.JAILVOTEREASON.getPath());
|
||||
|
||||
String timer = plugin.getConfig().getString(Settings.JAILVOTETIMER.getPath());
|
||||
@ -159,11 +161,9 @@ public class JailVoteManager {
|
||||
* @param name the name of the person who is being voted to be jailed
|
||||
*/
|
||||
public void scheduleCalculating(final String name) {
|
||||
int taskId = pl.getServer().getScheduler().runTaskLater(pl, new Runnable() {
|
||||
public void run() {
|
||||
int taskId = pl.getServer().getScheduler().runTaskLater(pl, () -> {
|
||||
doTheVoteCalculation(votes.get(name));
|
||||
tasks.remove(name);
|
||||
}
|
||||
}, timerTicks).getTaskId();
|
||||
|
||||
this.tasks.put(name, taskId);
|
||||
@ -224,7 +224,7 @@ public class JailVoteManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pl.getServer().broadcastMessage(Lang.VOTESNOTENOUGHYES.get(new String[] { v.getPlayerName(), String.valueOf(v.getYesVotes()), String.valueOf(minYes) }));
|
||||
pl.getServer().broadcastMessage(Lang.VOTESNOTENOUGHYES.get(v.getPlayerName(), String.valueOf(v.getYesVotes()), String.valueOf(minYes)));
|
||||
result = JailVoteResult.NOTENOUGHYESVOTES;
|
||||
}
|
||||
} else if (v.getYesVotes() == v.getNoVotes()) {
|
||||
|
@ -6,7 +6,7 @@ import com.graywolf336.jail.interfaces.IJailStickManager;
|
||||
* The static api interface for Jail plugin.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* If you're looking for non-static methods, please see the
|
||||
* {@link JailMain} interface.
|
||||
*
|
||||
|
@ -1,16 +1,5 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.graywolf336.jail.beans.AnyCell;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
@ -28,6 +17,16 @@ import com.graywolf336.jail.exceptions.JailRequiredException;
|
||||
import com.graywolf336.jail.exceptions.PrisonerAlreadyJailedException;
|
||||
import com.graywolf336.jail.exceptions.PrisonerRequiredException;
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Provides methods, non-statically, that do the preparing of jails, jailing, etc.
|
||||
@ -44,30 +43,26 @@ import com.graywolf336.jail.interfaces.ICell;
|
||||
* </ul>
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 2.x.x
|
||||
* @version 3.0.0
|
||||
* @since 2.x.x
|
||||
*/
|
||||
public class PrisonerManager {
|
||||
private JailMain pl;
|
||||
private ArrayList<Prisoner> releases;
|
||||
private final JailMain pl;
|
||||
private final ArrayList<Prisoner> releases;
|
||||
|
||||
protected PrisonerManager(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.releases = new ArrayList<Prisoner>();
|
||||
this.releases = new ArrayList<>();
|
||||
|
||||
// Schedule the releasing of prisoners
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
releaseScheduledPrisoners();
|
||||
}
|
||||
}, 100L, 20L);
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, this::releaseScheduledPrisoners, 100L, 20L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does everything preparing for the jailing of the provided prisoner, if they are online it forwards it to {@link #jailPrisoner(Jail, ICell, Player, Prisoner)}.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* In this we do the following:
|
||||
* <ol>
|
||||
* <li>Checks if the jail is null, if so it throws an Exception</li>
|
||||
@ -126,20 +121,16 @@ public class PrisonerManager {
|
||||
pl.getServer().getPluginManager().callEvent(new OfflinePrisonerJailedEvent(jail, cell, prisoner));
|
||||
} else {
|
||||
final ICell c = cell;
|
||||
pl.getServer().getScheduler().runTask(pl, new Runnable() {
|
||||
public void run() {
|
||||
jailPrisoner(jail, c, player, prisoner);
|
||||
}
|
||||
});
|
||||
pl.getServer().getScheduler().runTask(pl, () -> jailPrisoner(jail, c, player, prisoner));
|
||||
}
|
||||
|
||||
//Get a message ready for broadcasting or logging.
|
||||
String msg = "";
|
||||
String msg;
|
||||
|
||||
if (prisoner.getRemainingTime() < 0L)
|
||||
msg = Lang.BROADCASTMESSAGEFOREVER.get(new String[] { prisoner.getLastKnownName(), prisoner.getReason(), jail.getName(), cell == null ? "" : cell.getName() });
|
||||
msg = Lang.BROADCASTMESSAGEFOREVER.get(prisoner.getLastKnownName(), prisoner.getReason(), jail.getName(), cell == null ? "" : cell.getName());
|
||||
else
|
||||
msg = Lang.BROADCASTMESSAGEFORMINUTES.get(new String[] { prisoner.getLastKnownName(), String.valueOf(prisoner.getRemainingTimeInMinutes()), prisoner.getReason(), jail.getName(), cell == null ? "" : cell.getName() });
|
||||
msg = Lang.BROADCASTMESSAGEFORMINUTES.get(prisoner.getLastKnownName(), String.valueOf(prisoner.getRemainingTimeInMinutes()), prisoner.getReason(), jail.getName(), cell == null ? "" : cell.getName());
|
||||
|
||||
boolean broadcasted = false;
|
||||
//Broadcast the message, if it is enabled
|
||||
@ -225,7 +216,7 @@ public class PrisonerManager {
|
||||
|
||||
pl.getLogger().warning("Your jailed gamemode setting is problematic. It is currently '"
|
||||
+ pl.getConfig().getString(Settings.JAILEDGAMEMODE.getPath())
|
||||
+ "' and should be one of the following: " + gamemodes.toString());
|
||||
+ "' and should be one of the following: " + gamemodes);
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
|
||||
@ -263,8 +254,7 @@ public class PrisonerManager {
|
||||
//check if we store the inventory
|
||||
if (pl.getConfig().getBoolean(Settings.JAILEDSTOREINVENTORY.getPath(), true)) {
|
||||
final ICell theCell = cell;
|
||||
pl.getServer().getScheduler().runTaskLater(pl, new Runnable() {
|
||||
public void run() {
|
||||
pl.getServer().getScheduler().runTaskLater(pl, () -> {
|
||||
List<String> blacklist = pl.getConfig().getStringList(Settings.JAILEDINVENTORYBLACKLIST.getPath());
|
||||
//Check if there is a chest to store our items to and if it is a double chest, if not we will then serialize it
|
||||
if (theCell.hasChest()) {
|
||||
@ -303,7 +293,6 @@ public class PrisonerManager {
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getInventory().clear();
|
||||
}
|
||||
};
|
||||
}, 10);
|
||||
}
|
||||
} else {
|
||||
@ -314,8 +303,7 @@ public class PrisonerManager {
|
||||
|
||||
//There is no cell we're jailing them to, so stick them in the jail
|
||||
if (pl.getConfig().getBoolean(Settings.JAILEDSTOREINVENTORY.getPath(), true)) {
|
||||
pl.getServer().getScheduler().runTaskLater(pl, new Runnable() {
|
||||
public void run() {
|
||||
pl.getServer().getScheduler().runTaskLater(pl, () -> {
|
||||
List<String> blacklist = pl.getConfig().getStringList(Settings.JAILEDINVENTORYBLACKLIST.getPath());
|
||||
|
||||
for (ItemStack item : player.getInventory().getContents())
|
||||
@ -332,7 +320,6 @@ public class PrisonerManager {
|
||||
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getInventory().clear();
|
||||
};
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
@ -368,7 +355,7 @@ public class PrisonerManager {
|
||||
* Schedules a prisoner to be released, this method is to be used <strong>async</strong>.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* If you're wanting to unjail a prisoner, see the {@link #unJail(Jail, ICell, Player, Prisoner, CommandSender)} method.
|
||||
*
|
||||
* @param prisoner to be released.
|
||||
@ -378,7 +365,7 @@ public class PrisonerManager {
|
||||
}
|
||||
|
||||
private void releaseScheduledPrisoners() {
|
||||
ArrayList<Prisoner> lettingGo = new ArrayList<Prisoner>(releases);
|
||||
ArrayList<Prisoner> lettingGo = new ArrayList<>(releases);
|
||||
for (Prisoner p : lettingGo) {
|
||||
releases.remove(p);
|
||||
releasePrisoner(pl.getServer().getPlayer(p.getUUID()), p);
|
||||
@ -415,7 +402,7 @@ public class PrisonerManager {
|
||||
* Unjails a prisoner, <strong>sync</strong>, from jail, removing all their data.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* Throws an exception if either the jail is null or the prisoner is null.
|
||||
*
|
||||
* @param jail where the prisoner is located at
|
||||
@ -426,7 +413,6 @@ public class PrisonerManager {
|
||||
* @throws AsyncUnJailingNotSupportedException when this method is called via a thread that is <strong>not</strong> the primary thread.
|
||||
* @throws JailRequiredException when the jail provided is null.
|
||||
* @throws PrisonerRequiredException when the provided prisoner data is null.
|
||||
*
|
||||
*/
|
||||
public void unJail(final Jail jail, ICell cell, final Player player, final Prisoner prisoner, final CommandSender sender) throws AsyncUnJailingNotSupportedException, JailRequiredException, PrisonerRequiredException {
|
||||
if (!pl.getServer().isPrimaryThread()) throw new AsyncUnJailingNotSupportedException();
|
||||
@ -515,8 +501,7 @@ public class PrisonerManager {
|
||||
//let's enable their sleeping state taking place again
|
||||
player.setSleepingIgnored(false);
|
||||
|
||||
pl.getServer().getScheduler().runTaskLater(pl, new Runnable() {
|
||||
public void run() {
|
||||
pl.getServer().getScheduler().runTaskLater(pl, () -> {
|
||||
//If the config has us teleporting them back to their
|
||||
//previous position then let's do that
|
||||
boolean tpd = false;
|
||||
@ -536,7 +521,6 @@ public class PrisonerManager {
|
||||
if (pl.getConfig().getBoolean(Settings.RESTOREPREVIOUSGAMEMODE.getPath(), false)) {
|
||||
player.setGameMode(prisoner.getPreviousGameMode());
|
||||
}
|
||||
};
|
||||
}, 5);
|
||||
|
||||
//Get the commands to execute prisoners are unjailed
|
||||
@ -566,7 +550,7 @@ public class PrisonerManager {
|
||||
* Forcefully unjails a {@link Prisoner prisoner} from {@link Jail}.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This method forcefully removes all the references to this prisoner,
|
||||
* meaning if they're offline the following won't happened:
|
||||
* <ul>
|
||||
@ -574,7 +558,7 @@ public class PrisonerManager {
|
||||
* <li>Teleported anywhere</li>
|
||||
* <li>No messages sent, they'll be clueless.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>
|
||||
* But if they're online, it goes through the regular unjailing methods.
|
||||
*
|
||||
* <p>
|
||||
@ -594,7 +578,7 @@ public class PrisonerManager {
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This method forcefully removes all the references to this prisoner,
|
||||
* meaning if they're offline the following won't happened:
|
||||
* <ul>
|
||||
@ -602,7 +586,7 @@ public class PrisonerManager {
|
||||
* <li>Teleported anywhere</li>
|
||||
* <li>No messages sent, they'll be clueless.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>
|
||||
* But if they're online, it goes through the regular unjailing methods.
|
||||
*
|
||||
* <p>
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
@ -10,30 +10,25 @@ import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.ScoreboardManager;
|
||||
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ScoreBoardManager {
|
||||
private JailMain pl;
|
||||
private ScoreboardManager man;
|
||||
private HashMap<UUID, Scoreboard> boards;
|
||||
private OfflinePlayer time;
|
||||
private final JailMain pl;
|
||||
private final ScoreboardManager man;
|
||||
private final HashMap<UUID, Scoreboard> boards;
|
||||
private final OfflinePlayer time;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected ScoreBoardManager(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.man = plugin.getServer().getScoreboardManager();
|
||||
this.boards = new HashMap<UUID, Scoreboard>();
|
||||
this.boards = new HashMap<>();
|
||||
this.time = plugin.getServer().getOfflinePlayer(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTIME.getPath())));
|
||||
|
||||
//Start the task if it is enabled
|
||||
if (plugin.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
updatePrisonersTime();
|
||||
}
|
||||
}, 200L, 100L);
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, this::updatePrisonersTime, 200L, 100L);
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,9 +63,11 @@ public class ScoreBoardManager {
|
||||
player.setScoreboard(man.getMainScoreboard());
|
||||
}
|
||||
|
||||
/** Removes all of the scoreboards from the prisoners. */
|
||||
/**
|
||||
* Removes all of the scoreboards from the prisoners.
|
||||
*/
|
||||
public void removeAllScoreboards() {
|
||||
HashMap<UUID, Scoreboard> temp = new HashMap<UUID, Scoreboard>(boards);
|
||||
HashMap<UUID, Scoreboard> temp = new HashMap<>(boards);
|
||||
|
||||
for (UUID id : temp.keySet()) {
|
||||
Player p = pl.getServer().getPlayer(id);
|
||||
@ -83,7 +80,9 @@ public class ScoreBoardManager {
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates the prisoners time on their scoreboard. */
|
||||
/**
|
||||
* Updates the prisoners time on their scoreboard.
|
||||
*/
|
||||
private void updatePrisonersTime() {
|
||||
for (Jail j : pl.getJailManager().getJails()) {
|
||||
for (Prisoner p : j.getAllPrisoners().values()) {
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@ -7,14 +12,8 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
public class Update {
|
||||
private JailMain plugin;
|
||||
private final JailMain plugin;
|
||||
|
||||
// The project's unique ID
|
||||
private static final int projectID = 31139;
|
||||
@ -34,7 +33,7 @@ public class Update {
|
||||
|
||||
public void query() {
|
||||
String channel = plugin.getConfig().getString(Settings.UPDATECHANNEL.getPath(), "bukkit");
|
||||
URL url = null;
|
||||
URL url;
|
||||
|
||||
try {
|
||||
if (channel.equalsIgnoreCase("stable-dev")) {
|
||||
@ -116,23 +115,21 @@ public class Update {
|
||||
// There was an error reading the query
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().severe("There was an error checking for an update, please see the above stacktrace for details before reporting.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two version strings.
|
||||
*
|
||||
* <p>
|
||||
* Use this instead of String.compareTo() for a non-lexicographical
|
||||
* comparison that works for version strings. e.g. "1.10".compareTo("1.6").
|
||||
*
|
||||
* @note It does not work if "1.10" is supposed to be equal to "1.10.0".
|
||||
*
|
||||
* @param str1 a string of ordinal numbers separated by decimal points.
|
||||
* @param str2 a string of ordinal numbers separated by decimal points.
|
||||
* @return The result is a negative integer if str1 is _numerically_ less than str2.
|
||||
* The result is a positive integer if str1 is _numerically_ greater than str2.
|
||||
* The result is zero if the strings are _numerically_ equal.
|
||||
* @note It does not work if "1.10" is supposed to be equal to "1.10.0".
|
||||
*/
|
||||
private Integer versionCompare(String str1, String str2) {
|
||||
String[] vals1 = str1.split("\\.");
|
||||
|
@ -1,16 +1,7 @@
|
||||
package com.graywolf336.jail;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -23,15 +14,23 @@ import org.bukkit.util.io.BukkitObjectInputStream;
|
||||
import org.bukkit.util.io.BukkitObjectOutputStream;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Provides a variety of methods, static, that are used throughout the plugin.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 2.x.x
|
||||
* @version 3.1.0
|
||||
* @since 2.x.x
|
||||
*/
|
||||
public class Util {
|
||||
private final static Pattern DURATION_PATTERN = Pattern.compile("^(\\d+)\\s*(m(?:inute)?s?|h(?:ours?)?|d(?:ays?)?|s(?:econd)?s?)?$", Pattern.CASE_INSENSITIVE);
|
||||
@ -65,8 +64,8 @@ public class Util {
|
||||
* @return true if they are inside, false if not.
|
||||
*/
|
||||
private static boolean isInside(int loc, int first, int second) {
|
||||
int point1 = 0;
|
||||
int point2 = 0;
|
||||
int point1;
|
||||
int point2;
|
||||
if (first < second) {
|
||||
point1 = first;
|
||||
point2 = second;
|
||||
@ -80,7 +79,7 @@ public class Util {
|
||||
|
||||
/**
|
||||
* Checks if the given string is inside the array, ignoring the casing.
|
||||
*
|
||||
* <p>
|
||||
* <p/>
|
||||
*
|
||||
* @param value to check
|
||||
@ -97,7 +96,7 @@ public class Util {
|
||||
|
||||
/**
|
||||
* Checks if the given string is inside the list, ignoring the casing.
|
||||
*
|
||||
* <p>
|
||||
* <p/>
|
||||
*
|
||||
* @param value to check
|
||||
@ -208,7 +207,7 @@ public class Util {
|
||||
ItemStack wand = new ItemStack(Material.BRICK);
|
||||
ItemMeta meta = wand.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.AQUA + "Jail Wand");
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
LinkedList<String> lore = new LinkedList<>();
|
||||
lore.add(ChatColor.BLUE + "The wand for creating");
|
||||
lore.add(ChatColor.BLUE + "a jail or cell.");
|
||||
meta.setLore(lore);
|
||||
@ -239,19 +238,19 @@ public class Util {
|
||||
public static Long getTime(String time) throws Exception {
|
||||
if (time.equalsIgnoreCase("-1")) return -1L;
|
||||
|
||||
Long t = 10L;
|
||||
long t;
|
||||
Matcher match = DURATION_PATTERN.matcher(time);
|
||||
|
||||
if (match.matches()) {
|
||||
String units = match.group(2);
|
||||
if ("seconds".equals(units) || "second".equals(units) || "s".equals(units))
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.SECONDS);
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.SECONDS);
|
||||
else if ("minutes".equals(units) || "minute".equals(units) || "mins".equals(units) || "min".equals(units) || "m".equals(units))
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.MINUTES);
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.MINUTES);
|
||||
else if ("hours".equals(units) || "hour".equals(units) || "h".equals(units))
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.HOURS);
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.HOURS);
|
||||
else if ("days".equals(units) || "day".equals(units) || "d".equals(units))
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.DAYS);
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.DAYS);
|
||||
else {
|
||||
try {
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(time), TimeUnit.MINUTES);
|
||||
@ -328,12 +327,12 @@ public class Util {
|
||||
}
|
||||
|
||||
public static List<String> getUnusedItems(List<String> items, String[] args, boolean useP) {
|
||||
List<String> used = new ArrayList<String>();
|
||||
List<String> used = new ArrayList<>();
|
||||
for (String s : args)
|
||||
if (s.contains("-"))
|
||||
used.add(s.replace("-", ""));
|
||||
|
||||
List<String> unused = new ArrayList<String>();
|
||||
List<String> unused = new ArrayList<>();
|
||||
for (String t : items)
|
||||
if (!used.contains(t)) //don't add it if it is already used
|
||||
if (!t.equalsIgnoreCase("p") || (useP && t.equalsIgnoreCase("p")))//don't add -p unless otherwise stated
|
||||
@ -345,11 +344,10 @@ public class Util {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* A method to serialize an {@link ItemStack} array to Base64 String.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* Based off of {@link #toBase64(Inventory)}.
|
||||
*
|
||||
* @param items to turn into a Base64 String.
|
||||
@ -381,7 +379,7 @@ public class Util {
|
||||
* A method to serialize an inventory to Base64 string.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* Special thanks to Comphenix in the Bukkit forums or also known
|
||||
* as aadnk on GitHub. <a href="https://gist.github.com/aadnk/8138186">Original Source</a>
|
||||
*
|
||||
@ -411,11 +409,10 @@ public class Util {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* A method to get an {@link Inventory} from an encoded, Base64, string.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* Special thanks to Comphenix in the Bukkit forums or also known
|
||||
* as aadnk on GitHub.
|
||||
*
|
||||
@ -451,7 +448,7 @@ public class Util {
|
||||
* Gets an array of ItemStacks from Base64 string.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* Base off of {@link #fromBase64(String)}.
|
||||
*
|
||||
* @param data Base64 string to convert to ItemStack array.
|
||||
@ -484,8 +481,8 @@ public class Util {
|
||||
ItemStack[] armor = Util.itemStackArrayFromBase64(prisoner.getArmor());
|
||||
|
||||
for (ItemStack item : armor) {
|
||||
if(item == null)
|
||||
continue;
|
||||
if (item == null) {
|
||||
}
|
||||
else if (item.getType().toString().toLowerCase().contains("helmet"))
|
||||
player.getInventory().setHelmet(item);
|
||||
else if (item.getType().toString().toLowerCase().contains("chestplate"))
|
||||
@ -501,7 +498,8 @@ public class Util {
|
||||
}
|
||||
|
||||
for (ItemStack item : content.getContents()) {
|
||||
if(item == null) continue;
|
||||
if (item == null) {
|
||||
}
|
||||
else if (player.getInventory().firstEmpty() == -1)
|
||||
player.getWorld().dropItem(player.getLocation(), item);
|
||||
else
|
||||
|
@ -1,111 +1,133 @@
|
||||
package com.graywolf336.jail.beans;
|
||||
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Chest;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Chest;
|
||||
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
|
||||
/**
|
||||
* Pass this an instance of this class into the jailing of a player and they go to any open cell.
|
||||
* Pass this an instance of this class into the jailing of a player, and they go to any open cell.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class AnyCell implements ICell {
|
||||
|
||||
@Override
|
||||
public int getDatabaseID() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrisoner(Prisoner prisoner) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prisoner getPrisoner() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePrisoner() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrisoner() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllSigns(HashSet<SimpleLocation> signs) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSign(SimpleLocation sign) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<SimpleLocation> getSigns() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSigns() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignString() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInvalidSigns() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> cleanSigns() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, List<String>> updateSigns() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTeleport(SimpleLocation location) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getTeleport() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChestLocation(SimpleLocation simpleLocation) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getChestLocation() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chest getChest() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChest() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useChest() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChanged(boolean changed) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChanged() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ package com.graywolf336.jail.beans;
|
||||
* An object for storing online cached prisoners.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class CachePrisoner {
|
||||
private Jail jail;
|
||||
private Prisoner p;
|
||||
private final Jail jail;
|
||||
private final Prisoner p;
|
||||
|
||||
public CachePrisoner(Jail jail, Prisoner prisoner) {
|
||||
this.jail = jail;
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.graywolf336.jail.beans;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -12,32 +10,35 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/** Represents a Cell inside of a {@link Jail}.
|
||||
/**
|
||||
* Represents a Cell inside of a {@link Jail}.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.2.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class Cell implements ICell {
|
||||
private int databaseid;
|
||||
private String name;
|
||||
private final int databaseid;
|
||||
private final String name;
|
||||
private Prisoner p;
|
||||
private HashSet<SimpleLocation> signs;
|
||||
private final HashSet<SimpleLocation> signs;
|
||||
private SimpleLocation teleport, chest;
|
||||
private boolean changed;
|
||||
|
||||
/** Creates a new Cell with the given name
|
||||
/**
|
||||
* Creates a new Cell with the given name
|
||||
*
|
||||
* @param name The name of the cell.
|
||||
*/
|
||||
public Cell(String name) {
|
||||
this.databaseid = -1;
|
||||
this.name = name;
|
||||
this.signs = new HashSet<SimpleLocation>();
|
||||
this.signs = new HashSet<>();
|
||||
this.changed = false;
|
||||
}
|
||||
|
||||
@ -50,7 +51,7 @@ public class Cell implements ICell {
|
||||
public Cell(int id, String name) {
|
||||
this.databaseid = id;
|
||||
this.name = name;
|
||||
this.signs = new HashSet<SimpleLocation>();
|
||||
this.signs = new HashSet<>();
|
||||
this.changed = false;
|
||||
}
|
||||
|
||||
@ -99,25 +100,25 @@ public class Cell implements ICell {
|
||||
}
|
||||
|
||||
public String getSignString() {
|
||||
String r = "";
|
||||
StringBuilder r = new StringBuilder();
|
||||
|
||||
for (SimpleLocation s : signs) {
|
||||
if(r.isEmpty()) {
|
||||
r = s.toString();
|
||||
if (r.length() == 0) {
|
||||
r = new StringBuilder(s.toString());
|
||||
} else {
|
||||
r += ";" + s.toString();
|
||||
r.append(";").append(s.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
return r.toString();
|
||||
}
|
||||
|
||||
public List<String> getInvalidSigns() {
|
||||
List<String> invalid = new ArrayList<String>();
|
||||
List<String> invalid = new ArrayList<>();
|
||||
|
||||
for(SimpleLocation s : new HashSet<SimpleLocation>(signs))
|
||||
if (s.getLocation().getBlock().getState() instanceof Sign)
|
||||
continue;
|
||||
for (SimpleLocation s : new HashSet<>(signs))
|
||||
if (s.getLocation().getBlock().getState() instanceof Sign) {
|
||||
}
|
||||
else
|
||||
invalid.add(s.toString());
|
||||
|
||||
@ -125,11 +126,10 @@ public class Cell implements ICell {
|
||||
}
|
||||
|
||||
public List<String> cleanSigns() {
|
||||
List<String> cleaned = new ArrayList<String>();
|
||||
List<String> cleaned = new ArrayList<>();
|
||||
|
||||
for(SimpleLocation s : new HashSet<SimpleLocation>(signs)) {
|
||||
for (SimpleLocation s : new HashSet<>(signs)) {
|
||||
if (s.getLocation().getBlock().getState() instanceof Sign) {
|
||||
continue;
|
||||
} else {
|
||||
changed = true;
|
||||
signs.remove(s);
|
||||
@ -141,10 +141,10 @@ public class Cell implements ICell {
|
||||
}
|
||||
|
||||
public HashMap<String, List<String>> updateSigns() {
|
||||
List<String> removed = new ArrayList<String>();
|
||||
List<String> updated = new ArrayList<String>();
|
||||
List<String> removed = new ArrayList<>();
|
||||
List<String> updated = new ArrayList<>();
|
||||
|
||||
for(SimpleLocation s : new HashSet<SimpleLocation>(signs)) {
|
||||
for (SimpleLocation s : new HashSet<>(signs)) {
|
||||
BlockState bs = s.getLocation().getBlock().getState();
|
||||
|
||||
if (bs instanceof Sign) {
|
||||
@ -174,7 +174,7 @@ public class Cell implements ICell {
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, List<String>> results = new HashMap<String, List<String>>();
|
||||
HashMap<String, List<String>> results = new HashMap<>();
|
||||
results.put("removed", removed);
|
||||
results.put("updated", updated);
|
||||
|
||||
|
@ -10,10 +10,10 @@ import com.graywolf336.jail.enums.Confirmation;
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class ConfirmPlayer {
|
||||
private String name;
|
||||
private String[] args;
|
||||
private Confirmation confirm;
|
||||
private Long expires;
|
||||
private final String name;
|
||||
private final String[] args;
|
||||
private final Confirmation confirm;
|
||||
private final Long expires;
|
||||
|
||||
public ConfirmPlayer(String name, String[] args, Confirmation confirm) {
|
||||
this.name = name;
|
||||
|
@ -1,20 +1,20 @@
|
||||
package com.graywolf336.jail.beans;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Represents an instance of a player creating something, whether it be a jail or cell.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.1.0
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class CreationPlayer {
|
||||
private String jailName, cellName;
|
||||
private final String jailName;
|
||||
private String cellName;
|
||||
private int step;
|
||||
private int x1, y1, z1, x2, y2, z2;
|
||||
private String inWorld, freeWorld;
|
||||
@ -42,7 +42,7 @@ public class CreationPlayer {
|
||||
public CreationPlayer(String jailName, String cellName) {
|
||||
this.jailName = jailName;
|
||||
this.cellName = cellName;
|
||||
this.signs = new HashSet<SimpleLocation>();
|
||||
this.signs = new HashSet<>();
|
||||
this.step = 1;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class CreationPlayer {
|
||||
* Returns the step the creation is in.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* If it is a <strong>Jail</strong>, then when these numbers are returned it means the following:
|
||||
* <ol>
|
||||
* <li>Creating the first block of the Jail region.</li>
|
||||
@ -76,7 +76,7 @@ public class CreationPlayer {
|
||||
* <li>Creating the teleport in location.</li>
|
||||
* <li>Creating the teleport out location.</li>
|
||||
* </ol>
|
||||
*
|
||||
* <p>
|
||||
* If it is a <strong>Cell</strong>, then when these numbers are returned it means the following:
|
||||
* <ol>
|
||||
* <li>Setting the teleport in location.</li>
|
||||
@ -107,7 +107,6 @@ public class CreationPlayer {
|
||||
* <em>Notice:</em> Using this method can cause the step to go above four (three for cell),
|
||||
* which might cause errors later on. Only use when you know that it won't
|
||||
* be used again or you know for a fact that the next step is not above four (three for cell).
|
||||
*
|
||||
*/
|
||||
public void nextStep() {
|
||||
this.step++;
|
||||
@ -157,7 +156,8 @@ public class CreationPlayer {
|
||||
this.z2 = loc.getBlockZ();
|
||||
}
|
||||
|
||||
/** Sets the second corner with the given x, y, and z.
|
||||
/**
|
||||
* Sets the second corner with the given x, y, and z.
|
||||
*
|
||||
* @param x coordinate of the second corner's x
|
||||
* @param y coordinate of the second corner's x
|
||||
@ -169,7 +169,8 @@ public class CreationPlayer {
|
||||
this.z2 = z;
|
||||
}
|
||||
|
||||
/** Returns the <strong>second corner</strong> coords an array of int. <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong>
|
||||
/**
|
||||
* Returns the <strong>second corner</strong> coords an array of int. <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong>
|
||||
*
|
||||
* @return the first corner coords
|
||||
*/
|
||||
@ -294,7 +295,7 @@ public class CreationPlayer {
|
||||
* @return all of the signs, null if none.
|
||||
*/
|
||||
public HashSet<SimpleLocation> getSigns() {
|
||||
return this.signs == null ? null : new HashSet<SimpleLocation>(this.signs);
|
||||
return this.signs == null ? null : new HashSet<>(this.signs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,30 +1,30 @@
|
||||
package com.graywolf336.jail.beans;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.Util;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.Util;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
/** Represents a Jail, contains the prisoners and the cells.
|
||||
/**
|
||||
* Represents a Jail, contains the prisoners and the cells.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.3
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class Jail {
|
||||
private JailMain plugin;
|
||||
private final JailMain plugin;
|
||||
private boolean enabled;
|
||||
private HashMap<String, Cell> cells;
|
||||
private final HashMap<String, Cell> cells;
|
||||
private HashMap<UUID, Prisoner> nocellPrisoners;//prisoners who aren't in a cell
|
||||
private String name = "", world = "";
|
||||
private String name, world = "";
|
||||
private int minX, minY, minZ, maxX, maxY, maxZ;
|
||||
private Location in, free;
|
||||
|
||||
@ -32,8 +32,8 @@ public class Jail {
|
||||
this.plugin = plugin;
|
||||
this.enabled = true;
|
||||
this.name = name;
|
||||
cells = new HashMap<String, Cell>();
|
||||
nocellPrisoners = new HashMap<UUID, Prisoner>();
|
||||
cells = new HashMap<>();
|
||||
nocellPrisoners = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +138,9 @@ public class Jail {
|
||||
return new Location(plugin.getServer().getWorld(world), maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
/** Accepts an array of ints as the coord, where <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong>. */
|
||||
/**
|
||||
* Accepts an array of ints as the coord, where <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong>.
|
||||
*/
|
||||
public void setMaxPoint(int[] coords) {
|
||||
if (coords.length != 3) return;
|
||||
|
||||
@ -147,59 +149,81 @@ public class Jail {
|
||||
this.maxZ = coords[2];
|
||||
}
|
||||
|
||||
/** Sets the name of the world this Jail is in. */
|
||||
/**
|
||||
* Sets the name of the world this Jail is in.
|
||||
*/
|
||||
public void setWorld(String name) {
|
||||
this.world = name;
|
||||
}
|
||||
|
||||
/** Gets the name of the world this Jail is in. */
|
||||
/**
|
||||
* Gets the name of the world this Jail is in.
|
||||
*/
|
||||
public String getWorldName() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
/** Gets the instance of the {@link World world} this Jail is in. */
|
||||
/**
|
||||
* Gets the instance of the {@link World world} this Jail is in.
|
||||
*/
|
||||
public World getWorld() {
|
||||
return plugin.getServer().getWorld(world);
|
||||
}
|
||||
|
||||
/** Sets the {@link Location location} of the teleport <strong>in</strong>. */
|
||||
/**
|
||||
* Sets the {@link Location location} of the teleport <strong>in</strong>.
|
||||
*/
|
||||
public void setTeleportIn(Location location) {
|
||||
if (this.world.isEmpty()) this.world = location.getWorld().getName();
|
||||
|
||||
this.in = location;
|
||||
}
|
||||
|
||||
/** Gets the {@link Location location} of the teleport in. */
|
||||
/**
|
||||
* Gets the {@link Location location} of the teleport in.
|
||||
*/
|
||||
public Location getTeleportIn() {
|
||||
return this.in;
|
||||
}
|
||||
|
||||
/** Sets the {@link Location location} of the teleport for the <strong>free</strong> spot. */
|
||||
/**
|
||||
* Sets the {@link Location location} of the teleport for the <strong>free</strong> spot.
|
||||
*/
|
||||
public void setTeleportFree(Location location) {
|
||||
this.free = location;
|
||||
}
|
||||
|
||||
/** Gets the {@link Location location} of the teleport free spot.*/
|
||||
/**
|
||||
* Gets the {@link Location location} of the teleport free spot.
|
||||
*/
|
||||
public Location getTeleportFree() {
|
||||
return this.free;
|
||||
}
|
||||
|
||||
/** Add a prisoner to this jail. */
|
||||
/**
|
||||
* Add a prisoner to this jail.
|
||||
*/
|
||||
public void addPrisoner(Prisoner p) {
|
||||
this.nocellPrisoners.put(p.getUUID(), p);
|
||||
}
|
||||
|
||||
/** Removes a prisoner from this jail, doesn't remove it from the cell. */
|
||||
/**
|
||||
* Removes a prisoner from this jail, doesn't remove it from the cell.
|
||||
*/
|
||||
public void removePrisoner(Prisoner p) {
|
||||
this.nocellPrisoners.remove(p.getUUID());
|
||||
}
|
||||
|
||||
/** Returns if there are any cells or not. */
|
||||
/**
|
||||
* Returns if there are any cells or not.
|
||||
*/
|
||||
public boolean hasCells() {
|
||||
return !this.cells.isEmpty();
|
||||
}
|
||||
|
||||
/** Adds a cell to the Jail. */
|
||||
/**
|
||||
* Adds a cell to the Jail.
|
||||
*/
|
||||
public boolean addCell(Cell cell, boolean save) {
|
||||
if (save) plugin.getJailIO().saveCell(this, cell, false);
|
||||
|
||||
@ -209,17 +233,23 @@ public class Jail {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Gets the cell with the given name. */
|
||||
/**
|
||||
* Gets the cell with the given name.
|
||||
*/
|
||||
public Cell getCell(String name) {
|
||||
return this.cells.get(name);
|
||||
}
|
||||
|
||||
/** Checks if the given name is a valid cell. */
|
||||
/**
|
||||
* Checks if the given name is a valid cell.
|
||||
*/
|
||||
public boolean isValidCell(String name) {
|
||||
return this.cells.get(name) != null;
|
||||
}
|
||||
|
||||
/** Removes the cell from the jail. */
|
||||
/**
|
||||
* Removes the cell from the jail.
|
||||
*/
|
||||
public void removeCell(String name) {
|
||||
Cell c = this.cells.get(name);
|
||||
//If we have a chest, clear the inventory
|
||||
@ -243,7 +273,9 @@ public class Jail {
|
||||
this.cells.remove(name);
|
||||
}
|
||||
|
||||
/** Returns the cell which the given player name is jailed in, null if not. */
|
||||
/**
|
||||
* Returns the cell which the given player name is jailed in, null if not.
|
||||
*/
|
||||
public Cell getCellPrisonerIsIn(UUID uuid) {
|
||||
for (Cell c : cells.values())
|
||||
if (c.hasPrisoner())
|
||||
@ -253,18 +285,22 @@ public class Jail {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Returns the first empty cell, returns null if there aren't any cells or any free cells. */
|
||||
/**
|
||||
* Returns the first empty cell, returns null if there aren't any cells or any free cells.
|
||||
*/
|
||||
public Cell getFirstEmptyCell() {
|
||||
for (Cell c : getCells())
|
||||
if(c.hasPrisoner())
|
||||
continue;
|
||||
if (c.hasPrisoner()) {
|
||||
}
|
||||
else
|
||||
return c;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Checks if there is an empty cell in this Jail. */
|
||||
/**
|
||||
* Checks if there is an empty cell in this Jail.
|
||||
*/
|
||||
public boolean hasEmptyCell() {
|
||||
for (Cell c : getCells())
|
||||
if (!c.hasPrisoner())
|
||||
@ -273,17 +309,23 @@ public class Jail {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Gets the amount of cells the jail. */
|
||||
/**
|
||||
* Gets the amount of cells the jail.
|
||||
*/
|
||||
public int getCellCount() {
|
||||
return this.cells.size();
|
||||
}
|
||||
|
||||
/** Gets all the cells in the jail. */
|
||||
/**
|
||||
* Gets all the cells in the jail.
|
||||
*/
|
||||
public HashSet<Cell> getCells() {
|
||||
return new HashSet<Cell>(this.cells.values());
|
||||
return new HashSet<>(this.cells.values());
|
||||
}
|
||||
|
||||
/** Gets the closest cell to the provided location, via the teleport in location of the cells. */
|
||||
/**
|
||||
* Gets the closest cell to the provided location, via the teleport in location of the cells.
|
||||
*/
|
||||
public Cell getNearestCell(Location loc) {
|
||||
Cell cell = null;
|
||||
double distance = -1;
|
||||
@ -306,7 +348,9 @@ public class Jail {
|
||||
return cell;
|
||||
}
|
||||
|
||||
/** Clears all the prisoners from this Jail. */
|
||||
/**
|
||||
* Clears all the prisoners from this Jail.
|
||||
*/
|
||||
public void clearPrisoners() {
|
||||
//Remove the prisoners from all the cells
|
||||
for (Cell c : getCells()) {
|
||||
@ -315,12 +359,14 @@ public class Jail {
|
||||
|
||||
//Replace all the current no cell prisoners with
|
||||
//a new hashset of prisoners.
|
||||
this.nocellPrisoners = new HashMap<UUID, Prisoner>();
|
||||
this.nocellPrisoners = new HashMap<>();
|
||||
}
|
||||
|
||||
/** Gets a HashMap of <b>all</b> the prisoners, the ones in cells and ones who aren't. */
|
||||
/**
|
||||
* Gets a HashMap of <b>all</b> the prisoners, the ones in cells and ones who aren't.
|
||||
*/
|
||||
public HashMap<UUID, Prisoner> getAllPrisoners() {
|
||||
HashMap<UUID, Prisoner> all = new HashMap<UUID, Prisoner>(nocellPrisoners); //initalize the temp one to return with the prisoners not in any cells
|
||||
HashMap<UUID, Prisoner> all = new HashMap<>(nocellPrisoners); //initalize the temp one to return with the prisoners not in any cells
|
||||
|
||||
for (Cell c : cells.values())
|
||||
if (c.hasPrisoner())
|
||||
@ -329,9 +375,11 @@ public class Jail {
|
||||
return all;
|
||||
}
|
||||
|
||||
/** Gets a HashSet of the prisoners <b>in cells</b>. */
|
||||
/**
|
||||
* Gets a HashSet of the prisoners <b>in cells</b>.
|
||||
*/
|
||||
public HashSet<Prisoner> getPrisonersInCells() {
|
||||
HashSet<Prisoner> all = new HashSet<Prisoner>();
|
||||
HashSet<Prisoner> all = new HashSet<>();
|
||||
|
||||
for (Cell c : getCells())
|
||||
if (c.hasPrisoner())
|
||||
@ -340,7 +388,9 @@ public class Jail {
|
||||
return all;
|
||||
}
|
||||
|
||||
/** Gets a HashSet of the prisoners <b>not</b> in cells.*/
|
||||
/**
|
||||
* Gets a HashSet of the prisoners <b>not</b> in cells.
|
||||
*/
|
||||
public HashMap<UUID, Prisoner> getPrisonersNotInCells() {
|
||||
return this.nocellPrisoners;
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
package com.graywolf336.jail.beans;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a vote to jail someone.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class JailVote {
|
||||
private String name;
|
||||
private ArrayList<UUID> voters;
|
||||
private final String name;
|
||||
private final ArrayList<UUID> voters;
|
||||
private int yes, no;
|
||||
|
||||
/**
|
||||
@ -25,12 +25,14 @@ public class JailVote {
|
||||
*/
|
||||
public JailVote(String player) {
|
||||
this.name = player;
|
||||
this.voters = new ArrayList<UUID>();
|
||||
this.voters = new ArrayList<>();
|
||||
this.yes = 0;
|
||||
this.no = 0;
|
||||
}
|
||||
|
||||
/** The name of the player the vote is for. */
|
||||
/**
|
||||
* The name of the player the vote is for.
|
||||
*/
|
||||
public String getPlayerName() {
|
||||
return this.name;
|
||||
}
|
||||
@ -40,12 +42,13 @@ public class JailVote {
|
||||
*
|
||||
* @return the player who the vote is for to jail
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public Player getPlayer() {
|
||||
return Bukkit.getPlayer(name);
|
||||
}
|
||||
|
||||
/** Checks if the player with the given id has voted already. */
|
||||
/**
|
||||
* Checks if the player with the given id has voted already.
|
||||
*/
|
||||
public boolean hasVoted(UUID id) {
|
||||
return this.voters.contains(id);
|
||||
}
|
||||
@ -82,12 +85,16 @@ public class JailVote {
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the amount of yes votes. */
|
||||
/**
|
||||
* Get the amount of yes votes.
|
||||
*/
|
||||
public int getYesVotes() {
|
||||
return this.yes;
|
||||
}
|
||||
|
||||
/** Get the amount of no votes. */
|
||||
/**
|
||||
* Get the amount of no votes.
|
||||
*/
|
||||
public int getNoVotes() {
|
||||
return this.no;
|
||||
}
|
||||
|
@ -1,21 +1,19 @@
|
||||
package com.graywolf336.jail.beans;
|
||||
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Chest;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Chest;
|
||||
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
|
||||
/**
|
||||
* Pass this an instance of this class into the jailing of a player and they won't go into a cell.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class NoCell implements ICell {
|
||||
public int getDatabaseID() {
|
||||
|
@ -1,26 +1,30 @@
|
||||
package com.graywolf336.jail.beans;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Represents a Prisoner, player who is jailed, and contains all the information about him/her.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 2.x.x
|
||||
* @version 3.1.1
|
||||
* @since 2.x.x
|
||||
*/
|
||||
public class Prisoner {
|
||||
private String uuid, name, jailer, reason, inventory, armor;
|
||||
private final String uuid;
|
||||
private String name;
|
||||
private String jailer;
|
||||
private String reason;
|
||||
private String inventory;
|
||||
private String armor;
|
||||
private boolean muted = true, offlinePending = false, teleporting = false, toBeTransferred = false, changed = false;
|
||||
private long time = -1L, afk = 0L;
|
||||
private long time, afk = 0L;
|
||||
private Location previousPosition;
|
||||
private GameMode previousGameMode;
|
||||
|
||||
@ -156,7 +160,9 @@ public class Prisoner {
|
||||
finishSetup();
|
||||
}
|
||||
|
||||
/** Finishes the setup of the prisoner data, set to defaults. */
|
||||
/**
|
||||
* Finishes the setup of the prisoner data, set to defaults.
|
||||
*/
|
||||
private void finishSetup() {
|
||||
if (jailer == null)
|
||||
jailer = Lang.DEFAULTJAILER.get();
|
||||
@ -171,24 +177,32 @@ public class Prisoner {
|
||||
previousPosition = null;
|
||||
}
|
||||
|
||||
/** Returns the UUID of the prisoner. */
|
||||
/**
|
||||
* Returns the UUID of the prisoner.
|
||||
*/
|
||||
public UUID getUUID() {
|
||||
return UUID.fromString(this.uuid);
|
||||
}
|
||||
|
||||
/** Gets the name of this prisoner. */
|
||||
/**
|
||||
* Gets the name of this prisoner.
|
||||
*/
|
||||
public String getLastKnownName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/** Sets the name of this prisoner. */
|
||||
/**
|
||||
* Sets the name of this prisoner.
|
||||
*/
|
||||
public String setLastKnownName(String username) {
|
||||
this.name = username;
|
||||
this.changed = true;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/** Gets the reason this player was jailed for. */
|
||||
/**
|
||||
* Gets the reason this player was jailed for.
|
||||
*/
|
||||
public String getReason() {
|
||||
return this.reason;
|
||||
}
|
||||
@ -205,44 +219,60 @@ public class Prisoner {
|
||||
return this.reason;
|
||||
}
|
||||
|
||||
/** Gets the person who jailed this prisoner. */
|
||||
/**
|
||||
* Gets the person who jailed this prisoner.
|
||||
*/
|
||||
public String getJailer() {
|
||||
return this.jailer;
|
||||
}
|
||||
|
||||
/** Sets the person who jailed this prisoner. */
|
||||
/**
|
||||
* Sets the person who jailed this prisoner.
|
||||
*/
|
||||
public void setJailer(String jailer) {
|
||||
this.jailer = jailer;
|
||||
this.changed = true;
|
||||
}
|
||||
|
||||
/** Gets whether the prisoner is muted or not. */
|
||||
/**
|
||||
* Gets whether the prisoner is muted or not.
|
||||
*/
|
||||
public boolean isMuted() {
|
||||
return this.muted;
|
||||
}
|
||||
|
||||
/** Sets whether the prisoner is muted or not. */
|
||||
/**
|
||||
* Sets whether the prisoner is muted or not.
|
||||
*/
|
||||
public void setMuted(boolean muted) {
|
||||
this.muted = muted;
|
||||
this.changed = true;
|
||||
}
|
||||
|
||||
/** Gets whether the prisoner is jailed forever or not. */
|
||||
/**
|
||||
* Gets whether the prisoner is jailed forever or not.
|
||||
*/
|
||||
public boolean isJailedForever() {
|
||||
return this.time == -1;
|
||||
}
|
||||
|
||||
/** Gets the remaining time the prisoner has. */
|
||||
/**
|
||||
* Gets the remaining time the prisoner has.
|
||||
*/
|
||||
public long getRemainingTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
/** Gets the remaining time the prisoner has in minutes. */
|
||||
/**
|
||||
* Gets the remaining time the prisoner has in minutes.
|
||||
*/
|
||||
public long getRemainingTimeInMinutes() {
|
||||
return TimeUnit.MINUTES.convert(time, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/** Gets the remaining time the prison has in minutes except only in int format. */
|
||||
/**
|
||||
* Gets the remaining time the prison has in minutes except only in int format.
|
||||
*/
|
||||
public int getRemainingTimeInMinutesInt() {
|
||||
return (int) this.getRemainingTimeInMinutes();
|
||||
}
|
||||
@ -287,44 +317,60 @@ public class Prisoner {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
/** Gets whether the player is offline or not. */
|
||||
/**
|
||||
* Gets whether the player is offline or not.
|
||||
*/
|
||||
public boolean isOfflinePending() {
|
||||
return this.offlinePending;
|
||||
}
|
||||
|
||||
/** Sets whether the player is offline or not. */
|
||||
/**
|
||||
* Sets whether the player is offline or not.
|
||||
*/
|
||||
public void setOfflinePending(boolean offline) {
|
||||
this.offlinePending = offline;
|
||||
this.changed = true;
|
||||
}
|
||||
|
||||
/** Gets whether the player is being teleported or not. */
|
||||
/**
|
||||
* Gets whether the player is being teleported or not.
|
||||
*/
|
||||
public boolean isTeleporting() {
|
||||
return this.teleporting;
|
||||
}
|
||||
|
||||
/** Sets whether the player is being teleported or not. */
|
||||
/**
|
||||
* Sets whether the player is being teleported or not.
|
||||
*/
|
||||
public void setTeleporting(boolean teleport) {
|
||||
this.teleporting = teleport;
|
||||
}
|
||||
|
||||
/** Gets whether the prisoner is going to be transferred or not, mainly for teleporting on join purposes. */
|
||||
/**
|
||||
* Gets whether the prisoner is going to be transferred or not, mainly for teleporting on join purposes.
|
||||
*/
|
||||
public boolean isToBeTransferred() {
|
||||
return this.toBeTransferred;
|
||||
}
|
||||
|
||||
/** Sets whether the prisoner is going to be transferred or not, mainly for teleporting on join purposes. */
|
||||
/**
|
||||
* Sets whether the prisoner is going to be transferred or not, mainly for teleporting on join purposes.
|
||||
*/
|
||||
public void setToBeTransferred(boolean transferred) {
|
||||
this.toBeTransferred = transferred;
|
||||
this.changed = true;
|
||||
}
|
||||
|
||||
/** Gets the previous location of this player, can be null. */
|
||||
/**
|
||||
* Gets the previous location of this player, can be null.
|
||||
*/
|
||||
public Location getPreviousLocation() {
|
||||
return this.previousPosition;
|
||||
}
|
||||
|
||||
/** Gets the previous location of this player, separated by a comma. */
|
||||
/**
|
||||
* Gets the previous location of this player, separated by a comma.
|
||||
*/
|
||||
public String getPreviousLocationString() {
|
||||
if (previousPosition == null) return "";
|
||||
else if (previousPosition.getWorld() == null) return "";
|
||||
@ -336,12 +382,16 @@ public class Prisoner {
|
||||
previousPosition.getPitch();
|
||||
}
|
||||
|
||||
/** Sets the previous location of this player. */
|
||||
/**
|
||||
* Sets the previous location of this player.
|
||||
*/
|
||||
public void setPreviousPosition(Location location) {
|
||||
this.previousPosition = location;
|
||||
}
|
||||
|
||||
/** Sets the previous location of this player from a comma separated string. */
|
||||
/**
|
||||
* Sets the previous location of this player from a comma separated string.
|
||||
*/
|
||||
public void setPreviousPosition(String location) {
|
||||
if (location == null) return;
|
||||
if (location.isEmpty()) return;
|
||||
@ -349,25 +399,31 @@ public class Prisoner {
|
||||
this.changed = true;
|
||||
String[] s = location.split(",");
|
||||
this.previousPosition = new Location(Bukkit.getWorld(s[0]),
|
||||
Double.valueOf(s[1]),
|
||||
Double.valueOf(s[2]),
|
||||
Double.valueOf(s[3]),
|
||||
Float.valueOf(s[4]),
|
||||
Float.valueOf(s[5]));
|
||||
Double.parseDouble(s[1]),
|
||||
Double.parseDouble(s[2]),
|
||||
Double.parseDouble(s[3]),
|
||||
Float.parseFloat(s[4]),
|
||||
Float.parseFloat(s[5]));
|
||||
}
|
||||
|
||||
/** Gets the previous gamemode of this player. */
|
||||
/**
|
||||
* Gets the previous gamemode of this player.
|
||||
*/
|
||||
public GameMode getPreviousGameMode() {
|
||||
return this.previousGameMode;
|
||||
}
|
||||
|
||||
/** Sets the previous gamemode of this player. */
|
||||
/**
|
||||
* Sets the previous gamemode of this player.
|
||||
*/
|
||||
public void setPreviousGameMode(GameMode previous) {
|
||||
this.previousGameMode = previous;
|
||||
this.changed = true;
|
||||
}
|
||||
|
||||
/** Sets the previous gamemode of this player based upon the provided string. */
|
||||
/**
|
||||
* Sets the previous gamemode of this player based upon the provided string.
|
||||
*/
|
||||
public void setPreviousGameMode(String previous) {
|
||||
if (previous == null) return;
|
||||
else if (previous.isEmpty()) return;
|
||||
@ -375,44 +431,60 @@ public class Prisoner {
|
||||
this.changed = true;
|
||||
}
|
||||
|
||||
/** Gets the inventory string for this player, it is encoded in Base64 string. */
|
||||
/**
|
||||
* Gets the inventory string for this player, it is encoded in Base64 string.
|
||||
*/
|
||||
public String getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
/** Sets the inventory Base64 string. */
|
||||
/**
|
||||
* Sets the inventory Base64 string.
|
||||
*/
|
||||
public void setInventory(String inventory) {
|
||||
this.inventory = inventory;
|
||||
this.changed = true;
|
||||
}
|
||||
|
||||
/** Gets the armor content, encoded in Base64 string. */
|
||||
/**
|
||||
* Gets the armor content, encoded in Base64 string.
|
||||
*/
|
||||
public String getArmor() {
|
||||
return this.armor;
|
||||
}
|
||||
|
||||
/** Sets the armor inventory Base64 string. */
|
||||
/**
|
||||
* Sets the armor inventory Base64 string.
|
||||
*/
|
||||
public void setArmor(String armor) {
|
||||
this.armor = armor;
|
||||
this.changed = true;
|
||||
}
|
||||
|
||||
/** Gets the time, in milliseconds, this prisoner has been afk. */
|
||||
/**
|
||||
* Gets the time, in milliseconds, this prisoner has been afk.
|
||||
*/
|
||||
public long getAFKTime() {
|
||||
return this.afk;
|
||||
}
|
||||
|
||||
/** Sets the time, in milliseconds, this prisoner has been afk. */
|
||||
/**
|
||||
* Sets the time, in milliseconds, this prisoner has been afk.
|
||||
*/
|
||||
public void setAFKTime(long time) {
|
||||
this.afk = time;
|
||||
}
|
||||
|
||||
/** Checks if the prisoner was changed or not. */
|
||||
/**
|
||||
* Checks if the prisoner was changed or not.
|
||||
*/
|
||||
public boolean wasChanged() {
|
||||
return this.changed;
|
||||
}
|
||||
|
||||
/** Sets whether the prisoner was changed or not. */
|
||||
/**
|
||||
* Sets whether the prisoner was changed or not.
|
||||
*/
|
||||
public boolean setChanged(boolean change) {
|
||||
this.changed = change;
|
||||
return this.changed;
|
||||
|
@ -8,12 +8,14 @@ import org.bukkit.World;
|
||||
* Simple location class which doesn't store any instances of {@link World worlds} or {@link org.bukkit.block.Block blocks}, just uses strings, floats, and doubles.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.1.1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class SimpleLocation {
|
||||
private String world;
|
||||
private double x, y, z;
|
||||
private final String world;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private float yaw, pitch;
|
||||
|
||||
/**
|
||||
@ -59,9 +61,9 @@ public class SimpleLocation {
|
||||
*/
|
||||
public SimpleLocation(String world, String x, String y, String z) {
|
||||
this.world = world;
|
||||
this.x = Double.valueOf(x);
|
||||
this.y = Double.valueOf(y);
|
||||
this.z = Double.valueOf(z);
|
||||
this.x = Double.parseDouble(x);
|
||||
this.y = Double.parseDouble(y);
|
||||
this.z = Double.parseDouble(z);
|
||||
this.yaw = 0;
|
||||
this.pitch = 0;
|
||||
}
|
||||
@ -81,17 +83,23 @@ public class SimpleLocation {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/** Returns the instance from Bukkit of the world this location is in. */
|
||||
/**
|
||||
* Returns the instance from Bukkit of the world this location is in.
|
||||
*/
|
||||
public World getWorld() {
|
||||
return Bukkit.getWorld(world);
|
||||
}
|
||||
|
||||
/** Returns the name of the world this location is in. */
|
||||
/**
|
||||
* Returns the name of the world this location is in.
|
||||
*/
|
||||
public String getWorldName() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
/** Returns a new {@link Location} from this SimpleLocation. */
|
||||
/**
|
||||
* Returns a new {@link Location} from this SimpleLocation.
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
|
||||
}
|
||||
|
@ -8,9 +8,10 @@ package com.graywolf336.jail.beans;
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class Stick {
|
||||
private String jail, reason;
|
||||
private long time;
|
||||
private double health;
|
||||
private final String jail;
|
||||
private final String reason;
|
||||
private final long time;
|
||||
private final double health;
|
||||
|
||||
/**
|
||||
* Creates a new Jail Stick instance.
|
||||
@ -54,10 +55,11 @@ public class Stick {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
/** Gets the amount of health a player has to have before getting jailed via this stick.
|
||||
/**
|
||||
* Gets the amount of health a player has to have before getting jailed via this stick.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* See here for reference: http://dev.bukkit.org/bukkit-plugins/jail/tickets/415/
|
||||
*/
|
||||
public double getHealth() {
|
||||
|
@ -1,24 +1,23 @@
|
||||
package com.graywolf336.jail.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The base of all the commands.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.1.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public interface Command {
|
||||
/**
|
||||
* Execute the command given the arguments, returning whether the command handled it or not.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* When the method returns false, the usage message is printed to the sender. If the method
|
||||
* handles the command in any way, such as sending a message to the sender or actually doing
|
||||
* something, then it should return true so that the sender of the command doesn't get the
|
||||
@ -29,7 +28,7 @@ public interface Command {
|
||||
* @param args The args, in an array
|
||||
* @return True if the method handled it in any way, false if we should send the usage message.
|
||||
*/
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception;
|
||||
boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception;
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception;
|
||||
List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args);
|
||||
}
|
||||
|
@ -1,14 +1,5 @@
|
||||
package com.graywolf336.jail.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.commands.HandCuffCommand;
|
||||
@ -17,29 +8,37 @@ import com.graywolf336.jail.command.commands.UnHandCuffCommand;
|
||||
import com.graywolf336.jail.command.commands.UnJailCommand;
|
||||
import com.graywolf336.jail.command.commands.UnJailForceCommand;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Where all the commands are registered, handled, and processed.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.2
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class CommandHandler {
|
||||
private LinkedHashMap<String, Command> commands;
|
||||
private final LinkedHashMap<String, Command> commands;
|
||||
|
||||
public CommandHandler(JailMain plugin) {
|
||||
commands = new LinkedHashMap<String, Command>();
|
||||
commands = new LinkedHashMap<>();
|
||||
loadCommands();
|
||||
|
||||
plugin.debug("Loaded " + commands.size() + " commands.");
|
||||
}
|
||||
|
||||
public List<String> parseTabComplete(JailManager jm, CommandSender sender, String commandLine, String[] args) throws Exception {
|
||||
public List<String> parseTabComplete(JailManager jm, CommandSender sender, String commandLine, String[] args) {
|
||||
List<Command> matches = getMatches(commandLine);
|
||||
|
||||
if(matches.isEmpty() || matches.size() > 1) return Collections.emptyList();
|
||||
if (matches.size() != 1) return Collections.emptyList();
|
||||
else {
|
||||
CommandInfo i = matches.get(0).getClass().getAnnotation(CommandInfo.class);
|
||||
|
||||
@ -62,7 +61,7 @@ public class CommandHandler {
|
||||
* Handles the given command and checks that the command is in valid form.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* It checks in the following order:
|
||||
* <ol>
|
||||
* <li>If the command is registered or not.</li>
|
||||
@ -86,14 +85,12 @@ public class CommandHandler {
|
||||
if (matches.isEmpty()) {
|
||||
if (commandLine.startsWith("jail")) {
|
||||
String j = commandLine.substring(0, 4);
|
||||
String a0 = commandLine.substring(4, commandLine.length());
|
||||
String a0 = commandLine.substring(4);
|
||||
|
||||
ArrayList<String> args2 = new ArrayList<String>();
|
||||
for(String s : args)
|
||||
args2.add(s);
|
||||
ArrayList<String> args2 = new ArrayList<>(Arrays.asList(args));
|
||||
args2.add(a0);
|
||||
|
||||
if(jailmanager.getPlugin().onCommand(sender, null, j, args2.toArray(new String[args2.size()])))
|
||||
if (jailmanager.getPlugin().onCommand(sender, null, j, args2.toArray(new String[0])))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -140,7 +137,6 @@ public class CommandHandler {
|
||||
try {
|
||||
if (!c.execute(jailmanager, sender, args)) {
|
||||
showUsage(sender, c);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -150,7 +146,7 @@ public class CommandHandler {
|
||||
}
|
||||
|
||||
private List<Command> getMatches(String command) {
|
||||
List<Command> result = new ArrayList<Command>();
|
||||
List<Command> result = new ArrayList<>();
|
||||
|
||||
for (Entry<String, Command> entry : commands.entrySet()) {
|
||||
if (command.matches(entry.getKey())) {
|
||||
@ -174,7 +170,9 @@ public class CommandHandler {
|
||||
sender.sendMessage(info.usage());
|
||||
}
|
||||
|
||||
/** Loads all the commands into the hashmap. */
|
||||
/**
|
||||
* Loads all the commands into the hashmap.
|
||||
*/
|
||||
private void loadCommands() {
|
||||
load(HandCuffCommand.class);
|
||||
load(ToggleJailDebugCommand.class);
|
||||
|
@ -7,7 +7,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
* Contains a definition of all the annotations {@link Command commands} should have, if a {@link Command command} doesn't have any then it isn't registered.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This helps make loading and registering and verifying commands a lot
|
||||
* easier, makes sure that before we really process a command that it
|
||||
* is structured correctly and all the right information is passed. If
|
||||
@ -25,9 +25,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
* command. The order of checking is as defined in {@link CommandHandler#handleCommand(com.graywolf336.jail.JailManager, org.bukkit.command.CommandSender, String, String[]) CommandHandler.handleCommand}.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CommandInfo {
|
||||
@ -36,42 +35,42 @@ public @interface CommandInfo {
|
||||
*
|
||||
* @return The maximum number of arguments required, -1 if no maximum.
|
||||
*/
|
||||
public int maxArgs();
|
||||
int maxArgs();
|
||||
|
||||
/**
|
||||
* Gets the minimum amount of arguments required.
|
||||
*
|
||||
* @return The minimum number of arguments required.
|
||||
*/
|
||||
public int minimumArgs();
|
||||
int minimumArgs();
|
||||
|
||||
/**
|
||||
* Whether the command needs a player context or not.
|
||||
*
|
||||
* @return True if requires a player, false if not.
|
||||
*/
|
||||
public boolean needsPlayer();
|
||||
boolean needsPlayer();
|
||||
|
||||
/**
|
||||
* A regex pattern that allows for alternatives to the command (ex: /jail or /j, /jailstatus or /js).
|
||||
*
|
||||
* @return The regex pattern to match.
|
||||
*/
|
||||
public String pattern();
|
||||
String pattern();
|
||||
|
||||
/**
|
||||
* Gets the permission required to execute this command.
|
||||
*
|
||||
* @return The permission required.
|
||||
*/
|
||||
public String permission();
|
||||
String permission();
|
||||
|
||||
/**
|
||||
* Gets the usage message for this command.
|
||||
*
|
||||
* @return The usage message.
|
||||
*/
|
||||
public String usage();
|
||||
String usage();
|
||||
|
||||
// /**
|
||||
// * Gets the help messages for this command, color codes enabled.
|
||||
|
@ -1,14 +1,5 @@
|
||||
package com.graywolf336.jail.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.subcommands.JailCheckCommand;
|
||||
@ -39,28 +30,35 @@ import com.graywolf336.jail.command.subcommands.JailTransferCommand;
|
||||
import com.graywolf336.jail.command.subcommands.JailVersionCommand;
|
||||
import com.graywolf336.jail.command.subcommands.JailVoteCommand;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Where all the <strong>jail</strong> commands are registered, handled, and processed at.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.1.0
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class JailHandler {
|
||||
private LinkedHashMap<String, Command> commands;
|
||||
private final LinkedHashMap<String, Command> commands;
|
||||
|
||||
public JailHandler(JailMain plugin) {
|
||||
commands = new LinkedHashMap<String, Command>();
|
||||
commands = new LinkedHashMap<>();
|
||||
loadCommands();
|
||||
|
||||
plugin.debug("Loaded " + commands.size() + " sub-commands of /jail.");
|
||||
}
|
||||
|
||||
public List<String> parseTabComplete(JailManager jm, CommandSender sender, String[] args) throws Exception {
|
||||
public List<String> parseTabComplete(JailManager jm, CommandSender sender, String[] args) {
|
||||
if (args[0].isEmpty() || args.length == 1) {
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
String arg0 = args[0].toLowerCase();
|
||||
boolean hasJailPermission = false;
|
||||
|
||||
@ -136,7 +134,7 @@ public class JailHandler {
|
||||
* Handles the given command and checks that the command is in valid form.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* It checks in the following order:
|
||||
* <ol>
|
||||
* <li>If they have permission for it, if they don't then we send them a message stating so.</li>
|
||||
@ -151,7 +149,7 @@ public class JailHandler {
|
||||
* @param args The arguments passed to the command.
|
||||
*/
|
||||
public boolean parseCommand(JailManager jailmanager, CommandSender sender, String[] args) {
|
||||
Command c = null;
|
||||
Command c;
|
||||
|
||||
//If they didn't provide any arguments (aka just: /jail) then we will need to send them some help
|
||||
if (args.length == 0) {
|
||||
@ -232,7 +230,7 @@ public class JailHandler {
|
||||
}
|
||||
|
||||
private List<Command> getMatches(String command) {
|
||||
List<Command> result = new ArrayList<Command>();
|
||||
List<Command> result = new ArrayList<>();
|
||||
|
||||
for (Entry<String, Command> entry : commands.entrySet()) {
|
||||
if (command.matches(entry.getKey())) {
|
||||
@ -286,12 +284,12 @@ public class JailHandler {
|
||||
load(JailVoteCommand.class);
|
||||
}
|
||||
|
||||
private void load(Class<? extends Command> c) {
|
||||
CommandInfo info = c.getAnnotation(CommandInfo.class);
|
||||
private void load(Class<? extends Command> command) {
|
||||
CommandInfo info = command.getAnnotation(CommandInfo.class);
|
||||
if (info == null) return;
|
||||
|
||||
try {
|
||||
commands.put(info.pattern(), c.newInstance());
|
||||
commands.put(info.pattern(), command.newInstance());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -22,7 +21,6 @@ import com.graywolf336.jail.enums.Lang;
|
||||
usage = "/handcuff [player]"
|
||||
)
|
||||
public class HandCuffCommand implements Command {
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player player = jm.getPlugin().getServer().getPlayer(args[0]);
|
||||
|
||||
@ -45,8 +43,8 @@ public class HandCuffCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
List<String> results = new ArrayList<String>();
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||
if (!jm.getPlugin().getHandCuffManager().isHandCuffed(p.getUniqueId())) //don't send someone who is already handcuffed
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
@ -25,7 +24,7 @@ public class ToggleJailDebugCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//No tab completion required for toggling debug command
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -22,7 +21,6 @@ import com.graywolf336.jail.enums.Lang;
|
||||
usage = "/unhandcuff [player]"
|
||||
)
|
||||
public class UnHandCuffCommand implements Command {
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player player = jm.getPlugin().getServer().getPlayerExact(args[0]);
|
||||
|
||||
@ -39,8 +37,8 @@ public class UnHandCuffCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
List<String> results = new ArrayList<String>();
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||
if (jm.getPlugin().getHandCuffManager().isHandCuffed(p.getUniqueId())) //don't send someone who isn't already handcuffed
|
||||
|
@ -1,14 +1,5 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
@ -18,6 +9,14 @@ import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.exceptions.JailRequiredException;
|
||||
import com.graywolf336.jail.exceptions.PrisonerRequiredException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -58,7 +57,7 @@ public class UnJailCommand implements Command {
|
||||
}
|
||||
|
||||
if (jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
|
||||
jm.getPlugin().getLogger().info(ChatColor.stripColor(Lang.BROADCASTUNJAILING.get(new String[] { args[0], sender.getName() })));
|
||||
jm.getPlugin().getLogger().info(ChatColor.stripColor(Lang.BROADCASTUNJAILING.get(args[0], sender.getName())));
|
||||
}
|
||||
} else {
|
||||
//The player is not currently jailed
|
||||
@ -68,8 +67,8 @@ public class UnJailCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
List<String> results = new ArrayList<String>();
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Prisoner p : jm.getAllPrisoners().values())
|
||||
if (args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[0]))
|
||||
|
@ -1,13 +1,5 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
@ -16,6 +8,13 @@ import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.exceptions.JailRequiredException;
|
||||
import com.graywolf336.jail.exceptions.PrisonerRequiredException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -33,7 +32,7 @@ public class UnJailForceCommand implements Command {
|
||||
jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisonerByLastKnownName(args[0]), sender);
|
||||
|
||||
if (jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
|
||||
jm.getPlugin().getLogger().info(ChatColor.stripColor(Lang.BROADCASTUNJAILING.get(new String[] { args[0], sender.getName() })));
|
||||
jm.getPlugin().getLogger().info(ChatColor.stripColor(Lang.BROADCASTUNJAILING.get(args[0], sender.getName())));
|
||||
}
|
||||
} else {
|
||||
//The player is not currently jailed
|
||||
@ -43,8 +42,8 @@ public class UnJailForceCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
List<String> results = new ArrayList<String>();
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Prisoner p : jm.getAllPrisoners().values())
|
||||
if (args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[0]))
|
||||
|
@ -1,44 +1,51 @@
|
||||
package com.graywolf336.jail.command.commands.jewels;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.lexicalscope.jewel.cli.Option;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Jailing {
|
||||
|
||||
@Option(longName = {"player", "pl"}, shortName = "p", description = "the player's name")
|
||||
public String getPlayer();
|
||||
String getPlayer();
|
||||
|
||||
@Option(longName = {"force"}, shortName = "f", description = "force jailing someone who has never been online")
|
||||
public boolean getForce();
|
||||
boolean getForce();
|
||||
|
||||
@Option(longName = {"time", "length"}, shortName = "t", description = "the amount of time")
|
||||
public String getTime();
|
||||
String getTime();
|
||||
|
||||
@Option(longName = {"forever", "eternity", "infinite"}, shortName = "i", description = "jail the player for eternity")
|
||||
public boolean getInfinite();
|
||||
boolean getInfinite();
|
||||
|
||||
@Option(longName = {"jail", "prison"}, shortName = "j", description = "the jail")
|
||||
public String getJail();
|
||||
String getJail();
|
||||
|
||||
@Option(longName = {"cell"}, shortName = "c", description = "the cell")
|
||||
public String getCell();
|
||||
String getCell();
|
||||
|
||||
@Option(longName = {"anycell"}, shortName = "a", description = "decides whether the plugin will pick any open cell")
|
||||
public boolean getAnyCell();
|
||||
boolean getAnyCell();
|
||||
|
||||
@Option(longName = {"muted", "canttalk"}, shortName = "m", description = "whether the prisoner is muted or not")
|
||||
public boolean getMuted();
|
||||
boolean getMuted();
|
||||
|
||||
@Option(longName = {"reason"}, shortName = "r", description = "the reason this player is being jailed")
|
||||
public List<String> getReason();
|
||||
List<String> getReason();
|
||||
|
||||
public boolean isForce();
|
||||
public boolean isInfinite();
|
||||
public boolean isTime();
|
||||
public boolean isJail();
|
||||
public boolean isCell();
|
||||
public boolean isAnyCell();
|
||||
public boolean isMuted();
|
||||
public boolean isReason();
|
||||
boolean isForce();
|
||||
|
||||
boolean isInfinite();
|
||||
|
||||
boolean isTime();
|
||||
|
||||
boolean isJail();
|
||||
|
||||
boolean isCell();
|
||||
|
||||
boolean isAnyCell();
|
||||
|
||||
boolean isMuted();
|
||||
|
||||
boolean isReason();
|
||||
}
|
||||
|
@ -5,15 +5,17 @@ import com.lexicalscope.jewel.cli.Option;
|
||||
public interface Transfer {
|
||||
|
||||
@Option(longName = {"player", "pl"}, shortName = "p", description = "the player's name")
|
||||
public String getPlayer();
|
||||
String getPlayer();
|
||||
|
||||
@Option(longName = {"jail", "prison"}, shortName = "j", description = "the jail")
|
||||
public String getJail();
|
||||
String getJail();
|
||||
|
||||
@Option(longName = {"cell"}, shortName = "c", description = "the cell")
|
||||
public String getCell();
|
||||
String getCell();
|
||||
|
||||
public boolean isPlayer();
|
||||
public boolean isJail();
|
||||
public boolean isCell();
|
||||
boolean isPlayer();
|
||||
|
||||
boolean isJail();
|
||||
|
||||
boolean isCell();
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -42,8 +41,8 @@ public class JailCheckCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
List<String> results = new ArrayList<String>();
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Prisoner p : jm.getAllPrisoners().values()) {
|
||||
if (args.length == 2 && StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[1].toLowerCase())) {
|
||||
|
@ -1,12 +1,5 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.ConfirmPlayer;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
@ -14,6 +7,12 @@ import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Confirmation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
@ -29,8 +28,10 @@ public class JailClearCommand implements Command {
|
||||
|
||||
//Check if we need to forcefully clear something
|
||||
for (String s : args)
|
||||
if(s.equalsIgnoreCase("-f") || s.equalsIgnoreCase("-force"))
|
||||
if (s.equalsIgnoreCase("-f") || s.equalsIgnoreCase("-force")) {
|
||||
force = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
@ -45,8 +46,8 @@ public class JailClearCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
List<String> results = new ArrayList<String>();
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Jail j : jm.getJails()) {
|
||||
if ((args.length == 2 && StringUtil.startsWithIgnoreCase(j.getName(), args[1]))
|
||||
|
@ -1,19 +1,5 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
@ -28,6 +14,18 @@ import com.graywolf336.jail.events.PrePrisonerJailedEvent;
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import com.lexicalscope.jewel.cli.ArgumentValidationException;
|
||||
import com.lexicalscope.jewel.cli.CliFactory;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = -1,
|
||||
@ -39,7 +37,7 @@ import com.lexicalscope.jewel.cli.CliFactory;
|
||||
)
|
||||
public class JailCommand implements Command {
|
||||
private static final String noJailPermission = "jail.cantbejailed";
|
||||
private List<String> commands = Arrays.asList(new String[] { "p", "t", "i", "j", "c", "a", "m", "r", "f" });
|
||||
private final List<String> commands = Arrays.asList("p", "t", "i", "j", "c", "a", "m", "r", "f");
|
||||
|
||||
/*
|
||||
* Executes the command. Checks the following:
|
||||
@ -60,15 +58,15 @@ public class JailCommand implements Command {
|
||||
}
|
||||
|
||||
//This is just to add the -p param so CliFactory doesn't blow up
|
||||
List<String> arguments = new LinkedList<String>(Arrays.asList(args));
|
||||
List<String> arguments = new LinkedList<>(Arrays.asList(args));
|
||||
//Only add the "-p" if it doesn't already contain it, this way people can do `/jail -p check` in the event someone
|
||||
//has a name which is one of our subcommands
|
||||
if (!arguments.contains("-p")) arguments.add(0, "-p");
|
||||
|
||||
Jailing params = null;
|
||||
Jailing params;
|
||||
|
||||
try {
|
||||
params = CliFactory.parseArguments(Jailing.class, arguments.toArray(new String[arguments.size()]));
|
||||
params = CliFactory.parseArguments(Jailing.class, arguments.toArray(new String[0]));
|
||||
} catch (ArgumentValidationException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
return true;
|
||||
@ -97,7 +95,7 @@ public class JailCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
String uuid = "";
|
||||
String uuid;
|
||||
if (p == null) {
|
||||
if (!jm.getPlugin().getConfig().getBoolean(Settings.ALLOWJAILINGOFFLINEPLAYERS.getPath())) {
|
||||
sender.sendMessage(Lang.PLAYERHASNEVERPLAYEDBEFORE.get());
|
||||
@ -119,7 +117,7 @@ public class JailCommand implements Command {
|
||||
|
||||
//Try to parse the time, if they give us nothing in the time parameter then we get the default time
|
||||
//from the config and if that isn't there then we default to thirty minutes.
|
||||
Long time = 10L;
|
||||
Long time;
|
||||
try {
|
||||
if (params.isTime()) {
|
||||
time = Util.getTime(params.getTime());
|
||||
@ -141,7 +139,7 @@ public class JailCommand implements Command {
|
||||
//from the config. If that is nearest, let's make a call to getting the nearest jail to
|
||||
//the sender but otherwise if it isn't nearest then let's set it to the default jail
|
||||
//which is defined in the config.
|
||||
String jailName = "";
|
||||
String jailName;
|
||||
if (!params.isJail()) {
|
||||
String dJail = jm.getPlugin().getConfig().getString(Settings.DEFAULTJAIL.getPath());
|
||||
|
||||
@ -170,14 +168,14 @@ public class JailCommand implements Command {
|
||||
//Check if it is a valid cell
|
||||
if (!jm.getJail(jailName).isValidCell(params.getCell())) {
|
||||
//There is no cell by that name
|
||||
sender.sendMessage(Lang.NOCELL.get(new String[] { params.getCell(), jailName }));
|
||||
sender.sendMessage(Lang.NOCELL.get(params.getCell(), jailName));
|
||||
return true;
|
||||
} else if (jm.getJail(jailName).getCell(params.getCell()).hasPrisoner()) {
|
||||
//If the cell has a prisoner, don't allow jailing them to that particular cell but suggest another one
|
||||
sender.sendMessage(Lang.CELLNOTEMPTY.get(params.getCell()));
|
||||
Cell suggestedCell = jm.getJail(jailName).getFirstEmptyCell();
|
||||
if (suggestedCell != null) {
|
||||
sender.sendMessage(Lang.SUGGESTEDCELL.get(new String[] { jailName, suggestedCell.getName() }));
|
||||
sender.sendMessage(Lang.SUGGESTEDCELL.get(jailName, suggestedCell.getName()));
|
||||
} else {
|
||||
sender.sendMessage(Lang.NOEMPTYCELLS.get(jailName));
|
||||
}
|
||||
@ -207,7 +205,7 @@ public class JailCommand implements Command {
|
||||
}
|
||||
|
||||
//If the jailer gave no reason, then let's get the default reason
|
||||
String reason = "";
|
||||
String reason;
|
||||
if (params.isReason()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String s : params.getReason()) {
|
||||
@ -251,10 +249,10 @@ public class JailCommand implements Command {
|
||||
|
||||
//Player is not online
|
||||
if (p == null) {
|
||||
sender.sendMessage(Lang.OFFLINEJAIL.get(new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
||||
sender.sendMessage(Lang.OFFLINEJAIL.get(pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes())));
|
||||
} else {
|
||||
//Player *is* online
|
||||
sender.sendMessage(Lang.ONLINEJAIL.get(new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
||||
sender.sendMessage(Lang.ONLINEJAIL.get(pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes())));
|
||||
}
|
||||
|
||||
try {
|
||||
@ -267,7 +265,7 @@ public class JailCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//by the time it gets to this command it'll have at least two arguments
|
||||
String last = args[args.length - 1];
|
||||
|
||||
@ -292,7 +290,8 @@ public class JailCommand implements Command {
|
||||
if (jm.isValidJail(jail)) return getCells(jm, jail, last);
|
||||
}
|
||||
} else if (previous.endsWith("r")) return Collections.emptyList();
|
||||
else if(!commands.contains(args[args.length - 2].replace("-", ""))) return Util.getUnusedItems(commands, args, false);
|
||||
else if (!commands.contains(args[args.length - 2].replace("-", "")))
|
||||
return Util.getUnusedItems(commands, args, false);
|
||||
} else {
|
||||
return getPlayers(jm, last);
|
||||
}
|
||||
@ -310,7 +309,7 @@ public class JailCommand implements Command {
|
||||
}
|
||||
|
||||
private List<String> getPlayers(JailManager jm, String first) {
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||
if (first.isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), first))
|
||||
@ -324,7 +323,7 @@ public class JailCommand implements Command {
|
||||
}
|
||||
|
||||
private List<String> getCells(JailManager jm, String jail, String cell) {
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Cell c : jm.getJail(jail).getCells())
|
||||
if (!c.hasPrisoner() && (cell.isEmpty() || StringUtil.startsWithIgnoreCase(c.getName(), cell)))
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
@ -92,7 +91,7 @@ public class JailConfirmCommand implements Command{
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//confirming doesn't require any tab completing
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
@ -66,7 +65,7 @@ public class JailCreateCellCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//We shouldn't provide when they want a cell name
|
||||
if (args.length >= 3) return Collections.emptyList();
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -49,7 +48,7 @@ public class JailCreateCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//Creating a jail shouldn't provide tab completion
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,12 +1,5 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.ConfirmPlayer;
|
||||
@ -15,6 +8,12 @@ import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Confirmation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
@ -25,7 +24,7 @@ import com.graywolf336.jail.enums.Lang;
|
||||
usage = "/jail deletecell [jail] [cell]"
|
||||
)
|
||||
public class JailDeleteCellCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if (jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
} else {
|
||||
@ -36,8 +35,8 @@ public class JailDeleteCellCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
List<String> results = new ArrayList<String>();
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.ConfirmPlayer;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Confirmation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -20,7 +19,7 @@ import com.graywolf336.jail.enums.Lang;
|
||||
usage = "/jail deletecells [jail]"
|
||||
)
|
||||
public class JailDeleteCellsCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if (jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
} else {
|
||||
@ -31,7 +30,7 @@ public class JailDeleteCellsCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.ConfirmPlayer;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Confirmation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -20,7 +19,7 @@ import com.graywolf336.jail.enums.Lang;
|
||||
usage = "/jail delete [jail]"
|
||||
)
|
||||
public class JailDeleteCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if (jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
} else {
|
||||
@ -31,7 +30,7 @@ public class JailDeleteCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -19,13 +18,13 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
usage = "/jail help [page]"
|
||||
)
|
||||
public class JailHelpCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
sender.sendMessage(ChatColor.GREEN + "This command will be filled out shortly, use this link for now:");
|
||||
sender.sendMessage(ChatColor.GREEN + "https://github.com/graywolf336/Jail/wiki/Commands");
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//TODO implement
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,12 +1,5 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
@ -14,6 +7,12 @@ import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -31,7 +30,7 @@ public class JailListCellsCommand implements Command {
|
||||
if (jm.getJail(args[1]) != null) {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
|
||||
List<String> cells = new ArrayList<String>();
|
||||
List<String> cells = new ArrayList<>();
|
||||
|
||||
for (Cell c : j.getCells()) {
|
||||
cells.add(c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")"));
|
||||
@ -51,7 +50,7 @@ public class JailListCellsCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -33,8 +32,10 @@ public class JailListCommand implements Command {
|
||||
if (args.length == 1) {
|
||||
//No jail provided, so give them a list of the jails
|
||||
for (Jail j : jm.getJails()) {
|
||||
if(j.isEnabled()) sender.sendMessage(ChatColor.BLUE + " " + j.getName() + " (" + j.getAllPrisoners().size() + ")");
|
||||
else sender.sendMessage(ChatColor.RED + " " + j.getName() + " (" + j.getAllPrisoners().size() + ") - WORLD UNLOADED");
|
||||
if (j.isEnabled())
|
||||
sender.sendMessage(ChatColor.BLUE + " " + j.getName() + " (" + j.getAllPrisoners().size() + ")");
|
||||
else
|
||||
sender.sendMessage(ChatColor.RED + " " + j.getName() + " (" + j.getAllPrisoners().size() + ") - WORLD UNLOADED");
|
||||
}
|
||||
} else {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
@ -63,7 +64,7 @@ public class JailListCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
@ -22,7 +21,7 @@ import com.graywolf336.jail.enums.Lang;
|
||||
usage = "/jail mute [name]"
|
||||
)
|
||||
public class JailMuteCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Let's check if the player they're sending us is jailed
|
||||
if (jm.isPlayerJailedByLastKnownUsername(args[1])) {
|
||||
//They are, so let's toggle whether they are muted or not
|
||||
@ -42,18 +41,16 @@ public class JailMuteCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
switch(args.length) {
|
||||
case 2:
|
||||
List<String> results = new ArrayList<String>();
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
if (args.length == 2) {
|
||||
List<String> results = new ArrayList<>();
|
||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||
if (StringUtil.startsWithIgnoreCase(p.getName(), args[1].toLowerCase()))
|
||||
results.add(p.getName());
|
||||
|
||||
Collections.sort(results);
|
||||
return results;
|
||||
default:
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,5 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
@ -17,6 +7,15 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.interfaces.IJailPayManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
@ -27,7 +26,7 @@ import com.graywolf336.jail.interfaces.IJailPayManager;
|
||||
usage = "/jail pay (amount) (name)"
|
||||
)
|
||||
public class JailPayCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if (jm.getPlugin().getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) {
|
||||
IJailPayManager pm = jm.getPlugin().getJailPayManager();
|
||||
|
||||
@ -37,7 +36,7 @@ public class JailPayCommand implements Command {
|
||||
//send how much it costs to get out
|
||||
if (jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(sender.getName());
|
||||
String amt = "";
|
||||
String amt;
|
||||
|
||||
if (pm.usingItemsForPayment()) {
|
||||
amt = String.valueOf((int) Math.ceil(pm.calculateBill(p)));
|
||||
@ -47,14 +46,14 @@ public class JailPayCommand implements Command {
|
||||
|
||||
if (p.getRemainingTime() > 0) {
|
||||
if (pm.isTimedEnabled()) {
|
||||
sender.sendMessage(Lang.PAYCOST.get(new String[] { pm.getCostPerMinute(), pm.getCurrencyName(), amt }));
|
||||
sender.sendMessage(Lang.PAYCOST.get(pm.getCostPerMinute(), pm.getCurrencyName(), amt));
|
||||
} else {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
jm.getPlugin().debug("Jail pay 'timed' paying is not enabled (config has 0 as the cost).");
|
||||
}
|
||||
} else {
|
||||
if (pm.isInfiniteEnabled()) {
|
||||
sender.sendMessage(Lang.PAYCOST.get(new String[] { amt, pm.getCurrencyName() }));
|
||||
sender.sendMessage(Lang.PAYCOST.get(amt, pm.getCurrencyName()));
|
||||
} else {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
jm.getPlugin().debug("Jail pay 'infinite' paying is not enabled (config has 0 as the cost).");
|
||||
@ -86,7 +85,7 @@ public class JailPayCommand implements Command {
|
||||
if (args[1].startsWith("-")) {
|
||||
sender.sendMessage(Lang.PAYNONEGATIVEAMOUNTS.get());
|
||||
} else {
|
||||
double amt = 0;
|
||||
double amt;
|
||||
|
||||
try {
|
||||
amt = Double.parseDouble(args[1]);
|
||||
@ -108,7 +107,7 @@ public class JailPayCommand implements Command {
|
||||
long minutes = pm.getMinutesPayingFor(amt);
|
||||
pm.pay((Player) sender, amt);
|
||||
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
|
||||
sender.sendMessage(Lang.PAYPAIDLOWEREDTIME.get(new String[] { String.valueOf(amt), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
|
||||
sender.sendMessage(Lang.PAYPAIDLOWEREDTIME.get(String.valueOf(amt), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS))));
|
||||
}
|
||||
} else {
|
||||
//infinite jailing
|
||||
@ -154,7 +153,7 @@ public class JailPayCommand implements Command {
|
||||
if (args[1].startsWith("-")) {
|
||||
sender.sendMessage(Lang.PAYNONEGATIVEAMOUNTS.get());
|
||||
} else {
|
||||
double amt = 0;
|
||||
double amt;
|
||||
|
||||
try {
|
||||
amt = Double.parseDouble(args[1]);
|
||||
@ -171,19 +170,19 @@ public class JailPayCommand implements Command {
|
||||
//timed sentence
|
||||
if (amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASEDELSE.get(new String[] { String.valueOf(bill), p.getLastKnownName() }));
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASEDELSE.get(String.valueOf(bill), p.getLastKnownName()));
|
||||
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
|
||||
} else {
|
||||
long minutes = pm.getMinutesPayingFor(amt);
|
||||
pm.pay((Player) sender, amt);
|
||||
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
|
||||
sender.sendMessage(Lang.PAYPAIDLOWEREDTIMEELSE.get(new String[] { String.valueOf(amt), p.getLastKnownName(), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
|
||||
sender.sendMessage(Lang.PAYPAIDLOWEREDTIMEELSE.get(String.valueOf(amt), p.getLastKnownName(), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS))));
|
||||
}
|
||||
} else {
|
||||
//infinite jailing
|
||||
if (amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASEDELSE.get(new String[] { String.valueOf(bill), p.getLastKnownName() }));
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASEDELSE.get(String.valueOf(bill), p.getLastKnownName()));
|
||||
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
|
||||
} else {
|
||||
//You haven't provided enough money to get them out
|
||||
@ -211,11 +210,10 @@ public class JailPayCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
if (jm.getPlugin().getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) {
|
||||
switch(args.length) {
|
||||
case 3:
|
||||
List<String> results = new ArrayList<String>();
|
||||
if (args.length == 3) {
|
||||
List<String> results = new ArrayList<>();
|
||||
for (Prisoner p : jm.getAllPrisoners().values())
|
||||
if (!p.isOfflinePending()) //Don't list if they're offline pending
|
||||
if (p.getRemainingTime() != -1) //Don't list if they're jailed forever
|
||||
@ -225,8 +223,6 @@ public class JailPayCommand implements Command {
|
||||
Collections.sort(results);
|
||||
|
||||
return results;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
@ -25,7 +24,7 @@ public class JailRecordCommand implements Command {
|
||||
// /jail record <username>
|
||||
List<String> entries = jm.getPlugin().getJailIO().getRecordEntries(args[1]);
|
||||
|
||||
sender.sendMessage(Lang.RECORDTIMESJAILED.get(new String[] { args[1], String.valueOf(entries.size()) }));
|
||||
sender.sendMessage(Lang.RECORDTIMESJAILED.get(args[1], String.valueOf(entries.size())));
|
||||
} else if (args.length == 3) {
|
||||
// /jail record <username> something
|
||||
List<String> entries = jm.getPlugin().getJailIO().getRecordEntries(args[1]);
|
||||
@ -35,7 +34,7 @@ public class JailRecordCommand implements Command {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
|
||||
sender.sendMessage(Lang.RECORDTIMESJAILED.get(new String[] { args[1], String.valueOf(entries.size()) }));
|
||||
sender.sendMessage(Lang.RECORDTIMESJAILED.get(args[1], String.valueOf(entries.size())));
|
||||
} else {
|
||||
//They didn't do the command right
|
||||
//send them back to get the usage
|
||||
@ -45,7 +44,7 @@ public class JailRecordCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//We won't be implementing tab complete on this for now (unless requested)
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
@ -32,7 +31,7 @@ public class JailReloadCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//Reloading the plugin doesn't require tab completions
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,14 +1,5 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
@ -16,6 +7,14 @@ import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = -1,
|
||||
@ -28,7 +27,7 @@ import com.graywolf336.jail.enums.Lang;
|
||||
public class JailSignsCommand implements Command {
|
||||
private static final String[] options = new String[]{"clean", "refresh", "update", "verify"};
|
||||
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if (!jm.isValidJail(args[2])) {
|
||||
sender.sendMessage(" " + Lang.NOJAIL.get(args[1]));
|
||||
return true;
|
||||
@ -36,7 +35,7 @@ public class JailSignsCommand implements Command {
|
||||
|
||||
Jail j = jm.getJail(args[2]);
|
||||
|
||||
HashMap<String, List<String>> items = new HashMap<String, List<String>>();
|
||||
HashMap<String, List<String>> items = new HashMap<>();
|
||||
|
||||
if (args[1].equalsIgnoreCase("clean")) {
|
||||
//if they type clean, we can remove all signs which are no longer signs
|
||||
@ -82,7 +81,7 @@ public class JailSignsCommand implements Command {
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(Lang.SIGNSREFRESHED.get(new String[] { String.valueOf(updated), String.valueOf(removed), String.valueOf(cells) }));
|
||||
sender.sendMessage(Lang.SIGNSREFRESHED.get(String.valueOf(updated), String.valueOf(removed), String.valueOf(cells)));
|
||||
return true;
|
||||
} else if (args[1].equalsIgnoreCase("verify")) {
|
||||
//if they type verify, we will go through all the signs and then provide them
|
||||
@ -113,8 +112,8 @@ public class JailSignsCommand implements Command {
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
List<String> results = new ArrayList<String>();
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
@ -29,7 +28,7 @@ public class JailStatusCommand implements Command{
|
||||
if (jm.isPlayerJailed(pl.getUniqueId())) {
|
||||
Prisoner p = jm.getPrisoner(pl.getUniqueId());
|
||||
//They are jailed, so let's tell them some information
|
||||
sender.sendMessage(Lang.STATUS.get(new String[] { p.getReason(), p.getJailer(), String.valueOf(p.getRemainingTimeInMinutes()), Util.getDurationBreakdown(p.getRemainingTime()) }));
|
||||
sender.sendMessage(Lang.STATUS.get(p.getReason(), p.getJailer(), String.valueOf(p.getRemainingTimeInMinutes()), Util.getDurationBreakdown(p.getRemainingTime())));
|
||||
} else {
|
||||
//the sender of the command is not jailed, tell them that
|
||||
sender.sendMessage(Lang.YOUARENOTJAILED.get());
|
||||
@ -38,7 +37,7 @@ public class JailStatusCommand implements Command{
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//Checking your jail status doesn't require tab completion
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
@ -21,7 +20,7 @@ import com.graywolf336.jail.enums.Settings;
|
||||
usage = "/jail stick"
|
||||
)
|
||||
public class JailStickCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if (jm.getPlugin().getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||
boolean using = jm.getPlugin().getJailStickManager().toggleUsingStick(((Player) sender).getUniqueId());
|
||||
|
||||
@ -37,7 +36,7 @@ public class JailStickCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//Nothing to tab complete on jail stick
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
@ -41,7 +40,7 @@ public class JailStopCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//no tab completion required for stop command
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
@ -23,8 +22,7 @@ import com.graywolf336.jail.enums.Lang;
|
||||
usage = "/jail telein [jail] (name)"
|
||||
)
|
||||
public class JailTeleInCommand implements Command {
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
|
||||
//The jail doesn't exist
|
||||
@ -43,12 +41,12 @@ public class JailTeleInCommand implements Command {
|
||||
sender.sendMessage(Lang.PLAYERNOTONLINE.get(args[2]));
|
||||
} else {
|
||||
p.teleport(j.getTeleportIn());
|
||||
sender.sendMessage(Lang.TELEIN.get(new String[] { args[2], args[1] }));
|
||||
sender.sendMessage(Lang.TELEIN.get(args[2], args[1]));
|
||||
}
|
||||
} else {
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).teleport(j.getTeleportIn());
|
||||
sender.sendMessage(Lang.TELEIN.get(new String[] { sender.getName(), args[1] }));
|
||||
sender.sendMessage(Lang.TELEIN.get(sender.getName(), args[1]));
|
||||
} else {
|
||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||
}
|
||||
@ -58,12 +56,12 @@ public class JailTeleInCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
return jm.getJailsByPrefix(args[1]);
|
||||
case 3:
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||
if (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[2]))
|
||||
|
@ -1,18 +1,17 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
@ -23,8 +22,7 @@ import com.graywolf336.jail.enums.Lang;
|
||||
usage = "/jail teleout [jail] (name)"
|
||||
)
|
||||
public class JailTeleOutCommand implements Command {
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
|
||||
//The jail doesn't exist
|
||||
@ -43,12 +41,12 @@ public class JailTeleOutCommand implements Command {
|
||||
sender.sendMessage(Lang.PLAYERNOTONLINE.get(args[2]));
|
||||
} else {
|
||||
p.teleport(j.getTeleportFree());
|
||||
sender.sendMessage(Lang.TELEOUT.get(new String[] { args[2], args[1] }));
|
||||
sender.sendMessage(Lang.TELEOUT.get(args[2], args[1]));
|
||||
}
|
||||
} else {
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).teleport(j.getTeleportFree());
|
||||
sender.sendMessage(Lang.TELEOUT.get(new String[] { sender.getName(), args[1] }));
|
||||
sender.sendMessage(Lang.TELEOUT.get(sender.getName(), args[1]));
|
||||
} else {
|
||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||
}
|
||||
@ -58,12 +56,12 @@ public class JailTeleOutCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
return jm.getJailsByPrefix(args[1]);
|
||||
case 3:
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||
if (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[2]))
|
||||
|
@ -1,18 +1,17 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 3,
|
||||
@ -32,7 +31,7 @@ public class JailTimeCommand implements Command {
|
||||
switch (args.length) {
|
||||
case 3:
|
||||
if (args[1].equalsIgnoreCase("show")) {
|
||||
sender.sendMessage(Lang.PRISONERSTIME.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
sender.sendMessage(Lang.PRISONERSTIME.get(p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes())));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -48,7 +47,7 @@ public class JailTimeCommand implements Command {
|
||||
return false;
|
||||
}
|
||||
|
||||
sender.sendMessage(Lang.PRISONERSTIME.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
sender.sendMessage(Lang.PRISONERSTIME.get(p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes())));
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@ -60,8 +59,8 @@ public class JailTimeCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
List<String> results = new ArrayList<String>();
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
|
@ -1,19 +1,18 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
@ -24,7 +23,7 @@ import com.graywolf336.jail.enums.Lang;
|
||||
usage = "/jail transferall [current] [target]"
|
||||
)
|
||||
public class JailTransferAllCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if (jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(Lang.NOJAILS.get());
|
||||
return true;
|
||||
@ -45,7 +44,7 @@ public class JailTransferAllCommand implements Command {
|
||||
jm.getPlugin().debug("Sending the transferring off, jail checks all came clean.");
|
||||
|
||||
Jail old = jm.getJail(args[1]);
|
||||
HashSet<Prisoner> oldPrisoners = new HashSet<Prisoner>(old.getAllPrisoners().values());
|
||||
HashSet<Prisoner> oldPrisoners = new HashSet<>(old.getAllPrisoners().values());
|
||||
|
||||
//Transfer all the prisoners
|
||||
for (Prisoner p : oldPrisoners) {
|
||||
@ -53,17 +52,17 @@ public class JailTransferAllCommand implements Command {
|
||||
}
|
||||
|
||||
//Send the messages to the sender when completed
|
||||
sender.sendMessage(Lang.TRANSFERALLCOMPLETE.get(new String[] { old.getName(), args[2] }));
|
||||
sender.sendMessage(Lang.TRANSFERALLCOMPLETE.get(old.getName(), args[2]));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
return jm.getJailsByPrefix(args[1]);
|
||||
case 3:
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Jail j : jm.getJails())
|
||||
if (!j.getName().equalsIgnoreCase(args[1]) && (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(j.getName(), args[2])))
|
||||
|
@ -1,17 +1,5 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
@ -24,6 +12,17 @@ import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.events.PrePrisonerTransferredEvent;
|
||||
import com.lexicalscope.jewel.cli.ArgumentValidationException;
|
||||
import com.lexicalscope.jewel.cli.CliFactory;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 6,
|
||||
@ -34,24 +33,24 @@ import com.lexicalscope.jewel.cli.CliFactory;
|
||||
usage = "/jail transfer [-p player] (-j jail) (-c cell)"
|
||||
)
|
||||
public class JailTransferCommand implements Command {
|
||||
private List<String> commands = Arrays.asList(new String[] { "p", "j", "c" });
|
||||
private final List<String> commands = Arrays.asList("p", "j", "c");
|
||||
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if (jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(Lang.NOJAILS.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
//Convert to a List<String> so we can edit the list
|
||||
List<String> arguments = new LinkedList<String>(Arrays.asList(args));
|
||||
List<String> arguments = new LinkedList<>(Arrays.asList(args));
|
||||
//remove the first argument of "transfer"
|
||||
arguments.remove(0);
|
||||
|
||||
//Parse the command
|
||||
Transfer params = null;
|
||||
Transfer params;
|
||||
|
||||
try {
|
||||
params = CliFactory.parseArguments(Transfer.class, arguments.toArray(new String[arguments.size()]));
|
||||
params = CliFactory.parseArguments(Transfer.class, arguments.toArray(new String[0]));
|
||||
} catch (ArgumentValidationException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
return true;
|
||||
@ -86,7 +85,7 @@ public class JailTransferCommand implements Command {
|
||||
//Check if they provided a cell and if so does it exist
|
||||
if (params.getCell() != null) {
|
||||
if (target.getCell(params.getCell()) == null) {
|
||||
sender.sendMessage(Lang.NOCELL.get(new String[] { params.getCell(), params.getJail() }));
|
||||
sender.sendMessage(Lang.NOCELL.get(params.getCell(), params.getJail()));
|
||||
return true;
|
||||
} else {
|
||||
//Store the cell for easy of access and also check if it already is full
|
||||
@ -98,7 +97,7 @@ public class JailTransferCommand implements Command {
|
||||
//But suggest the first empty cell we find
|
||||
Cell suggestedCell = jm.getJail(params.getCell()).getFirstEmptyCell();
|
||||
if (suggestedCell != null) {
|
||||
sender.sendMessage(Lang.SUGGESTEDCELL.get(new String[] { params.getCell(), suggestedCell.getName() }));
|
||||
sender.sendMessage(Lang.SUGGESTEDCELL.get(params.getCell(), suggestedCell.getName()));
|
||||
} else {
|
||||
sender.sendMessage(Lang.NOEMPTYCELLS.get(params.getCell()));
|
||||
}
|
||||
@ -135,15 +134,15 @@ public class JailTransferCommand implements Command {
|
||||
|
||||
//Send the messages to the sender, if no cell then say that but if cell send that as well
|
||||
if (targetCell == null) {
|
||||
sender.sendMessage(Lang.TRANSFERCOMPLETENOCELL.get(new String[] { params.getPlayer(), target.getName() }));
|
||||
sender.sendMessage(Lang.TRANSFERCOMPLETENOCELL.get(params.getPlayer(), target.getName()));
|
||||
} else {
|
||||
sender.sendMessage(Lang.TRANSFERCOMPLETECELL.get(new String[] { params.getPlayer(), target.getName(), targetCell.getName() }));
|
||||
sender.sendMessage(Lang.TRANSFERCOMPLETECELL.get(params.getPlayer(), target.getName(), targetCell.getName()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//by the time it gets to this command it'll have at least two arguments
|
||||
String last = args[args.length - 1];
|
||||
|
||||
@ -165,7 +164,8 @@ public class JailTransferCommand implements Command {
|
||||
jm.getPlugin().debug("The jail is: " + jail);
|
||||
if (jm.isValidJail(jail)) return getCells(jm, jail, last);
|
||||
}
|
||||
}else if(!commands.contains(args[args.length - 2].replace("-", ""))) return Util.getUnusedItems(commands, args, true);
|
||||
} else if (!commands.contains(args[args.length - 2].replace("-", "")))
|
||||
return Util.getUnusedItems(commands, args, true);
|
||||
}
|
||||
} else if (last.equalsIgnoreCase("-")) {
|
||||
//add some smart checking so that it only returns a list of what isn't already
|
||||
@ -179,7 +179,7 @@ public class JailTransferCommand implements Command {
|
||||
}
|
||||
|
||||
private List<String> getPlayers(JailManager jm, String first) {
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||
if (first.isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), first))
|
||||
@ -191,7 +191,7 @@ public class JailTransferCommand implements Command {
|
||||
}
|
||||
|
||||
private List<String> getCells(JailManager jm, String jail, String cell) {
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (Cell c : jm.getJail(jail).getCells())
|
||||
if (!c.hasPrisoner() && (cell.isEmpty() || StringUtil.startsWithIgnoreCase(c.getName(), cell)))
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
@ -26,7 +25,7 @@ public class JailVersionCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
//no tab completion required for version command
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,13 +1,5 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.JailVoteManager;
|
||||
import com.graywolf336.jail.beans.JailVote;
|
||||
@ -15,6 +7,13 @@ import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
@ -27,7 +26,6 @@ import com.graywolf336.jail.enums.Settings;
|
||||
public class JailVoteCommand implements Command {
|
||||
private static final String[] options = new String[]{"yes", "no"};
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if (jm.getPlugin().getConfig().getBoolean(Settings.JAILVOTEENABLED.getPath()) && jm.getPlugin().getJailVoteManager() != null && !jm.getJails().isEmpty()) {
|
||||
Player p = (Player) sender;
|
||||
@ -57,7 +55,7 @@ public class JailVoteCommand implements Command {
|
||||
jvm.addVote(voteAgainst.getName(), p.getUniqueId(), true);
|
||||
|
||||
jm.getPlugin().getServer().broadcastMessage(Lang.VOTEBROADCASTHEADER.get());
|
||||
jm.getPlugin().getServer().broadcastMessage(Lang.VOTEBROADCASTLINE1.get(new String[] { sender.getName(), args[1] }));
|
||||
jm.getPlugin().getServer().broadcastMessage(Lang.VOTEBROADCASTLINE1.get(sender.getName(), args[1]));
|
||||
jm.getPlugin().getServer().broadcastMessage(Lang.VOTEBROADCASTLINE2.get(voteAgainst.getName()));
|
||||
jm.getPlugin().getServer().broadcastMessage(Lang.VOTEBROADCASTLINE3.get(voteAgainst.getName()));
|
||||
jm.getPlugin().getServer().broadcastMessage(Lang.VOTEBROADCASTLINE4.get(jvm.getTimerLengthDescription()));
|
||||
@ -106,9 +104,9 @@ public class JailVoteCommand implements Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||
if (jm.getPlugin().getConfig().getBoolean(Settings.JAILVOTEENABLED.getPath()) && jm.getPlugin().getJailVoteManager() != null && !jm.getJails().isEmpty()) {
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
|
@ -1,14 +1,24 @@
|
||||
package com.graywolf336.jail.enums;
|
||||
|
||||
public enum Confirmation {
|
||||
/** When they are clearing a jail from all their prisoner's with releasing properly. */
|
||||
/**
|
||||
* When they are clearing a jail from all their prisoner's with releasing properly.
|
||||
*/
|
||||
CLEAR,
|
||||
/** When they are clearing a jail from all their prisoner's by force. */
|
||||
/**
|
||||
* When they are clearing a jail from all their prisoner's by force.
|
||||
*/
|
||||
CLEARFORCE,
|
||||
/** When they are deleting a cell from a jail. */
|
||||
/**
|
||||
* When they are deleting a cell from a jail.
|
||||
*/
|
||||
DELETECELL,
|
||||
/** When they are deleting all a jail's cells. */
|
||||
/**
|
||||
* When they are deleting all a jail's cells.
|
||||
*/
|
||||
DELETECELLS,
|
||||
/** When they are deleting a jail. */
|
||||
DELETE;
|
||||
/**
|
||||
* When they are deleting a jail.
|
||||
*/
|
||||
DELETE
|
||||
}
|
||||
|
@ -1,22 +1,40 @@
|
||||
package com.graywolf336.jail.enums;
|
||||
|
||||
public enum JailVoteResult {
|
||||
/** The result when the PrePrisonerJailedEvent is cancelled. */
|
||||
/**
|
||||
* The result when the PrePrisonerJailedEvent is cancelled.
|
||||
*/
|
||||
EVENTCANCELLED,
|
||||
/** The result when the jailing results in an exception for some reason. */
|
||||
/**
|
||||
* The result when the jailing results in an exception for some reason.
|
||||
*/
|
||||
JAILEDEXCEPTION,
|
||||
/** The result when the jail which is picked is not enabled. */
|
||||
/**
|
||||
* The result when the jail which is picked is not enabled.
|
||||
*/
|
||||
JAILNOTENABLED,
|
||||
/** The result when the player who the vote is for is no longer online. */
|
||||
/**
|
||||
* The result when the player who the vote is for is no longer online.
|
||||
*/
|
||||
NOTONLINE,
|
||||
/** The result when there aren't enough yes votes as configured. */
|
||||
/**
|
||||
* The result when there aren't enough yes votes as configured.
|
||||
*/
|
||||
NOTENOUGHYESVOTES,
|
||||
/** The result when there are no jails. */
|
||||
/**
|
||||
* The result when there are no jails.
|
||||
*/
|
||||
NOJAIL,
|
||||
/** The result when there are more no votes than yes votes. */
|
||||
/**
|
||||
* The result when there are more no votes than yes votes.
|
||||
*/
|
||||
NO,
|
||||
/** The result when the votes are tied, resulting in no jailing. */
|
||||
/**
|
||||
* The result when the votes are tied, resulting in no jailing.
|
||||
*/
|
||||
TIED,
|
||||
/** The result when there are enough yes votes over no votes for the vote to be successful. */
|
||||
/**
|
||||
* The result when there are enough yes votes over no votes for the vote to be successful.
|
||||
*/
|
||||
YES
|
||||
}
|
||||
|
@ -5,266 +5,514 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public enum Lang {
|
||||
// actions section
|
||||
/** Section for when they break a block. */
|
||||
/**
|
||||
* Section for when they break a block.
|
||||
*/
|
||||
BLOCKBREAKING("actions"),
|
||||
/** Section for when they place a block. */
|
||||
/**
|
||||
* Section for when they place a block.
|
||||
*/
|
||||
BLOCKPLACING("actions"),
|
||||
/** Section for when they try to do a command that isn't whitelisted. */
|
||||
/**
|
||||
* Section for when they try to do a command that isn't whitelisted.
|
||||
*/
|
||||
COMMAND("actions"),
|
||||
/** Section for when a player tramples a crop and protection is enabled. */
|
||||
/**
|
||||
* Section for when a player tramples a crop and protection is enabled.
|
||||
*/
|
||||
CROPTRAMPLING("actions"),
|
||||
/** Section for when a player interacts with a block that is blacklisted. */
|
||||
/**
|
||||
* Section for when a player interacts with a block that is blacklisted.
|
||||
*/
|
||||
INTERACTIONBLOCKS("actions"),
|
||||
/** Section for when a player interacts with an item that is blacklisted. */
|
||||
/**
|
||||
* Section for when a player interacts with an item that is blacklisted.
|
||||
*/
|
||||
INTERACTIONITEMS("actions"),
|
||||
/** Section for when a player moves outside of the jail. */
|
||||
/**
|
||||
* Section for when a player moves outside of the jail.
|
||||
*/
|
||||
MOVING("actions"),
|
||||
|
||||
// Jailing section
|
||||
/** The message displayed when players are kicked for being afk. */
|
||||
/**
|
||||
* The message displayed when players are kicked for being afk.
|
||||
*/
|
||||
AFKKICKMESSAGE("jailing"),
|
||||
/** The message sent when jailing someone that is already jailed. */
|
||||
/**
|
||||
* The message sent when jailing someone that is already jailed.
|
||||
*/
|
||||
ALREADYJAILED("jailing"),
|
||||
/** The message sent when we broadcast/log the message for time below -1. */
|
||||
/**
|
||||
* The message sent when we broadcast/log the message for time below -1.
|
||||
*/
|
||||
BROADCASTMESSAGEFOREVER("jailing"),
|
||||
/** The message sent when we broadcast/log the message for any time above -1. */
|
||||
/**
|
||||
* The message sent when we broadcast/log the message for any time above -1.
|
||||
*/
|
||||
BROADCASTMESSAGEFORMINUTES("jailing"),
|
||||
/** The message sent to the broadcast/log the unjailing of someone. */
|
||||
/**
|
||||
* The message sent to the broadcast/log the unjailing of someone.
|
||||
*/
|
||||
BROADCASTUNJAILING("jailing"),
|
||||
/** The message sent to the sender when trying to jail someone and a plugin cancels it but doesn't leave a message why. */
|
||||
/**
|
||||
* The message sent to the sender when trying to jail someone and a plugin cancels it but doesn't leave a message why.
|
||||
*/
|
||||
CANCELLEDBYANOTHERPLUGIN("jailing"),
|
||||
/** The message sent when trying to jail someone who can't be jailed by permission. */
|
||||
/**
|
||||
* The message sent when trying to jail someone who can't be jailed by permission.
|
||||
*/
|
||||
CANTBEJAILED("jailing"),
|
||||
/** The message sent to the sender when they are trying to jail into a cell which is not empty. */
|
||||
/**
|
||||
* The message sent to the sender when they are trying to jail into a cell which is not empty.
|
||||
*/
|
||||
CELLNOTEMPTY("jailing"),
|
||||
/** The jailer set whenever a jailer is not provided. */
|
||||
/**
|
||||
* The jailer set whenever a jailer is not provided.
|
||||
*/
|
||||
DEFAULTJAILER("jailing"),
|
||||
/** The message sent when someone is jailed without a reason. */
|
||||
/**
|
||||
* The message sent when someone is jailed without a reason.
|
||||
*/
|
||||
DEFAULTJAILEDREASON("jailing"),
|
||||
/** The message sent when someone is unjailed yet they never came online and so they were forcefully unjailed. */
|
||||
/**
|
||||
* The message sent when someone is unjailed yet they never came online and so they were forcefully unjailed.
|
||||
*/
|
||||
FORCEUNJAILED("jailing"),
|
||||
/** The message sent when players are jailed without a reason. */
|
||||
/**
|
||||
* The message sent when players are jailed without a reason.
|
||||
*/
|
||||
JAILED("jailing"),
|
||||
/** The message sent when players are jailed with a reason. */
|
||||
/**
|
||||
* The message sent when players are jailed with a reason.
|
||||
*/
|
||||
JAILEDWITHREASON("jailing"),
|
||||
/** The message sent when players are jailed and they try to talk. */
|
||||
/**
|
||||
* The message sent when players are jailed and they try to talk.
|
||||
*/
|
||||
MUTED("jailing"),
|
||||
/** The message sent when the sender tries to jail someone in a cell and there aren't any cells to suggest. */
|
||||
/**
|
||||
* The message sent when the sender tries to jail someone in a cell and there aren't any cells to suggest.
|
||||
*/
|
||||
NOEMPTYCELLS("jailing"),
|
||||
/** The message sent to the sender when they list all the prisoners in a jail which has no prisoners. */
|
||||
/**
|
||||
* The message sent to the sender when they list all the prisoners in a jail which has no prisoners.
|
||||
*/
|
||||
NOPRISONERS("jailing"),
|
||||
/** The message sent when a player is not jailed and the sender is trying to see/do something about it. */
|
||||
/**
|
||||
* The message sent when a player is not jailed and the sender is trying to see/do something about it.
|
||||
*/
|
||||
NOTJAILED("jailing"),
|
||||
/** The message sent to the sender when they mute a prisoner. */
|
||||
/**
|
||||
* The message sent to the sender when they mute a prisoner.
|
||||
*/
|
||||
NOWMUTED("jailing"),
|
||||
/** The message sent to the sender when they unmute a prisoner. */
|
||||
/**
|
||||
* The message sent to the sender when they unmute a prisoner.
|
||||
*/
|
||||
NOWUNMUTED("jailing"),
|
||||
/** The message sent to the jailer when they jail someone offline. */
|
||||
/**
|
||||
* The message sent to the jailer when they jail someone offline.
|
||||
*/
|
||||
OFFLINEJAIL("jailing"),
|
||||
/** The message sent to the jailer when they jail someone who is online. */
|
||||
/**
|
||||
* The message sent to the jailer when they jail someone who is online.
|
||||
*/
|
||||
ONLINEJAIL("jailing"),
|
||||
/** The message sent to the jailer when they jail someone who has never played before. */
|
||||
/**
|
||||
* The message sent to the jailer when they jail someone who has never played before.
|
||||
*/
|
||||
PLAYERHASNEVERPLAYEDBEFORE("jailing"),
|
||||
/** The message sent when finding out how much time a prisoner has. */
|
||||
/**
|
||||
* The message sent when finding out how much time a prisoner has.
|
||||
*/
|
||||
PRISONERSTIME("jailing"),
|
||||
/** The message sent to the prisoner when they try to do something but it is protected. */
|
||||
/**
|
||||
* The message sent to the prisoner when they try to do something but it is protected.
|
||||
*/
|
||||
PROTECTIONMESSAGE("jailing"),
|
||||
/** The message sent to the prisoner when they try to do something and it is protected, but no penalty. */
|
||||
/**
|
||||
* The message sent to the prisoner when they try to do something and it is protected, but no penalty.
|
||||
*/
|
||||
PROTECTIONMESSAGENOPENALTY("jailing"),
|
||||
/** The message sent to the sender when they need to provide a player. */
|
||||
/**
|
||||
* The message sent to the sender when they need to provide a player.
|
||||
*/
|
||||
PROVIDEAPLAYER("jailing"),
|
||||
/** The message sent to the sender when they need to provide a jail. */
|
||||
/**
|
||||
* The message sent to the sender when they need to provide a jail.
|
||||
*/
|
||||
PROVIDEAJAIL("jailing"),
|
||||
/** The message sent to someone trying to jail someone else with a jail stick that requires health below a certain amount. */
|
||||
/**
|
||||
* The message sent to someone trying to jail someone else with a jail stick that requires health below a certain amount.
|
||||
*/
|
||||
RESISTEDARRESTJAILER("jailing"),
|
||||
/** The message sent to the person someone else is trying to jail that requires their health below a certain amount. */
|
||||
/**
|
||||
* The message sent to the person someone else is trying to jail that requires their health below a certain amount.
|
||||
*/
|
||||
RESISTEDARRESTPLAYER("jailing"),
|
||||
/** The message sent when to a prisoner about their status in jail. */
|
||||
/**
|
||||
* The message sent when to a prisoner about their status in jail.
|
||||
*/
|
||||
STATUS("jailing"),
|
||||
/** The message sent to the sender of a command when suggesting a cell. */
|
||||
/**
|
||||
* The message sent to the sender of a command when suggesting a cell.
|
||||
*/
|
||||
SUGGESTEDCELL("jailing"),
|
||||
/** The message sent to the sender when they teleport someone to a jail's teleport in location. */
|
||||
/**
|
||||
* The message sent to the sender when they teleport someone to a jail's teleport in location.
|
||||
*/
|
||||
TELEIN("jailing"),
|
||||
/** The message sent to the sender when they teleport someone to a jail's teleport out location. */
|
||||
/**
|
||||
* The message sent to the sender when they teleport someone to a jail's teleport out location.
|
||||
*/
|
||||
TELEOUT("jailing"),
|
||||
/** The message sent to the sender when they transfer all a jail's prisoners to another jail. */
|
||||
/**
|
||||
* The message sent to the sender when they transfer all a jail's prisoners to another jail.
|
||||
*/
|
||||
TRANSFERALLCOMPLETE("jailing"),
|
||||
/** The message sent when another plugin cancels the transferring but doesn't provide a reason why. */
|
||||
/**
|
||||
* The message sent when another plugin cancels the transferring but doesn't provide a reason why.
|
||||
*/
|
||||
TRANSFERCANCELLEDBYANOTHERPLUGIN("jailing"),
|
||||
/** The message sent to the sender when they transfer someone to a jail and a cell. */
|
||||
/**
|
||||
* The message sent to the sender when they transfer someone to a jail and a cell.
|
||||
*/
|
||||
TRANSFERCOMPLETECELL("jailing"),
|
||||
/** The message sent to the sender when they transfer someone to a jail. */
|
||||
/**
|
||||
* The message sent to the sender when they transfer someone to a jail.
|
||||
*/
|
||||
TRANSFERCOMPLETENOCELL("jailing"),
|
||||
/** The message sent to the player when they get transferred to a new jail. */
|
||||
/**
|
||||
* The message sent to the player when they get transferred to a new jail.
|
||||
*/
|
||||
TRANSFERRED("jailing"),
|
||||
/** The message sent when players are released from jail. */
|
||||
/**
|
||||
* The message sent when players are released from jail.
|
||||
*/
|
||||
UNJAILED("jailing"),
|
||||
/** The message sent to the person who released a prisoner from jail. */
|
||||
/**
|
||||
* The message sent to the person who released a prisoner from jail.
|
||||
*/
|
||||
UNJAILSUCCESS("jailing"),
|
||||
/** The message sent when you jailing offline players is not allowed. */
|
||||
/**
|
||||
* The message sent when you jailing offline players is not allowed.
|
||||
*/
|
||||
UNALLOWEDTOJAILOFFLINE("jailing"),
|
||||
/** The message went when an offline player is unjailed. */
|
||||
/**
|
||||
* The message went when an offline player is unjailed.
|
||||
*/
|
||||
WILLBEUNJAILED("jailing"),
|
||||
/** The message sent when trying to jail a player in an unloaded world. */
|
||||
/**
|
||||
* The message sent when trying to jail a player in an unloaded world.
|
||||
*/
|
||||
WORLDUNLOADED("jailing"),
|
||||
/** The message sent when a player joins and is jailed in a world that is unloaded. */
|
||||
/**
|
||||
* The message sent when a player joins and is jailed in a world that is unloaded.
|
||||
*/
|
||||
WORLDUNLOADEDKICK("jailing"),
|
||||
/** The message sent to the sender when they check their jail status and they aren't jailed. */
|
||||
/**
|
||||
* The message sent to the sender when they check their jail status and they aren't jailed.
|
||||
*/
|
||||
YOUARENOTJAILED("jailing"),
|
||||
|
||||
// Handcuffing section
|
||||
/** The message sent to the sender when trying to handcuff someone who can't be. */
|
||||
/**
|
||||
* The message sent to the sender when trying to handcuff someone who can't be.
|
||||
*/
|
||||
CANTBEHANDCUFFED("handcuffing"),
|
||||
/** The message sent to the sender whenever they try to handcuff someone who is in jail. */
|
||||
/**
|
||||
* The message sent to the sender whenever they try to handcuff someone who is in jail.
|
||||
*/
|
||||
CURRENTLYJAILEDHANDCUFF("handcuffing", "currentlyjailed"),
|
||||
/** The message sent to the sender when the player doesn't have any handcuffs. */
|
||||
/**
|
||||
* The message sent to the sender when the player doesn't have any handcuffs.
|
||||
*/
|
||||
NOTHANDCUFFED("handcuffing"),
|
||||
/** The message sent to the handcuff on a successful handcuffing. */
|
||||
/**
|
||||
* The message sent to the handcuff on a successful handcuffing.
|
||||
*/
|
||||
HANDCUFFSON("handcuffing"),
|
||||
/** The message sent when players are handcuffed. */
|
||||
/**
|
||||
* The message sent when players are handcuffed.
|
||||
*/
|
||||
HANDCUFFED("handcuffing"),
|
||||
/** The message sent to the player who has release handcuffs. */
|
||||
/**
|
||||
* The message sent to the player who has release handcuffs.
|
||||
*/
|
||||
HANDCUFFSRELEASED("handcuffing"),
|
||||
/** The message sent when the player has his/her handcuffs removed. */
|
||||
/**
|
||||
* The message sent when the player has his/her handcuffs removed.
|
||||
*/
|
||||
UNHANDCUFFED("handcuffing"),
|
||||
|
||||
// General section, used by different parts
|
||||
/** Part message of any messages which require 'all the jails' or such. */
|
||||
/**
|
||||
* Part message of any messages which require 'all the jails' or such.
|
||||
*/
|
||||
ALLJAILS("general"),
|
||||
/** The one line on signs when the cell is empty. */
|
||||
/**
|
||||
* The one line on signs when the cell is empty.
|
||||
*/
|
||||
CELLEMPTYSIGN("general"),
|
||||
/** The message sent to the sender whenever they try to remove a cell but was unsuccessful due to a prisoner. */
|
||||
/**
|
||||
* The message sent to the sender whenever they try to remove a cell but was unsuccessful due to a prisoner.
|
||||
*/
|
||||
CELLREMOVALUNSUCCESSFUL("general"),
|
||||
/** The message sent whenever a cell is successfully removed. */
|
||||
/**
|
||||
* The message sent whenever a cell is successfully removed.
|
||||
*/
|
||||
CELLREMOVED("general"),
|
||||
/** The message sent when cleaning our cell signs. */
|
||||
/**
|
||||
* The message sent when cleaning our cell signs.
|
||||
*/
|
||||
CLEANEDSIGNS("general"),
|
||||
/** The message sent when seeing what signs are invalid. */
|
||||
/**
|
||||
* The message sent when seeing what signs are invalid.
|
||||
*/
|
||||
INVALIDSIGNS("general"),
|
||||
/** The line on a cell's sign when the prisoner is jailed forever. */
|
||||
/**
|
||||
* The line on a cell's sign when the prisoner is jailed forever.
|
||||
*/
|
||||
JAILEDFOREVERSIGN("general"),
|
||||
/** The simple word jailing to be put in other parts. */
|
||||
/**
|
||||
* The simple word jailing to be put in other parts.
|
||||
*/
|
||||
JAILING("general"),
|
||||
/** The message sent to the sender when they try to remove a jail but there are still prisoners in there. */
|
||||
/**
|
||||
* The message sent to the sender when they try to remove a jail but there are still prisoners in there.
|
||||
*/
|
||||
JAILREMOVALUNSUCCESSFUL("general"),
|
||||
/** The message sent whenever a jail is successfully removed. */
|
||||
/**
|
||||
* The message sent whenever a jail is successfully removed.
|
||||
*/
|
||||
JAILREMOVED("general"),
|
||||
/** The message sent whenever a player toggles using jail stick to disabled. */
|
||||
/**
|
||||
* The message sent whenever a player toggles using jail stick to disabled.
|
||||
*/
|
||||
JAILSTICKDISABLED("general"),
|
||||
/** The message sent whenever a player toggles using jail stick to enabled. */
|
||||
/**
|
||||
* The message sent whenever a player toggles using jail stick to enabled.
|
||||
*/
|
||||
JAILSTICKENABLED("general"),
|
||||
/** The message sent whenever a player tries to toggle using jail stick but the config has it disabled. */
|
||||
/**
|
||||
* The message sent whenever a player tries to toggle using jail stick but the config has it disabled.
|
||||
*/
|
||||
JAILSTICKUSAGEDISABLED("general"),
|
||||
/** Message sent when doing something that requires a cell but the given name of a cell doesn't exist. */
|
||||
/**
|
||||
* Message sent when doing something that requires a cell but the given name of a cell doesn't exist.
|
||||
*/
|
||||
NOCELL("general"),
|
||||
/** Message sent when needing a cell or something and there are no cells. */
|
||||
/**
|
||||
* Message sent when needing a cell or something and there are no cells.
|
||||
*/
|
||||
NOCELLS("general"),
|
||||
/** Message sent when no invalid signs were found. */
|
||||
/**
|
||||
* Message sent when no invalid signs were found.
|
||||
*/
|
||||
NOINVALIDSIGNS("general"),
|
||||
/** The message sent whenever the sender does something which the jail does not found. */
|
||||
/**
|
||||
* The message sent whenever the sender does something which the jail does not found.
|
||||
*/
|
||||
NOJAIL("general"),
|
||||
/** The message sent whenever the sender does something and there are no jails. */
|
||||
/**
|
||||
* The message sent whenever the sender does something and there are no jails.
|
||||
*/
|
||||
NOJAILS("general"),
|
||||
/** The message sent whenever the sender/player doesn't have permission. */
|
||||
/**
|
||||
* The message sent whenever the sender/player doesn't have permission.
|
||||
*/
|
||||
NOPERMISSION("general"),
|
||||
/** The message sent whenever the sender/player supplies a number format that is incorrect. */
|
||||
/**
|
||||
* The message sent whenever the sender/player supplies a number format that is incorrect.
|
||||
*/
|
||||
NUMBERFORMATINCORRECT("general"),
|
||||
/** The message sent whenever something is done that needs a player but doesn't have it. */
|
||||
/**
|
||||
* The message sent whenever something is done that needs a player but doesn't have it.
|
||||
*/
|
||||
PLAYERCONTEXTREQUIRED("general"),
|
||||
/** The message sent whenever an online player is required but not found. */
|
||||
/**
|
||||
* The message sent whenever an online player is required but not found.
|
||||
*/
|
||||
PLAYERNOTONLINE("general"),
|
||||
/** The message sent to the sender when the plugin data has been reloaded. */
|
||||
/**
|
||||
* The message sent to the sender when the plugin data has been reloaded.
|
||||
*/
|
||||
PLUGINRELOADED("general"),
|
||||
/** The message sent to the sender of a command when the plugin didn't start correct. */
|
||||
/**
|
||||
* The message sent to the sender of a command when the plugin didn't start correct.
|
||||
*/
|
||||
PLUGINNOTLOADED("general"),
|
||||
/** The message sent whenever the prisoners are cleared from jail(s). */
|
||||
/**
|
||||
* The message sent whenever the prisoners are cleared from jail(s).
|
||||
*/
|
||||
PRISONERSCLEARED("general"),
|
||||
/** The format we should use when entering a record into flatfile or showing it. */
|
||||
/**
|
||||
* The format we should use when entering a record into flatfile or showing it.
|
||||
*/
|
||||
RECORDENTRY("general"),
|
||||
/** The message format sent saying how many times a user has been jailed. */
|
||||
/**
|
||||
* The message format sent saying how many times a user has been jailed.
|
||||
*/
|
||||
RECORDTIMESJAILED("general"),
|
||||
/** The simple word: sign. */
|
||||
/**
|
||||
* The simple word: sign.
|
||||
*/
|
||||
SIGN("general"),
|
||||
/** The message sent when the signs are refreshed. */
|
||||
/**
|
||||
* The message sent when the signs are refreshed.
|
||||
*/
|
||||
SIGNSREFRESHED("general"),
|
||||
/** The format of the time entry we should use for the record entries. */
|
||||
/**
|
||||
* The format of the time entry we should use for the record entries.
|
||||
*/
|
||||
TIMEFORMAT("general"),
|
||||
/** The simple word transferring to be put in other parts. */
|
||||
/**
|
||||
* The simple word transferring to be put in other parts.
|
||||
*/
|
||||
TRANSFERRING("general"),
|
||||
/** The message sent whenever someone does a command we don't know. */
|
||||
/**
|
||||
* The message sent whenever someone does a command we don't know.
|
||||
*/
|
||||
UNKNOWNCOMMAND("general"),
|
||||
|
||||
// Jail pay
|
||||
/** The message sent when the jail pay portion is not enabled. */
|
||||
/**
|
||||
* The message sent when the jail pay portion is not enabled.
|
||||
*/
|
||||
PAYNOTENABLED("jailpay", "notenabled"),
|
||||
/** The message sent when finding out how much it costs. */
|
||||
/**
|
||||
* The message sent when finding out how much it costs.
|
||||
*/
|
||||
PAYCOST("jailpay", "cost"),
|
||||
/** The message sent when finding out how much it costs and they are jailed forever. */
|
||||
/**
|
||||
* The message sent when finding out how much it costs and they are jailed forever.
|
||||
*/
|
||||
PAYCOSTINFINITE("jailpay", "costinfinite"),
|
||||
/** The message sent when someone tries to pay a negative amount. */
|
||||
/**
|
||||
* The message sent when someone tries to pay a negative amount.
|
||||
*/
|
||||
PAYNONEGATIVEAMOUNTS("jailpay", "nonegativeamounts"),
|
||||
/** The message sent when someone is jailed and tries to pay for someone else. */
|
||||
/**
|
||||
* The message sent when someone is jailed and tries to pay for someone else.
|
||||
*/
|
||||
PAYCANTPAYWHILEJAILED("jailpay", "cantpayforotherswhilejailed"),
|
||||
/** The message sent whenever someone tries to pay an amount they don't have. */
|
||||
/**
|
||||
* The message sent whenever someone tries to pay an amount they don't have.
|
||||
*/
|
||||
PAYNOTENOUGHMONEY("jailpay", "notenoughmoney"),
|
||||
/** The message sent when they try to pay an amount but it isn't enough for the jailing sentence. */
|
||||
/**
|
||||
* The message sent when they try to pay an amount but it isn't enough for the jailing sentence.
|
||||
*/
|
||||
PAYNOTENOUGHMONEYPROVIDED("jailpay", "notenoughmoneyprovided"),
|
||||
/** The message sent when they pay and get released. */
|
||||
/**
|
||||
* The message sent when they pay and get released.
|
||||
*/
|
||||
PAYPAIDRELEASED("jailpay", "paidreleased"),
|
||||
/** The message sent when they pay for someone else and release them. */
|
||||
/**
|
||||
* The message sent when they pay for someone else and release them.
|
||||
*/
|
||||
PAYPAIDRELEASEDELSE("jailpay", "paidreleasedelse"),
|
||||
/** The message sent when they pay and lower their time. */
|
||||
/**
|
||||
* The message sent when they pay and lower their time.
|
||||
*/
|
||||
PAYPAIDLOWEREDTIME("jailpay", "paidloweredtime"),
|
||||
/** The message sent when they pay and lower someone else's time. */
|
||||
/**
|
||||
* The message sent when they pay and lower someone else's time.
|
||||
*/
|
||||
PAYPAIDLOWEREDTIMEELSE("jailpay", "paidloweredtimeelse"),
|
||||
|
||||
// Jail vote
|
||||
/** The header sent when broadcasting a new jail vote. */
|
||||
/**
|
||||
* The header sent when broadcasting a new jail vote.
|
||||
*/
|
||||
VOTEBROADCASTHEADER("jailvote.broadcast", "header"),
|
||||
/** The footer sent when broadcasting a new jail vote. */
|
||||
/**
|
||||
* The footer sent when broadcasting a new jail vote.
|
||||
*/
|
||||
VOTEBROADCASTFOOTER("jailvote.broadcast", "footer"),
|
||||
/** Line1 of the broadcast message sent when a new jail vote is happening. */
|
||||
/**
|
||||
* Line1 of the broadcast message sent when a new jail vote is happening.
|
||||
*/
|
||||
VOTEBROADCASTLINE1("jailvote.broadcast", "line1"),
|
||||
/** Line2 of the broadcast message sent when a new jail vote is happening. */
|
||||
/**
|
||||
* Line2 of the broadcast message sent when a new jail vote is happening.
|
||||
*/
|
||||
VOTEBROADCASTLINE2("jailvote.broadcast", "line2"),
|
||||
/** Line3 of the broadcast message sent when a new jail vote is happening. */
|
||||
/**
|
||||
* Line3 of the broadcast message sent when a new jail vote is happening.
|
||||
*/
|
||||
VOTEBROADCASTLINE3("jailvote.broadcast", "line3"),
|
||||
/** Line4 of the broadcast message sent when a new jail vote is happening. */
|
||||
/**
|
||||
* Line4 of the broadcast message sent when a new jail vote is happening.
|
||||
*/
|
||||
VOTEBROADCASTLINE4("jailvote.broadcast", "line4"),
|
||||
/** The message sent when someone tries to vote for a player when a vote isn't running. */
|
||||
/**
|
||||
* The message sent when someone tries to vote for a player when a vote isn't running.
|
||||
*/
|
||||
VOTENOVOTEFORTHATPLAYER("jailvote", "novotegoingforthatplayer"),
|
||||
/** The message sent to a player who tries to start a vote to jail someone and doesn't have permission. */
|
||||
/**
|
||||
* The message sent to a player who tries to start a vote to jail someone and doesn't have permission.
|
||||
*/
|
||||
VOTENOPERMISSIONTOSTART("jailvote", "nopermissiontostartvote"),
|
||||
/** The message sent when jail vote is not enabled. */
|
||||
/**
|
||||
* The message sent when jail vote is not enabled.
|
||||
*/
|
||||
VOTENOTENABLED("jailvote", "notenabled"),
|
||||
/** The message sent whenever someone's vote is not successful. */
|
||||
/**
|
||||
* The message sent whenever someone's vote is not successful.
|
||||
*/
|
||||
VOTEUNSUCCESSFUL("jailvote", "voteunsuccessful"),
|
||||
/** The message sent whenever a player successfully votes no. */
|
||||
/**
|
||||
* The message sent whenever a player successfully votes no.
|
||||
*/
|
||||
VOTENOSUCCESS("jailvote", "votenosuccessful"),
|
||||
/** The message sent whenever a player successfully votes yes. */
|
||||
/**
|
||||
* The message sent whenever a player successfully votes yes.
|
||||
*/
|
||||
VOTEYESSUCCESS("jailvote", "voteyessuccessful"),
|
||||
/** The message broadcasted whenever a vote is tied. */
|
||||
/**
|
||||
* The message broadcasted whenever a vote is tied.
|
||||
*/
|
||||
VOTESTIED("jailvote", "votestied"),
|
||||
/** The message broadcasted whenever there are more no votes. */
|
||||
/**
|
||||
* The message broadcasted whenever there are more no votes.
|
||||
*/
|
||||
VOTESSAIDNO("jailvote", "morenovotes"),
|
||||
/** The message broadcasted whenever there aren't the minimum yes votes. */
|
||||
/**
|
||||
* The message broadcasted whenever there aren't the minimum yes votes.
|
||||
*/
|
||||
VOTESNOTENOUGHYES("jailvote", "notenoughyes"),
|
||||
/** The message broadcasted whenever the player the vote is for is no longer online. */
|
||||
/**
|
||||
* The message broadcasted whenever the player the vote is for is no longer online.
|
||||
*/
|
||||
VOTEPLAYERNOLONGERONLINE("jailvote", "playernolongeronline"),
|
||||
/** The message sent when a player tries to vote again for someone. */
|
||||
/**
|
||||
* The message sent when a player tries to vote again for someone.
|
||||
*/
|
||||
VOTEALREADYVOTEDFOR("jailvote", "alreadyvotedfor"),
|
||||
|
||||
// Confirming action messages.
|
||||
/** The message sent when the sender is already confirming something. */
|
||||
/**
|
||||
* The message sent when the sender is already confirming something.
|
||||
*/
|
||||
ALREADY("confirm"),
|
||||
/** The message sent when their confirmation has expired. */
|
||||
/**
|
||||
* The message sent when their confirmation has expired.
|
||||
*/
|
||||
EXPIRED("confirm"),
|
||||
/** The message sent to the sender when they tried to confirm something but don't have anything to confirm. */
|
||||
/**
|
||||
* The message sent to the sender when they tried to confirm something but don't have anything to confirm.
|
||||
*/
|
||||
NOTHING("confirm"),
|
||||
/** The message sent to the sender when they type something and need to confirm it. */
|
||||
/**
|
||||
* The message sent to the sender when they type something and need to confirm it.
|
||||
*/
|
||||
START("confirm");
|
||||
|
||||
private String section, name, path;
|
||||
private final String section;
|
||||
private final String name;
|
||||
private final String path;
|
||||
private static YamlConfiguration lang;
|
||||
|
||||
Lang(String section) {
|
||||
@ -282,19 +530,22 @@ public enum Lang {
|
||||
/**
|
||||
* Sets the {@link YamlConfiguration} instance to use.
|
||||
*
|
||||
* @param file
|
||||
* of the language to use.
|
||||
* @param file of the language to use.
|
||||
*/
|
||||
public static void setFile(YamlConfiguration file) {
|
||||
lang = file;
|
||||
}
|
||||
|
||||
/** Gets the {@link YamlConfiguration} instance. */
|
||||
/**
|
||||
* Gets the {@link YamlConfiguration} instance.
|
||||
*/
|
||||
public static YamlConfiguration getFile() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
/** Writes any new language settings to the language file in storage. */
|
||||
/**
|
||||
* Writes any new language settings to the language file in storage.
|
||||
*/
|
||||
public static boolean writeNewLanguage(YamlConfiguration newLang) {
|
||||
boolean anything = false;
|
||||
|
||||
@ -308,21 +559,24 @@ public enum Lang {
|
||||
return anything;
|
||||
}
|
||||
|
||||
/** Returns the message in the language, no variables are replaced. */
|
||||
/**
|
||||
* Returns the message in the language, no variables are replaced.
|
||||
*/
|
||||
public String get() {
|
||||
return get(new String[]{});
|
||||
}
|
||||
|
||||
/** Returns the message in the language, no variables are replaced. */
|
||||
/**
|
||||
* Returns the message in the language, no variables are replaced.
|
||||
*/
|
||||
public String get(Lang langString) {
|
||||
return get(new String[] { langString.get() });
|
||||
return get(langString.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message in the language, with the provided variables being replaced.
|
||||
*
|
||||
* @param variables
|
||||
* All the variables to replace, in order from 0 to however many.
|
||||
* @param variables All the variables to replace, in order from 0 to however many.
|
||||
* @return The message as a colorful message or an empty message if that
|
||||
* isn't defined in the language file.
|
||||
*/
|
||||
|
@ -73,14 +73,15 @@ public enum Settings {
|
||||
UPDATETIME("system.updates.time"),
|
||||
USEBUKKITTIMER("system.useBukkitTimer");
|
||||
|
||||
private String path;
|
||||
private final String path;
|
||||
|
||||
private Settings(String path) {
|
||||
Settings(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path this setting is in config.
|
||||
*
|
||||
* @return The path where this setting resides in the config.
|
||||
*/
|
||||
public String getPath() {
|
||||
|
@ -1,26 +1,25 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
|
||||
/**
|
||||
* Event thrown after the plugin is reloaded, internal usage only.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This event is called right after the plugin and mostly everything has reloaded.
|
||||
* We listen to this event for updating various items in classes which are only
|
||||
* listeners so we don't store instances of them elsewhere.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class JailPluginReloadedEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private JailMain plugin;
|
||||
private final JailMain plugin;
|
||||
|
||||
public JailPluginReloadedEvent(JailMain main) {
|
||||
this.plugin = main;
|
||||
|
@ -1,30 +1,29 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Event thrown when a prisoner is offline put will be put into jail next time they come online.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This event is called before everything for the jailing takes place, as the player is offline.
|
||||
* This event is called for informative purposes, see {@link PrePrisonerJailedEvent}
|
||||
* for the event called before they teleported in and all that fancy stuff.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class OfflinePrisonerJailedEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private ICell cell;
|
||||
private Prisoner prisoner;
|
||||
private final Jail jail;
|
||||
private final ICell cell;
|
||||
private final Prisoner prisoner;
|
||||
|
||||
/**
|
||||
* Creates a new {@link OfflinePrisonerJailedEvent prisoner jailed event} for the given prisoner.
|
||||
@ -39,32 +38,44 @@ public class OfflinePrisonerJailedEvent extends Event {
|
||||
this.prisoner = prisoner;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is being sent to.
|
||||
*/
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell we're going to be sending the prisoner to, can be null. */
|
||||
/**
|
||||
* Gets the cell we're going to be sending the prisoner to, can be null.
|
||||
*/
|
||||
public ICell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Checks if there was a cell involved. */
|
||||
/**
|
||||
* Checks if there was a cell involved.
|
||||
*/
|
||||
public boolean hasCell() {
|
||||
return this.cell != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
/**
|
||||
* Gets the {@link Prisoner} data for this prisoner.
|
||||
*/
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the jailer who jailed this prisoner. */
|
||||
/**
|
||||
* Gets the jailer who jailed this prisoner.
|
||||
*/
|
||||
public String getJailer() {
|
||||
return this.prisoner.getJailer();
|
||||
}
|
||||
|
||||
/** Gets the reason the prisoner was jailed. */
|
||||
/**
|
||||
* Gets the reason the prisoner was jailed.
|
||||
*/
|
||||
public String getReason() {
|
||||
return this.prisoner.getReason();
|
||||
}
|
||||
|
@ -1,36 +1,35 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.beans.Stick;
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Event thrown before we a player is jailed by someone hitting them with a {@link Stick jail stick}.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This event is called right before we actually jail a player, and is cancellable.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrePrisonerJailedByJailStickEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private Jail jail;
|
||||
private final Jail jail;
|
||||
private ICell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private final Prisoner prisoner;
|
||||
private final Player player;
|
||||
private String jailer, cancelMsg;
|
||||
private Stick stick;
|
||||
private final Stick stick;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerJailedByJailStickEvent prisoner jailed by a jail stick event} for the given player before they get sent to jail.
|
||||
@ -52,37 +51,51 @@ public class PrePrisonerJailedByJailStickEvent extends Event implements Cancella
|
||||
this.cancelMsg = "";
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is being sent to.
|
||||
*/
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell we're going to be sending the prisoner to. */
|
||||
/**
|
||||
* Gets the cell we're going to be sending the prisoner to.
|
||||
*/
|
||||
public ICell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Sets the cell we're going to be sending the prisoner to. */
|
||||
/**
|
||||
* Sets the cell we're going to be sending the prisoner to.
|
||||
*/
|
||||
public void setCell(Cell cell) {
|
||||
this.cell = cell;
|
||||
}
|
||||
|
||||
/** Checks if there is a cell involved. */
|
||||
/**
|
||||
* Checks if there is a cell involved.
|
||||
*/
|
||||
public boolean hasCell() {
|
||||
return this.cell != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
/**
|
||||
* Gets the {@link Prisoner} data for this prisoner.
|
||||
*/
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being jailed. */
|
||||
/**
|
||||
* Gets the instance of the player being jailed.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** Gets the jailer who jailed this prisoner. */
|
||||
/**
|
||||
* Gets the jailer who jailed this prisoner.
|
||||
*/
|
||||
public String getJailer() {
|
||||
return this.jailer;
|
||||
}
|
||||
@ -96,27 +109,37 @@ public class PrePrisonerJailedByJailStickEvent extends Event implements Cancella
|
||||
this.jailer = jailer;
|
||||
}
|
||||
|
||||
/** Gets the jail stick used. */
|
||||
/**
|
||||
* Gets the jail stick used.
|
||||
*/
|
||||
public Stick getJailStick() {
|
||||
return this.stick;
|
||||
}
|
||||
|
||||
/** Checks whether this event is cancelled or not. */
|
||||
/**
|
||||
* Checks whether this event is cancelled or not.
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/** Sets whether this event should be cancelled. */
|
||||
/**
|
||||
* Sets whether this event should be cancelled.
|
||||
*/
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
/** Returns the cancelled message. */
|
||||
/**
|
||||
* Returns the cancelled message.
|
||||
*/
|
||||
public String getCancelledMessage() {
|
||||
return this.cancelMsg;
|
||||
}
|
||||
|
||||
/** Sets the cancelled message. */
|
||||
/**
|
||||
* Sets the cancelled message.
|
||||
*/
|
||||
public void setCancelledMessage(String msg) {
|
||||
this.cancelMsg = msg;
|
||||
}
|
||||
|
@ -1,34 +1,33 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Event thrown before we are jailing a player, both offline and online players.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This event is called right before we actually jail a player, and is cancellable, whether the player is offline or online, getPlayer() will always return null if isOnline() return false.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrePrisonerJailedEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private boolean online;
|
||||
private Jail jail;
|
||||
private final boolean online;
|
||||
private final Jail jail;
|
||||
private ICell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private final Prisoner prisoner;
|
||||
private final Player player;
|
||||
private String jailer, cancelMsg;
|
||||
|
||||
/**
|
||||
@ -51,42 +50,58 @@ public class PrePrisonerJailedEvent extends Event implements Cancellable {
|
||||
this.cancelMsg = "";
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is being sent to.
|
||||
*/
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell we're going to be sending the prisoner to. */
|
||||
/**
|
||||
* Gets the cell we're going to be sending the prisoner to.
|
||||
*/
|
||||
public ICell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Sets the cell we're going to be sending the prisoner to. */
|
||||
/**
|
||||
* Sets the cell we're going to be sending the prisoner to.
|
||||
*/
|
||||
public void setCell(Cell cell) {
|
||||
this.cell = cell;
|
||||
}
|
||||
|
||||
/** Checks if there is a cell involved. */
|
||||
/**
|
||||
* Checks if there is a cell involved.
|
||||
*/
|
||||
public boolean hasCell() {
|
||||
return this.cell != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
/**
|
||||
* Gets the {@link Prisoner} data for this prisoner.
|
||||
*/
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being jailed <strong>but will return null if {@link #isOnline()} returns false</strong>. */
|
||||
/**
|
||||
* Gets the instance of the player being jailed <strong>but will return null if {@link #isOnline()} returns false</strong>.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** Gets whether the prisoner being jailed is online or not. */
|
||||
/**
|
||||
* Gets whether the prisoner being jailed is online or not.
|
||||
*/
|
||||
public boolean isOnline() {
|
||||
return this.online;
|
||||
}
|
||||
|
||||
/** Gets the jailer who jailed this prisoner. */
|
||||
/**
|
||||
* Gets the jailer who jailed this prisoner.
|
||||
*/
|
||||
public String getJailer() {
|
||||
return this.jailer;
|
||||
}
|
||||
@ -100,7 +115,9 @@ public class PrePrisonerJailedEvent extends Event implements Cancellable {
|
||||
this.jailer = jailer;
|
||||
}
|
||||
|
||||
/** Gets the reason the player was jailed for. */
|
||||
/**
|
||||
* Gets the reason the player was jailed for.
|
||||
*/
|
||||
public String getReason() {
|
||||
return this.prisoner.getReason();
|
||||
}
|
||||
@ -114,22 +131,30 @@ public class PrePrisonerJailedEvent extends Event implements Cancellable {
|
||||
this.prisoner.setReason(reason);
|
||||
}
|
||||
|
||||
/** Checks whether this event is cancelled or not. */
|
||||
/**
|
||||
* Checks whether this event is cancelled or not.
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/** Sets whether this event should be cancelled. */
|
||||
/**
|
||||
* Sets whether this event should be cancelled.
|
||||
*/
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
/** Returns the cancelled message. */
|
||||
/**
|
||||
* Returns the cancelled message.
|
||||
*/
|
||||
public String getCancelledMessage() {
|
||||
return this.cancelMsg;
|
||||
}
|
||||
|
||||
/** Sets the cancelled message. */
|
||||
/**
|
||||
* Sets the cancelled message.
|
||||
*/
|
||||
public void setCancelledMessage(String msg) {
|
||||
this.cancelMsg = msg;
|
||||
}
|
||||
|
@ -1,32 +1,31 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Event thrown after a prisoner is released.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This event is called before everything for the releasing takes place.
|
||||
* This event is called for informative purposes, see {@link PrisonerReleasedEvent}
|
||||
* for the event called after they get teleported out and all that fancy stuff.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrePrisonerReleasedEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private ICell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private final Jail jail;
|
||||
private final ICell cell;
|
||||
private final Prisoner prisoner;
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerReleasedEvent pre-prisoner released event} for the given player.
|
||||
@ -43,27 +42,37 @@ public class PrePrisonerReleasedEvent extends Event {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is coming from.
|
||||
*/
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell where the prisoner was jailed in, null if they weren't in one. */
|
||||
/**
|
||||
* Gets the cell where the prisoner was jailed in, null if they weren't in one.
|
||||
*/
|
||||
public ICell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Checks if there is a cell involved. */
|
||||
/**
|
||||
* Checks if there is a cell involved.
|
||||
*/
|
||||
public boolean hasCell() {
|
||||
return this.cell != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
/**
|
||||
* Gets the {@link Prisoner} data for this prisoner.
|
||||
*/
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being released. */
|
||||
/**
|
||||
* Gets the instance of the player being released.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
@ -1,32 +1,33 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
|
||||
/**
|
||||
* Event thrown before we transfer a prisoner, both offline and online prisoner.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This event is called right before we actually transfer a prisoner, and is cancellable, whether the prisoner is offline or online, getPlayer() will always return null if isOnline() return false.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrePrisonerTransferredEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private Jail originalJail, targetJail;
|
||||
private Cell originalCell, targetCell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private final Jail originalJail;
|
||||
private Jail targetJail;
|
||||
private final Cell originalCell;
|
||||
private Cell targetCell;
|
||||
private final Prisoner prisoner;
|
||||
private final Player player;
|
||||
private String transferor, cancelMsg;
|
||||
|
||||
/**
|
||||
@ -51,22 +52,30 @@ public class PrePrisonerTransferredEvent extends Event implements Cancellable {
|
||||
this.cancelMsg = "";
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is coming from.
|
||||
*/
|
||||
public Jail getOriginalJail() {
|
||||
return this.originalJail;
|
||||
}
|
||||
|
||||
/** Gets the {@link Cell} this prisoner is coming from, can be null. */
|
||||
/**
|
||||
* Gets the {@link Cell} this prisoner is coming from, can be null.
|
||||
*/
|
||||
public Cell getOriginalCell() {
|
||||
return this.originalCell;
|
||||
}
|
||||
|
||||
/** Checks if there is an original cell involved. */
|
||||
/**
|
||||
* Checks if there is an original cell involved.
|
||||
*/
|
||||
public boolean hasOriginalCell() {
|
||||
return this.originalCell != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being transferred to. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is being transferred to.
|
||||
*/
|
||||
public Jail getTargetJail() {
|
||||
return this.targetJail;
|
||||
}
|
||||
@ -80,8 +89,9 @@ public class PrePrisonerTransferredEvent extends Event implements Cancellable {
|
||||
this.targetJail = jail;
|
||||
}
|
||||
|
||||
/** Gets the {@link Cell} this prisoner is being sent to, can be null.
|
||||
*
|
||||
/**
|
||||
* Gets the {@link Cell} this prisoner is being sent to, can be null.
|
||||
* <p>
|
||||
* Will return null if the cell is not in the targetJail.
|
||||
*/
|
||||
public Cell getTargetCell() {
|
||||
@ -89,7 +99,9 @@ public class PrePrisonerTransferredEvent extends Event implements Cancellable {
|
||||
else return null;
|
||||
}
|
||||
|
||||
/** Checks if there is a target cell involved. */
|
||||
/**
|
||||
* Checks if there is a target cell involved.
|
||||
*/
|
||||
public boolean hasTargetCell() {
|
||||
return this.getTargetCell() != null;
|
||||
}
|
||||
@ -148,22 +160,30 @@ public class PrePrisonerTransferredEvent extends Event implements Cancellable {
|
||||
this.transferor = transferor;
|
||||
}
|
||||
|
||||
/** Checks whether this event is cancelled or not. */
|
||||
/**
|
||||
* Checks whether this event is cancelled or not.
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/** Sets whether this event should be cancelled. */
|
||||
/**
|
||||
* Sets whether this event should be cancelled.
|
||||
*/
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
/** Returns the cancelled message. */
|
||||
/**
|
||||
* Returns the cancelled message.
|
||||
*/
|
||||
public String getCancelledMessage() {
|
||||
return this.cancelMsg;
|
||||
}
|
||||
|
||||
/** Sets the cancelled message. */
|
||||
/**
|
||||
* Sets the cancelled message.
|
||||
*/
|
||||
public void setCancelledMessage(String msg) {
|
||||
this.cancelMsg = msg;
|
||||
}
|
||||
|
@ -1,28 +1,27 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
|
||||
/**
|
||||
* Event thrown when a prisoner dies.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrisonerDeathEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private PlayerDeathEvent event;
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private final PlayerDeathEvent event;
|
||||
private final Jail jail;
|
||||
private final Cell cell;
|
||||
private final Prisoner prisoner;
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrisonerDeathEvent prisoner death event} for the given player.
|
||||
@ -41,32 +40,44 @@ public class PrisonerDeathEvent extends Event {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link PlayerDeathEvent} which triggered this PrisonerDeathEvent. */
|
||||
/**
|
||||
* Gets the {@link PlayerDeathEvent} which triggered this PrisonerDeathEvent.
|
||||
*/
|
||||
public PlayerDeathEvent getPlayerDeathEvent() {
|
||||
return this.event;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is in. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is in.
|
||||
*/
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell the prisoner is in, can be null. */
|
||||
/**
|
||||
* Gets the cell the prisoner is in, can be null.
|
||||
*/
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Checks if there is a cell involved. */
|
||||
/**
|
||||
* Checks if there is a cell involved.
|
||||
*/
|
||||
public boolean hasCell() {
|
||||
return this.cell != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner}'s data. */
|
||||
/**
|
||||
* Gets the {@link Prisoner}'s data.
|
||||
*/
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player who died. */
|
||||
/**
|
||||
* Gets the instance of the player who died.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
@ -1,32 +1,31 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Event thrown after a prisoner is put into jail.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This event is called after everything for the jailing takes place.
|
||||
* This event is called for informative purposes, see {@link PrePrisonerJailedEvent}
|
||||
* for the event called before they teleported in and all that fancy stuff.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrisonerJailedEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private final Jail jail;
|
||||
private final Cell cell;
|
||||
private final Prisoner prisoner;
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrisonerJailedEvent prisoner jailed event} for the given player.
|
||||
@ -43,37 +42,51 @@ public class PrisonerJailedEvent extends Event {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is being sent to.
|
||||
*/
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell we're going to be sending the prisoner to, can be null. */
|
||||
/**
|
||||
* Gets the cell we're going to be sending the prisoner to, can be null.
|
||||
*/
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Checks if there was a cell involved. */
|
||||
/**
|
||||
* Checks if there was a cell involved.
|
||||
*/
|
||||
public boolean hasCell() {
|
||||
return this.cell != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
/**
|
||||
* Gets the {@link Prisoner} data for this prisoner.
|
||||
*/
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being jailed. */
|
||||
/**
|
||||
* Gets the instance of the player being jailed.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** Gets the jailer who jailed this prisoner. */
|
||||
/**
|
||||
* Gets the jailer who jailed this prisoner.
|
||||
*/
|
||||
public String getJailer() {
|
||||
return this.prisoner.getJailer();
|
||||
}
|
||||
|
||||
/** Gets the reason the prisoner was jailed. */
|
||||
/**
|
||||
* Gets the reason the prisoner was jailed.
|
||||
*/
|
||||
public String getReason() {
|
||||
return this.prisoner.getReason();
|
||||
}
|
||||
|
@ -1,32 +1,31 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Event thrown after a prisoner is released.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This event is called after everything for the releasing takes place.
|
||||
* This event is called for informative purposes, see {@link PrePrisonerReleasedEvent}
|
||||
* for the event called before they teleported out and all that fancy stuff.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrisonerReleasedEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private final Jail jail;
|
||||
private final Cell cell;
|
||||
private final Prisoner prisoner;
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrisonerReleasedEvent prisoner released event} for the given player.
|
||||
@ -43,27 +42,37 @@ public class PrisonerReleasedEvent extends Event {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is coming from.
|
||||
*/
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell where the prisoner was jailed in, null if they weren't in one. */
|
||||
/**
|
||||
* Gets the cell where the prisoner was jailed in, null if they weren't in one.
|
||||
*/
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Checks if there was a cell involved. */
|
||||
/**
|
||||
* Checks if there was a cell involved.
|
||||
*/
|
||||
public boolean hasCell() {
|
||||
return this.cell != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
/**
|
||||
* Gets the {@link Prisoner} data for this prisoner.
|
||||
*/
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being released. */
|
||||
/**
|
||||
* Gets the instance of the player being released.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
@ -1,29 +1,29 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
|
||||
/**
|
||||
* Event thrown when a prisoner's time changes.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrisonerTimeChangeEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private long before, after;
|
||||
private final Jail jail;
|
||||
private final Cell cell;
|
||||
private final Prisoner prisoner;
|
||||
private final Player player;
|
||||
private final long before;
|
||||
private long after;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrisonerTimeChangeEvent prisoner time change event} for the given prisoner.
|
||||
@ -44,51 +44,67 @@ public class PrisonerTimeChangeEvent extends Event implements Cancellable {
|
||||
this.after = after;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is in. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is in.
|
||||
*/
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell the prisoner is in, can be null. */
|
||||
/**
|
||||
* Gets the cell the prisoner is in, can be null.
|
||||
*/
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Checks if there is a cell involved. */
|
||||
/**
|
||||
* Checks if there is a cell involved.
|
||||
*/
|
||||
public boolean hasCell() {
|
||||
return this.cell != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner}'s data. */
|
||||
/**
|
||||
* Gets the {@link Prisoner}'s data.
|
||||
*/
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player who died. */
|
||||
/**
|
||||
* Gets the instance of the player who died.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** Gets the time the prisoner had before it changed. */
|
||||
/**
|
||||
* Gets the time the prisoner had before it changed.
|
||||
*/
|
||||
public long getTimeBeforeChange() {
|
||||
return this.before;
|
||||
}
|
||||
|
||||
/** Gets the time the prisoner will have after the change. */
|
||||
/**
|
||||
* Gets the time the prisoner will have after the change.
|
||||
*/
|
||||
public long getTimeAfterChange() {
|
||||
return this.after;
|
||||
}
|
||||
|
||||
/** Sets the time the prisoner will have after the change. */
|
||||
/**
|
||||
* Sets the time the prisoner will have after the change.
|
||||
*/
|
||||
public void setTimeAfterChange(long newtime) {
|
||||
this.after = Math.max(0, newtime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the difference the change is making.
|
||||
*
|
||||
* <p>
|
||||
* <p/>
|
||||
*
|
||||
* <p>
|
||||
* The change can be positive or negative. If it is positive then the
|
||||
* time after is smaller than it was before. If it is negative then the
|
||||
* time after is larger than it was before.
|
||||
@ -99,12 +115,16 @@ public class PrisonerTimeChangeEvent extends Event implements Cancellable {
|
||||
return this.before - this.after;
|
||||
}
|
||||
|
||||
/** Checks whether this event is cancelled or not. */
|
||||
/**
|
||||
* Checks whether this event is cancelled or not.
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/** Sets whether this event should be cancelled. */
|
||||
/**
|
||||
* Sets whether this event should be cancelled.
|
||||
*/
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
@ -1,30 +1,31 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Event thrown after we transfer a prisoner, both an offline and an online prisoner.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* This event is called after we transfer the prisoner whether the prisoner is offline or online, getPlayer() will always return null if isOnline() return false.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrisonerTransferredEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail originalJail, targetJail;
|
||||
private Cell originalCell, targetCell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private final Jail originalJail;
|
||||
private final Jail targetJail;
|
||||
private final Cell originalCell;
|
||||
private final Cell targetCell;
|
||||
private final Prisoner prisoner;
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrisonerTransferredEvent prisoner transferred event} for the given player after they get transferred to their new jail and cell.
|
||||
@ -45,28 +46,37 @@ public class PrisonerTransferredEvent extends Event {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is coming from.
|
||||
*/
|
||||
public Jail getOriginalJail() {
|
||||
return this.originalJail;
|
||||
}
|
||||
|
||||
/** Gets the {@link Cell} this prisoner is coming from, can be null. */
|
||||
/**
|
||||
* Gets the {@link Cell} this prisoner is coming from, can be null.
|
||||
*/
|
||||
public Cell getOriginalCell() {
|
||||
return this.originalCell;
|
||||
}
|
||||
|
||||
/** Checks if there was an original cell involved. */
|
||||
/**
|
||||
* Checks if there was an original cell involved.
|
||||
*/
|
||||
public boolean hasOriginalCell() {
|
||||
return this.originalCell != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being transferred to. */
|
||||
/**
|
||||
* Gets the {@link Jail} this prisoner is being transferred to.
|
||||
*/
|
||||
public Jail getTargetJail() {
|
||||
return this.targetJail;
|
||||
}
|
||||
|
||||
/** Gets the {@link Cell} this prisoner is being sent to, can be null.
|
||||
*
|
||||
/**
|
||||
* Gets the {@link Cell} this prisoner is being sent to, can be null.
|
||||
* <p>
|
||||
* Will return null if the cell is not in the targetJail.
|
||||
*/
|
||||
public Cell getTargetCell() {
|
||||
@ -74,22 +84,30 @@ public class PrisonerTransferredEvent extends Event {
|
||||
else return null;
|
||||
}
|
||||
|
||||
/** Checks if there was a target cell involved. */
|
||||
/**
|
||||
* Checks if there was a target cell involved.
|
||||
*/
|
||||
public boolean hasTargetCell() {
|
||||
return this.getTargetCell() != null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
/**
|
||||
* Gets the {@link Prisoner} data for this prisoner.
|
||||
*/
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being transferred <strong>but will return null if {@link #isOnline()} returns false</strong>. */
|
||||
/**
|
||||
* Gets the instance of the player being transferred <strong>but will return null if {@link #isOnline()} returns false</strong>.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** Gets whether the prisoner being transferred is online or not. */
|
||||
/**
|
||||
* Gets whether the prisoner being transferred is online or not.
|
||||
*/
|
||||
public boolean isOnline() {
|
||||
return player == null;
|
||||
}
|
||||
|
@ -1,19 +1,17 @@
|
||||
package com.graywolf336.jail.exceptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* The exception thrown trying to unjail via a thread that is NOT the primary thread.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class AsyncUnJailingNotSupportedException extends Exception {
|
||||
private static final long serialVersionUID = -1540695375715404835L;
|
||||
|
||||
/**
|
||||
* Creation of an exception from unjailing via a thread that is not the primary one.
|
||||
*
|
||||
*/
|
||||
public AsyncUnJailingNotSupportedException() {
|
||||
super("Unjailing via a thread that is NOT the primary thread is not supported.");
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.graywolf336.jail.exceptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* The exception thrown when a cell is required but wasn't provided.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class CellRequiredException extends Exception {
|
||||
private static final long serialVersionUID = 6496748770371151376L;
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.graywolf336.jail.exceptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* The exception thrown when a jail is required but wasn't provided.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class JailRequiredException extends Exception {
|
||||
private static final long serialVersionUID = 1046287197309037470L;
|
||||
|
@ -1,19 +1,17 @@
|
||||
package com.graywolf336.jail.exceptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* The exception thrown when a prisoner is already jailed.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrisonerAlreadyJailedException extends Exception {
|
||||
private static final long serialVersionUID = -5830449694077279409L;
|
||||
|
||||
/**
|
||||
* Creation of a prisoner is already jailed exception.
|
||||
*
|
||||
*/
|
||||
public PrisonerAlreadyJailedException() {
|
||||
super("A prisoner (no name or uuid provided) is already jailed and can not be jailed twice.");
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.graywolf336.jail.exceptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* The exception thrown when a prisoner's data is required but wasn't provided.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class PrisonerRequiredException extends Exception {
|
||||
private static final long serialVersionUID = 5289068334047189357L;
|
||||
|
@ -1,158 +1,159 @@
|
||||
package com.graywolf336.jail.interfaces;
|
||||
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.beans.SimpleLocation;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Chest;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Chest;
|
||||
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.beans.SimpleLocation;
|
||||
|
||||
public interface ICell {
|
||||
/**
|
||||
* Gets the id of the cell in the database, <strong>internal usage only</strong>
|
||||
*
|
||||
* @return database's id, don't use for external reasons
|
||||
*/
|
||||
public int getDatabaseID();
|
||||
int getDatabaseID();
|
||||
|
||||
/**
|
||||
* Gets the name of the cell.
|
||||
*
|
||||
* @return Cell's name
|
||||
*/
|
||||
public String getName();
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Sets the prisoner in this cell.
|
||||
*
|
||||
* @param prisoner the {@link Prisoner} to set
|
||||
*/
|
||||
public void setPrisoner(Prisoner prisoner);
|
||||
void setPrisoner(Prisoner prisoner);
|
||||
|
||||
/**
|
||||
* Gets the prisoner being held in this cell.
|
||||
*
|
||||
* @return the {@link Prisoner} instance in this cell, null if no prisoner
|
||||
*/
|
||||
public Prisoner getPrisoner();
|
||||
Prisoner getPrisoner();
|
||||
|
||||
/** Nullifies the prisoner data. */
|
||||
public void removePrisoner();
|
||||
/**
|
||||
* Nullifies the prisoner data.
|
||||
*/
|
||||
void removePrisoner();
|
||||
|
||||
/**
|
||||
* Returns true if there is currently a prisoner in this cell.
|
||||
*
|
||||
* @return Whether there is a prisoner or not
|
||||
*/
|
||||
public boolean hasPrisoner();
|
||||
boolean hasPrisoner();
|
||||
|
||||
/**
|
||||
* Adds all the given signs to the cell.
|
||||
*
|
||||
* @param signs all of the signs to add
|
||||
*/
|
||||
public void addAllSigns(HashSet<SimpleLocation> signs);
|
||||
void addAllSigns(HashSet<SimpleLocation> signs);
|
||||
|
||||
/**
|
||||
* Adds a sign to the cell.
|
||||
*
|
||||
* @param sign the {@link SimpleLocation} of the sign to add
|
||||
*/
|
||||
public void addSign(SimpleLocation sign);
|
||||
void addSign(SimpleLocation sign);
|
||||
|
||||
/**
|
||||
* Returns all the signs for this cell.
|
||||
*
|
||||
* @return All the signs used by this cell
|
||||
*/
|
||||
public HashSet<SimpleLocation> getSigns();
|
||||
HashSet<SimpleLocation> getSigns();
|
||||
|
||||
/**
|
||||
* Checks if there are any signs for this cell.
|
||||
*
|
||||
* @return Whether this cell has signs or not.
|
||||
*/
|
||||
public boolean hasSigns();
|
||||
boolean hasSigns();
|
||||
|
||||
/**
|
||||
* Returns the entire list of signs in a string.
|
||||
*
|
||||
* @return the serialized string of sign locations
|
||||
*/
|
||||
public String getSignString();
|
||||
String getSignString();
|
||||
|
||||
/**
|
||||
* Gets a list of all the signs which are invalid (not signs anymore).
|
||||
*
|
||||
* @return Returns a list of all the invalid signs
|
||||
*/
|
||||
public List<String> getInvalidSigns();
|
||||
List<String> getInvalidSigns();
|
||||
|
||||
/**
|
||||
* Removes all the signs which are no longer sign blocks.
|
||||
*
|
||||
* @return The signs cleaned up
|
||||
*/
|
||||
public List<String> cleanSigns();
|
||||
List<String> cleanSigns();
|
||||
|
||||
/**
|
||||
* Updates all the signs this cell has.
|
||||
*
|
||||
* @return collection of changes. The <strong>"removed"</strong> entry has all the signs which were removed. The <strong>"updated"</strong> entry has all the signs which got updated.
|
||||
*/
|
||||
public HashMap<String, List<String>> updateSigns();
|
||||
HashMap<String, List<String>> updateSigns();
|
||||
|
||||
/**
|
||||
* Sets the location of where the prisoner will be teleported at when jailed here.
|
||||
*
|
||||
* @param location the {@link SimpleLocation} of the teleport
|
||||
*/
|
||||
public void setTeleport(SimpleLocation location);
|
||||
void setTeleport(SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Gets the teleport location where the prisoner will be teleported at when jailed here.
|
||||
*
|
||||
* @return the teleport in {@link Location location}
|
||||
*/
|
||||
public Location getTeleport();
|
||||
Location getTeleport();
|
||||
|
||||
/**
|
||||
* Sets the location of the chest.
|
||||
*
|
||||
* @param simpleLocation the {@link SimpleLocation} of the chest
|
||||
*/
|
||||
public void setChestLocation(SimpleLocation simpleLocation);
|
||||
void setChestLocation(SimpleLocation simpleLocation);
|
||||
|
||||
/**
|
||||
* Gets the location of the chest, returns null if no chest is stored at this cell.
|
||||
*
|
||||
* @return The location of the chest, null if none.
|
||||
*/
|
||||
public Location getChestLocation();
|
||||
Location getChestLocation();
|
||||
|
||||
/**
|
||||
* Gets the chest for this cell, returns null if there is no chest or the location we have is not a chest.
|
||||
*
|
||||
* @return The chest and its state.
|
||||
*/
|
||||
public Chest getChest();
|
||||
Chest getChest();
|
||||
|
||||
/**
|
||||
* Checks if the chest location doesn't equal null and if it is a double chest.
|
||||
*
|
||||
* @return true if there is a chest, false if there isn't.
|
||||
*/
|
||||
public boolean hasChest();
|
||||
boolean hasChest();
|
||||
|
||||
/**
|
||||
* Checks to see if this cell uses a chest or not.
|
||||
*
|
||||
* @return Whether there is a location for chest stored.
|
||||
*/
|
||||
public boolean useChest();
|
||||
boolean useChest();
|
||||
|
||||
/**
|
||||
* Sets whether this cell has been changed or not.
|
||||
@ -160,12 +161,12 @@ public interface ICell {
|
||||
* @param changed true if we've changed it, mostly use if you want to force an update
|
||||
* @return the resulting change, whether it is changed or not
|
||||
*/
|
||||
public boolean setChanged(boolean changed);
|
||||
boolean setChanged(boolean changed);
|
||||
|
||||
/**
|
||||
* Gets whether the Cell has changed from the last save or not.
|
||||
*
|
||||
* @return Whether the cell has changed or not since last save
|
||||
*/
|
||||
public boolean hasChanged();
|
||||
boolean hasChanged();
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
package com.graywolf336.jail.interfaces;
|
||||
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
|
||||
public interface IJailPayManager {
|
||||
|
||||
/**
|
||||
@ -14,21 +12,21 @@ public interface IJailPayManager {
|
||||
*
|
||||
* @return Whether infinite paying is enabled.
|
||||
*/
|
||||
public boolean isInfiniteEnabled();
|
||||
boolean isInfiniteEnabled();
|
||||
|
||||
/**
|
||||
* Checks if paying for timed is enabled.
|
||||
*
|
||||
* @return Whether time paying is enabled.
|
||||
*/
|
||||
public boolean isTimedEnabled();
|
||||
boolean isTimedEnabled();
|
||||
|
||||
/**
|
||||
* Gets how much it cost per minute in string format.
|
||||
*
|
||||
* @return How much it costs per minute
|
||||
*/
|
||||
public String getCostPerMinute();
|
||||
String getCostPerMinute();
|
||||
|
||||
/**
|
||||
* Calculates how much players have to pay to get completely free.
|
||||
@ -36,7 +34,7 @@ public interface IJailPayManager {
|
||||
* @param prisoner data of who we're calculating
|
||||
* @return The economy cost the prisoner will need to pay to get completely free.
|
||||
*/
|
||||
public double calculateBill(Prisoner prisoner);
|
||||
double calculateBill(Prisoner prisoner);
|
||||
|
||||
/**
|
||||
* Gets how many minutes someone is paying for (rounds to the lowest number).
|
||||
@ -44,21 +42,21 @@ public interface IJailPayManager {
|
||||
* @param amount amount of money
|
||||
* @return the amount of time they're paying for
|
||||
*/
|
||||
public long getMinutesPayingFor(double amount);
|
||||
long getMinutesPayingFor(double amount);
|
||||
|
||||
/**
|
||||
* Returns if we are using items for payment instead of economy.
|
||||
*
|
||||
* @return Whether paying using items is enabled
|
||||
*/
|
||||
public boolean usingItemsForPayment();
|
||||
boolean usingItemsForPayment();
|
||||
|
||||
/**
|
||||
* Gets the {@link Material} it costs for jail pay, will be air if using economy.
|
||||
*
|
||||
* @return The item type it costs, air if using virtual economy.
|
||||
*/
|
||||
public Material getItemItCost();
|
||||
Material getItemItCost();
|
||||
|
||||
/**
|
||||
* Checks if the player has enough money/items to pay what they have said they want to.
|
||||
@ -67,7 +65,7 @@ public interface IJailPayManager {
|
||||
* @param amount The amount to check they if they have.
|
||||
* @return true if they have enough, false if not.
|
||||
*/
|
||||
public boolean hasEnoughToPay(Player player, double amount);
|
||||
boolean hasEnoughToPay(Player player, double amount);
|
||||
|
||||
/**
|
||||
* Pays the required fees from the given player, removing items or money from economy.
|
||||
@ -75,19 +73,19 @@ public interface IJailPayManager {
|
||||
* @param player The player who is paying.
|
||||
* @param amount The amount of items or money to withdraw from the player.
|
||||
*/
|
||||
public void pay(Player player, double amount);
|
||||
void pay(Player player, double amount);
|
||||
|
||||
/**
|
||||
* Gets the name of the item in nice capitals.
|
||||
*
|
||||
* @return The currency name in nice capital letters.
|
||||
*/
|
||||
public String getCurrencyName();
|
||||
String getCurrencyName();
|
||||
|
||||
/**
|
||||
* Returns the economy provider to do transaction with.
|
||||
*
|
||||
* @return the {@link Economy} instance
|
||||
*/
|
||||
public Economy getEconomy();
|
||||
Economy getEconomy();
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.graywolf336.jail.interfaces;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.graywolf336.jail.beans.Stick;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.graywolf336.jail.beans.Stick;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Interface for the jail stick manager.
|
||||
@ -12,7 +11,6 @@ import com.graywolf336.jail.beans.Stick;
|
||||
* @author graywolf336
|
||||
* @version 1.0.0
|
||||
* @since 3.0.0
|
||||
*
|
||||
*/
|
||||
public interface IJailStickManager {
|
||||
|
||||
@ -22,7 +20,7 @@ public interface IJailStickManager {
|
||||
* @param mat of the stick to get
|
||||
* @return The {@link Stick jail stick}
|
||||
*/
|
||||
public Stick getStick(Material mat);
|
||||
Stick getStick(Material mat);
|
||||
|
||||
/**
|
||||
* Checks if the provided Material is a valid {@link Stick jail stick}
|
||||
@ -30,21 +28,21 @@ public interface IJailStickManager {
|
||||
* @param mat the {@link Material} to check
|
||||
* @return whether the provided material is a valid stick
|
||||
*/
|
||||
public boolean isValidStick(Material mat);
|
||||
boolean isValidStick(Material mat);
|
||||
|
||||
/**
|
||||
* Adds a player to be using a jail stick, with the uuid of the player.
|
||||
*
|
||||
* @param id of the player to add
|
||||
*/
|
||||
public void addUsingStick(UUID id);
|
||||
void addUsingStick(UUID id);
|
||||
|
||||
/**
|
||||
* Removes a player from using a jail stick, with the uuid of the player.
|
||||
*
|
||||
* @param id of the player to remove using a jail stick
|
||||
*/
|
||||
public void removeUsingStick(UUID id);
|
||||
void removeUsingStick(UUID id);
|
||||
|
||||
/**
|
||||
* Returns whether or not the player is using a jail stick.
|
||||
@ -52,7 +50,7 @@ public interface IJailStickManager {
|
||||
* @param id of the player to check if using one
|
||||
* @return true if the player is using a jail stick, false if not
|
||||
*/
|
||||
public boolean isUsingJailStick(UUID id);
|
||||
boolean isUsingJailStick(UUID id);
|
||||
|
||||
/**
|
||||
* Toggles whether the player is using a jail stick, returning the true if enabled false if disabled.
|
||||
@ -60,8 +58,10 @@ public interface IJailStickManager {
|
||||
* @param id of the player to toggle using a stick
|
||||
* @return true if we enabled it, false if we disabled it.
|
||||
*/
|
||||
public boolean toggleUsingStick(UUID id);
|
||||
boolean toggleUsingStick(UUID id);
|
||||
|
||||
/** Removes all the users currently using the sticks. */
|
||||
public void removeAllStickUsers();
|
||||
/**
|
||||
* Removes all the users currently using the sticks.
|
||||
*/
|
||||
void removeAllStickUsers();
|
||||
}
|
||||
|
@ -1,12 +1,5 @@
|
||||
package com.graywolf336.jail.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.beans.CachePrisoner;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
@ -15,23 +8,28 @@ import com.graywolf336.jail.events.PrePrisonerReleasedEvent;
|
||||
import com.graywolf336.jail.events.PrePrisonerTransferredEvent;
|
||||
import com.graywolf336.jail.events.PrisonerJailedEvent;
|
||||
import com.graywolf336.jail.events.PrisonerTransferredEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
/**
|
||||
* The listen for all events which need to add/remove to the prisoner cache.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* These listeners add and remove prisoner cache objects to the cache,
|
||||
* this way we gain performance for servers which have a high amount
|
||||
* of prisoners jailed. (500+)
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class CacheListener implements Listener {
|
||||
private JailMain pl;
|
||||
private final JailMain pl;
|
||||
|
||||
public CacheListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
|
@ -1,11 +1,5 @@
|
||||
package com.graywolf336.jail.listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
@ -15,10 +9,15 @@ import com.graywolf336.jail.events.PrisonerJailedEvent;
|
||||
import com.graywolf336.jail.events.PrisonerReleasedEvent;
|
||||
import com.graywolf336.jail.events.PrisonerTimeChangeEvent;
|
||||
import com.graywolf336.jail.events.PrisonerTransferredEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CellSignListener implements Listener {
|
||||
private String lineOne = "", lineTwo = "", lineThree = "", lineFour = "";
|
||||
private JailMain pl;
|
||||
private final JailMain pl;
|
||||
|
||||
public CellSignListener(JailMain plugin) {
|
||||
pl = plugin;
|
||||
@ -39,12 +38,10 @@ public class CellSignListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void changeTheCellSigns(final PrisonerTimeChangeEvent event) {
|
||||
pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new Runnable() {
|
||||
public void run() {
|
||||
pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, () -> {
|
||||
if (event.hasCell() && event.getCell().hasSigns()) {
|
||||
event.getCell().updateSigns();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.graywolf336.jail.listeners;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
public class EntityListener implements Listener {
|
||||
private JailMain pl;
|
||||
private final JailMain pl;
|
||||
|
||||
public EntityListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.graywolf336.jail.listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -13,20 +12,20 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class HandCuffListener implements Listener {
|
||||
private JailMain pl;
|
||||
private HashMap<String, Location> tos;
|
||||
private final JailMain pl;
|
||||
private final HashMap<String, Location> tos;
|
||||
|
||||
public HandCuffListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.tos = new HashMap<String, Location>();
|
||||
this.tos = new HashMap<>();
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
if (false) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
Location to = pl.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
|
||||
@ -45,7 +44,7 @@ public class HandCuffListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
if (false) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && event.getTo() != tos.get(event.getPlayer().getName())) {
|
||||
Location to = pl.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
|
||||
@ -64,7 +63,7 @@ public class HandCuffListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void playerChat(AsyncPlayerChatEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
if (false) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && !event.getPlayer().hasPermission("jail.command.handcuff")) {
|
||||
event.setCancelled(true);
|
||||
@ -74,7 +73,7 @@ public class HandCuffListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
if (false) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
@ -84,7 +83,7 @@ public class HandCuffListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void blockPlace(BlockPlaceEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
if (false) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
@ -94,7 +93,7 @@ public class HandCuffListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void preCommands(PlayerCommandPreprocessEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
if (false) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && !event.getPlayer().hasPermission("jail.command.handcuff") && (!event.getMessage().startsWith("/r") || !event.getMessage().startsWith("/reply"))) {
|
||||
event.setCancelled(true);
|
||||
|
@ -1,26 +1,25 @@
|
||||
package com.graywolf336.jail.listeners;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.events.PrePrisonerJailedByJailStickEvent;
|
||||
import com.graywolf336.jail.events.PrePrisonerJailedEvent;
|
||||
import com.graywolf336.jail.events.PrisonerJailedEvent;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class JailingListener implements Listener {
|
||||
private JailMain pl;
|
||||
private DateFormat dateFormat;
|
||||
private final JailMain pl;
|
||||
private final DateFormat dateFormat;
|
||||
|
||||
public JailingListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
@ -50,8 +49,7 @@ public class JailingListener implements Listener {
|
||||
@EventHandler
|
||||
public void setInmatesClothing(final PrisonerJailedEvent event) {
|
||||
if (pl.getConfig().getBoolean(Settings.CLOTHINGENABLED.getPath())) {
|
||||
pl.getServer().getScheduler().runTaskLater(pl, new Runnable() {
|
||||
public void run() {
|
||||
pl.getServer().getScheduler().runTaskLater(pl, () -> {
|
||||
String[] helmet = pl.getConfig().getString(Settings.CLOTHINGHELMET.getPath()).toUpperCase().split("~");
|
||||
switch (helmet.length) {
|
||||
case 1:
|
||||
@ -119,7 +117,6 @@ public class JailingListener implements Listener {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,5 @@
|
||||
package com.graywolf336.jail.listeners;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.CachePrisoner;
|
||||
@ -14,9 +7,15 @@ import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class MoveProtectionListener implements Listener {
|
||||
private JailMain pl;
|
||||
private final JailMain pl;
|
||||
|
||||
public MoveProtectionListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
@ -57,7 +56,7 @@ public class MoveProtectionListener implements Listener {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.MOVEPENALTY.getPath()));
|
||||
p.addTime(add);
|
||||
|
||||
String msg = "";
|
||||
String msg;
|
||||
if (add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
@ -65,7 +64,7 @@ public class MoveProtectionListener implements Listener {
|
||||
} else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.MOVING.get() });
|
||||
msg = Lang.PROTECTIONMESSAGE.get(String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.MOVING.get());
|
||||
}
|
||||
|
||||
//Send the message
|
||||
|
@ -1,10 +1,18 @@
|
||||
package com.graywolf336.jail.listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.AnyCell;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.beans.Stick;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.events.PrePrisonerJailedByJailStickEvent;
|
||||
import com.graywolf336.jail.events.PrisonerDeathEvent;
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -22,27 +30,18 @@ import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.AnyCell;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.beans.Stick;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.events.PrePrisonerJailedByJailStickEvent;
|
||||
import com.graywolf336.jail.events.PrisonerDeathEvent;
|
||||
import com.graywolf336.jail.interfaces.ICell;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
private JailMain pl;
|
||||
private HashMap<UUID, Long> clicks;
|
||||
private final JailMain pl;
|
||||
private final HashMap<UUID, Long> clicks;
|
||||
|
||||
public PlayerListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.clicks = new HashMap<UUID, Long>();
|
||||
this.clicks = new HashMap<>();
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@ -91,8 +90,9 @@ public class PlayerListener implements Listener {
|
||||
//If the config has receive messages set to false, let's remove all the prisoners
|
||||
//from getting the chat messages.
|
||||
if (!pl.getConfig().getBoolean(Settings.RECIEVEMESSAGES.getPath())) {
|
||||
if(pl.inDebug()) pl.getLogger().info("Debug - There are " + event.getRecipients().size() + " players getting the message before.");
|
||||
Set<Player> rec = new HashSet<Player>(event.getRecipients());
|
||||
if (pl.inDebug())
|
||||
pl.getLogger().info("Debug - There are " + event.getRecipients().size() + " players getting the message before.");
|
||||
Set<Player> rec = new HashSet<>(event.getRecipients());
|
||||
|
||||
for (Jail j : pl.getJailManager().getJails())
|
||||
for (Prisoner p : j.getAllPrisoners().values())
|
||||
@ -100,7 +100,8 @@ public class PlayerListener implements Listener {
|
||||
|
||||
event.getRecipients().clear();
|
||||
event.getRecipients().addAll(rec);
|
||||
if(pl.inDebug()) pl.getLogger().info("Debug - There are now " + event.getRecipients().size() + " players getting the message.");
|
||||
if (pl.inDebug())
|
||||
pl.getLogger().info("Debug - There are now " + event.getRecipients().size() + " players getting the message.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,13 +134,12 @@ public class PlayerListener implements Listener {
|
||||
if (c == null) {
|
||||
p.setTeleporting(true);
|
||||
event.getPlayer().teleport(j.getTeleportIn());
|
||||
p.setTeleporting(false);
|
||||
} else {
|
||||
//If they are in a cell, teleport them into that cell
|
||||
p.setTeleporting(true);
|
||||
event.getPlayer().teleport(c.getTeleport());
|
||||
p.setTeleporting(false);
|
||||
}
|
||||
p.setTeleporting(false);
|
||||
|
||||
p.setToBeTransferred(false);
|
||||
} else {
|
||||
@ -248,7 +248,8 @@ public class PlayerListener implements Listener {
|
||||
if (!pl.getJailStickManager().isValidStick(attacker.getInventory().getItemInMainHand().getType())) return;
|
||||
|
||||
//They don't have permission for that type of jail stick
|
||||
if(!attacker.hasPermission("jail.usejailstick." + attacker.getInventory().getItemInMainHand().getType().toString().toLowerCase())) return;
|
||||
if (!attacker.hasPermission("jail.usejailstick." + attacker.getInventory().getItemInMainHand().getType().toString().toLowerCase()))
|
||||
return;
|
||||
|
||||
//The player they hit is already jailed.
|
||||
if (pl.getJailManager().isPlayerJailed(player.getUniqueId())) {
|
||||
@ -297,10 +298,10 @@ public class PlayerListener implements Listener {
|
||||
|
||||
//Player is not online
|
||||
if (player == null) {
|
||||
attacker.sendMessage(Lang.OFFLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
attacker.sendMessage(Lang.OFFLINEJAIL.get(p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes())));
|
||||
} else {
|
||||
//Player *is* online
|
||||
attacker.sendMessage(Lang.ONLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
attacker.sendMessage(Lang.ONLINEJAIL.get(p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes())));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.graywolf336.jail.listeners;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -12,13 +14,10 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ProtectionListener implements Listener {
|
||||
private JailMain pl;
|
||||
private final JailMain pl;
|
||||
|
||||
public ProtectionListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
@ -41,7 +40,7 @@ public class ProtectionListener implements Listener {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.BLOCKBREAKPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
String msg;
|
||||
if (add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
@ -49,7 +48,7 @@ public class ProtectionListener implements Listener {
|
||||
} else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.BLOCKBREAKING.get() });
|
||||
msg = Lang.PROTECTIONMESSAGE.get(String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.BLOCKBREAKING.get());
|
||||
}
|
||||
|
||||
//Send the message
|
||||
@ -93,7 +92,7 @@ public class ProtectionListener implements Listener {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.BLOCKPLACEPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
String msg;
|
||||
if (add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
@ -101,7 +100,7 @@ public class ProtectionListener implements Listener {
|
||||
} else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.BLOCKPLACING.get() });
|
||||
msg = Lang.PROTECTIONMESSAGE.get(String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.BLOCKPLACING.get());
|
||||
}
|
||||
|
||||
//Send the message
|
||||
@ -148,7 +147,7 @@ public class ProtectionListener implements Listener {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.COMMANDPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
String msg;
|
||||
if (add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
@ -156,7 +155,7 @@ public class ProtectionListener implements Listener {
|
||||
} else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.COMMAND.get() });
|
||||
msg = Lang.PROTECTIONMESSAGE.get(String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.COMMAND.get());
|
||||
}
|
||||
|
||||
//Send the message
|
||||
@ -196,22 +195,20 @@ public class ProtectionListener implements Listener {
|
||||
|
||||
if (pos1 || pos2 || pos3 || pos4) {
|
||||
//it is a double chest, so they're free to go!
|
||||
if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: You're opening up a double chest.");
|
||||
if (pl.inDebug())
|
||||
event.getPlayer().sendMessage("[Jail Debug]: You're opening up a double chest.");
|
||||
} else {
|
||||
//it is not a double chest, so we won't be allowing it.
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
//the config has opening chests disabled
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
//The prisoner is not in a cell, so let's not allow it. IF we get feedback from people who
|
||||
//use the plugin, this might get removed or permission node might be added.
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -229,7 +226,7 @@ public class ProtectionListener implements Listener {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.CROPTRAMPLINGPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
String msg;
|
||||
if (add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
@ -237,7 +234,7 @@ public class ProtectionListener implements Listener {
|
||||
} else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.CROPTRAMPLING.get() });
|
||||
msg = Lang.PROTECTIONMESSAGE.get(String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.CROPTRAMPLING.get());
|
||||
}
|
||||
|
||||
//Send the message
|
||||
@ -270,7 +267,7 @@ public class ProtectionListener implements Listener {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.PREVENTINTERACTIONBLOCKSPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
String msg;
|
||||
if (add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
@ -278,7 +275,7 @@ public class ProtectionListener implements Listener {
|
||||
} else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.INTERACTIONBLOCKS.get() });
|
||||
msg = Lang.PROTECTIONMESSAGE.get(String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.INTERACTIONBLOCKS.get());
|
||||
}
|
||||
|
||||
//Send the message
|
||||
@ -299,7 +296,7 @@ public class ProtectionListener implements Listener {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
String msg;
|
||||
if (add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
@ -307,7 +304,7 @@ public class ProtectionListener implements Listener {
|
||||
} else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.INTERACTIONITEMS.get() });
|
||||
msg = Lang.PROTECTIONMESSAGE.get(String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.INTERACTIONITEMS.get());
|
||||
}
|
||||
|
||||
//Send the message
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.graywolf336.jail.listeners;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
private JailMain pl;
|
||||
private final JailMain pl;
|
||||
|
||||
public WorldListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
|
@ -1,15 +1,5 @@
|
||||
package com.graywolf336.jail.steps;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
@ -17,16 +7,28 @@ import com.graywolf336.jail.beans.CreationPlayer;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.SimpleLocation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* Class for stepping a player through the Cell creation process, instance is stored in {@link JailManager}.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class CellCreationSteps {
|
||||
/** Sends the Cell Creation message for starting out. */
|
||||
/**
|
||||
* Sends the Cell Creation message for starting out.
|
||||
*/
|
||||
public void startStepping(Player player) {
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation (tp) ----------");
|
||||
player.sendMessage(ChatColor.GREEN + "First, you must select a teleport point for the cell! Move to the teleport point and then click anywhere with your clay brick to set it.");
|
||||
@ -71,7 +73,9 @@ public class CellCreationSteps {
|
||||
}
|
||||
}
|
||||
|
||||
/** Applies the first step, which is setting the teleport in location. */
|
||||
/**
|
||||
* Applies the first step, which is setting the teleport in location.
|
||||
*/
|
||||
private void firstStep(JailManager jm, CreationPlayer cp, Player player) {
|
||||
Vector v1 = jm.getJail(cp.getJailName()).getMinPoint().toVector().clone();
|
||||
Vector v2 = jm.getJail(cp.getJailName()).getMaxPoint().toVector().clone();
|
||||
@ -91,9 +95,11 @@ public class CellCreationSteps {
|
||||
}
|
||||
}
|
||||
|
||||
/** Applies the second step, which is adding signs to the cell. */
|
||||
/**
|
||||
* 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 || block.getType() == Material.WALL_SIGN) {
|
||||
if (Tag.SIGNS.isTagged(block.getType()) || Tag.WALL_SIGNS.isTagged(block.getType())) {
|
||||
cp.addSign(new SimpleLocation(block.getLocation()));
|
||||
|
||||
//Set the sign's first text
|
||||
@ -113,7 +119,9 @@ public class CellCreationSteps {
|
||||
}
|
||||
}
|
||||
|
||||
/** Applies the third step, which is adding a chest or select not to have a chest. */
|
||||
/**
|
||||
* Applies the third step, which is adding a chest or select not to have a chest.
|
||||
*/
|
||||
private void thirdStep(JailManager jm, CreationPlayer cp, Player player, Block block) {
|
||||
if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST) {
|
||||
if (((Chest) block.getState()).getInventory().getSize() >= 40) {
|
||||
|
@ -1,26 +1,27 @@
|
||||
package com.graywolf336.jail.steps;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.CreationPlayer;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.Util;
|
||||
import com.graywolf336.jail.beans.CreationPlayer;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
|
||||
/**
|
||||
* Class for stepping a player through the Jail creation process, instance is stored in {@link JailManager}.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.1.1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class JailCreationSteps {
|
||||
|
||||
/** Sends the Jail Creation message for starting out. */
|
||||
/**
|
||||
* Sends the Jail Creation message for starting out.
|
||||
*/
|
||||
public void startStepping(Player player) {
|
||||
player.sendMessage(ChatColor.AQUA + "----------Jail Zone Creation----------");
|
||||
player.sendMessage(ChatColor.GREEN + "First, you must select jail cuboid. Select the first point of the cuboid by right clicking on the block with your clay brick. DO NOT FORGET TO MARK THE FLOOR AND CEILING TOO!");
|
||||
@ -68,7 +69,9 @@ public class JailCreationSteps {
|
||||
}
|
||||
}
|
||||
|
||||
/** Applies the first step, which is setting the first corner. */
|
||||
/**
|
||||
* Applies the first step, which is setting the first corner.
|
||||
*/
|
||||
private void firstStep(CreationPlayer cp, Player p, Location location) {
|
||||
p.sendMessage(ChatColor.AQUA + "---------- Jail Zone Creation----------");
|
||||
p.sendMessage(ChatColor.GREEN + "First point selected. Now select the second point.");
|
||||
@ -78,7 +81,9 @@ public class JailCreationSteps {
|
||||
cp.nextStep();
|
||||
}
|
||||
|
||||
/** Applies the second step, which is setting the second corner. */
|
||||
/**
|
||||
* Applies the second step, which is setting the second corner.
|
||||
*/
|
||||
private void secondStep(CreationPlayer cp, Player p, Location location) {
|
||||
p.sendMessage(ChatColor.AQUA + "---------- Jail Zone Creation ----------");
|
||||
p.sendMessage(ChatColor.GREEN + "Second point selected. Now go inside the jail and right click anywhere to select your current position as the teleport location for the jail.");
|
||||
@ -88,7 +93,9 @@ public class JailCreationSteps {
|
||||
cp.nextStep();
|
||||
}
|
||||
|
||||
/** Applies the third step, which is setting the teleport in location. */
|
||||
/**
|
||||
* Applies the third step, which is setting the teleport in location.
|
||||
*/
|
||||
private void thirdStep(CreationPlayer cp, Player p) {
|
||||
|
||||
int[] p1 = cp.getCornerOne();
|
||||
|
@ -6,7 +6,7 @@ authors: [graywolf336]
|
||||
website: dev.bukkit.org/server-mods/jail/
|
||||
softdepend: [WorldEdit, Vault, Multiverse-Core]
|
||||
load: POSTWORLD
|
||||
api-version: 1.13
|
||||
api-version: 1.17
|
||||
|
||||
commands:
|
||||
jail:
|
||||
@ -153,8 +153,6 @@ permissions:
|
||||
default: op
|
||||
jail.command.jailversion:
|
||||
default: op
|
||||
jail.usercmd.jailvote:
|
||||
default: op
|
||||
jail.vote.start:
|
||||
default: op
|
||||
jail.see.broadcast:
|
||||
|
@ -1,90 +0,0 @@
|
||||
package test.java.com.graywolf336.jail;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import test.java.com.graywolf336.jail.util.TestInstanceCreator;
|
||||
|
||||
import com.carrotsearch.junitbenchmarks.AbstractBenchmark;
|
||||
import com.carrotsearch.junitbenchmarks.BenchmarkOptions;
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.beans.CachePrisoner;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ JailMain.class, PluginDescriptionFile.class })
|
||||
public class BenchmarkTest extends AbstractBenchmark {
|
||||
private static TestInstanceCreator creator;
|
||||
private static JailMain main;
|
||||
private static UUID use;
|
||||
private static Random r;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertNotNull("The instance creator is null.", creator);
|
||||
assertTrue(creator.setup());
|
||||
main = creator.getMain();
|
||||
assertNotNull("The JailMain class is null.", main);
|
||||
assertTrue("The adding of a jail failed.", creator.addJail("testingJail"));
|
||||
assertFalse("There are no jails.", main.getJailManager().getJails().isEmpty());
|
||||
|
||||
for(int i = 0; i < 1000; i++) {
|
||||
if(i == 555)
|
||||
use = UUID.randomUUID();
|
||||
main.getPrisonerManager().prepareJail(main.getJailManager().getJail("testingJail"), null, null, new Prisoner(i == 555 ? use.toString() : UUID.randomUUID().toString(), "mockPlayer" + i, true, 100000L, "testJailer", "Test jailing " + i));
|
||||
}
|
||||
|
||||
//This puts the cache object into the cache for the move event and others to use (move in this test)
|
||||
main.getJailManager().addCacheObject(new CachePrisoner(main.getJailManager().getJailPlayerIsIn(use), main.getJailManager().getPrisoner(use)));
|
||||
r = new Random();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
main = null;
|
||||
}
|
||||
|
||||
@BenchmarkOptions(benchmarkRounds = 1000, warmupRounds = 0)
|
||||
@Test
|
||||
public void testPrisonerSizeAndJailed() {
|
||||
assertEquals("Prisoners not jailed?", 1000, main.getJailManager().getAllPrisoners().size());
|
||||
assertTrue("Prisoner 555 is not jailed", main.getJailManager().isPlayerJailed(use));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@BenchmarkOptions(benchmarkRounds = 5000, warmupRounds = 0)
|
||||
@Test
|
||||
public void testPlayerMoveEvent() {
|
||||
Player p = mock(Player.class);
|
||||
when(p.getUniqueId()).thenReturn(use);
|
||||
when(p.getName()).thenReturn("mockPlayer555");
|
||||
when(p.teleport(any(Location.class))).thenReturn(true);
|
||||
|
||||
Location from = new Location(main.getServer().getWorld("world"), 15, 64, -239);
|
||||
Location to = new Location(main.getServer().getWorld("world"), r.nextInt(), r.nextInt(), r.nextInt());
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(p, from, to);
|
||||
|
||||
main.getPlayerMoveListener().moveProtection(e);
|
||||
}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
package test.java.com.graywolf336.jail;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import test.java.com.graywolf336.jail.util.TestInstanceCreator;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.JailsAPI;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ JailMain.class, PluginDescriptionFile.class })
|
||||
public class TestJailAPI {
|
||||
private static TestInstanceCreator creator;
|
||||
private static JailMain main;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertNotNull("The instance creator is null.", creator);
|
||||
assertTrue(creator.setup());
|
||||
main = creator.getMain();
|
||||
assertNotNull("The JailMain class is null.", main);
|
||||
assertTrue("The adding of a jail failed.", creator.addJail("TestJailAPI"));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
main = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManagersAreThere() {
|
||||
assertNotNull(main.getHandCuffManager());
|
||||
assertNotNull(main.getJailManager());
|
||||
assertNotNull(main.getPrisonerManager());
|
||||
assertNotNull(main.getJailVoteManager());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyManagersAreTheSame() {
|
||||
assertThat("The HandCuff Manager references are different.", JailsAPI.getHandCuffManager(), is(main.getHandCuffManager()));
|
||||
assertThat("The Jail Manager references are different.", JailsAPI.getJailManager(), is(main.getJailManager()));
|
||||
assertThat("The Prisoner Manager references are different.", JailsAPI.getPrisonerManager(), is(main.getPrisonerManager()));
|
||||
assertThat("The Jail Stick Manager references are different.", JailsAPI.getJailStickManager(), is(main.getJailStickManager()));
|
||||
assertThat("The Jail Vote Manager references are different.", JailsAPI.getJailVoteManager(), is(main.getJailVoteManager()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandCuffManagerAPI() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Location loc = new Location(main.getServer().getWorld("world"), 11.469868464778077, 65.0, -239.27944647045672, Float.valueOf("38.499817"), Float.valueOf("2.0000453"));
|
||||
assertFalse("The test id of someone is already handcuffed.", JailsAPI.getHandCuffManager().isHandCuffed(id));
|
||||
|
||||
JailsAPI.getHandCuffManager().addHandCuffs(id, loc);
|
||||
assertTrue(JailsAPI.getHandCuffManager().isHandCuffed(id));
|
||||
assertThat(JailsAPI.getHandCuffManager().getLocation(id), is(loc));
|
||||
|
||||
JailsAPI.getHandCuffManager().removeHandCuffs(id);
|
||||
assertFalse(JailsAPI.getHandCuffManager().isHandCuffed(id));
|
||||
assertNull(JailsAPI.getHandCuffManager().getLocation(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJailManagerAPI() {
|
||||
assertThat("The Jail Manager reference to the plugin is different.", JailsAPI.getJailManager().getPlugin(), is(main));
|
||||
assertNotNull("The getJails method returned a null value.", JailsAPI.getJailManager().getJails());
|
||||
assertEquals("There isn't a Jail in the returned Jails.", 1, JailsAPI.getJailManager().getJails().size());
|
||||
assertThat("Jail Names aren't equal..", new String[] { "TestJailAPI" }, is(JailsAPI.getJailManager().getJailNames()));
|
||||
assertTrue("The adding of a new jail, furtherTesting, wasn't successful.", creator.addJail("furtherTesting"));
|
||||
assertTrue("The added jail, furtherTesting, doesn't exist.", JailsAPI.getJailManager().isValidJail("furtherTesting"));
|
||||
JailsAPI.getJailManager().removeJail("furtherTesting");
|
||||
assertFalse("The jail furtherTesting wasn't successfully removed.", JailsAPI.getJailManager().isValidJail("furtherTesting"));
|
||||
assertNull("The jail furtherTesting is not null.", JailsAPI.getJailManager().getJail("furtherTesting"));
|
||||
assertNotNull("The jail TestJailAPI is null.", JailsAPI.getJailManager().getJail("TestJailAPI"));
|
||||
assertNotNull("An empty string returned a null value even though there is one jail.", JailsAPI.getJailManager().getJail(""));
|
||||
assertNotNull("The first jail is null from the console sender.", JailsAPI.getJailManager().getNearestJail(creator.getCommandSender()));
|
||||
assertNotNull("The nearest jail from the player sender is null.", JailsAPI.getJailManager().getNearestJail(creator.getPlayerCommandSender()));
|
||||
assertNotNull("The cells object returned is null.", JailsAPI.getJailManager().getAllCells());
|
||||
assertTrue("There are some cells even though there shouldn't be.", JailsAPI.getJailManager().getAllCells().isEmpty());
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user