parts, String raw ) {
+ super( parts, raw);
+
+
+ // Override the unitType:
+
+ // unitType:
+ String unitTypeStr = parts.size() > 3 ? parts.get( 3 ) : null;
+ TimeTransformationUnitTypes timeUnitType =
+ TimeTransformationUnitTypes.fromString( unitTypeStr );
+
+ setTimeUnitType( timeUnitType );
+
+ }
+
+ @Override
+ public String format(Long value) {
+ String results = null;
+
+ String spaces = StringUtils.repeat( " ", getSpaces() );
+
+ try {
+ // & will not work in the DecimalFormat so replace it with ^|^ then replace after formatting:
+ //String fmt = getFormat();//.replace( "&", "^|^" );
+ //DecimalFormat dFmt = Prison.get().getDecimalFormat( fmt );
+
+ switch ( getTimeUnitType() )
+ {
+ case none:
+
+ results = PlaceholdersUtil.formattedTime( value );
+ break;
+
+ case LONG:
+ results = PlaceholdersUtil.formattedTime( value, spaces );
+ break;
+
+ case SHORT:
+ results = PlaceholdersUtil.formattedShortTime( value, spaces );
+ break;
+
+ case colons:
+ results = PlaceholdersUtil.formattedColonsTime( value, spaces );
+ break;
+
+ default:
+ break;
+ }
+
+// if ( results.contains( "^|^" ) ) {
+// //results = results.replace( "^|^", "&" );
+// }
+
+ }
+ catch (Exception e ) {
+ // Ignore unless in debug mode:
+ if ( isDebug() ) {
+ Output.get().logError(
+ String.format( "Error formatting results. long value= %s " +
+ "spaces=%d timeUnitType= %s ERRROR: %s",
+
+ Double.toString( value ), getSpaces(),
+ getTimeUnitType(), e.getMessage()
+ ));
+ }
+ }
+
+
+ if ( isHex2() ) {
+ results = Text.translateAmpColorCodesAltHexCode( results );
+ }
+ else if ( isHex() ) {
+ results = Text.translateAmpColorCodes( results );
+ }
+
+ if ( isDebug() ) {
+ String rawResults = Text.escapeAmpCodes(results);
+ String rawAttribute = Text.escapeAmpCodes(getRaw());
+
+ String message = String.format( "Placeholder Attribute time: double value= %s " +
+ "spaces=%d timeUnitType=%s Results: [%s] " +
+ "raw: &3[&7%s&3] &3[&7%s&3]" +
+ "(remove :debug from placeholder to disable this message)",
+
+ Double.toString( value ), getSpaces(),
+ getTimeUnitType(), results, rawResults, rawAttribute
+ );
+ Output.get().logInfo( message );
+ }
+
+ return results;
+
+ }
+
+ /**
+ * Not used.
+ */
+ @Override
+ public String format(String value) {
+ String results = null;
+
+ try {
+ long lValue = Long.parseLong( value );
+ results = format( lValue );
+ }
+ catch (Exception e ) {
+ // Ignore unless in debug mode:
+ if ( isDebug() ) {
+ Output.get().logError(
+ String.format( "Error parsing value to a long. String value= [%s] " +
+ "spaces=%d timeUnitType= %s ERRROR: %s",
+
+ value, getSpaces(),
+ getTimeUnitType(), e.getMessage()
+ ));
+ }
+ }
+
+ return results;
+ }
+
+
+
+ @Override
+ public String format(Double value) {
+ String results = null;
+
+ try {
+ long lValue = value.longValue();
+
+ results = format( lValue );
+ }
+ catch (Exception e ) {
+ // Ignore unless in debug mode:
+ if ( isDebug() ) {
+ Output.get().logError(
+ String.format( "Error parsing value to a long. String value= [%s] " +
+ "spaces=%d timeUnitType= %s ERRROR: %s",
+
+ value, getSpaces(),
+ getTimeUnitType(), e.getMessage()
+ ));
+ }
+ }
+
+ return results;
+ }
+
+ public TimeTransformationUnitTypes getTimeUnitType() {
+ return timeUnitType;
+ }
+ public void setTimeUnitType(TimeTransformationUnitTypes timeUnitType) {
+ this.timeUnitType = timeUnitType;
+ }
+
+
+}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java
index 1d48eee65..a9409b9d4 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderIdentifier.java
@@ -167,6 +167,14 @@ public boolean checkPlaceholderKey(PlaceHolderKey placeHolderKey) {
return results;
}
+ /**
+ * Set the player's object, based upon the player's name, or based upon the
+ * placeholder attribute if a player attribute is provided.
+ *
+ *
+ * @param playerUuid
+ * @param playerName
+ */
public void setPlayer( UUID playerUuid, String playerName ) {
Player player = null;
@@ -194,6 +202,28 @@ public void setPlayer( UUID playerUuid, String playerName ) {
if ( player != null ) {
setPlayer(player);
}
+ else {
+ // Check placeholder attributes for a defined player's namme:
+ String pName = getPlayerNameFromPlaceholderAttributes();
+
+ if ( pName != null ) {
+
+ setPlayer( null, pName );
+ }
+ }
+ }
+
+ public String getPlayerNameFromPlaceholderAttributes() {
+ String player = null;
+
+ for (PlaceholderAttribute phAttr : getAttributes() ) {
+ if ( phAttr.getPlayer() != null ) {
+ player = phAttr.getPlayer();
+ break;
+ }
+ }
+
+ return player;
}
public PlaceholderAttributeBar getAttributeBar() {
@@ -235,6 +265,19 @@ public PlaceholderAttributeText getAttributeText() {
return phAttribute;
}
+ public PlaceholderAttributeTime getAttributeTime() {
+ PlaceholderAttributeTime phAttribute = null;
+
+ for (PlaceholderAttribute placeholderAttribute : getAttributes() ) {
+ if ( placeholderAttribute instanceof PlaceholderAttributeTime ) {
+ phAttribute = (PlaceholderAttributeTime) placeholderAttribute;
+ break;
+ }
+ }
+
+ return phAttribute;
+ }
+
public String getIdentifierRaw() {
return identifierRaw;
}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java
index ed75add67..b3cf4bfe7 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManager.java
@@ -4,6 +4,9 @@
import java.util.List;
import java.util.regex.Pattern;
+import tech.mcprison.prison.Prison;
+import tech.mcprison.prison.modules.ModuleManager;
+
public class PlaceholderManager {
public static final String PRISON_PLACEHOLDER_PREFIX = "prison";
@@ -95,7 +98,8 @@ public boolean hasSequence() {
public enum PlaceholderAttributePrefixes {
nFormat,
bar,
- text;
+ text,
+ time;
public static PlaceholderAttributePrefixes fromString( String value ) {
PlaceholderAttributePrefixes pap = null;
@@ -133,6 +137,27 @@ public static NumberTransformationUnitTypes fromString( String value ) {
}
}
+ public enum TimeTransformationUnitTypes {
+ none,
+ LONG,
+ SHORT,
+ colons;
+
+ public static TimeTransformationUnitTypes fromString( String value ) {
+ TimeTransformationUnitTypes pap = none;
+
+ if ( value != null ) {
+ for ( TimeTransformationUnitTypes nTrans : values() ) {
+ if ( nTrans.name().equalsIgnoreCase( value ) ) {
+ pap = nTrans;
+ }
+ }
+ }
+
+ return pap;
+ }
+ }
+
/**
* The given place holders should have both the prison prefix and without,
* with the without having the suppress value set. The suppressable items
@@ -777,11 +802,34 @@ public static List getAllChatList( boolean omitSuppressable) {
boolean hasDeprecated = false;
+
+ boolean isMinesEnabled = Prison.get().getModuleManager().isEnabled( ModuleManager.MODULE_NAME_MINES );
+ boolean isRanksEnabled = Prison.get().getModuleManager().isEnabled( ModuleManager.MODULE_NAME_RANKS );
+
+
int totalCount = 0;
for ( PlaceholderFlags type : PlaceholderFlags.values() )
{
if ( type == PlaceholderFlags.ALIAS || type == PlaceholderFlags.SUPRESS ) {
- break;
+ continue;
+ }
+
+ if ( !isMinesEnabled && (
+ type == PlaceholderFlags.MINES ||
+ type == PlaceholderFlags.MINEPLAYERS ||
+ type == PlaceholderFlags.PLAYERBLOCKS ||
+ type == PlaceholderFlags.STATSMINES )) {
+ continue;
+ }
+
+ if ( !isRanksEnabled && (
+// type == PlaceholderFlags.PLAYER && placeholder.name().toLowerCase().contains("rank") ||
+ type == PlaceholderFlags.LADDERS ||
+ type == PlaceholderFlags.RANKS ||
+ type == PlaceholderFlags.RANKPLAYERS ||
+ type == PlaceholderFlags.STATSPLAYERS ||
+ type == PlaceholderFlags.STATSRANKS )) {
+ continue;
}
int pos = results.size();
@@ -820,6 +868,11 @@ else if ( type == PlaceholderFlags.STATSRANKS ) {
int count = 0;
for ( PrisonPlaceHolders ph : values() )
{
+ if ( !isRanksEnabled && (
+ type == PlaceholderFlags.PLAYER && ph.name().toLowerCase().contains("rank") )) {
+ break;
+ }
+
if ( ph.getFlags().contains( type ) &&
( !omitSuppressable ||
omitSuppressable && !ph.isSuppressed() && !ph.isAlias() )) {
diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManagerUtils.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManagerUtils.java
index f6c3bff67..6b7ff9aec 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManagerUtils.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholderManagerUtils.java
@@ -97,7 +97,8 @@ private PlaceholderAttribute attributeFactory( String rawAttribute ) {
if ( rawAttribute != null && !rawAttribute.isEmpty() ) {
ArrayList parts = new ArrayList<>();
- parts.addAll( Arrays.asList( rawAttribute.split( PlaceholderManager.PRISON_PLACEHOLDER_ATTRIBUTE_FIELD_SEPARATOR )) );
+ parts.addAll( Arrays.asList(
+ rawAttribute.split( PlaceholderManager.PRISON_PLACEHOLDER_ATTRIBUTE_FIELD_SEPARATOR )) );
if ( parts.size() >= 0 ) {
PlaceholderAttributePrefixes pap = PlaceholderAttributePrefixes.fromString( parts.get( 0 ) );
@@ -118,6 +119,12 @@ private PlaceholderAttribute attributeFactory( String rawAttribute ) {
attribute = new PlaceholderAttributeText( parts, rawAttribute );
break;
+ case time:
+ // Insert the dummy value "format" as the second element of 'parts' since Time does not use it:
+ parts.add(1, "");
+ attribute = new PlaceholderAttributeTime( parts, rawAttribute );
+ break;
+
default:
break;
}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersStats.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersStats.java
index bee6b1cf0..56ad91a77 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersStats.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersStats.java
@@ -13,7 +13,10 @@ public class PlaceholdersStats {
private static PlaceholdersStats stats;
- TreeMap placeholders;
+ private TreeMap placeholders;
+
+ private int invalidWorldCount = 0;
+
private PlaceholdersStats() {
super();
@@ -154,6 +157,13 @@ public ArrayList generatePlaceholderReport() {
}
+
+ results.add(
+ String.format( "&7Invalid World Usage Total: &3%10s &b(Placeholders replaced with banks)",
+ iFmt.format( getInvalidWorldCount() ) ));
+
+
+
return results;
}
@@ -174,6 +184,7 @@ public void clearCache(boolean resetCache, boolean removeErrors) {
getPlaceholders().remove( key );
}
+ setInvalidWorldCount( 0 );
Output.get().logInfo( "PlaceholderStats: Cache was purged of %s placeholders. Removed: %s ",
resetCache ? "all" :
@@ -190,5 +201,15 @@ public TreeMap getPlaceholders() {
public void setPlaceholders(TreeMap placeholders) {
this.placeholders = placeholders;
}
+
+ public int incrementInvalidWorldCount() {
+ return invalidWorldCount++;
+ }
+ public int getInvalidWorldCount() {
+ return invalidWorldCount;
+ }
+ public void setInvalidWorldCount(int invalidWorldCount) {
+ this.invalidWorldCount = invalidWorldCount;
+ }
}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java
index a1efb18b4..101ebca6e 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/placeholders/PlaceholdersUtil.java
@@ -48,6 +48,31 @@ public class PlaceholdersUtil
}
}
+ public static String formattedShortTime( double timeSec, String spaces ) {
+
+ long durationMs = (long) (timeSec * 1000d);
+ String formattedTime = Text.getTimeUntilShortString( durationMs, spaces );
+
+ return formattedTime;
+ }
+ public static String formattedColonsTime( double timeSec, String spaces ) {
+
+ long durationMs = (long) (timeSec * 1000d);
+ String formattedTime = Text.getTimeUntilColonsString( durationMs, spaces );
+
+ String textAnd = " " + Text.coreOutputTextAndMsg() + " ";
+
+ formattedTime = formattedTime.replace( textAnd, "" );
+
+ return formattedTime;
+ }
+ public static String formattedTime( double timeSec, String spaces ) {
+
+ long durationMs = (long) (timeSec * 1000d);
+ String formattedTime = Text.getTimeUntilString( durationMs, spaces );
+
+ return formattedTime;
+ }
/**
* Formats seconds to 0d 0h 0m 0s.
diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/Rank.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/Rank.java
index 976e61da9..007d2fd87 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/Rank.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/Rank.java
@@ -403,10 +403,15 @@ public int compareTo( Rank r )
}
/**
- * This new implementation of position is lazy loaded and should never be saved.
- * This is to provide a quick reference to the position within the ladder's rank's
- * ArrayList. This should never be used to access a rank or to refer to a rank; the
+ *
This provides a quick reference to the position within the ladder's rank's
+ * ArrayList. This value is zero based, where the first rank on the ladders has
+ * a position of 0.
+ *
+ *
+ * This new implementation of position is lazy loaded and should never be saved.
+ * This should never be used to access a rank or to refer to a rank; the
* actual objects should be used for that.
+ *
*
* @return
*/
diff --git a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java
index 6021ed64e..06af55f65 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/ranks/data/RankPlayer.java
@@ -114,6 +114,8 @@ public class RankPlayer
// private double rankScoreBalanceThreshold = 0;
// private long rankScoreCooldown = 0L;
+
+ private long economyCacheUpdateDelayTicks = -1;
public RankPlayer() {
super();
@@ -1182,6 +1184,19 @@ public double getBalanceUnsaved() {
return unsavedBalance;
}
+
+ public long getEconomyCacheUpdateDelayTicks() {
+
+ if ( this.economyCacheUpdateDelayTicks == -1 ) {
+
+ this.economyCacheUpdateDelayTicks =
+ Prison.get().getPlatform().getConfigLong(
+ "ranks.player-economy-cache-update-delay-ticks", DELAY_THREE_SECONDS );
+ }
+
+ return this.economyCacheUpdateDelayTicks;
+ }
+
public void addBalance( double amount ) {
synchronized ( unsavedBalanceLock )
@@ -1202,7 +1217,7 @@ public void addBalance( double amount ) {
unsavedBalance = 0;
ubTaskId = 0;
}
- }, DELAY_THREE_SECONDS );
+ }, getEconomyCacheUpdateDelayTicks() );
}
}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java
index 8706a810d..4a39bdb0f 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/tasks/PrisonCommandTasks.java
@@ -69,12 +69,14 @@ public void run() {
else if ( Output.get().isDebug() && cmTasksPosition > 0 ) {
// Done running all tasks. If debug is enabled, print:
+ String playerName = getPlayer() != null ? getPlayer().getName() : null;
+
String message = String.format( "Prison Command Debug Details: %d", cmTasksPosition );
- Output.get().logDebug( message );
+ Output.get().logDebug( message, playerName );
for ( PrisonCommandTaskData cmdTask : cmdTasks ) {
- Output.get().logInfo( cmdTask.getDebugDetails() );
+ Output.get().logDebug( cmdTask.getDebugDetails(), playerName );
}
}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/ExampleJavaDoubleVsBigDecimal.java b/prison-core/src/main/java/tech/mcprison/prison/util/ExampleJavaDoubleVsBigDecimal.java
index a856abc35..807cd35db 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/util/ExampleJavaDoubleVsBigDecimal.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/util/ExampleJavaDoubleVsBigDecimal.java
@@ -4,8 +4,6 @@
import java.text.DecimalFormat;
import java.util.ArrayList;
-import tech.mcprison.prison.Prison;
-
public class ExampleJavaDoubleVsBigDecimal {
public static void main( String[] args ) {
@@ -15,11 +13,13 @@ public static void main( String[] args ) {
ArrayList out = app.runSample();
String header = String.format(
- "%s %30s %35s %16s %s",
+ "%s %45s %3s %55s %3s %35s %s",
"Int Digits ",
" double ",
+ "Row",
" BigDecimal ",
- "Delta ",
+ "Row",
+ "Delta - loss of double precision ",
"Row" );
System.out.println( header );
@@ -36,9 +36,10 @@ private ArrayList runSample() {
StringBuilder sb = new StringBuilder();
sb.append( ".111111" );
- DecimalFormat dFmt = Prison.get().getDecimalFormat( "#,##0.00000" );
+ DecimalFormat dFmt = new DecimalFormat( "#,##0.000000" );
+// DecimalFormat iFmt = new DecimalFormat( "#,##0.00000" );
- for ( int i = 1; i < 25; i++ ) {
+ for ( int i = 1; i < 35; i++ ) {
sb.insert( 0, "1" );
double dub = Double.parseDouble( sb.toString() );
@@ -47,12 +48,14 @@ private ArrayList runSample() {
BigDecimal delta = bigD.subtract( BigDecimal.valueOf(dub) );
String rpt = String.format(
- "%2d %40s %35s %16s %2d",
+ "%3d %55s %3d %55s %3d %35s %3d",
i,
dFmt.format( dub ),
- bigD.toString(), delta.toString(),
- i
- );
+ i,
+ dFmt.format( bigD ),
+ i,
+ dFmt.format( delta ),
+ i );
out.add( rpt );
diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/Location.java b/prison-core/src/main/java/tech/mcprison/prison/util/Location.java
index 2c2a83a20..734a63a81 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/util/Location.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/util/Location.java
@@ -38,6 +38,7 @@ public class Location {
private Vector direction;
private boolean isEdge;
+ private boolean isCorner;
public Location(World world, double x, double y, double z, float pitch, float yaw, Vector direction) {
this.world = world;
@@ -163,6 +164,13 @@ public void setEdge( boolean isEdge ) {
this.isEdge = isEdge;
}
+ public boolean isCorner() {
+ return isCorner;
+ }
+ public void setCorner(boolean isCorner) {
+ this.isCorner = isCorner;
+ }
+
@Override public boolean equals(Object o) {
if (this == o) {
return true;
diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java b/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
index 56857746c..a597c11ae 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/util/PrisonStatsUtil.java
@@ -10,14 +10,103 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.TreeSet;
import tech.mcprison.prison.Prison;
+import tech.mcprison.prison.backups.PrisonBackups;
+import tech.mcprison.prison.commands.RegisteredCommand;
import tech.mcprison.prison.discord.PrisonPasteChat;
import tech.mcprison.prison.file.JsonFileIO;
import tech.mcprison.prison.output.ChatDisplay;
import tech.mcprison.prison.output.Output;
public class PrisonStatsUtil {
+
+
+ /**
+ * This will return in a StringBuilder all of the information from the following
+ * commands. They will be combined in one large StringBuilder object so a table of
+ * contents can be built from it. This is similar to running the following 4
+ * commands, but are better organized with the order of the details (files last).
+ *
+ *
+ * /prison support submit version
+ * /prison support submit ranks
+ * /prison support submit mines
+ * /prison support submit commands
+ *
+ * The difference with this function, is that all of the raw files are
+ * included at the end, instead of being mixed in with the other non-raw file
+ * dumps.
+ *
+ *
+ * Order of reports:
+ *
+ * - Version ALL
+ * - listeners ALL
+ * - Command Stats
+ *
+ * - Ladder List - Missing?
+ * - Rank List
+ * - Rank details
+ *
+ * - Mine List
+ * - Mine details
+ *
+ * - Prison Backup Files
+
+ * - Ladder Files
+ * - Rank Files
+ *
+ * - Mine Files
+ *
+ * - ConfigSettings Files
+ *
+ *
+ *
+ * @return
+ */
+ public StringBuilder getSupportSubmitBasic() {
+ StringBuilder sb = new StringBuilder();
+
+ // version info:
+ sb.append( getSupportSubmitVersionData() );
+
+ // Listeners:
+ sb.append( getSupportSubmitListenersData( "all" ) );
+
+ // Command Stats:
+ sb.append( getCommandStatsDetailData() );
+
+
+ // Rank Lists and Rank details:
+ sb.append( getSupportSubmitRanksData() );
+
+
+ // Mine lists and Mine details:
+ sb.append( getSupportSubmitMinesData() );
+
+
+ // Backup log files:
+ sb.append( getPrisonBackupLogsData() );
+
+
+ // Rank Files:
+ sb.append( getSupportSubmitRanksFileData() );
+
+
+ // Mine files:
+ sb.append( getSupportSubmitMinesFileData() );
+
+
+ // Config files:
+ sb.append( getSupportSubmitConfigsData() );
+
+
+ sb.append( getColorTest() );
+
+ return sb;
+ }
public ChatDisplay displayVersion(String options) {
@@ -52,6 +141,61 @@ public StringBuilder getSupportSubmitVersionData() {
return text;
}
+
+ public StringBuilder getColorTest() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "\n\n" );
+ sb.append( "Color Test:\n\n" );
+ sb.append( "||Color Test||\n" );
+
+ sb.append( "&0######### &r&1######### &r&2#########\n" );
+ sb.append( "&0### 0 ### &r&1### 1 ### &r&2### 2 ###\n" );
+ sb.append( "&0######### &r&1######### &r&2#########\n" );
+
+ sb.append( "&3######### &r&4######### &r&5#########\n" );
+ sb.append( "&3### 3 ### &r&4### 4 ### &r&5### 5 ###\n" );
+ sb.append( "&3######### &r&4######### &r&5#########\n" );
+
+ sb.append( "&6######### &r&7######### &r&8#########\n" );
+ sb.append( "&6### 6 ### &r&7### 7 ### &r&8### 8 ###\n" );
+ sb.append( "&6######### &r&7######### &r&8#########\n" );
+
+ sb.append( "&9######### &r&a######### &r&b#########\n" );
+ sb.append( "&9### 9 ### &r&a### a ### &r&b### b ###\n" );
+ sb.append( "&9######### &r&a######### &r&b#########\n" );
+
+ sb.append( "&c######### &r&d######### &r&e#########\n" );
+ sb.append( "&c### c ### &r&d### d ### &r&e### e ###\n" );
+ sb.append( "&c######### &r&d######### &r&e#########\n" );
+
+ sb.append( "&f######### &r\n" );
+ sb.append( "&f### f ### &r\n" );
+ sb.append( "&f######### &r\n" );
+
+
+ sb.append( "&3&l#####################&r\n" );
+ sb.append( "&3&l### Bold & 3 ###&r\n" );
+ sb.append( "&3&l#####################&r\n" );
+
+ sb.append( "&3&m#####################&r\n" );
+ sb.append( "&3&m### Strike & 3 ###&r\n" );
+ sb.append( "&3&m#####################&r\n" );
+
+ sb.append( "&3&n#####################&r\n" );
+ sb.append( "&3&n### Underline & 3 ###&r\n" );
+ sb.append( "&3&n#####################&r\n" );
+
+ sb.append( "&3&o#####################&r\n" );
+ sb.append( "&3&o### Italic & 3 ###&r\n" );
+ sb.append( "&3&o#####################&r\n" );
+
+ sb.append( "\n\n" );
+
+ return sb;
+ }
+
+
public StringBuilder getSupportSubmitConfigsData() {
Prison.get().getPlatform().saveResource("plugin.yml", true);
@@ -102,14 +246,30 @@ public void copyConfigsFiles() {
}
-
+
public StringBuilder getSupportSubmitRanksData() {
+
+ StringBuilder text = new StringBuilder();
+
+ text.append(Prison.get().getPlatform().getRanksListString());
+ printFooter(text);
+
+// List files = listFiles("data_storage/ranksDb/ladders/", ".json");
+// files.addAll(listFiles("data_storage/ranksDb/ranks/", ".json"));
+// for (File file : files) {
+//
+// addFileToText(file, text);
+// }
+
+ return text;
+ }
+
+ public StringBuilder getSupportSubmitRanksFileData() {
List files = listFiles("data_storage/ranksDb/ladders/", ".json");
files.addAll(listFiles("data_storage/ranksDb/ranks/", ".json"));
StringBuilder text = new StringBuilder();
- text.append(Prison.get().getPlatform().getRanksListString());
printFooter(text);
for (File file : files) {
@@ -121,28 +281,46 @@ public StringBuilder getSupportSubmitRanksData() {
}
public StringBuilder getSupportSubmitMinesData() {
- List files = listFiles("data_storage/mines/mines/", ".json");
- Collections.sort(files);
+// List files = listFiles("data_storage/mines/mines/", ".json");
+// Collections.sort(files);
StringBuilder text = new StringBuilder();
- text.append("\n");
- text.append("Table of contents:\n");
- text.append(" 1. Mine list - All mines including virtual mines: /mines list all\n");
- text.append(" 2. Mine info - All mines: /mines info all\n");
- text.append(" 3. Mine files - Raw JSON dump of all mine configuration files.\n");
- text.append("\n");
+// text.append("\n");
+// text.append("Table of contents:\n");
+// text.append(" 1. Mine list - All mines including virtual mines: /mines list all\n");
+// text.append(" 2. Mine info - All mines: /mines info all\n");
+// text.append(" 3. Mine files - Raw JSON dump of all mine configuration files.\n");
+// text.append("\n");
// Display a list of all mines, then display the /mines info all for
// each:
text.append(Prison.get().getPlatform().getMinesListString());
- printFooter(text);
+// printFooter(text);
+// // get all the file details for each mine:
+// for (File file : files) {
+//
+// addFileToText(file, text);
+// }
+
+ return text;
+ }
+
+ public StringBuilder getSupportSubmitMinesFileData() {
+ List files = listFiles("data_storage/mines/mines/", ".json");
+ Collections.sort(files);
+
+ StringBuilder text = new StringBuilder();
+
+ printFooter(text);
+
+ // get all the file details for each mine:
for (File file : files) {
-
+
addFileToText(file, text);
-
}
+
return text;
}
@@ -156,11 +334,13 @@ public StringBuilder getSupportSubmitListenersData( String listenerType ) {
if ( "blockBreak".equalsIgnoreCase( listenerType ) || "all".equalsIgnoreCase( listenerType ) ) {
+ sb.append( "||Listeners blockBreak||" );
sb.append( Prison.get().getPlatform().dumpEventListenersBlockBreakEvents() );
}
if ( "chat".equalsIgnoreCase( listenerType ) || "all".equalsIgnoreCase( listenerType ) ) {
+ sb.append( "||Listeners chat||" );
sb.append( Prison.get().getPlatform().dumpEventListenersPlayerChatEvents() );
}
@@ -172,12 +352,109 @@ public StringBuilder getSupportSubmitListenersData( String listenerType ) {
if ( "playerInteract".equalsIgnoreCase( listenerType ) || "all".equalsIgnoreCase( listenerType ) ) {
+ sb.append( "||Listeners playerInteract||" );
sb.append( Prison.get().getPlatform().dumpEventListenersPlayerInteractEvents() );
}
return sb;
}
+
+ public StringBuilder getCommandStatsDetailData() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "\n\n" );
+
+ List cmds = getCommandStats();
+ cmds.add( 1, "||CommandStats List||" );
+
+ for (String cmd : cmds) {
+
+ sb.append( cmd ).append( "\n" );
+ }
+
+ return sb;
+ }
+
+ public void getCommandStatsData() {
+
+ List cmds = getCommandStats();
+ for (String cmd : cmds) {
+
+ Output.get().logInfo( cmd );
+ }
+ }
+
+ private List getCommandStats() {
+ List results = new ArrayList<>();
+
+ DecimalFormat iFmt = Prison.get().getDecimalFormatInt();
+ DecimalFormat dFmt = Prison.get().getDecimalFormatDouble();
+
+ TreeSet allCmds = Prison.get().getCommandHandler().getAllRegisteredCommands();
+
+ results.add( "Prison Command Stats:" );
+ results.add(
+ Output.stringFormat( " &a&n%-40s&r &a&n%7s&r &a&n%-11s&r",
+ " Commands ", " Usage ", " Avg ms ") );
+
+ int count = 0;
+ int totals = 0;
+ double totalDuration = 0d;
+ for (RegisteredCommand cmd : allCmds) {
+
+ if ( cmd.getUsageCount() > 0 ) {
+
+ double duration = cmd.getUsageRunTimeNanos() / (double) cmd.getUsageCount() / 1000000.0d;
+
+ results.add( Output.stringFormat( " &2%-40s &2%7s &2%11s",
+ cmd.getCompleteLabel(),
+ iFmt.format( cmd.getUsageCount() ),
+ dFmt.format( duration )
+ ) );
+ count++;
+ totals += cmd.getUsageCount();
+ totalDuration += cmd.getUsageRunTimeNanos();
+ }
+ }
+
+ results.add( Output.stringFormat(" &3Total Registered Prison Commands: &7%9s", iFmt.format( allCmds.size() )) );
+ results.add( Output.stringFormat(" &3Total Prison Commands Listed: &7%9s", iFmt.format( count )) );
+ results.add( Output.stringFormat(" &3Total Prison Command Usage: &7%9s", iFmt.format( totals )) );
+
+ double avgDuration = totalDuration / (double) count / 1000000.0d;
+ results.add( Output.stringFormat(" &3Average Command Duration ms: &7%9s", dFmt.format( avgDuration )) );
+
+ results.add( " &d&oNOTE: Async Commands like '/mines reset' will not show actual runtime values. " );
+
+
+ return results;
+ }
+
+
+ public StringBuilder getPrisonBackupLogsData() {
+ StringBuilder sb = new StringBuilder();
+
+ // Include Prison backup logs:
+ sb.append( "\n\n" );
+ sb.append( "Prison Backup Logs:" ).append( "\n" );
+ List backupLogs = getPrisonBackupLogs();
+
+ for (String log : backupLogs) {
+ sb.append( Output.decodePercentEncoding(log) ).append( "\n" );
+ }
+
+ return sb;
+ }
+
+
+ public List getPrisonBackupLogs() {
+ PrisonBackups prisonBackup = new PrisonBackups();
+ List backupLogs = prisonBackup.backupReport02BackupLog();
+ return backupLogs;
+ }
+
+
public void readFileToStringBulider(File textFile, StringBuilder text) {
try (BufferedReader br = Files.newBufferedReader(textFile.toPath());) {
String line = br.readLine();
@@ -220,20 +497,71 @@ private List listFiles(String path, String fileSuffix) {
}
private void addFileToText(File file, StringBuilder sb) {
- DecimalFormat dFmt = Prison.get().getDecimalFormatInt();
+ DecimalFormat iFmt = Prison.get().getDecimalFormatInt();
+ DecimalFormat dFmt = Prison.get().getDecimalFormatDouble();
SimpleDateFormat sdFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ String parentDirName = file.getParentFile().getName();
+
+ String header = "";
+ String name = "";
+
+ if ( "ranks".equalsIgnoreCase(parentDirName) ) {
+ // Rank file names have a prefix of "ranks_" and then the rankId, followed by the suffix.
+ // Need to use the rankId to find the rank's name:
+
+ header = "Rank";
+ name = Prison.get().getPlatform().getRankByFileName( file.getName() );
+ }
+ else if ( "ladders".equalsIgnoreCase(parentDirName) ) {
+ // Ladder file names have a prefix of "ladders_" and then the ladderId, followed by the suffix.
+ // Need to use the ladderId to find the ladder's name:
+
+ header = "Ladder";
+ name = Prison.get().getPlatform().getLadderByFileName( file.getName() );
+ }
+ else if ( "mines".equalsIgnoreCase(parentDirName) ) {
+ // The file name of the mine, minus the suffix, is the name's name.
+
+ header = "Mine";
+ name = file.getName().replace(".json", "");
+ }
+ else {
+ header = "Config";
+ name = file.getName();
+ }
+
+
sb.append("\n");
JumboTextFont.makeJumboFontText(file.getName(), sb);
sb.append("\n");
+
- sb.append("File Name: ").append(file.getName()).append("\n");
- sb.append("File Path: ").append(file.getAbsolutePath()).append("\n");
- sb.append("File Size: ").append(dFmt.format(file.length())).append(" bytes\n");
- sb.append("File Date: ").append(sdFmt.format(new Date(file.lastModified()))).append(" bytes\n");
- sb.append("File Stats: ").append(file.exists() ? "EXISTS " : "").append(file.canRead() ? "READABLE " : "")
+ // Hyper Link codes:
+ sb.append( "||" )
+ .append( header )
+ .append( " " )
+ .append( name )
+ .append( " " )
+ .append( "File" )
+ .append( "||\n" );
+
+ String prisonPath = Prison.get().getDataFolder().getAbsolutePath();
+ String filePath = file.getAbsolutePath().replace( prisonPath, "" );
+
+ long fileSize = file.length();
+ double fileSizeKB = fileSize / 1024.0;
+
+ sb.append("File Name: ").append( file.getName() ).append("\n");
+ sb.append("Prison Path: ").append( prisonPath ).append("\n");
+ sb.append("File Path: ").append( filePath ).append("\n");
+ sb.append("File Size: ").append( iFmt.format( fileSize ) ).append(" bytes\n");
+ sb.append("File Size: ").append( dFmt.format( fileSizeKB ) ).append(" KB\n");
+ sb.append("File Date: ").append( sdFmt.format(new Date(file.lastModified())) ).append(" \n");
+ sb.append("File Stats: ").append( file.exists() ? "EXISTS " : "" ).append(file.canRead() ? "READABLE " : "")
.append(file.canWrite() ? "WRITEABLE " : "").append("\n");
sb.append("\n");
@@ -241,7 +569,9 @@ private void addFileToText(File file, StringBuilder sb) {
sb.append("\n");
if (file.exists() && file.canRead()) {
+ sb.append("&-");
readFileToStringBulider(file, sb);
+ sb.append("\n&+");
} else {
sb.append("Warning: The file is not readable so it cannot be included.\n");
}
@@ -251,7 +581,7 @@ private void addFileToText(File file, StringBuilder sb) {
public void printFooter(StringBuilder sb) {
- sb.append("\n\n\n");
+ sb.append("\n\n");
sb.append("=== --- === --- === --- === --- === --- ===\n");
sb.append("=== # # ### # # # ### # # # ### # # # ### # # # ### # # ===\n");
sb.append("=== --- === --- === --- === --- === --- ===\n");
diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/Text.java b/prison-core/src/main/java/tech/mcprison/prison/util/Text.java
index 01088b199..c9af8c48f 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/util/Text.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/util/Text.java
@@ -63,6 +63,26 @@ public class Text
"minute:minutes", millisPerMinute,
"second:seconds", millisPerSecond);
+ private static Map unitMillisShort = CollectionUtil
+ .map(
+ "y", millisPerYear,
+ "m", millisPerMonth,
+ "w", millisPerWeek,
+ "d", millisPerDay,
+ "h", millisPerHour,
+ "m", millisPerMinute,
+ "s", millisPerSecond);
+
+ private static Map unitMillisColons = CollectionUtil
+ .map(
+ "y", millisPerYear,
+ "m", millisPerMonth,
+ "w", millisPerWeek,
+ "day:", millisPerDay,
+ "hour:", millisPerHour,
+ "min:", millisPerMinute,
+ "", millisPerSecond);
+
private static String unit_time_text_prefix = "&3";
private static String unit_time_text_just_now = "just now";
private static String unit_time_text_ago = "ago";
@@ -115,6 +135,9 @@ public static void initialize() {
String timeUnitsSingular = coreOutputTextTimeUnitsSingularMsg();
String timeUnitsPlural = coreOutputTextTimeUnitsPluralMsg();
+
+ String timeUnitsShort = coreOutputTextTimeUnitsShortMsg();
+
String[] tuS = timeUnitsSingular.split( "," );
String[] tuP = timeUnitsPlural.split( "," );
@@ -131,6 +154,40 @@ public static void initialize() {
unitMillis.put( tuS[i] + ":" + tuP[i++], millisPerMinute );
unitMillis.put( tuS[i] + ":" + tuP[i++], millisPerSecond );
}
+
+
+ String[] tuShort = timeUnitsShort.split( "," );
+
+ if ( tuShort.length == 7 ) {
+ unitMillisShort = new LinkedHashMap<>();
+
+ int i = 0;
+ unitMillisShort.put( tuShort[i++], millisPerYear );
+ unitMillisShort.put( tuShort[i++], millisPerMonth );
+ unitMillisShort.put( tuShort[i++], millisPerWeek );
+ unitMillisShort.put( tuShort[i++], millisPerDay );
+ unitMillisShort.put( tuShort[i++], millisPerHour );
+ unitMillisShort.put( tuShort[i++], millisPerMinute );
+ unitMillisShort.put( tuShort[i++], millisPerSecond );
+
+ }
+
+ if ( tuShort.length == 7 ) {
+ unitMillisColons = new LinkedHashMap<>();
+
+ int i = 0;
+ unitMillisColons.put( tuShort[i++], millisPerYear );
+ unitMillisColons.put( tuShort[i++], millisPerMonth );
+ unitMillisColons.put( tuShort[i++], millisPerWeek );
+ unitMillisColons.put( "day:", millisPerDay );
+ unitMillisColons.put( "hour:", millisPerHour );
+ unitMillisColons.put( "min:", millisPerMinute );
+ unitMillisColons.put( "", millisPerSecond );
+
+ }
+
+
+
}
/**
@@ -572,18 +629,33 @@ public static String tab(String text) {
* @return The human-readable string.
*/
public static String getTimeUntilString(long millis) {
+ return getTimeUntilString( millis, unitMillis, unitPrefixSpacer, null );
+ }
+ public static String getTimeUntilString(long millis, String spaces ) {
+ return getTimeUntilString( millis, unitMillis, spaces, null );
+ }
+ public static String getTimeUntilShortString(long millis, String spaces ) {
+ return getTimeUntilString( millis, unitMillisShort, spaces, null );
+ }
+ public static String getTimeUntilColonsString(long millis, String spaces ) {
+ DecimalFormat dFmt = new DecimalFormat( "00" );
+ return getTimeUntilString( millis, unitMillisColons, spaces, dFmt );
+ }
+ private static String getTimeUntilString(long millis, Map units,
+ String unitSpacer, DecimalFormat dFmt ) {
String ret = unit_time_text_prefix;
double millisLeft = (double) Math.abs(millis);
List unitCountParts = new ArrayList<>();
- for (Map.Entry entry : unitMillis.entrySet()) {
+ for (Map.Entry entry : units.entrySet()) {
if (unitCountParts.size() == 3) {
break;
}
+ boolean isColons = ( entry.getKey().endsWith( ":" ) );
String[] unitNames = entry.getKey().split( ":" );
- String unitNameSingular = unitNames[0];
- String unitNamePlural = unitNames.length > 1 ? unitNames[1] : unitNames[0];
+ String unitNameSingular = isColons ? ":" : unitNames[0];
+ String unitNamePlural = isColons ? ":" : unitNames.length > 1 ? unitNames[1] : unitNames[0];
long unitSize = entry.getValue();
long unitCount = (long) Math.floor(millisLeft / unitSize);
@@ -592,7 +664,9 @@ public static String getTimeUntilString(long millis) {
}
millisLeft -= unitSize * unitCount;
- unitCountParts.add(unitCount + unitPrefixSpacer +
+ String unitCountStr = dFmt == null ? Long.toString( unitCount ) : dFmt.format( unitCount );
+
+ unitCountParts.add( unitCountStr + unitSpacer +
( unitCount == 1 ? unitNameSingular : unitNamePlural) );
}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/util/TextMessage.java b/prison-core/src/main/java/tech/mcprison/prison/util/TextMessage.java
index 7d3ebf2ce..7d5c3b9c8 100644
--- a/prison-core/src/main/java/tech/mcprison/prison/util/TextMessage.java
+++ b/prison-core/src/main/java/tech/mcprison/prison/util/TextMessage.java
@@ -46,7 +46,7 @@ protected static String coreOutputTextFromNowMsg() {
.localize();
}
- protected static String coreOutputTextAndMsg() {
+ public static String coreOutputTextAndMsg() {
return Prison.get().getLocaleManager()
.getLocalizable( "core_text__and" )
.withReplacements( "%s" )
@@ -77,5 +77,13 @@ protected static String coreOutputTextTimeUnitsPluralMsg() {
.setFailSilently()
.localize();
}
+
+ protected static String coreOutputTextTimeUnitsShortMsg() {
+ return Prison.get().getLocaleManager()
+ .getLocalizable( "core_text__time_units_short" )
+ .withReplacements( "%s" )
+ .setFailSilently()
+ .localize();
+ }
}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldEdit.java b/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldEdit.java
new file mode 100644
index 000000000..390cb4fa0
--- /dev/null
+++ b/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldEdit.java
@@ -0,0 +1,5 @@
+package tech.mcprison.prison.worldguard;
+
+public abstract class PrisonWorldEdit {
+
+}
diff --git a/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldGuard.java b/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldGuard.java
new file mode 100644
index 000000000..8757b7419
--- /dev/null
+++ b/prison-core/src/main/java/tech/mcprison/prison/worldguard/PrisonWorldGuard.java
@@ -0,0 +1,5 @@
+package tech.mcprison.prison.worldguard;
+
+public abstract class PrisonWorldGuard {
+
+}
diff --git a/prison-core/src/main/resources/lang/core/de_DE.properties b/prison-core/src/main/resources/lang/core/de_DE.properties
index deb59d124..e426fcec9 100644
--- a/prison-core/src/main/resources/lang/core/de_DE.properties
+++ b/prison-core/src/main/resources/lang/core/de_DE.properties
@@ -64,6 +64,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -84,7 +93,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/en_GB.properties b/prison-core/src/main/resources/lang/core/en_GB.properties
index f9b079bd7..12a920078 100644
--- a/prison-core/src/main/resources/lang/core/en_GB.properties
+++ b/prison-core/src/main/resources/lang/core/en_GB.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/en_US.properties b/prison-core/src/main/resources/lang/core/en_US.properties
index 9533f6cea..c5499c0d2 100644
--- a/prison-core/src/main/resources/lang/core/en_US.properties
+++ b/prison-core/src/main/resources/lang/core/en_US.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/es_ES.properties b/prison-core/src/main/resources/lang/core/es_ES.properties
index 590e00ba6..b6e6fbcde 100644
--- a/prison-core/src/main/resources/lang/core/es_ES.properties
+++ b/prison-core/src/main/resources/lang/core/es_ES.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/fi_FI.properties b/prison-core/src/main/resources/lang/core/fi_FI.properties
index 424e2488a..831d6af77 100644
--- a/prison-core/src/main/resources/lang/core/fi_FI.properties
+++ b/prison-core/src/main/resources/lang/core/fi_FI.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/fr_FR.properties b/prison-core/src/main/resources/lang/core/fr_FR.properties
index d33f66512..9997d0444 100644
--- a/prison-core/src/main/resources/lang/core/fr_FR.properties
+++ b/prison-core/src/main/resources/lang/core/fr_FR.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Envoi à System.err en raison de l'échec du log d'Output.log):
core_output__error_incorrect_number_of_parameters=Échec du log (%1): Nombre de paramètres incorrect: [%2] Message brut original: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/hu_HU.properties b/prison-core/src/main/resources/lang/core/hu_HU.properties
index 6dcfc75bc..fee17ae76 100644
--- a/prison-core/src/main/resources/lang/core/hu_HU.properties
+++ b/prison-core/src/main/resources/lang/core/hu_HU.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/it_IT.properties b/prison-core/src/main/resources/lang/core/it_IT.properties
index 3da4b9a97..7868eee2f 100644
--- a/prison-core/src/main/resources/lang/core/it_IT.properties
+++ b/prison-core/src/main/resources/lang/core/it_IT.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/nl_BE.properties b/prison-core/src/main/resources/lang/core/nl_BE.properties
index 6e970e303..bec93ed55 100644
--- a/prison-core/src/main/resources/lang/core/nl_BE.properties
+++ b/prison-core/src/main/resources/lang/core/nl_BE.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/nl_NL.properties b/prison-core/src/main/resources/lang/core/nl_NL.properties
index f8be4ce03..270b1fc24 100644
--- a/prison-core/src/main/resources/lang/core/nl_NL.properties
+++ b/prison-core/src/main/resources/lang/core/nl_NL.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/pt_PT.properties b/prison-core/src/main/resources/lang/core/pt_PT.properties
index 0a3281bf5..9c87f5f9d 100644
--- a/prison-core/src/main/resources/lang/core/pt_PT.properties
+++ b/prison-core/src/main/resources/lang/core/pt_PT.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/ro_RO.properties b/prison-core/src/main/resources/lang/core/ro_RO.properties
index ed5bf728a..647284ad2 100644
--- a/prison-core/src/main/resources/lang/core/ro_RO.properties
+++ b/prison-core/src/main/resources/lang/core/ro_RO.properties
@@ -59,6 +59,15 @@
# nefiind șters, poți integra manual schimbările în fișierul nou. Fișierele vechi, redenumite
# nu vor fi șterse de către Prison; poți să le ștergi când consideri că este sigur să o faci.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Puteți ajuta Prison și utilizatorii acestuia prin a adăuga traduceri în alte limbi.
# Acestea ar trebui să fie traduceri precise, ce mențin înțelesul mesajului original,
# fără glume de prost gust și abateri de la semnificația originală. Dacă dorești să
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/zh-CN.properties b/prison-core/src/main/resources/lang/core/zh-CN.properties
index 3d48d2fc8..cfeca845d 100644
--- a/prison-core/src/main/resources/lang/core/zh-CN.properties
+++ b/prison-core/src/main/resources/lang/core/zh-CN.properties
@@ -62,6 +62,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -82,7 +91,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=监狱: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters= 日志失败(%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/core/zh_TW.properties b/prison-core/src/main/resources/lang/core/zh_TW.properties
index 7cc23d779..99880acb3 100644
--- a/prison-core/src/main/resources/lang/core/zh_TW.properties
+++ b/prison-core/src/main/resources/lang/core/zh_TW.properties
@@ -61,6 +61,15 @@
# renamed files will never be deleted by prison; you can remove them when you feel like it
# is safe to do so.
#
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
# Please consider helping Prison, and everyone else who may use Prison, by contributing all
# translations to other languages. They should be faithful translations, and not something
# for the sake of humor or changes just for cosmetic styling. If you have something you would
@@ -81,7 +90,7 @@ core_output__prefix_template_debug=Debug
core_output__color_code_info=&3
core_output__color_code_warning=&c
core_output__color_code_error=&c
-core_output__color_code_debug=&9
+core_output__color_code_debug=&b
core_output__error_startup_failure=Prison: (Sending to System.err due to Output.log Logger failure):
core_output__error_incorrect_number_of_parameters=Log Failure (%1): Incorrect number of parameters: [%2] Original raw message: [%3] Arguments: %4
diff --git a/prison-core/src/main/resources/lang/mines/de_DE.properties b/prison-core/src/main/resources/lang/mines/de_DE.properties
index b8c0f73f4..da99ff80f 100644
--- a/prison-core/src/main/resources/lang/mines/de_DE.properties
+++ b/prison-core/src/main/resources/lang/mines/de_DE.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/en_US.properties b/prison-core/src/main/resources/lang/mines/en_US.properties
index 3f86d76e8..d7c409967 100644
--- a/prison-core/src/main/resources/lang/mines/en_US.properties
+++ b/prison-core/src/main/resources/lang/mines/en_US.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/es_ES.properties b/prison-core/src/main/resources/lang/mines/es_ES.properties
index c6bbeb44f..11692e63a 100644
--- a/prison-core/src/main/resources/lang/mines/es_ES.properties
+++ b/prison-core/src/main/resources/lang/mines/es_ES.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/fi_FI.properties b/prison-core/src/main/resources/lang/mines/fi_FI.properties
index 0600f57f3..4d8607849 100644
--- a/prison-core/src/main/resources/lang/mines/fi_FI.properties
+++ b/prison-core/src/main/resources/lang/mines/fi_FI.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/fr_FR.properties b/prison-core/src/main/resources/lang/mines/fr_FR.properties
index 4928b82e5..d6cf696c7 100644
--- a/prison-core/src/main/resources/lang/mines/fr_FR.properties
+++ b/prison-core/src/main/resources/lang/mines/fr_FR.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/hu_HU.properties b/prison-core/src/main/resources/lang/mines/hu_HU.properties
index 8748e42d6..e1d896577 100644
--- a/prison-core/src/main/resources/lang/mines/hu_HU.properties
+++ b/prison-core/src/main/resources/lang/mines/hu_HU.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/it_IT.properties b/prison-core/src/main/resources/lang/mines/it_IT.properties
index ee9efefba..e3e9aea98 100644
--- a/prison-core/src/main/resources/lang/mines/it_IT.properties
+++ b/prison-core/src/main/resources/lang/mines/it_IT.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/nl_BE.properties b/prison-core/src/main/resources/lang/mines/nl_BE.properties
index 921617ad9..e56e952e1 100644
--- a/prison-core/src/main/resources/lang/mines/nl_BE.properties
+++ b/prison-core/src/main/resources/lang/mines/nl_BE.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/nl_NL.properties b/prison-core/src/main/resources/lang/mines/nl_NL.properties
index 1013398f9..3ae2e01cb 100644
--- a/prison-core/src/main/resources/lang/mines/nl_NL.properties
+++ b/prison-core/src/main/resources/lang/mines/nl_NL.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/pt_PT.properties b/prison-core/src/main/resources/lang/mines/pt_PT.properties
index b1dd86d80..ede5b9ef7 100644
--- a/prison-core/src/main/resources/lang/mines/pt_PT.properties
+++ b/prison-core/src/main/resources/lang/mines/pt_PT.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/ro_RO.properties b/prison-core/src/main/resources/lang/mines/ro_RO.properties
index c875ef329..97432e42f 100644
--- a/prison-core/src/main/resources/lang/mines/ro_RO.properties
+++ b/prison-core/src/main/resources/lang/mines/ro_RO.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=4
diff --git a/prison-core/src/main/resources/lang/mines/zh-CN.properties b/prison-core/src/main/resources/lang/mines/zh-CN.properties
index b30302b63..29973987e 100644
--- a/prison-core/src/main/resources/lang/mines/zh-CN.properties
+++ b/prison-core/src/main/resources/lang/mines/zh-CN.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=3
diff --git a/prison-core/src/main/resources/lang/mines/zh_TW.properties b/prison-core/src/main/resources/lang/mines/zh_TW.properties
index ea87cda68..1ad538fbb 100644
--- a/prison-core/src/main/resources/lang/mines/zh_TW.properties
+++ b/prison-core/src/main/resources/lang/mines/zh_TW.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=5
diff --git a/prison-core/src/main/resources/lang/ranks/en_US.properties b/prison-core/src/main/resources/lang/ranks/en_US.properties
index ff6e18da4..8d0fc484d 100644
--- a/prison-core/src/main/resources/lang/ranks/en_US.properties
+++ b/prison-core/src/main/resources/lang/ranks/en_US.properties
@@ -49,8 +49,19 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
+# NOTE: You can add line feeds to your messages by inserting the placeholder '{br}'.
+#
-messages__version=28
+messages__version=29
messages__auto_refresh=true
ranks_rankup__rankup_no_player_name=You have
@@ -250,7 +261,7 @@ ranks_rankCommands__error_writting_ladder=&3The '&7%1&3' ladder could not be sav
ranks_rankCommands__auto_config_preexisting_warning=&3You are trying to run &7/ranks autoConfigure&3 with ranks or mines already setup. Rank count = &7%1&3. Mine count = &7%2&3. Please run this command with the &7help&3 keyword for more information and other customization options: &7/ranks autoConfigure help&3. It's best to run this command from the &7console&3 due to the volume of data it generates. Add the option '&7force&3' to force this process to run. If there is a conflict with a preexisting rank or mine, this process will do it's best to merge the new ranks and mines with what already exist. There is the risk something may not merge correctly. When merging, all blocks will be replaced, but in the console the original block list will be printed for reference if you want to recreate them. Please backup your &7plugins/Prison/&3 directory before running to be safe.
ranks_rankCommands__auto_config_force_warning=&aWarning! &3Running autoConfigure with &7force&3 enabled. Not responsible if mines or ranks collide.
-ranks_rankCommands__auto_config_invalid_options=&3Invalid options. Use %1&3. Was: &3%2
+ranks_rankCommands__auto_config_invalid_options=&3Invalid options detected. {br}Use %1&3. {br}&3The unknown remaining options were: [&7%2&3]
ranks_rankCommands__auto_config_skip_rank_warning=&aWarning! &3Rank &7%1 &3already exists and is being skipped along with generating the mine if enabled, along with all of the other features.
ranks_rankCommands__auto_config_no_ranks_created=Ranks autoConfigure: No ranks were created.
diff --git a/prison-core/src/main/resources/lang/ranks/fr_FR.properties b/prison-core/src/main/resources/lang/ranks/fr_FR.properties
index 90af5af69..6f5e7f54e 100644
--- a/prison-core/src/main/resources/lang/ranks/fr_FR.properties
+++ b/prison-core/src/main/resources/lang/ranks/fr_FR.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=28
messages__auto_refresh=true
diff --git a/prison-core/src/main/resources/lang/ranks/pt_PT.properties b/prison-core/src/main/resources/lang/ranks/pt_PT.properties
index 9210d41b4..c6f5ada05 100644
--- a/prison-core/src/main/resources/lang/ranks/pt_PT.properties
+++ b/prison-core/src/main/resources/lang/ranks/pt_PT.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=6
messages__auto_refresh=true
diff --git a/prison-core/src/main/resources/lang/ranks/zh-CN.properties b/prison-core/src/main/resources/lang/ranks/zh-CN.properties
index 0bdc603b6..9111dfdcb 100644
--- a/prison-core/src/main/resources/lang/ranks/zh-CN.properties
+++ b/prison-core/src/main/resources/lang/ranks/zh-CN.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=25
messages__auto_refresh=true
diff --git a/prison-core/src/main/resources/lang/ranks/zh_TW.properties b/prison-core/src/main/resources/lang/ranks/zh_TW.properties
index a503b64b9..88443d906 100644
--- a/prison-core/src/main/resources/lang/ranks/zh_TW.properties
+++ b/prison-core/src/main/resources/lang/ranks/zh_TW.properties
@@ -49,6 +49,15 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
messages__version=9
messages__auto_refresh=true
@@ -130,7 +139,7 @@ ranks_prisonRanks__failure_loading_players=玩家資料資料失敗. %1
ranks_prisonRanks__failed_loading_players=&c無法載入玩家: %1
ranks_prisonRanks__failed_to_load_player_file=玩家資料載入失敗. %1
-ranks_prisonRanks__status_loaded_ranks=載入 %1 éšŽç´ default ranks: %2 prestige ranks: %3 other ranks: %4
+ranks_prisonRanks__status_loaded_ranks=載入 %1 階� default ranks: %2 prestige ranks: %3 other ranks: %4
ranks_prisonRanks__status_loaded_ladders=載入 %1 階
ranks_prisonRanks__status_loaded_players=載入 %1 玩家
@@ -272,8 +281,8 @@ ranks_rankCommands__rank_was_removed=階級 '%1' 已刪除æˆåŠŸ
ranks_rankCommands__rank_delete_error=階級 '%1' å› å‡ºç¾éŒ¯èª¤è€Œåˆªé™¤å¤±æ•—
-ranks_rankCommands__ranks_list_header=%1 ä¸çš„ 階ç´
-šranks_rankCommands__ranks_list_ladder_cost_multplier=&3 Ladder Rank Cost Multiplier per Rank: &7%1
+ranks_rankCommands__ranks_list_header=%1 ä¸çš„ 階�
+�ranks_rankCommands__ranks_list_ladder_cost_multplier=&3 Ladder Rank Cost Multiplier per Rank: &7%1
ranks_rankCommands__ranks_list_ladder_apply_ranks_cost_multplier=&3 Apply global Rank Cost Multipliers to this Rank? &7%1
ranks_rankCommands__ranks_list_ladder_edit_cost_multplier=Edit this Ladder's Rank Cost Multiplier.
diff --git a/prison-core/src/main/resources/lang/sellall/en_US.properties b/prison-core/src/main/resources/lang/sellall/en_US.properties
index 916f8cfb4..b83231b04 100644
--- a/prison-core/src/main/resources/lang/sellall/en_US.properties
+++ b/prison-core/src/main/resources/lang/sellall/en_US.properties
@@ -49,6 +49,16 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
+
messages__version=2
messages__auto_refresh=true
diff --git a/prison-core/src/main/resources/lang/sellall/fi_FI.properties b/prison-core/src/main/resources/lang/sellall/fi_FI.properties
index bc3352c73..62ecd191f 100644
--- a/prison-core/src/main/resources/lang/sellall/fi_FI.properties
+++ b/prison-core/src/main/resources/lang/sellall/fi_FI.properties
@@ -49,6 +49,16 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
+
messages__version=2
messages__auto_refresh=true
@@ -58,10 +68,10 @@ sellall_function__message=&dNormaali viesti
sellall_spigot_utils__money_earned=&3Tienasit &a$%1
-sellall_spigot_utils__only_sellall_signs_are_enabled=&3Voit vain myydä kylteillä, komento disabloitu.
+sellall_spigot_utils__only_sellall_signs_are_enabled=&3Voit vain myyd� kylteill�, komento disabloitu.
sellall_spigot_utils__rate_limit_exceeded=&3Hidasta..
-sellall_spigot_utils__shop_is_empty=&3Anteeksi, tämä myynti kauppa on tyhjä..
-sellall_spigot_utils__you_have_nothing_to_sell=&3Anteeksi, sinulla ei ole myytävää.
+sellall_spigot_utils__shop_is_empty=&3Anteeksi, t�m� myynti kauppa on tyhj�..
+sellall_spigot_utils__you_have_nothing_to_sell=&3Anteeksi, sinulla ei ole myyt�v��.
sellall_spigot_utils__sellall_is_disabled=&3Anteeksi, sellall on disabloitu
sellall_spigot_utils__sellall_gui_is_disabled=&3Sorry, the sellall GUI is disabled..
diff --git a/prison-core/src/main/resources/lang/sellall/fr_FR.properties b/prison-core/src/main/resources/lang/sellall/fr_FR.properties
index 10d609a7a..2ae8bca16 100644
--- a/prison-core/src/main/resources/lang/sellall/fr_FR.properties
+++ b/prison-core/src/main/resources/lang/sellall/fr_FR.properties
@@ -49,6 +49,16 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
+
messages__version=2
messages__auto_refresh=true
diff --git a/prison-core/src/main/resources/lang/sellall/pt_PT.properties b/prison-core/src/main/resources/lang/sellall/pt_PT.properties
index 5fa3d2a7e..1cc23b939 100644
--- a/prison-core/src/main/resources/lang/sellall/pt_PT.properties
+++ b/prison-core/src/main/resources/lang/sellall/pt_PT.properties
@@ -49,6 +49,16 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
+
messages__version=2
messages__auto_refresh=true
diff --git a/prison-core/src/main/resources/lang/sellall/zh_CN.properties b/prison-core/src/main/resources/lang/sellall/zh_CN.properties
index eb9e536b4..589235f44 100644
--- a/prison-core/src/main/resources/lang/sellall/zh_CN.properties
+++ b/prison-core/src/main/resources/lang/sellall/zh_CN.properties
@@ -49,6 +49,16 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
+
messages__version=2
messages__auto_refresh=true
diff --git a/prison-core/src/main/resources/lang/spigot/en_US.properties b/prison-core/src/main/resources/lang/spigot/en_US.properties
index a53f646b3..7207e9d4f 100644
--- a/prison-core/src/main/resources/lang/spigot/en_US.properties
+++ b/prison-core/src/main/resources/lang/spigot/en_US.properties
@@ -49,6 +49,16 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
+
messages__version=6
messages__auto_refresh=true
@@ -215,20 +225,20 @@ spigot_message_prestiges_cancelled_wrong_keyword=Prestige &ccancelled&7, you did
## Ranks Messages
spigot_message_ranks_disabled=Sorry, Ranks are disabled.
spigot_message_ranks_or_gui_disabled=Sorry, Ranks or GUIs are disabled.
-spigot_message_ranks_tag_chat_rename_1=Please write the &6tag &7you'd like to use and &6submit&7.
+spigot_message_ranks_tag_chat_rename_1=Please enter the &6tag &7you'd like to use and &6submit&7.
spigot_message_ranks_tag_chat_rename_2=Input &cclose &7to cancel or wait &c30 seconds&7.
-spigot_message_ranks_tag_chat_cancelled=Rename tag &cclosed&7, nothing got changed!
+spigot_message_ranks_tag_chat_cancelled=Rename tag &cclosed&7, nothing was changed!
## SellAll Messages
-spigot_message_sellall_auto_already_enabled=Sellall Auto already enabled.
-spigot_message_sellall_auto_already_disabled=SellAll Auto already disabled.
-spigot_message_sellall_auto_disabled=SellAll Auto disabled with success.
+spigot_message_sellall_auto_already_enabled=Sellall AutoSell was already enabled.
+spigot_message_sellall_auto_already_disabled=SellAll AutoSell wasg already disabled.
+spigot_message_sellall_auto_disabled=AutoSell has been disabled.
spigot_message_sellall_auto_disabled_cant_use=Sorry, you need to enable AutoSell to use this.
-spigot_message_sellall_auto_enabled=SellAll Auto enabled with success.
-spigot_message_sellall_auto_perusertoggleable_enabled=Sellall Auto perUserToggleable enabled with success.
-spigot_message_sellall_auto_perusertoggleable_disabled=Sellall Auto perUserToggleable disabled with success.
-spigot_message_sellall_auto_perusertoggleable_already_enabled=Sellall Auto perUserToggleable already enabled.
-spigot_message_sellall_auto_perusertoggleable_already_disabled=Sellall Auto perUserToggleable already disabled.
+spigot_message_sellall_auto_enabled=AutoSell has been enabled.
+spigot_message_sellall_auto_perusertoggleable_enabled=Sellall AutoSell perUserToggleable is enabled.
+spigot_message_sellall_auto_perusertoggleable_disabled=Sellall AutoSell perUserToggleable is disabled.
+spigot_message_sellall_auto_perusertoggleable_already_enabled=Sellall AutoSell perUserToggleable already enabled.
+spigot_message_sellall_auto_perusertoggleable_already_disabled=Sellall AutoSell perUserToggleable already disabled.
spigot_message_sellall_boolean_input_invalid=The boolean value isn't valid (Valid values are True or False).
spigot_message_sellall_cant_find_item_config=Sorry, can't find your item in the config.
spigot_message_sellall_currency_chat_1=&3Started setup of new currency for SellAll!
@@ -238,7 +248,7 @@ spigot_message_sellall_currency_chat_4=Type the &aCurrency name &7to set the new
spigot_message_sellall_currency_edit_success=SellAll Currency edited with success.
spigot_message_sellall_currency_not_found=Sorry, currency not found.
spigot_message_sellall_hand_disabled=SellAll Hand disabled with success.
-spigot_message_sellall_hand_enabled=Sellall Hand enabled with success.
+spigot_message_sellall_hand_enabled=SellAll Hand enabled with success.
spigot_message_sellall_hand_is_disabled=SellAll Hand is disabled.
spigot_message_sellall_item_add_success=Item added with success.
spigot_message_sellall_item_already_added=You've already added this item, please use the edit command instead.
diff --git a/prison-core/src/main/resources/lang/spigot/fr_FR.properties b/prison-core/src/main/resources/lang/spigot/fr_FR.properties
index 3386e0a61..57a4eadbb 100644
--- a/prison-core/src/main/resources/lang/spigot/fr_FR.properties
+++ b/prison-core/src/main/resources/lang/spigot/fr_FR.properties
@@ -49,6 +49,16 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
+
messages__version=6
messages__auto_refresh=true
diff --git a/prison-core/src/main/resources/lang/spigot/pt_PT.properties b/prison-core/src/main/resources/lang/spigot/pt_PT.properties
index 2c2272449..198f1828d 100644
--- a/prison-core/src/main/resources/lang/spigot/pt_PT.properties
+++ b/prison-core/src/main/resources/lang/spigot/pt_PT.properties
@@ -49,6 +49,16 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
+
messages__version=2
messages__auto_refresh=true
diff --git a/prison-core/src/main/resources/lang/spigot/zh-CN.properties b/prison-core/src/main/resources/lang/spigot/zh-CN.properties
index 0f067c215..5cb478919 100644
--- a/prison-core/src/main/resources/lang/spigot/zh-CN.properties
+++ b/prison-core/src/main/resources/lang/spigot/zh-CN.properties
@@ -49,6 +49,16 @@
## /prison support submit.
##
+# NOTE: If you need to eliminate a message, leave an empty String after the equal sign `=`, or
+# use the key word `*none*`. Prison will not insert element or send a message if
+# these values are found.
+# Example: `core_text__from_now=from now` use either `core_text__from_now=` or `core_text__from_now=*none*`
+#
+# NOTE: Specific to the `core_output__` messages, `/prison reload locales` cannot reload them because
+# these are a very low level static component of the fallback messaging system within Prison.
+# You will have to restart the server if you make any changes to the messages with these prefixes.
+#
+
messages__version=5
messages__auto_refresh=true
diff --git a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
index 6875c4201..a1d5ca6d6 100644
--- a/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
+++ b/prison-core/src/test/java/tech/mcprison/prison/TestPlatform.java
@@ -295,10 +295,23 @@ public double getConfigDouble( String key, double defaultValue ) {
}
@Override
- public List> getConfigStringArray( String key ) {
+ public List getConfigStringArray( String key ) {
return new ArrayList();
}
+ /**
+ * Given the path to a hash, this will return all of the keys within
+ * the hash at the root level. It will not traverse deeper.
+ * The list of keys can then be used to access all of the values.
+ *
+ *
+ */
+ @Override
+ public List getConfigHashKeys(String hashPrefix) {
+ return new ArrayList();
+ }
+
+
@Override
public boolean isWorldExcluded( String worldName ) {
return false;
@@ -421,6 +434,13 @@ public void saveResource( String string, boolean replace ) {
}
+
+ @Override
+ public boolean isMineNameValid(String mineName) {
+ return false;
+ }
+
+
@Override
public String getMinesListString() {
return "";
@@ -533,4 +553,13 @@ public int getMinY() {
public int getMaxY() {
return 255;
}
+
+ public String getLadderByFileName(String name) {
+ return "default";
+ }
+
+
+ public String getRankByFileName(String name) {
+ return "a";
+ }
}
diff --git a/prison-core/src/test/java/tech/mcprison/prison/discord/PrisonSupportFilesTest.java b/prison-core/src/test/java/tech/mcprison/prison/discord/PrisonSupportFilesTest.java
new file mode 100644
index 000000000..69d495bdd
--- /dev/null
+++ b/prison-core/src/test/java/tech/mcprison/prison/discord/PrisonSupportFilesTest.java
@@ -0,0 +1,49 @@
+package tech.mcprison.prison.discord;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class PrisonSupportFilesTest
+ extends PrisonSupportFiles
+{
+
+ @Test
+ public void test() {
+
+ String t1 = "This is a test";
+ String r1 = "This is a test\n";
+
+ assertEquals(r1, convertColorCodes(t1) );
+
+
+ String t2 = "&3This is a test";
+ String r2 = "This is a test\n";
+
+ assertEquals(r2, convertColorCodes(t2) );
+
+
+ String t3 = "&3This is a &1test";
+ String r3 = "This is a "
+ + "test\n";
+
+ assertEquals(r3, convertColorCodes(t3) );
+
+
+ String t4 = "&3This is a &1test & sample";
+ String r4 = "This is a "
+ + "test & sample\n";
+
+ assertEquals(r4, convertColorCodes(t4) );
+
+
+ String t5 = "&3This is a &1test & a&r fun &1sample";
+ String r5 = "This is a "
+ + "test & a"
+ + " fun sample\n";
+
+ assertEquals(r5, convertColorCodes(t5) );
+
+ }
+
+}
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/PrisonMines.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/PrisonMines.java
index da33a9961..d827c336d 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/PrisonMines.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/PrisonMines.java
@@ -38,6 +38,7 @@
import tech.mcprison.prison.mines.managers.MineManager;
import tech.mcprison.prison.mines.managers.MineManager.MineSortOrder;
import tech.mcprison.prison.modules.Module;
+import tech.mcprison.prison.modules.ModuleManager;
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.store.Database;
import tech.mcprison.prison.util.Location;
@@ -49,7 +50,9 @@
* @author The MC-Prison Team
*/
public class PrisonMines extends Module {
- public static final String MODULE_NAME = "Mines";
+
+ public static final String MODULE_NAME = ModuleManager.MODULE_NAME_MINES;
+// public static final String MODULE_NAME = "Mines";
private static PrisonMines i = null;
private MinesConfig config;
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java
index f4ae83f64..61b967958 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesBlockCommands.java
@@ -340,7 +340,12 @@ public void setBlockCommand(CommandSender sender,
prisonBlock = prisonBlockTypes.getBlockTypesByName( block );
}
-
+ if ( block == null || prisonBlock == null ) {
+
+ sender.sendMessage(
+ String.format( "Invalid blockk name: [%s]", block ) );
+ return;
+ }
// Change behavior: If trying to change a block that is not in the mine, then instead add it:
if (!m.isInMine(prisonBlock)) {
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesCommands.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesCommands.java
index 505fbcae0..35512e819 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesCommands.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/commands/MinesCommands.java
@@ -37,6 +37,7 @@
import tech.mcprison.prison.internal.CommandSender;
import tech.mcprison.prison.internal.Player;
import tech.mcprison.prison.internal.block.Block;
+import tech.mcprison.prison.internal.block.MineResetType;
import tech.mcprison.prison.internal.block.PrisonBlock;
import tech.mcprison.prison.mines.PrisonMines;
import tech.mcprison.prison.mines.data.Mine;
@@ -897,6 +898,8 @@ private ChatDisplay mineInfoDetails( CommandSender sender, boolean isMineStats,
DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
ChatDisplay chatDisplay = new ChatDisplay("&bMine: &3" + m.getName());
+
+ chatDisplay.addSupportHyperLinkData( "Mine %s", m.getName() );
{
RowComponent row = new RowComponent();
@@ -1882,7 +1885,7 @@ public void skipResetCommand(CommandSender sender,
@Command(identifier = "mines set resetTime", permissions = "mines.set",
description = "Set a mine's auto reset time as expressed in seconds.")
public void resetTimeCommand(CommandSender sender,
- @Arg(name = "mineName", description = "The name of the mine to edit.") String mineName,
+ @Arg(name = "mineName", description = "The name of the mine to edit, or '*all' to apply to all mines.") String mineName,
@Arg(name = "time", description = "Time in seconds for the mine to auto reset. " +
"With a minimum value of "+ MineData.MINE_RESET__TIME_SEC__MINIMUM + " seconds. " +
"Using '*disable*' will turn off the auto reset. Use of "
@@ -1915,7 +1918,7 @@ else if ( "*default*".equalsIgnoreCase( time ) ) {
return;
}
}
- if ( resetTime < MineData.MINE_RESET__TIME_SEC__MINIMUM ) {
+ if ( !"*disable*".equalsIgnoreCase( time ) && resetTime < MineData.MINE_RESET__TIME_SEC__MINIMUM ) {
Output.get().sendWarn( sender,
"&7Invalid resetTime value for &b%s&7. Must be an integer value of &b%d&7 or greater. [&b%d&7]",
mineName, MineData.MINE_RESET__TIME_SEC__MINIMUM, resetTime );
@@ -2775,25 +2778,41 @@ public void backupMineCommand(CommandSender sender,
}
- @Command(identifier = "mines set tracer", permissions = "mines.set",
- description = "Clear the mine and set a tracer around the outside")
+ @Command(identifier = "mines set tracer",
+ description = "Clears the mine of all blocks and sest a tracer of "
+ + "pink glass blocks around the outside",
+ permissions = "mines.set")
public void setTracerCommand(CommandSender sender,
- @Arg(name = "mineName", description = "The name of the mine to set the tracer in.") String mineName) {
+ @Arg(name = "mineName",
+ description = "The name of the mine to set the tracer in.") String mineName,
+ @Arg(name = "options", def = "outline",
+ description = "Options to control how the tracer is set. "
+ + "Defaults to 'outline' which draws a pink glass block around the edges of the mine. "
+ + "The option 'corners' will only place blocks within the corners of the mine. "
+ + "The option of 'clear' will just clear the mine and will not place any tracers. "
+ + "[outline corners clear]") String option ) {
if (!performCheckMineExists(sender, mineName)) {
return;
}
+ MineResetType resetType = MineResetType.fromString(option);
+
+ if ( resetType != MineResetType.corners && resetType != MineResetType.clear ) {
+ resetType = MineResetType.tracer;
+ }
+
+
PrisonMines pMines = PrisonMines.getInstance();
Mine mine = pMines.getMine(mineName);
-
+
if ( mine.isVirtual() ) {
sender.sendMessage( "&cMine is a virtual mine&7. Use &a/mines set area &7to enable the mine." );
return;
}
- mine.enableTracer();
+ mine.enableTracer( resetType );
}
@@ -3311,6 +3330,53 @@ else if ( playerAlt != null && !player.getName().equalsIgnoreCase( playerAlt.get
}
}
+
+
+ @Command(identifier = "mines top",
+ description = "TP to the top of the current mine. Will default to the mine's " +
+ "spawn location if set, but can specify the target [spawn, mine]. If not in a "
+ + "mine, then it will be the same as '/mtp' where it will take you to a mine that "
+ + "is linked to your current rank. This command has no options.",
+ aliases = "mtop",
+ altPermissions = {"access-by-rank", "mines.tp"})
+ public void mineTpTop(CommandSender sender ) {
+
+
+ Player player = getPlayer( sender );
+ //oboolean isOp = sender.isOp();
+
+
+ if ( player == null || !player.isOnline() ) {
+
+ teleportPlayerMustBeIngameMsg( sender );
+ return;
+ }
+
+
+ PrisonMines pMines = PrisonMines.getInstance();
+
+ Mine mine = pMines.findMineLocationExact( player.getLocation() );
+
+
+ if ( mine != null ) {
+ if ( mine.isVirtual() ) {
+ teleportCannotUseVirtualMinesMsg( sender );
+ return;
+ }
+ else {
+
+ mineTp( sender, mine.getName(), "", "spawn");
+ }
+ }
+ else {
+ // Player is not in a mine, so issue `/mtp` command for them:
+ mineTp( sender, "", "", "");
+ }
+
+
+
+ }
+
private void teleportPlayer( Player player, Mine mine, String target ) {
if ( Prison.get().getPlatform().getConfigBooleanFalse( "prison-mines.tp-warmup.enabled" ) ) {
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java
index 214b745f6..d397bfdc6 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/data/MineReset.java
@@ -596,8 +596,11 @@ public void generateBlockListAsync() {
boolean isEdge = xEdge && yEdge || xEdge && zEdge ||
yEdge && zEdge;
+ boolean isCorner = xEdge && yEdge && zEdge;
+
Location targetBlock = new Location(world, x, y, z);
targetBlock.setEdge( isEdge );
+ targetBlock.setCorner( isCorner );
// MineTargetBlock mtb = null;
@@ -1269,8 +1272,11 @@ public List refreshAirCountSyncTaskBuildLocations() {
boolean isEdge = xEdge && yEdge || xEdge && zEdge ||
yEdge && zEdge;
+ boolean isCorner = xEdge && yEdge && zEdge;
+
Location targetBlock = new Location(world, x, y, z);
targetBlock.setEdge( isEdge );
+ targetBlock.setCorner( isCorner );
locations.add( targetBlock );
@@ -1790,11 +1796,12 @@ private void constraintsApplyMin( PrisonBlockStatusData block )
/**
* This clears the mine, then provides particle tracers around the outer corners.
+ * @param resetType
*/
- public void enableTracer() {
+ public void enableTracer(MineResetType resetType) {
// First clear the mine:
- clearMine( true );
+ clearMine( resetType );
// Prison.get().getPlatform().enableMineTracer(
// getWorldName(),
@@ -1817,7 +1824,7 @@ public void enableTracer() {
public void adjustSize( Edges edge, int amount ) {
// First clear the mine:
- clearMine( false );
+ clearMine( MineResetType.clear );
// if amount is zero, then just refresh the liner:
@@ -1852,7 +1859,7 @@ else if ( amount > 0 ) {
}
// Finally trace the mine:
- clearMine( true );
+ clearMine( MineResetType.tracer );
}
@@ -1863,10 +1870,10 @@ public void moveMine( Edges edge, int amount ) {
}
- public void clearMine( boolean tracer ) {
+ public void clearMine( MineResetType resetType ) {
MineTracerBuilder tracerBuilder = new MineTracerBuilder();
- tracerBuilder.clearMine( (Mine) this, tracer );
+ tracerBuilder.clearMine( (Mine) this, resetType );
}
@@ -1885,7 +1892,7 @@ private void addMineTargetPrisonBlock( PrisonBlockStatusData block, Location tar
MineTargetPrisonBlock mtpb = new MineTargetPrisonBlock( block, getWorld().get(),
targetBlock.getBlockX(), targetBlock.getBlockY(), targetBlock.getBlockZ(),
- targetBlock.isEdge() );
+ targetBlock.isEdge(), targetBlock.isCorner() );
synchronized ( getMineStateMutex() ) {
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineBlockEvent.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineBlockEvent.java
index 7873665d8..c34a3d527 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineBlockEvent.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineBlockEvent.java
@@ -41,12 +41,21 @@ public enum BlockEventType {
RevEnExplosion,
RevEnJackHammer,
+ ExplosionTriggerEvent,
+ LayerTriggerEvent,
+ NukeTriggerEvent,
+
eventTypeAll( all ),
eventBlockBreak( blockBreak ),
eventTEXplosion( TEXplosion ),
eventRevEnExplosion( RevEnExplosion ),
- eventRevEnJackHammer( RevEnJackHammer ),
+ eventRevEnJackHammer( RevEnJackHammer ),
+
+ XPrisonExplosionTriggerEvent( ExplosionTriggerEvent ),
+ XPrisonLayerTriggerEvent( LayerTriggerEvent ),
+ XPrisonNukeTriggerEvent( NukeTriggerEvent ),
+
;
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java
index 7d61ecec1..250e24613 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineLinerBuilder.java
@@ -8,6 +8,7 @@
import tech.mcprison.prison.internal.World;
import tech.mcprison.prison.internal.block.Block;
import tech.mcprison.prison.internal.block.BlockFace;
+import tech.mcprison.prison.internal.block.MineResetType;
import tech.mcprison.prison.internal.block.PrisonBlock;
import tech.mcprison.prison.mines.data.Mine;
import tech.mcprison.prison.mines.features.MineLinerData.LadderType;
@@ -192,7 +193,7 @@ public MineLinerBuilder( Mine mine, Edges edge, LinerPatterns pattern, boolean i
this.isForced = isForced;
if ( pattern != null ) {
- mine.enableTracer();
+ mine.enableTracer( MineResetType.clear );
generatePattern( edge );
}
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineMover.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineMover.java
index d5dcee4b5..5d21a7fe6 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineMover.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineMover.java
@@ -1,5 +1,6 @@
package tech.mcprison.prison.mines.features;
+import tech.mcprison.prison.internal.block.MineResetType;
import tech.mcprison.prison.mines.data.Mine;
import tech.mcprison.prison.mines.features.MineLinerBuilder.LinerPatterns;
import tech.mcprison.prison.util.Bounds;
@@ -14,7 +15,7 @@ public MineMover() {
public void moveMine( Mine mine, Edges edge, int amount ) {
- mine.clearMine( false );
+ mine.clearMine( MineResetType.clear );
new MineLinerBuilder( mine, Edges.top, LinerPatterns.repair, false );
new MineLinerBuilder( mine, Edges.bottom, LinerPatterns.repair, false );
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineTracerBuilder.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineTracerBuilder.java
index 84737cb1b..6f2059a17 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineTracerBuilder.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/features/MineTracerBuilder.java
@@ -45,7 +45,7 @@ public static TracerType fromString( String type ) {
}
}
- public void clearMine( Mine mine, boolean tracer ) {
+ public void clearMine( Mine mine, MineResetType resetType ) {
if ( mine == null ) {
Output.get().logError(" #### Null MINE? ###");
@@ -56,7 +56,7 @@ public void clearMine( Mine mine, boolean tracer ) {
return;
}
- MineResetType resetType = tracer ? MineResetType.tracer : MineResetType.clear;
+// MineResetType resetType = tracer ? MineResetType.tracer : MineResetType.clear;
MinePagedResetAsyncTask resetTask = new MinePagedResetAsyncTask( mine, resetType );
resetTask.submitTaskAsync();
diff --git a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java
index 91e6ea570..f53f77ae6 100644
--- a/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java
+++ b/prison-mines/src/main/java/tech/mcprison/prison/mines/managers/MineManager.java
@@ -45,6 +45,7 @@
import tech.mcprison.prison.placeholders.PlaceholderAttributeBar;
import tech.mcprison.prison.placeholders.PlaceholderAttributeNumberFormat;
import tech.mcprison.prison.placeholders.PlaceholderAttributeText;
+import tech.mcprison.prison.placeholders.PlaceholderAttributeTime;
import tech.mcprison.prison.placeholders.PlaceholderIdentifier;
import tech.mcprison.prison.placeholders.PlaceholderManager;
import tech.mcprison.prison.placeholders.PlaceholderManager.PlaceholderFlags;
@@ -775,6 +776,8 @@ public String getTranslateMinesPlaceholder( PlaceholderIdentifier identifier ) {
PlaceholderAttributeBar attributeBar = identifier.getAttributeBar();
PlaceholderAttributeNumberFormat attributeNFormat = identifier.getAttributeNFormat();
PlaceholderAttributeText attributeText = identifier.getAttributeText();
+ PlaceholderAttributeTime attributeTime = identifier.getAttributeTime();
+
int sequence = identifier.getSequence();
@@ -791,6 +794,7 @@ public String getTranslateMinesPlaceholder( PlaceholderIdentifier identifier ) {
if ( mine != null ||
placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.PLAYERBLOCKS ) ||
placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINEPLAYERS )) {
+
DecimalFormat dFmt = Prison.get().getDecimalFormat("#,##0.00");
DecimalFormat iFmt = Prison.get().getDecimalFormatInt();
// DecimalFormat fFmt = Prison.get().getDecimalForma("#,##0.00");
@@ -828,6 +832,10 @@ public String getTranslateMinesPlaceholder( PlaceholderIdentifier identifier ) {
results = attributeNFormat.format( (long) mine.getResetTime() );
}
+ else if ( attributeTime != null ) {
+
+ results = attributeTime.format( (long) mine.getResetTime() );
+ }
else {
results = iFmt.format( mine.getResetTime() );
@@ -846,6 +854,10 @@ public String getTranslateMinesPlaceholder( PlaceholderIdentifier identifier ) {
results = attributeNFormat.format( (long) mine.getResetTime() );
}
+ else if ( attributeTime != null ) {
+
+ results = attributeTime.format( (long) mine.getResetTime() );
+ }
else {
double timeMif = mine.getResetTime();
@@ -866,6 +878,10 @@ public String getTranslateMinesPlaceholder( PlaceholderIdentifier identifier ) {
results = attributeNFormat.format( (long) mine.getRemainingTimeSec() );
}
+ else if ( attributeTime != null ) {
+
+ results = attributeTime.format( (long) mine.getResetTime() );
+ }
else {
results = dFmt.format( mine.getRemainingTimeSec() );
}
diff --git a/prison-misc/build.gradle b/prison-misc/build.gradle
new file mode 100644
index 000000000..5d17da6d5
--- /dev/null
+++ b/prison-misc/build.gradle
@@ -0,0 +1,91 @@
+/*
+ * Prison is a Minecraft plugin for the prison game mode.
+ * Copyright (C) 2017 The Prison Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+group 'tech.mcprison'
+
+apply plugin: 'java'
+
+compileJava.options.encoding = 'UTF-8'
+compileTestJava.options.encoding = "UTF-8"
+
+//sourceCompatibility = 1.8
+
+
+// https://www.spigotmc.org/wiki/spigot-gradle/
+
+
+repositories {
+ mavenCentral()
+
+
+ maven {
+ url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
+
+ // As of Gradle 5.1, you can limit this to only those
+ // dependencies you expect from it
+ content {
+ includeGroup 'org.bukkit'
+ includeGroup 'org.spigotmc'
+ }
+ }
+ /*
+ As Spigot-API depends on the BungeeCord ChatComponent-API,
+ we need to add the Sonatype OSS repository, as Gradle,
+ in comparison to maven, doesn't want to understand the ~/.m2
+ directory unless added using mavenLocal(). Maven usually just gets
+ it from there, as most people have run the BuildTools at least once.
+ This is therefore not needed if you're using the full Spigot/CraftBukkit,
+ or if you're using the Bukkit API.
+ */
+ maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
+ maven { url = 'https://oss.sonatype.org/content/repositories/central' }
+
+ // mavenLocal() // This is needed for CraftBukkit and Spigot.
+ maven {
+ url "https://mvnrepository.com/artifact"
+ }
+
+ // maven { url = "https://hub.spigotmc.org/nexus/content/groups/public" }
+
+
+ // maven { url = "https://maven.enginehub.org/repo/" }
+}
+
+
+
+dependencies {
+// implementation project(':prison-core')
+// implementation project(':prison-mines')
+// implementation project(':prison-ranks')
+// implementation project(':prison-sellall')
+
+
+ // https://mvnrepository.com/artifact/org.jetbrains/annotations
+ implementation 'org.jetbrains:annotations:24.0.1'
+
+
+ compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
+
+
+
+ testImplementation group: 'junit', name: 'junit', version: '4.12'
+
+}
+
+
+
diff --git a/prison-misc/src/main/java/su/nightexpress/coinsengine/api/CoinsEngineAPI.java b/prison-misc/src/main/java/su/nightexpress/coinsengine/api/CoinsEngineAPI.java
new file mode 100644
index 000000000..70bac8065
--- /dev/null
+++ b/prison-misc/src/main/java/su/nightexpress/coinsengine/api/CoinsEngineAPI.java
@@ -0,0 +1,72 @@
+package su.nightexpress.coinsengine.api;
+
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import su.nightexpress.coinsengine.api.currency.Currency;
+
+public class CoinsEngineAPI {
+
+ //public static final CoinsEngine PLUGIN = CoinsEngine.getPlugin(CoinsEngine.class);
+
+ public static double getBalance(@NotNull Player player, @NotNull Currency currency) {
+ return 0d;
+ }
+
+ public static void addBalance(@NotNull Player player, @NotNull Currency currency, double amount) {
+
+ }
+
+ public static void setBalance(@NotNull Player player, @NotNull Currency currency, double amount) {
+
+ }
+
+ public static void removeBalance(@NotNull Player player, @NotNull Currency currency, double amount) {
+
+ }
+
+// @NotNull
+// public static CoinsUser getUserData(@NotNull Player player) {
+// return PLUGIN.getUserManager().getUserData(player);
+// }
+//
+// @Nullable
+// public static CoinsUser getUserData(@NotNull String name) {
+// return PLUGIN.getUserManager().getUserData(name);
+// }
+//
+// @NotNull
+// public static CompletableFuture getUserDataAsync(@NotNull String name) {
+// return PLUGIN.getUserManager().getUserDataAsync(name);
+// }
+//
+// @Nullable
+// public static CoinsUser getUserData(@NotNull UUID uuid) {
+// return PLUGIN.getUserManager().getUserData(uuid);
+// }
+//
+// @NotNull
+// public static CompletableFuture getUserDataAsync(@NotNull UUID uuid) {
+// return PLUGIN.getUserManager().getUserDataAsync(uuid);
+// }
+
+ @Nullable
+ public static Currency getCurrency(@NotNull String id) {
+ return null;
+ }
+
+ public static boolean hasCurrency(@NotNull String id) {
+ return false;
+ }
+
+// @NotNull
+// public static UserManager getUserManager() {
+// return PLUGIN.getUserManager();
+// }
+//
+// @NotNull
+// public static CurrencyManager getCurrencyManager() {
+// return PLUGIN.getCurrencyManager();
+// }
+}
diff --git a/prison-misc/src/main/java/su/nightexpress/coinsengine/api/currency/Currency.java b/prison-misc/src/main/java/su/nightexpress/coinsengine/api/currency/Currency.java
new file mode 100644
index 000000000..0123349c8
--- /dev/null
+++ b/prison-misc/src/main/java/su/nightexpress/coinsengine/api/currency/Currency.java
@@ -0,0 +1,88 @@
+package su.nightexpress.coinsengine.api.currency;
+
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
+
+public interface Currency {
+
+ default boolean isUnlimited() {
+ return true;
+ }
+
+ default boolean isLimited() {
+ return false;
+ }
+
+ default boolean isInteger() {
+ return false;
+ }
+
+ default double fine(double amount) {
+ return 0d;
+ }
+
+ default double limit(double amount) {
+ return 0d;
+ }
+
+ default double fineAndLimit(double amount) {
+ return 0d;
+ }
+
+ @NotNull
+ default String getPermission() {
+ return "";
+ }
+
+ @NotNull
+ default String formatValue(double balance) {
+ return "";
+ }
+
+ @NotNull
+ default String format(double balance) {
+ return "";
+ }
+
+ @NotNull String getId();
+
+ @NotNull String getName();
+
+ //void setName(@NotNull String name);
+
+ @NotNull String getSymbol();
+
+ @NotNull String getFormat();
+
+ //void setSymbol(@NotNull String symbol);
+
+ @NotNull String[] getCommandAliases();
+
+ @NotNull ItemStack getIcon();
+
+ //void setCommandAliases(@NotNull String... aliases);
+
+ boolean isDecimal();
+
+ //void setDecimal(boolean decimal);
+
+ boolean isPermissionRequired();
+
+ //void setPermissionRequired(boolean permissionRequired);
+
+ boolean isTransferAllowed();
+
+ double getMinTransferAmount();
+
+ //void setTransferAllowed(boolean transferAllowed);
+
+ double getStartValue();
+
+ //void setStartValue(double startValue);
+
+ double getMaxValue();
+
+ //void setMaxValue(double maxValue);
+
+ boolean isVaultEconomy();
+}
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java
index c42474100..80527e11c 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/PrisonRanks.java
@@ -28,6 +28,7 @@
import tech.mcprison.prison.integration.IntegrationType;
import tech.mcprison.prison.internal.Player;
import tech.mcprison.prison.localization.LocaleManager;
+import tech.mcprison.prison.modules.ModuleManager;
import tech.mcprison.prison.modules.ModuleStatus;
import tech.mcprison.prison.output.LogLevel;
import tech.mcprison.prison.output.Output;
@@ -55,7 +56,8 @@
public class PrisonRanks
extends PrisonRanksMessages {
- public static final String MODULE_NAME = "Ranks";
+ public static final String MODULE_NAME = ModuleManager.MODULE_NAME_RANKS;
+// public static final String MODULE_NAME = "Ranks";
/*
* Fields & Constants
*/
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java
index 4e166ba48..abd6901ac 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/LadderCommands.java
@@ -1,16 +1,20 @@
package tech.mcprison.prison.ranks.commands;
import tech.mcprison.prison.Prison;
+import tech.mcprison.prison.backups.PrisonBackups;
+import tech.mcprison.prison.backups.PrisonBackups.BackupTypes;
import tech.mcprison.prison.commands.Arg;
import tech.mcprison.prison.commands.Command;
import tech.mcprison.prison.internal.CommandSender;
import tech.mcprison.prison.output.BulletedListComponent;
import tech.mcprison.prison.output.ChatDisplay;
+import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.ranks.PrisonRanks;
import tech.mcprison.prison.ranks.data.PlayerRankRefreshTask;
import tech.mcprison.prison.ranks.data.Rank;
import tech.mcprison.prison.ranks.data.RankLadder;
import tech.mcprison.prison.ranks.managers.LadderManager;
+import tech.mcprison.prison.ranks.managers.RankManager;
/**
* @author Faizaan A. Datoo
@@ -94,7 +98,57 @@ public void ladderRemove(CommandSender sender, @Arg(name = "ladderName") String
@Command(identifier = "ranks ladder list", description = "Lists all rank ladders.",
onlyPlayers = false, permissions = "ranks.ladder")
public void ladderList(CommandSender sender) {
- ChatDisplay display = new ChatDisplay("Ladders");
+
+ ChatDisplay display = getLadderList();
+
+// ChatDisplay display = new ChatDisplay("Ladders");
+//
+// display.addSupportHyperLinkData( "Ladder List" );
+//
+// BulletedListComponent.BulletedListBuilder list =
+// new BulletedListComponent.BulletedListBuilder();
+//
+//// DecimalFormat dFmt = Prison.get().getDecimalFormat( "#,##0.0000" );
+//
+//// String header = String.format(
+//// "&d%-12s %16s %5s %12s %12s",
+//// "Ladder",
+//// "Rank Cost Mult",
+//// "Ranks",
+//// "First Rank",
+//// "Last Rank"
+//// );
+//
+// list.add( PrisonRanks.getInstance().getLadderManager().printRankLadderInfoHeader() );
+//
+// for (RankLadder ladder : PrisonRanks.getInstance().getLadderManager().getLadders()) {
+//
+//// int rankCount = ladder.getRanks() == null ? 0 : ladder.getRanks().size();
+////
+//// Rank firstRank = rankCount == 0 ? null : ladder.getRanks().get(0);
+//// Rank lastRank = rankCount == 0 ? null : ladder.getRanks().get( rankCount - 1 );
+////
+//// String ladderInfo = String.format(
+//// "&7%-12s %16s %4d %-12s %-12s",
+//// ladder.getName(),
+//// dFmt.format( ladder.getRankCostMultiplierPerRank() ),
+//// rankCount,
+//// firstRank.getName(),
+//// lastRank.getName()
+//// );
+//
+// list.add( PrisonRanks.getInstance().getLadderManager().printRankLadderInfoDetail( ladder ) );
+// }
+//
+// display.addComponent(list.build());
+
+ display.send(sender);
+ }
+
+ public ChatDisplay getLadderList() {
+ ChatDisplay display = new ChatDisplay("Ladders");
+
+ display.addSupportHyperLinkData( "Ladder List" );
BulletedListComponent.BulletedListBuilder list =
new BulletedListComponent.BulletedListBuilder();
@@ -132,8 +186,8 @@ public void ladderList(CommandSender sender) {
}
display.addComponent(list.build());
-
- display.send(sender);
+
+ return display;
}
// @Command(identifier = "ranks ladder listranks", description = "Lists the ranks within a ladder.",
@@ -316,12 +370,44 @@ public void ladderRemoveRank(CommandSender sender,
@Command( identifier = "ranks ladder rankCostMultiplier",
- description = "Sets or removes a ladder's Rank Cost Multiplier. Setting the " +
- "value to zero will remove the multiplier from the calculations. The " +
- "Rank Cost Multiplier from all ladders a player has active, will be " +
- "summed together and applied to the cost of all of their ranks. The Rank " +
- "Cost Multiplier represents a percentage, and can be either postive or " +
- "negative. ",
+ description = "Sets a ladder's rank cost multiplier which is used to calculate " +
+ "a rank's cost on ladders that have them enabled. " +
+ "Setting the value to zero will remove that ladder's rank multiplier from " +
+ "the calculations. " +
+ "Rank Cost Multiplier represents a percentage, and can be either postive or " +
+ "negative, and is multiplied by the rank's position (1's based). " +
+ "This means that for ladders have have a rank cost multiplier, the " +
+ "multiplier increases by the rank's position, such that if the prestige " +
+ "ladder has a ranks cost multiplier of 0.1, the P1=0.1, P2=0.2, P3=0.3, etc... {br}" +
+
+ "All rank cost multipliers for the player's rank on that ladder, are " +
+ "combined from all ladders the player is on, " +
+ "then this value is added to a value of 1.0 before being multiplied to the rank cost. " +
+ "This will result in a progressively more expensive rank cost for the " +
+ "player as they advance on multiple ladders. " +
+ "If a ladder has 'applyRankCostMultiplier' disabled, then rank costs on that " +
+ "ladder will not use the player's combined rank cost multiplier. {br}" +
+
+ "This calculates " +
+ "what a player would have to pay when ranking up. " +
+ "It should be understood that a ladder can contribute to the total " +
+ "ranks multiplier, but yet it could ignore the ranks multiplier when " +
+ "calculating the rank costs for that ladder. {br}" +
+
+ "Example of this kind of setup would be to have the " +
+ "default ladder apply the rank cost multiplier to its rank's costs, " +
+ "but yet have the default ladder set it's rank cost multiplier to a value of 0.0. " +
+ "Then have the prestige ladder ignore " +
+ "them, but have the prestige ladder contribute to the global rank " +
+ "cost multipliers. This configuration will result in rank costs increasing " +
+ "for the default ladder's ranks, as the player increases their prestige ranks. " +
+ "But yet the prestiges ladder rank costs will not be impacted " +
+ "by the rank cost multipliers. Using the example above for p1, p2, p3, etc, " +
+ "the rank costs on the default ladder will increase by 10 percent each time " +
+ "the player prestiges. At a 10% increase, the default rank costs will be " +
+ "twice as expensive when the are at P10, compared to when they were at " +
+ "p0 (no prestige rank)."
+ ,
onlyPlayers = false, permissions = "ranks.ladder" )
public void ladderSetRankCostMultiplier( CommandSender sender,
@Arg( name = "ladderName" ) String ladderName,
@@ -379,15 +465,15 @@ public void ladderSetRankCostMultiplier( CommandSender sender,
@Command( identifier = "ranks ladder applyRankCostMultiplier",
- description = "Controls if the rank costs multiplier should apply to the" +
- "ranks on this ladder. If the ladder has a rank cost multipiler " +
- "enabled, this setting will not effect its contribution to other " +
- "the multiplier.",
+ description = "Controls if the rank costs multiplier should apply to the " +
+ "ranks on this ladder. This is an 'ON' or 'OFF' situation for the whole " +
+ "ladder, where the Rank Cost Multiplier will be ignored for a ladder " +
+ "if this is disabled.",
onlyPlayers = false, permissions = "ranks.ladder" )
public void ladderApplyRankCostMultiplier( CommandSender sender,
@Arg( name = "ladderName" ) String ladderName,
@Arg( name = "applyRankCostMultiplier", def = "apply",
- description = "Applies or disables the ranks on this ladder "
+ description = "Applies or disables the ranks on this ladder "
+ "from applying the rank multiplier to the rank cost for players."
)
String applyRankCostMultiplier )
@@ -433,4 +519,118 @@ public void ladderApplyRankCostMultiplier( CommandSender sender,
}
+ @Command( identifier = "ranks ladder resetRankCosts",
+ description = "For a given ladder, this command will reset all rank costs "
+ + "based upon a formula, where each rank is progressivly more "
+ + "expensive. "
+ + "This allow easier adjustments to many ranks at the same time. "
+ + "The ranks within this ladder will not be changed, and they will be "
+ + "processed in the same order in which they are listed with the "
+ + "command: '/ranks list '.",
+ onlyPlayers = false, permissions = "ranks.ladder" )
+ public void ladderResetRankCosts(CommandSender sender,
+ @Arg(name = "ladderName") String ladderName,
+
+ @Arg(name = "initialCost",
+ def = "1000000000", verifiers = "min[1]",
+ description = "The 'initialCost' will set the cost of the first rank on "
+ + "this ladder. All other rank costs will be based upon this "
+ + "value. The default value is 1_000_000_0000."
+ ) double initialCost,
+ @Arg(name = "addMult", def = "1", verifiers = "min[1]",
+ description = "This is an 'additional multiplier' for all ranks on the ladder, "
+ + "with the default value of 1. The cost for each rank is based upon "
+ + "the initial rank cost, times the rank's level. So the default ranks "
+ + "named 'C', or 'p3', since both are the third rank on their ladders, "
+ + "will be 3 times the cost of the first ranks, 'A' or 'p1', with this "
+ + "additional multiplier being multiplied against that value. "
+ + "So for default values for a rankk in the third position, "
+ + "with a 1.75 multipler will have a "
+ + "cost = 1_000_000_000 * 3 * 1.75.") double addMult,
+ @Arg(name = "exponent", def = "1", verifiers = "min[0.00001]",
+ description = "See the cost formula for the 'addMult' parameter. "
+ + "This parameter adds an exponent to the formula. For a linear "
+ + "rank cost, use a value of 1.0 for this parameter. Use a value "
+ + "greater than 1.0, such as 1.2 for slightly more agressive cost "
+ + "calculation. Since cost is a IEEE double, there is a risk of "
+ + "lost precision with numbers greater than 16 digits. "
+ + "cost = (initialCost * rankPosition * addMult)^exponent.")
+ double exponent ) {
+
+
+ LadderManager lm = PrisonRanks.getInstance().getLadderManager();
+ RankManager rm = PrisonRanks.getInstance().getRankManager();
+
+ RankLadder ladder = lm.getLadder(ladderName);
+
+ if ( ladder == null ) {
+ ladderDoesNotExistsMsg( sender, ladderName );
+ return;
+ }
+
+
+ if ( exponent <= 0 ) {
+ sender.sendMessage("Error: ranks ladder resetRankCosts: Exponent parameter must be greater than zero.");
+ return;
+ }
+
+ // Force a backup:
+ PrisonBackups prisonBackup = new PrisonBackups();
+
+ String backupComment = String.format(
+ "Resetting all rank costs on ladder %s.",
+ ladder.getName() );
+ String message = prisonBackup.startBackup( BackupTypes.auto, backupComment );
+
+ sender.sendMessage( message );
+ sender.sendMessage( "Forced a Backup of prison configs prior to changing rank costs." );
+
+
+ int ranksChanged = 0;
+
+ int i = 1;
+ for (Rank rank : ladder.getRanks() ) {
+
+ double cost = Math.pow(initialCost * i++ * addMult, exponent );
+
+ if ( rank.getRawRankCost() != cost ) {
+ rank.setRawRankCost( cost );
+
+ rm.saveRank( rank );
+
+ ranksChanged++;
+ }
+
+ }
+
+ if ( ranksChanged > 0 ) {
+ // Reload the placeholders:
+ Prison.get().getPlatform().getPlaceholders().reloadPlaceholders();
+
+ String msg = String.format(
+ "Done resetting all rank costs on the '%s' ladder. "
+ + "There were %d ranks that had cost changes.",
+ ladder.getName(),
+ ranksChanged );
+
+ Output.get().logInfo( msg );
+ }
+
+// for ( int i = 0; i < prestigeRanks; i++ ) {
+// String name = "P" + (i + 1);
+// String tag = "&5[&d+" + (i > 0 ? i + 1 : "" ) + "&5]";
+// double cost = prestigeCost * (i + 1) * prestigeMult;
+//
+// // Only add prestige ranks if they do not already exist:
+// if ( PrisonRanks.getInstance().getRankManager().getRank( name ) == null ) {
+//
+// createRank(sender, name, cost, LadderManager.LADDER_PRESTIGES, tag, "noPlaceholderUpdate");
+// prestigesCount++;
+// }
+// }
+
+
+ }
+
+
}
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java
index 71abf642c..6ca277370 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RankUpCommand.java
@@ -455,7 +455,19 @@ private boolean rankUpPrivate(CommandSender sender, String playerName, String la
RankPlayer rankPlayer = getRankPlayer( sender, player.getUUID(), player.getName() );
+
+
+ PlayerRank rankCurrent = rankPlayer.getPlayerRank(ladder);
+
+
+ // If the player has a rank on the target ladder, mmake sure the next rank is not null
+ if ( rankCurrent != null && rankCurrent.getRank().getRankNext() == null ) {
+ rankupAtLastRankMsg(sender);
+ return false;
+ }
+ // If at last rank on ladder, then cannot /rankup
+// if ( rankPlayer.getran)
// Get the player's next rank on default ladder, or if at end then it will return the next
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java
index 47b28ea24..3dcb370cd 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/commands/RanksCommands.java
@@ -216,20 +216,46 @@ public boolean createRank(CommandSender sender,
}
- @Command(identifier = "ranks autoConfigure", description = "Auto configures Ranks and Mines using " +
+ @Command(identifier = "ranks autoConfigure",
+ description = "Auto configures Ranks, Mines, and Prestiges using " +
"single letters A through Z for both the rank and mine names. Both ranks and mines are " +
- "generated, they will also be linked together automatically. To set the starting price use " +
- "price=x. To set multiplier mult=x. AutoConfigure will try to merge any preexsiting ranks " +
- "and mines, but you must use the 'force' keyword in 'options'. Force will replace all blocks " +
- "in preexisting " +
- "mines. To keep preexisting blocks, use 'forceKeepBlocks' with the 'force' option. " +
- "Default values [full price=50000 mult=1.5]",
+ "generated, they will also be linked together automatically. Prestige ranks will "
+ + "also be auto generated with a default of 25 that will be created. {br}"
+ + "To set the starting price use " +
+ "'price=x'. To set multiplier 'mult=x'. {br}"
+ + "AutoConfigure will try to merge any preexsiting ranks " +
+ "and mines, but you must use the 'force' keyword in 'options' and force will " +
+ "replace all blocks in preexisting " +
+ "mines. To keep preexisting blocks, use 'forceKeepBlocks' with the 'force' option. {br}" +
+
+ "The option 'full' will enable ranks, mines, and prestiges. No options will default to 'full'. " +
+ "The options 'ranks', 'mines', and 'prestiges' will enable each of these if they are listed. " +
+ "So using just 'mines' will only generate mines and no ranks or prestiges." +
+
+ "The option 'prestiges=x' will set how many initial prestige ranks to create. " +
+ "The option `prestigeCost=x` sets the initial cost for P1; default value is 1_000_000_000. " +
+ "The option 'prestigeMult=x' is an additional multiplier for presetige ranks, with the " +
+ "default value of 1. The cost for each prestige rank is based upon the initial " +
+ "presetigeCost, times the prestige level so p3 will be 3 times the cost of p1 with the " +
+ "prestige multiplier will multiplied against that value. So for default values " +
+ " with a 1.75 multiplier p3 cost = 1_000_000_000 * 3 * 1.75. " +
+ "Default values [full price=50000 mult=1.5 prestiges=25 presetigeCost=1000000000 " +
+ "prestigeMult=1] {br}" +
+
+ "Example of just adding more prestige ranks using the other default values: " +
+ "'/ranks autoConfigure force prestiges presetiges=1000', no ranks and no mines will " +
+ "be created. " +
+ "Warning: If trying to rerun autoConfigure with existing mines or ranks, then do a " +
+ "prison backup with this command: '/prison support backup save adding more prestiges'",
onlyPlayers = false, permissions = "ranks.set",
aliases = {"prison autoConfigure"} )
public void autoConfigureRanks(CommandSender sender,
@Wildcard(join=true)
@Arg(name = "options",
- description = "Options: [full ranks mines price=x mult=x force forceKeepBlocks dontForceLinerWalls dontForceLinerBottoms]",
+ description = "Options: [full ranks mines prestiges price=x mult=x "
+ + "prestiges=x prestigeCost=x prestigeMult=x "
+ + "force forceKeepBlocks "
+ + "dontForceLinerWalls dontForceLinerBottoms]",
def = "full") String options
) {
@@ -240,6 +266,9 @@ public void autoConfigureRanks(CommandSender sender,
boolean forceLinersWalls = true;
boolean forceLinersBottom = true;
boolean forceKeepBlocks = false;
+ int prestigeRanks = 25;
+ long prestigeCost = 1_000_000_000;
+ double prestigeMult = 10d;
if ( options.contains( "forcekeepblocks" ) ) {
@@ -274,9 +303,13 @@ public void autoConfigureRanks(CommandSender sender,
autoConfigForceWarningMsg( sender );
}
- String optionHelp = "&b[&7full ranks mines price=&dx &7mult=&dx &7force forceKeepBlocks dontForceLinerWalls dontForceLinerBottoms&b]";
+ String optionHelp = "&b[&7full ranks mines prestiges price=&dx &7mult=&dx "
+ + "&7prestiges=&dx &7prestigeCost=&dx &7prestigeMult=&dx "
+ + "&7force forceKeepBlocks dontForceLinerWalls dontForceLinerBottoms&b]";
boolean ranks = false;
boolean mines = false;
+ boolean prestiges = false;
+
double startingPrice = 50000;
double percentMultipler = 1.5;
@@ -292,6 +325,7 @@ public void autoConfigureRanks(CommandSender sender,
if ( options.contains( "full" ) ) {
ranks = true;
mines = true;
+ prestiges = true;
options = options.replace( "full", "" ).trim();
}
if ( options.contains( "ranks" ) ) {
@@ -302,6 +336,7 @@ public void autoConfigureRanks(CommandSender sender,
mines = true;
options = options.replace( "mines", "" ).trim();
}
+
String priceStr = extractParameter("price=", options);
if ( priceStr != null ) {
@@ -317,6 +352,20 @@ public void autoConfigureRanks(CommandSender sender,
}
+ String prestigeMultStr = extractParameter("prestigeMult=", options);
+ if ( prestigeMultStr != null ) {
+ options = options.replace( prestigeMultStr, "" );
+ prestigeMultStr = prestigeMultStr.replace( "prestigeMult=", "" ).trim();
+
+ try {
+ prestigeMult = Double.parseDouble( prestigeMultStr );
+ }
+ catch ( NumberFormatException e ) {
+ // Not a valid double number, or price:
+ }
+ }
+
+
String multStr = extractParameter("mult=", options);
if ( multStr != null ) {
options = options.replace( multStr, "" );
@@ -329,6 +378,41 @@ public void autoConfigureRanks(CommandSender sender,
// Not a valid double number, or price:
}
}
+
+ String prestigesStr = extractParameter("prestiges=", options);
+ if ( prestigesStr != null ) {
+ options = options.replace( prestigesStr, "" );
+ prestigesStr = prestigesStr.replace( "prestiges=", "" ).trim();
+
+ try {
+ prestigeRanks = Integer.parseInt( prestigesStr );
+ }
+ catch ( NumberFormatException e ) {
+ // Not a valid double number, or price:
+ }
+ }
+
+ String prestigeCostStr = extractParameter("prestigeCost=", options);
+ if ( prestigeCostStr != null ) {
+ options = options.replace( prestigeCostStr, "" );
+ prestigeCostStr = prestigeCostStr.replace( "prestigeCost=", "" ).trim();
+
+ try {
+ prestigeCost = Long.parseLong( prestigeCostStr );
+ }
+ catch ( NumberFormatException e ) {
+ // Not a valid double number, or price:
+ }
+ }
+
+
+ // This has to be checked after prestiges= or this will destroy that config setting:
+ if ( options.contains( "prestiges" ) ) {
+ prestiges = true;
+ options = options.replace( "prestiges", "" ).trim();
+ }
+
+
// What's left over, if not just a blank string, must be an error:
@@ -491,13 +575,22 @@ public void autoConfigureRanks(CommandSender sender,
int prestigesCount = 0;
// add in 10 prestiges at 1 billion each:
- double prestigeCost = 1000000000;
+// double prestigeCost = 1_000_000_000;
- for ( int i = 0; i < 10; i++ ) {
- String name = "P" + (i + 1);
- String tag = "&5[&d+" + (i > 0 ? i + 1 : "" ) + "&5]";
- createRank(sender, name, (prestigeCost * (i + 1) ), LadderManager.LADDER_PRESTIGES, tag, "noPlaceholderUpdate");
- prestigesCount++;
+ if ( prestiges ) {
+
+ for ( int i = 0; i < prestigeRanks; i++ ) {
+ String name = "P" + (i + 1);
+ String tag = "&5[&d+" + (i > 0 ? i + 1 : "" ) + "&5]";
+ double cost = prestigeCost * (i + 1) * prestigeMult;
+
+ // Only add prestige ranks if they do not already exist:
+ if ( PrisonRanks.getInstance().getRankManager().getRank( name ) == null ) {
+
+ createRank(sender, name, cost, LadderManager.LADDER_PRESTIGES, tag, "noPlaceholderUpdate");
+ prestigesCount++;
+ }
+ }
}
// If mines were created, go ahead and auto assign blocks to the mines:
@@ -517,9 +610,9 @@ public void autoConfigureRanks(CommandSender sender,
// Set the prestiges ladder with a 10% base rank cost multiplier
double rankCostMultiplier = 0.10;
- RankLadder prestiges = PrisonRanks.getInstance().getLadderManager().getLadder( LadderManager.LADDER_PRESTIGES );
- prestiges.setRankCostMultiplierPerRank( rankCostMultiplier );
- PrisonRanks.getInstance().getLadderManager().save( prestiges );
+ RankLadder prestigesLadder = PrisonRanks.getInstance().getLadderManager().getLadderPrestiges();
+ prestigesLadder.setRankCostMultiplierPerRank( rankCostMultiplier );
+ PrisonRanks.getInstance().getLadderManager().save( prestigesLadder );
// Log that the rank cost multiplier has been applied to the ladder
// with information on how to change it.
@@ -544,6 +637,8 @@ public void autoConfigureRanks(CommandSender sender,
// Reloads autoFeatures and blockConverters:
AutoFeaturesWrapper.getInstance().reloadConfigs();
+ AutoFeaturesWrapper.getBlockConvertersInstance().reloadConfig();
+
// Reset all player to the first rank on the default ladder:
PrisonRanks.getInstance().checkAllPlayersForJoin();
@@ -587,6 +682,9 @@ public void autoConfigureRanks(CommandSender sender,
}
private String extractParameter( String key, String options ) {
+ return extractParameter( key, options, true );
+ }
+ private String extractParameter( String key, String options, boolean tryLowerCase ) {
String results = null;
int idx = options.indexOf( key );
if ( idx != -1 ) {
@@ -596,6 +694,10 @@ private String extractParameter( String key, String options ) {
}
results = options.substring( idx, idxEnd );
}
+ else if ( tryLowerCase ) {
+ // try again, but lowercase the key
+ results = extractParameter( key.toLowerCase(), options, false );
+ }
return results;
}
@@ -676,6 +778,8 @@ public void listRanks(CommandSender sender,
else {
display = new ChatDisplay( "List ALL Ranks" );
+ display.addSupportHyperLinkData( "Rank List" );
+
listAllRanksByLadders( display, hasPerm, rPlayer );
}
@@ -836,6 +940,8 @@ private ChatDisplay listRanksOnLadder( RankLadder ladder, boolean hasPerm, RankP
String rankHeader = ranksListHeaderMsg( ladder.getName() );
ChatDisplay display = new ChatDisplay( rankHeader );
+ display.addSupportHyperLinkData( "Ladder List %s", ladder.getName() );
+
display.addText( " " + PrisonRanks.getInstance().getLadderManager().printRankLadderInfoHeader() );
display.addText( " " + PrisonRanks.getInstance().getLadderManager().printRankLadderInfoDetail(ladder) );
@@ -859,23 +965,35 @@ private ChatDisplay listRanksOnLadder( RankLadder ladder, boolean hasPerm, RankP
new BulletedListComponent.BulletedListBuilder();
DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.0000");
+ DecimalFormat iFmt = Prison.get().getDecimalFormat("#,##0");
// Here's the deal... With color codes, Java's String.format() cannot detect the correct
// length of a tag. So go through all tags, strip the colors, and see how long they are.
// We need to know the max length so we can pad the others with periods to align all costs.
int maxRankNameSize = 0;
int maxRankTagNoColorSize = 0;
+ int maxRankCostSize = 0;
+
for (Rank rank : ladder.getRanks()) {
- if ( rank.getName().length() > maxRankNameSize ) {
- maxRankNameSize = rank.getName().length();
+ String nameNoColor = Text.stripColor( rank.getName() );
+ if ( nameNoColor.length() > maxRankNameSize ) {
+ maxRankNameSize = nameNoColor.length();
}
String tag = rank.getTag() == null ? "" : rank.getTag();
String tagNoColor = Text.stripColor( tag );
if ( tagNoColor.length() > maxRankTagNoColorSize ) {
maxRankTagNoColorSize = tagNoColor.length();
}
+
+ int costSize = iFmt.format( rank.getRawRankCost() ).length();
+ if ( costSize > maxRankCostSize ) {
+ maxRankCostSize = costSize;
+ }
}
+ maxRankCostSize++;
+ String nameStringFormat = "%-" + maxRankNameSize + "s ";
+ String tagStringFormat = "%-" + maxRankTagNoColorSize + "s ";
RankPlayerFactory rankPlayerFactory = new RankPlayerFactory();
@@ -885,12 +1003,24 @@ private ChatDisplay listRanksOnLadder( RankLadder ladder, boolean hasPerm, RankP
boolean defaultRank = (LadderManager.LADDER_DEFAULT.equalsIgnoreCase( ladder.getName() ) && first);
+ String nameNoColor = Text.stripColor( rank.getName() );
+ String tag = rank.getTag() == null ? "" : rank.getTag();
+ String tagNoColor = Text.stripColor( tag );
+// String rankCost = iFmt.format( rank.getRawRankCost() );
+
+ String nameFormatted = String.format( nameStringFormat, nameNoColor );
+ nameFormatted = nameFormatted.replace( nameNoColor, rank.getName() );
+
+ String tagFormatted = String.format( tagStringFormat, tagNoColor );
+ tagFormatted = tagFormatted.replace( tagNoColor, tag );
+
+
// Since the formatting gets confused with color formatting, we must
// strip the color codes and then inject them back in. So instead, this
// provides the formatting rules for both name and rank tag, thus
// taking in to consideration the color codes and if the hasPerms is
// true. To prevent variable space issues, the difference is filled in with periods.
- String textRankNameString = padRankName( rank, maxRankNameSize, maxRankTagNoColorSize, hasPerm );
+// String textRankNameString = padRankName( rank, maxRankNameSize, maxRankTagNoColorSize, hasPerm );
// // trick it to deal correctly with tags. Tags can have many colors, but
// // it will render as if it had the colors stripped. So first generate the
@@ -945,26 +1075,43 @@ private ChatDisplay listRanksOnLadder( RankLadder ladder, boolean hasPerm, RankP
String players = rank.getPlayers().size() == 0 ? "" :
" &dPlayers: &3" + rank.getPlayers().size();
- String rawRankId = ( hasPerm ?
- String.format( "(rankId: %s%s%s)",
- Integer.toString( rank.getId() ),
- (rank.getRankPrior() == null ? "" : " -"),
- (rank.getRankNext() == null ? "" : " +") )
- : "");
+// String rawRankId = ( hasPerm ?
+// String.format( "(rankId: %s%s%s)",
+// Integer.toString( rank.getId() ),
+// (rank.getRankPrior() == null ? "" : " -"),
+// (rank.getRankNext() == null ? "" : " +") )
+// : "");
+
+
+ StringBuilder minesSb = new StringBuilder();
+ for ( ModuleElement mine : rank.getMines() ) {
+ if ( minesSb.length() > 0 ) {
+ minesSb.append( "&6,&7" );
+ }
+ minesSb.append( mine.getTag() );
+ }
+ if ( minesSb.length() > 0 ) {
+ minesSb.insert( 0, " &6Mines: &7" );
+// minesSb.append( "8" );
+ }
String text =
- String.format("&3%s &7%-17s%s&7 &b%s &3%s %s&7 %s%s",
- textRankNameString,
- Text.numberToDollars( rankCost ),
+ String.format("&3%s %s &7%" + maxRankCostSize + "s &a%s &b%s %s&7 %s%s%s",
+ nameFormatted,
+ tagFormatted,
+
+ iFmt.format( rankCost ),
+// Text.numberToDollars( rankCost ),
(defaultRank ? "{def}" : ""),
rankMultiplier,
- rawRankId,
+// rawRankId,
textCurrency,
textCmdCount,
- players
+ players,
+ minesSb.toString()
);
// // Swap the color tag back in:
@@ -972,7 +1119,7 @@ private ChatDisplay listRanksOnLadder( RankLadder ladder, boolean hasPerm, RankP
if ( defaultRank ) {
// Swap out the default placeholder for the actual content:
- text = text.replace( "{def}", "&c(&9Default&c)" );
+ text = text.replace( "{def}", "&c(&r&9Default&r&c)" );
}
String rankName = rank.getName();
@@ -1161,6 +1308,9 @@ private ChatDisplay rankInfoDetails( CommandSender sender, Rank rank, String opt
ChatDisplay display = new ChatDisplay( ranksInfoHeaderMsg( title ));
+ display.addSupportHyperLinkData( "Rank %s", rank.getName() );
+
+
boolean isOp = sender != null && sender.isOp();
boolean isConsole = sender == null || !sender.isPlayer();
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java
index be8763fd6..de0a28878 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java
@@ -12,6 +12,7 @@
import tech.mcprison.prison.file.FileIOData;
import tech.mcprison.prison.file.JsonFileIO;
import tech.mcprison.prison.internal.Player;
+import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.ranks.PrisonRanks;
import tech.mcprison.prison.ranks.tasks.TopNPlayerUpdateAsyncTask;
@@ -130,7 +131,11 @@ public File getSaveFile() {
*/
private void launchTopNPlayerUpdateAsyncTask() {
- if ( PrisonRanks.getInstance().getPlayerManager() != null ) {
+ if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getPlayerManager() != null &&
+ PrisonRanks.getInstance().getDefaultLadder().getRanks().size() > 0
+ ) {
Long delayTicks = Prison.get().getPlatform().getConfigLong(
"topNPlayers.refresh.delay-ticks", DELAY_THIRTY_SECONDS_TICKS );
@@ -140,6 +145,15 @@ private void launchTopNPlayerUpdateAsyncTask() {
TopNPlayerUpdateAsyncTask.submitTaskTimerAsync( this, delayTicks, intervalTicks );
}
+ else if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getDefaultLadder().getRanks().size() == 0 ) {
+
+ Output.get().logWarn( "TopNPlayer: Cannot start the TopNPlayer task. Ranks are "
+ + "enabled, but there are no default ranks setup. "
+ + "Either turn off the Ranks Module, or add ranks and "
+ + "then restart the server to get the TopNPlayer task running.");
+ }
}
@@ -169,7 +183,9 @@ private void launchTopNPlayerUpdateAsyncTask() {
public void loadSaveFile() {
// If Ranks module is not loaded, then do not try to load any save file:
- if ( PrisonRanks.getInstance().getPlayerManager() == null ) {
+ if ( PrisonRanks.getInstance() == null ||
+ !PrisonRanks.getInstance().isEnabled() ||
+ PrisonRanks.getInstance().getPlayerManager() == null ) {
// Ranks is not loaded, so reset to empties:
setTopNList( new ArrayList<>() );
@@ -242,7 +258,9 @@ public void loadSaveFile() {
*/
public void forceReloadAllPlayers() {
- if ( PrisonRanks.getInstance().getPlayerManager() != null ) {
+ if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getPlayerManager() != null ) {
long start = System.nanoTime();
@@ -380,7 +398,9 @@ private void addPlayerData( TopNPlayersData topN, PlayerState activePlayerState
public void refreshAndSort() {
- if ( PrisonRanks.getInstance().getPlayerManager() == null ) {
+ if ( PrisonRanks.getInstance() == null ||
+ !PrisonRanks.getInstance().isEnabled() ||
+ PrisonRanks.getInstance().getPlayerManager() == null ) {
return;
}
@@ -491,7 +511,9 @@ public void refreshAndSort() {
private void calculateAllRankScores( ArrayList topNList ) {
- if ( PrisonRanks.getInstance().getPlayerManager() != null ) {
+ if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getPlayerManager() != null ) {
for ( TopNPlayersData topN : topNList ) {
@@ -590,7 +612,9 @@ else if ( getArchivedMap().containsKey( key ) ) {
*/
public void updatePlayerData( RankPlayer rPlayer ) {
- if ( PrisonRanks.getInstance().getPlayerManager() != null ) {
+ if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getPlayerManager() != null ) {
addPlayerData( rPlayer);
@@ -662,7 +686,9 @@ public RankPlayer getTopNRankArchivedPlayer( int rankPosition ) {
private RankPlayer getTopNRankPlayer( int rankPosition, boolean archived ) {
RankPlayer rPlayer = null;
- if ( PrisonRanks.getInstance().getPlayerManager() != null ) {
+ if ( PrisonRanks.getInstance() != null &&
+ PrisonRanks.getInstance().isEnabled() &&
+ PrisonRanks.getInstance().getPlayerManager() != null ) {
ArrayList tList =
archived ?
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/LadderManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/LadderManager.java
index b2613746c..f9bd31eac 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/LadderManager.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/LadderManager.java
@@ -134,9 +134,13 @@ public void saveLadder(RankLadder ladder, String fileKey) throws IOException {
* @throws IOException If the ladder could not be serialized, or if the ladder could not be saved to the file.
*/
private void saveLadder(RankLadder ladder) throws IOException {
- this.saveLadder(ladder, "ladder_" + ladder.getId());
+ this.saveLadder(ladder, getLadderName(ladder));
}
+ private String getLadderName( RankLadder ladder ) {
+ return "ladder_" + ladder.getId();
+ }
+
/**
* This is the save function that should be used from outside of the LadderManager, such as
* within the LadderCommands functions because this will be able to handle the possible
@@ -369,5 +373,17 @@ public String printRankLadderInfoDetail( RankLadder ladder ) {
return ladderInfo;
}
+
+ public String getLadderByFileName(String fileName) {
+ String results = "";
+
+ for (RankLadder rankLadder : loadedLadders) {
+ String ladderFileName = getLadderName(rankLadder) + ".json";
+ if ( ladderFileName.equalsIgnoreCase(fileName) ) {
+ results = rankLadder.getName();
+ }
+ }
+ return results;
+ }
}
diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankManager.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankManager.java
index f56f41209..c4d6d20d8 100644
--- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankManager.java
+++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/managers/RankManager.java
@@ -37,6 +37,7 @@
import tech.mcprison.prison.placeholders.PlaceholderAttributeBar;
import tech.mcprison.prison.placeholders.PlaceholderAttributeNumberFormat;
import tech.mcprison.prison.placeholders.PlaceholderAttributeText;
+import tech.mcprison.prison.placeholders.PlaceholderAttributeTime;
import tech.mcprison.prison.placeholders.PlaceholderIdentifier;
import tech.mcprison.prison.placeholders.PlaceholderManager;
import tech.mcprison.prison.placeholders.PlaceholderManager.PlaceholderFlags;
@@ -718,6 +719,7 @@ public String getTranslateRanksPlaceHolder( PlaceholderIdentifier identifier ) {
PlaceholderAttributeBar attributeBar = identifier.getAttributeBar();
PlaceholderAttributeNumberFormat attributeNFormat = identifier.getAttributeNFormat();
PlaceholderAttributeText attributeText = identifier.getAttributeText();
+ PlaceholderAttributeTime attributeTime = identifier.getAttributeTime();
int sequence = identifier.getSequence();
@@ -1570,6 +1572,19 @@ public void reloadPlaceholders() {
getTranslatedPlaceHolderKeys();
}
+
+
+ public String getRankByFileName(String fileName) {
+ String results = "";
+
+ for (Rank rank : loadedRanks) {
+ String rankFileName = rank.filename() + ".json";
+ if ( rankFileName.equalsIgnoreCase(fileName) ) {
+ results = rank.getName();
+ }
+ }
+ return results;
+ }
private List getLoadedRanks() {
return loadedRanks;
diff --git a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java
index 479589162..0c254e71f 100644
--- a/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java
+++ b/prison-sellall/src/main/java/tech/mcprison/prison/sellall/messages/SpigotVariousGuiMessages.java
@@ -53,7 +53,7 @@ protected String prisonSellallTest03Msg() {
}
- protected String sellallAmountEarnedMsg( String earningsAmount ) {
+ public String sellallAmountEarnedMsg( String earningsAmount ) {
return PrisonSellall.getInstance().getSellallMessages()
.getLocalizable( "sellall_spigot_utils__money_earned" )
diff --git a/prison-spigot/build.gradle b/prison-spigot/build.gradle
index 3ab4ae5fe..1e33b8b42 100644
--- a/prison-spigot/build.gradle
+++ b/prison-spigot/build.gradle
@@ -94,6 +94,8 @@ dependencies {
implementation project(':prison-ranks')
implementation project(':prison-sellall')
+ // implementation project(':prison-worldguard6')
+
// https://mvnrepository.com/artifact/org.bstats/bstats-base
// https://mvnrepository.com/artifact/org.bstats/bstats-bukkit
@@ -112,6 +114,28 @@ dependencies {
implementation 'org.apache.commons:commons-lang3:3.12.0'
+
+/*
+ // https://mvnrepository.com/artifact/com.sk89q.worldedit/worldedit-core
+ implementation 'com.sk89q.worldedit:worldedit-core:7.2.15'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldedit/worldedit-bukkit
+ compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.15'
+
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard/worldguard-core
+ compileOnly 'com.sk89q.worldguard:worldguard-core:7.0.8'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard/worldguard-bukkit
+ compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.8'
+
+ // https://mvnrepository.com/artifact/com.sk89q.worldguard.worldguard-libs/core
+ implementation 'com.sk89q.worldguard.worldguard-libs:core:7.0.8'
+*/
+
+
+
+
compileOnly 'me.clip:placeholderapi:2.11.2'
//compileOnly 'me.clip:placeholderapi:2.10.9'
@@ -168,7 +192,7 @@ dependencies {
// https://github.com/tr7zw/Item-NBT-API/wiki/Using-Gradle
// https://www.spigotmc.org/resources/nbt-api.7939/
// https://mvnrepository.com/artifact/de.tr7zw/item-nbt-api-plugin
- implementation 'de.tr7zw:item-nbt-api:2.11.3'
+ implementation 'de.tr7zw:item-nbt-api:2.12.0'
// implementation 'de.tr7zw:item-nbt-api-plugin:2.11.2'
// implementation 'de.tr7zw:item-nbt-api-plugin:2.10.0'
// implementation 'de.tr7zw:item-nbt-api-plugin:2.9.2'
diff --git a/prison-spigot/lib/CoinsEngine pseudo API not-real.jar b/prison-spigot/lib/CoinsEngine pseudo API not-real.jar
new file mode 100644
index 000000000..31eebc6c2
Binary files /dev/null and b/prison-spigot/lib/CoinsEngine pseudo API not-real.jar differ
diff --git a/prison-spigot/lib/XPrison-api-1.12.13-RELEASE.jar b/prison-spigot/lib/XPrison-api-1.12.13-RELEASE.jar
new file mode 100644
index 000000000..6ae3be4da
Binary files /dev/null and b/prison-spigot/lib/XPrison-api-1.12.13-RELEASE.jar differ
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
index c560ec3a9..3bfc67237 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPlatform.java
@@ -42,6 +42,7 @@
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.SimpleCommandMap;
+import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
@@ -97,6 +98,7 @@
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.output.RowComponent;
import tech.mcprison.prison.ranks.PrisonRanks;
+import tech.mcprison.prison.ranks.commands.LadderCommands;
import tech.mcprison.prison.ranks.commands.RanksCommands;
import tech.mcprison.prison.ranks.data.PlayerRank;
import tech.mcprison.prison.ranks.data.Rank;
@@ -113,6 +115,9 @@
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerRevEnchantsExplosiveEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerRevEnchantsJackHammerEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerTokenEnchant;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonExplosionTriggerEvent;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonLayerTriggerEvent;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonNukeTriggerEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerZenchantments;
import tech.mcprison.prison.spigot.backpacks.BackpacksUtil;
import tech.mcprison.prison.spigot.block.BlockBreakPriority;
@@ -407,11 +412,13 @@ else if ( oPlayer == null || oPlayer.getName() == null ) {
return plugin.getDescription().getVersion();
}
- @Override public File getPluginDirectory() {
+ @Override
+ public File getPluginDirectory() {
return plugin.getDataFolder();
}
- @Override public void registerCommand(PluginCommand command) {
+ @Override
+ public void registerCommand(PluginCommand command) {
try {
Command cmd = new Command(
command.getLabel(),
@@ -555,15 +562,18 @@ public PluginCommand findCommand( String label ) {
return results;
}
- @Override public List getCommands() {
+ @Override
+ public List getCommands() {
return commands;
}
- @Override public void dispatchCommand(String cmd) {
+ @Override
+ public void dispatchCommand(String cmd) {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
}
- @Override public void dispatchCommand(tech.mcprison.prison.internal.CommandSender sender, String cmd) {
+ @Override
+ public void dispatchCommand(tech.mcprison.prison.internal.CommandSender sender, String cmd) {
if ( sender instanceof SpigotCommandSender ) {
SpigotCommandSender cmdSender = (SpigotCommandSender) sender;
@@ -580,7 +590,8 @@ public PluginCommand findCommand( String label ) {
}
- @Override public Scheduler getScheduler() {
+ @Override
+ public Scheduler getScheduler() {
return plugin.scheduler;
}
@@ -927,9 +938,11 @@ public String getConfigString( String key, String defaultValue ) {
}
+ @SuppressWarnings("unchecked")
@Override
- public List> getConfigStringArray( String key ) {
- return SpigotPrison.getInstance().getConfig().getList( key, new ArrayList() );
+ public List getConfigStringArray( String key ) {
+ return (List) SpigotPrison.getInstance().getConfig()
+ .getList( key, new ArrayList() );
}
@@ -1062,6 +1075,26 @@ public double getConfigDouble( String key, double defaultValue ) {
return results;
}
+ /**
+ * Given the path to a hash, this will return all of the keys within
+ * the hash at the root level. It will not traverse deeper.
+ * The list of keys can then be used to access all of the values.
+ *
+ *
+ */
+ @Override
+ public List getConfigHashKeys( String hashPrefix ) {
+ List keys = new ArrayList<>();
+
+ ConfigurationSection configSection =
+ SpigotPrison.getInstance().getConfig().getConfigurationSection( hashPrefix );
+
+ if ( configSection != null ) {
+ keys.addAll( configSection.getKeys(false) );
+ }
+
+ return keys;
+ }
@Override
public boolean isWorldExcluded( String worldName ) {
@@ -1990,6 +2023,20 @@ public List buildBlockListXMaterial() {
blockList.add( new SellAllBlockData( XMaterial.SUGAR, 13 ) );
blockList.add( new SellAllBlockData( XMaterial.PAPER, 13 ) );
+
+ blockList.add( new SellAllBlockData( XMaterial.SOUL_SAND, 25 ) );
+ blockList.add( new SellAllBlockData( XMaterial.BROWN_MUSHROOM, 5 ) );
+ blockList.add( new SellAllBlockData( XMaterial.BROWN_MUSHROOM_BLOCK, 5 ) );
+ blockList.add( new SellAllBlockData( XMaterial.RED_MUSHROOM, 5 ) );
+ blockList.add( new SellAllBlockData( XMaterial.RED_MUSHROOM_BLOCK, 5 ) );
+ blockList.add( new SellAllBlockData( XMaterial.SLIME_BALL, 7 ) );
+ blockList.add( new SellAllBlockData( XMaterial.SLIME_BLOCK, 63 ) );
+ blockList.add( new SellAllBlockData( XMaterial.PACKED_ICE, 7 ) );
+
+ blockList.add( new SellAllBlockData( XMaterial.BRICK, 4 ) );
+ blockList.add( new SellAllBlockData( XMaterial.BRICKS, 16 ) ); // 1 bricks = 4 brick
+
+
return blockList;
}
@@ -2085,6 +2132,9 @@ public List getActiveFeatures( boolean showLaddersAndRanks ) {
results.add( " " );
}
+ else {
+ results.add( "&7Ranks: &9Not Enabled." );
+ }
}
@@ -2118,16 +2168,30 @@ public List getActiveFeatures( boolean showLaddersAndRanks ) {
results.add( mineDetails );
}
+ else {
+ results.add( "&7Mines: &9Not Enabled." );
+ }
// Load the autoFeaturesConfig.yml and blockConvertersConfig.json files:
AutoFeaturesWrapper afw = AutoFeaturesWrapper.getInstance();
- afw.reloadConfigs();
+// afw.reloadConfigs();
+
+// AutoFeaturesWrapper.getBlockConvertersInstance();
+
+
+
boolean isAutoManagerEnabled = afw.isBoolean( AutoFeatures.isAutoManagerEnabled );
- results.add( String.format("AutoManager Enabled:&b %s", isAutoManagerEnabled) );
+
+ String autoMangerHeader = "&7AutoManager: " +
+ ( isAutoManagerEnabled ?
+ "&9Enabled" :
+ "&9Not Enabled" );
+
+ results.add( autoMangerHeader );
if ( isAutoManagerEnabled ) {
@@ -2148,78 +2212,98 @@ public List getActiveFeatures( boolean showLaddersAndRanks ) {
Boolean.toString( bbeCabebd ) ) );
+
+ results.add( formatAFEvent( "'&7org.bukkit.BlockBreakEvent&3'", AutoFeatures.blockBreakEventPriority ) );
+ results.add( formatAFEvent( "Prison's own '&7ExplosiveBlockBreakEvent&3'", AutoFeatures.ProcessPrisons_ExplosiveBlockBreakEventsPriority ) );
+ results.add( formatAFEvent( "Pulsi_'s PrisonEnchants '&7PEExplosiveEvent&3'", AutoFeatures.PrisonEnchantsExplosiveEventPriority ) );
+ results.add( formatAFEvent( "TokenEnchant '&7BlockExplodeEvent&3'", AutoFeatures.TokenEnchantBlockExplodeEventPriority ) );
+
+ results.add( formatAFEvent( "CrazyEnchant '&7BlastUseEvent&3'", AutoFeatures.CrazyEnchantsBlastUseEventPriority ) );
+ results.add( formatAFEvent( "RevEnchant '&7ExplosiveEvent&3'", AutoFeatures.RevEnchantsExplosiveEventPriority ) );
+ results.add( formatAFEvent( "RevEnchant '&7JackHammerEvent&3'", AutoFeatures.RevEnchantsJackHammerEventPriority ) );
+ results.add( formatAFEvent( "Zenchantments '&7BlockShredEvent&3'", AutoFeatures.ZenchantmentsBlockShredEventPriority ) );
+
+ results.add( formatAFEvent( "XPrison '&7ExplosionTriggerEvent&3'", AutoFeatures.XPrisonExplosionTriggerEventPriority ) );
+ results.add( formatAFEvent( "XPrison '&7LayerTriggerEvent&3'", AutoFeatures.XPrisonLayerTriggerEventPriority ) );
+ results.add( formatAFEvent( "XPrison '&7NukeTriggerEvent&3'", AutoFeatures.XPrisonNukeTriggerEventPriority ) );
+
+
-
- String bbePriority = afw.getMessage( AutoFeatures.blockBreakEventPriority );
- BlockBreakPriority blockBreakPriority = BlockBreakPriority.fromString( bbePriority );
- results.add( String.format(". '&7org.bukkit.BlockBreakEvent&3' Priority:&b %s",
- blockBreakPriority.name() ) );
-
- String pebbePriority = afw.getMessage( AutoFeatures.ProcessPrisons_ExplosiveBlockBreakEventsPriority );
- boolean isPebbeEnabled = pebbePriority != null && !"DISABLED".equalsIgnoreCase( pebbePriority );
- BlockBreakPriority pebbeEventPriority = BlockBreakPriority.fromString( pebbePriority );
- results.add( String.format("%s. Prison's own '&7ExplosiveBlockBreakEvent&3' Priority:&b %s %s",
- (isPebbeEnabled ? "" : "+" ),
- pebbeEventPriority.name(),
- (isPebbeEnabled ? "&2Enabled" : "&cDisabled")
- ) );
+// String bbePriority = afw.getMessage( AutoFeatures.blockBreakEventPriority );
+// BlockBreakPriority blockBreakPriority = BlockBreakPriority.fromString( bbePriority );
+// results.add( String.format(". '&7org.bukkit.BlockBreakEvent&3' Priority:&b %s",
+// blockBreakPriority.name() ) );
- String peeePriority = afw.getMessage( AutoFeatures.PrisonEnchantsExplosiveEventPriority );
- boolean isPeeeEnabled = peeePriority != null && !"DISABLED".equalsIgnoreCase( peeePriority );
- BlockBreakPriority peeeEventPriority = BlockBreakPriority.fromString( peeePriority );
- results.add( String.format("%s. Pulsi_'s PrisonEnchants '&7PEExplosiveEvent&3' Priority:&b %s %s",
- (isPeeeEnabled ? "" : "+" ),
- peeeEventPriority.name(),
- (isPeeeEnabled ? "&2Enabled" : "&cDisabled")
- ) );
+// String pebbePriority = afw.getMessage( AutoFeatures.ProcessPrisons_ExplosiveBlockBreakEventsPriority );
+// boolean isPebbeEnabled = pebbePriority != null && !"DISABLED".equalsIgnoreCase( pebbePriority );
+// BlockBreakPriority pebbeEventPriority = BlockBreakPriority.fromString( pebbePriority );
+// results.add( String.format("%s. Prison's own '&7ExplosiveBlockBreakEvent&3' Priority:&b %s %s",
+// (isPebbeEnabled ? "" : "+" ),
+// pebbeEventPriority.name(),
+// (isPebbeEnabled ? "&2Enabled" : "&cDisabled")
+// ) );
- String tebePriority = afw.getMessage( AutoFeatures.TokenEnchantBlockExplodeEventPriority );
- boolean isTebeEnabled = tebePriority != null && !"DISABLED".equalsIgnoreCase( tebePriority );
- BlockBreakPriority tebEventPriority = BlockBreakPriority.fromString( tebePriority );
- results.add( String.format("%s. TokenEnchant '&7BlockExplodeEvent&3' Priority:&b %s %s",
- (isTebeEnabled ? "" : "+" ),
- tebEventPriority.name(),
- (isTebeEnabled ? "&2Enabled" : "&cDisabled")
- ) );
+// String peeePriority = afw.getMessage( AutoFeatures.PrisonEnchantsExplosiveEventPriority );
+// boolean isPeeeEnabled = peeePriority != null && !"DISABLED".equalsIgnoreCase( peeePriority );
+// BlockBreakPriority peeeEventPriority = BlockBreakPriority.fromString( peeePriority );
+// results.add( String.format("%s. Pulsi_'s PrisonEnchants '&7PEExplosiveEvent&3' Priority:&b %s %s",
+// (isPeeeEnabled ? "" : "+" ),
+// peeeEventPriority.name(),
+// (isPeeeEnabled ? "&2Enabled" : "&cDisabled")
+// ) );
+//
+// String tebePriority = afw.getMessage( AutoFeatures.TokenEnchantBlockExplodeEventPriority );
+// boolean isTebeEnabled = tebePriority != null && !"DISABLED".equalsIgnoreCase( tebePriority );
+// BlockBreakPriority tebEventPriority = BlockBreakPriority.fromString( tebePriority );
+// results.add( String.format("%s. TokenEnchant '&7BlockExplodeEvent&3' Priority:&b %s %s",
+// (isTebeEnabled ? "" : "+" ),
+// tebEventPriority.name(),
+// (isTebeEnabled ? "&2Enabled" : "&cDisabled")
+// ) );
- String reeePriority = afw.getMessage( AutoFeatures.RevEnchantsExplosiveEventPriority );
- boolean isReeeEnabled = reeePriority != null && !"DISABLED".equalsIgnoreCase( reeePriority );
- BlockBreakPriority reeEventPriority = BlockBreakPriority.fromString( reeePriority );
- results.add( String.format("%s. RevEnchant '&7ExplosiveEvent&3' Priority:&b %s %s",
- (isReeeEnabled ? "" : "+" ),
- reeEventPriority.name(),
- (isReeeEnabled ? "&2Enabled" : "&cDisabled")
- ) );
- String rejhePriority = afw.getMessage( AutoFeatures.RevEnchantsJackHammerEventPriority );
- boolean isRejheEnabled = rejhePriority != null && !"DISABLED".equalsIgnoreCase( rejhePriority );
- BlockBreakPriority rejhEventPriority = BlockBreakPriority.fromString( rejhePriority );
- results.add( String.format("%s. RevEnchant '&7JackHammerEvent&3' Priority:&b %s %s",
- (isRejheEnabled ? "" : "+" ),
- rejhEventPriority.name(),
- (isRejheEnabled ? "&2Enabled" : "&cDisabled")
- ) );
+// String reeePriority = afw.getMessage( AutoFeatures.RevEnchantsExplosiveEventPriority );
+// boolean isReeeEnabled = reeePriority != null && !"DISABLED".equalsIgnoreCase( reeePriority );
+// BlockBreakPriority reeEventPriority = BlockBreakPriority.fromString( reeePriority );
+// results.add( String.format("%s. RevEnchant '&7ExplosiveEvent&3' Priority:&b %s %s",
+// (isReeeEnabled ? "" : "+" ),
+// reeEventPriority.name(),
+// (isReeeEnabled ? "&2Enabled" : "&cDisabled")
+// ) );
+//
+// String rejhePriority = afw.getMessage( AutoFeatures.RevEnchantsJackHammerEventPriority );
+// boolean isRejheEnabled = rejhePriority != null && !"DISABLED".equalsIgnoreCase( rejhePriority );
+// BlockBreakPriority rejhEventPriority = BlockBreakPriority.fromString( rejhePriority );
+// results.add( String.format("%s. RevEnchant '&7JackHammerEvent&3' Priority:&b %s %s",
+// (isRejheEnabled ? "" : "+" ),
+// rejhEventPriority.name(),
+// (isRejheEnabled ? "&2Enabled" : "&cDisabled")
+// ) );
- String cebuePriority = afw.getMessage( AutoFeatures.CrazyEnchantsBlastUseEventPriority );
- boolean isCebueEnabled = cebuePriority != null && !"DISABLED".equalsIgnoreCase( cebuePriority );
- BlockBreakPriority cebuEventPriority = BlockBreakPriority.fromString( cebuePriority );
- results.add( String.format("%s. CrazyEnchant '&7BlastUseEvent&3' Priority:&b %s %s",
- (isCebueEnabled ? "" : "+" ),
- cebuEventPriority.name(),
- (isCebueEnabled ? "&2Enabled" : "&cDisabled")
- ) );
-
- String zbsePriority = afw.getMessage( AutoFeatures.ZenchantmentsBlockShredEventPriority );
- boolean isZbseEnabled = zbsePriority != null && !"DISABLED".equalsIgnoreCase( zbsePriority );
- BlockBreakPriority zbsEventPriority = BlockBreakPriority.fromString( zbsePriority );
- results.add( String.format("%s. Zenchantments '&7BlockShredEvent&3' Priority:&b %s %s",
- (isZbseEnabled ? "" : "+" ),
- zbsEventPriority.name(),
- (isZbseEnabled ? "&2Enabled" : "&cDisabled")
- ) );
+// String cebuePriority = afw.getMessage( AutoFeatures.CrazyEnchantsBlastUseEventPriority );
+// boolean isCebueEnabled = cebuePriority != null && !"DISABLED".equalsIgnoreCase( cebuePriority );
+// BlockBreakPriority cebuEventPriority = BlockBreakPriority.fromString( cebuePriority );
+// results.add( String.format("%s. CrazyEnchant '&7BlastUseEvent&3' Priority:&b %s %s",
+// (isCebueEnabled ? "" : "+" ),
+// cebuEventPriority.name(),
+// (isCebueEnabled ? "&2Enabled" : "&cDisabled")
+// ) );
+//
+// String zbsePriority = afw.getMessage( AutoFeatures.ZenchantmentsBlockShredEventPriority );
+// boolean isZbseEnabled = zbsePriority != null && !"DISABLED".equalsIgnoreCase( zbsePriority );
+// BlockBreakPriority zbsEventPriority = BlockBreakPriority.fromString( zbsePriority );
+// results.add( String.format("%s. Zenchantments '&7BlockShredEvent&3' Priority:&b %s %s",
+// (isZbseEnabled ? "" : "+" ),
+// zbsEventPriority.name(),
+// (isZbseEnabled ? "&2Enabled" : "&cDisabled")
+// ) );
+
+
+
+
// String peeePriority = afw.getMessage( AutoFeatures.PrisonEnchantsExplosiveEventPriority );
// boolean isPeeeeEnabled = afw.isBoolean( AutoFeatures.isProcessPrisonEnchantsExplosiveEvents );
// BlockBreakPriority peeEventPriority = BlockBreakPriority.fromString( peeePriority );
@@ -2271,13 +2355,34 @@ public List getActiveFeatures( boolean showLaddersAndRanks ) {
(isDurabilityEnabled ? "" : "+"),
isDurabilityEnabled) );
+ boolean isPreventToolBreakage = afw.isBoolean( AutoFeatures.isPreventToolBreakage );
+ results.add( String.format("%s. Prevent Tool Breakage:&b %s",
+ (isPreventToolBreakage ? "" : "+"),
+ isPreventToolBreakage) );
+
+ results.add( String.format("%s. Prevent Tool Breakage Threshold:&b %s",
+ (isPreventToolBreakage ? "" : "+"),
+ afw.getInteger( AutoFeatures.preventToolBreakageThreshold )) );
+
+
+
+
boolean isCalcFortune = afw.isBoolean( AutoFeatures.isCalculateFortuneEnabled );
+
results.add( String.format(". Calculate Fortune:&b %s", isCalcFortune) );
- results.add( String.format("+. . Fortune Multiplier:&b %s",
+
+ boolean isUseTEFortuneLevel = afw.isBoolean( AutoFeatures.isUseTokenEnchantsFortuneLevel );
+ results.add( String.format("%s. . Use TokenEnchants Fortune Level:&b %b",
+ (isUseTEFortuneLevel ? "" : "+"),
+ isUseTEFortuneLevel) );
+
+ results.add( String.format("+. . Fortune Multiplier Global:&b %s",
afw.getInteger( AutoFeatures.fortuneMultiplierGlobal )) );
results.add( String.format("+. . Max Fortune Level:&b %s &3(0 = no max Level)",
afw.getInteger( AutoFeatures.fortuneMultiplierMax )) );
+ results.add( String.format("+. . Fortune Bukkit Drops Multiplier:&b %s &3",
+ afw.getDouble( AutoFeatures.fortuneBukkitDropsMultiplier )) );
boolean isExtendedBukkitFortune = afw.isBoolean( AutoFeatures.isExtendBukkitFortuneCalculationsEnabled );
results.add( String.format(". . Extended Bukkit Fortune Enabled:&b %s",
@@ -2289,17 +2394,46 @@ public List getActiveFeatures( boolean showLaddersAndRanks ) {
afw.getInteger( AutoFeatures.extendBukkitFortuneFactorPercentRangeHigh )) );
+ boolean isAltFortune = afw.isBoolean( AutoFeatures.isCalculateAltFortuneEnabled);
results.add( "+&3NOTE: If you enable Extended Bukkit Fortune, then it auto disables the following Alt Fortune Cals." );
results.add( "+&3NOTE: First try Extended Bukkit Fortune and if it does not work, then disable it and use " +
"Alt Fortune." );
- results.add( String.format("%s. . Calculate Alt Fortune Enabled:&b %s %s",
+ results.add( String.format("%s. . Calculate Alt Fortune Enabled:&b %s",
(isExtendedBukkitFortune ? "+" : "" ),
- ( afw.isBoolean( AutoFeatures.isCalculateAltFortuneEnabled) ? "&2Enabled" : "&cDisabled"),
- ( isExtendedBukkitFortune ? "&d[disabled by Exended Bukkit Fortune]" : "")) );
- results.add( String.format("%s. . Calculate Alt Fortune on all Blocks:&b %s %s",
+ ( isAltFortune ? "&2Enabled" : "&cDisabled")
+ ) );
+ results.add( String.format("%s. . Calculate Alt Fortune on all Blocks:&b %s",
(isExtendedBukkitFortune ? "+" : "" ),
- ( afw.isBoolean( AutoFeatures.isCalculateAltFortuneOnAllBlocksEnabled) ? "&2Enabled" : "&cDisabled"),
- ( isExtendedBukkitFortune ? "&d[disabled by Exended Bukkit Fortune]" : "")) );
+ ( afw.isBoolean( AutoFeatures.isCalculateAltFortuneOnAllBlocksEnabled) ? "&2Enabled" : "&cDisabled")
+ ) );
+ if ( isAltFortune && isExtendedBukkitFortune ) {
+ results.add( "&dWarning: Alt Fortune is disabled by Exended Bukkit Fortune." );
+ }
+
+
+ boolean isGradientFortune = afw.isBoolean( AutoFeatures.isPercentGradientFortuneEnabled );
+
+ results.add( String.format("%s. Percent Gradient Fortune Enabled:&b %s",
+ (isGradientFortune ? "" : "+"),
+ isGradientFortune ) );
+
+ if ( isGradientFortune ) {
+
+ if ( isExtendedBukkitFortune ) {
+ results.add( "&dWarning: Percent Gradient Fortune is disabled by Exended Bukkit Fortune." );
+ }
+ if ( isAltFortune ) {
+ results.add( "&dWarning: Percent Gradient Fortune is disabled by Alt Fortune." );
+ }
+
+ results.add( String.format(". . Percent Gradient Fortune: Max Fortune Level:&b %s",
+ afw.getInteger( AutoFeatures.percentGradientFortuneMaxFortuneLevel )) );
+ results.add( String.format(". . Percent Gradient Fortune: Max Bonus Blocks: &b %s",
+ afw.getInteger( AutoFeatures.percentGradientFortuneMaxBonusBlocks )) );
+ results.add( String.format(". . Percent Gradient Fortune: Min Percent Randomness: &b%s",
+ afw.getDouble( AutoFeatures.percentGradientFortuneMinPercentRandomness )) );
+
+ }
results.add( " " );
@@ -2365,6 +2499,25 @@ public List getActiveFeatures( boolean showLaddersAndRanks ) {
}
+ private String formatAFEvent(String description, AutoFeatures autoFeature ) {
+ String results = null;
+
+ String ePriority = AutoFeaturesWrapper.getInstance().getMessage( autoFeature );
+
+ BlockBreakPriority eventPriority = BlockBreakPriority.fromString( ePriority );
+
+ boolean isEnabled = eventPriority != BlockBreakPriority.DISABLED;
+
+ results = String.format("%s. %s Priority:&b %s %s",
+ (isEnabled ? "" : "+" ),
+ description,
+ eventPriority.name(),
+ (isEnabled ? "&2Enabled" : "&cDisabled")
+ );
+
+ return results;
+ }
+
@Override
public void prisonVersionFeatures( ChatDisplay display, boolean isBasic,
boolean showLaddersAndRanks ) {
@@ -2549,7 +2702,9 @@ else if ( !isBasic ) {
}
-
+ // REMOVE! The following will "load" the WorldGuard settings and then dump them as json to console
+ // to confirm they were loaded properly. Remove when done with this test1
+// new WorldGuardSettings();
}
@@ -2620,6 +2775,20 @@ public String dumpEventListenersBlockBreakEvents() {
zenchantments.dumpEventListeners( sb );
+
+ AutoManagerXPrisonExplosionTriggerEvent xpExplosion = new AutoManagerXPrisonExplosionTriggerEvent();
+ xpExplosion.dumpEventListeners( sb );
+
+ AutoManagerXPrisonLayerTriggerEvent xpLayer = new AutoManagerXPrisonLayerTriggerEvent();
+ xpLayer.dumpEventListeners( sb );
+
+ AutoManagerXPrisonNukeTriggerEvent xpNuke = new AutoManagerXPrisonNukeTriggerEvent();
+ xpNuke.dumpEventListeners( sb );
+
+
+
+
+
// Shorten the prison package names:
// 'tmps.' = 'tech.mcprison.prison.spigot.'
// 'tmpsae.' = 'tmps.autofeatures.events.'
@@ -2832,45 +3001,86 @@ public void saveResource( String fileName, boolean replace ) {
SpigotPrison.getInstance().saveResource( fileName, replace );
}
-
@Override
- public String getMinesListString() {
+ public boolean isMineNameValid( String mineName ) {
+ boolean results = false;
+ if ( PrisonMines.getInstance().isEnabled() ) {
+
+ Mine mine = PrisonMines.getInstance().getMine(mineName);
+
+ results = mine != null;
+ }
- MinesCommands mc = PrisonMines.getInstance().getMinesCommands();
+ return results;
+ }
+
+ @Override
+ public String getMinesListString() {
+ String results = "";
-
- ChatDisplay display = new ChatDisplay("Mines");
- mc.getMinesList( display, MineManager.MineSortOrder.sortOrder, "all", null );
-
- StringBuilder sb = display.toStringBuilder();
-
- sb.append( "\n" );
-
- mc.allMinesInfoDetails( sb );
+ if ( PrisonMines.getInstance().isEnabled() ) {
+
+ MinesCommands mc = PrisonMines.getInstance().getMinesCommands();
+
+
+ ChatDisplay display = new ChatDisplay("Mines");
+
+ display.addSupportHyperLinkData( "Mines List" );
+
+ // get the mine list:
+ mc.getMinesList( display, MineManager.MineSortOrder.sortOrder, "all", null );
+
+ StringBuilder sb = display.toStringBuilder();
+
+ sb.append( "\n" );
+
+ // get the mine details for all mines:
+ mc.allMinesInfoDetails( sb );
+
+ results = sb.toString();
+ }
- return sb.toString();
+ return results;
// return Text.stripColor( sb.toString() );
}
@Override
public String getRanksListString() {
+ StringBuilder sb = new StringBuilder();
- RanksCommands rc =
+ if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) {
+
+ LadderCommands lc =
+ PrisonRanks.getInstance().getRankManager().getLadderCommands();
+
+ RanksCommands rc =
PrisonRanks.getInstance().getRankManager().getRanksCommands();
-
-
- ChatDisplay display = new ChatDisplay("Ranks");
-
- RankPlayer rPlayer = null;
- rc.listAllRanksByLadders( display, true, rPlayer );
-
- StringBuilder sb = display.toStringBuilder();
-
- sb.append( "\n" );
-
- rc.listAllRanksByInfo( sb );
+
+ sb.append( "\n\n" );
+
+ ChatDisplay displayLadders = lc.getLadderList();
+
+ sb.append( displayLadders.toStringBuilder() );
+ sb.append( "\n" );
+
+
+ RankPlayer rPlayer = null;
+
+ ChatDisplay displayRanks = new ChatDisplay("Ranks");
+ rc.listAllRanksByLadders( displayRanks, true, rPlayer );
+
+ sb.append( displayRanks.toStringBuilder() );
+ sb.append( "\n" );
+
+
+ rc.listAllRanksByInfo( sb );
// rc.allRanksInfoDetails( sb );
+ }
+ else {
+ sb.append( "Ranks are disabled.\n\n" );
+ }
+
return sb.toString();
// return Text.stripColor( sb.toString() );
@@ -3115,4 +3325,27 @@ public int getMinY() {
public int getMaxY() {
return SpigotCompatibility.getInstance().getMaxY();
}
+
+ @Override
+ public String getLadderByFileName(String name) {
+ String results = "";
+
+ if ( PrisonRanks.getInstance().isEnabled() ) {
+ results = PrisonRanks.getInstance().getLadderManager().getLadderByFileName( name );
+ }
+
+ return results;
+ }
+
+ @Override
+ public String getRankByFileName(String name) {
+ String results = "";
+
+ if ( PrisonRanks.getInstance().isEnabled() ) {
+
+ results = PrisonRanks.getInstance().getRankManager().getRankByFileName( name );
+ }
+
+ return results;
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPrison.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPrison.java
index 4008430ef..1945db12c 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPrison.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotPrison.java
@@ -40,6 +40,7 @@
import tech.mcprison.prison.PrisonCommand;
import tech.mcprison.prison.PrisonCommand.RegisteredPluginsData;
import tech.mcprison.prison.alerts.Alerts;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.backups.PrisonBackups;
import tech.mcprison.prison.integration.Integration;
import tech.mcprison.prison.integration.IntegrationType;
@@ -66,7 +67,9 @@
import tech.mcprison.prison.spigot.block.OnBlockBreakEventListener;
import tech.mcprison.prison.spigot.bstats.PrisonBStats;
import tech.mcprison.prison.spigot.commands.PrisonSpigotBackpackCommands;
+import tech.mcprison.prison.spigot.commands.PrisonSpigotGUIBackPackCommands;
import tech.mcprison.prison.spigot.commands.PrisonSpigotGUICommands;
+import tech.mcprison.prison.spigot.commands.PrisonSpigotGUISellAllCommands;
import tech.mcprison.prison.spigot.commands.PrisonSpigotMinesCommands;
import tech.mcprison.prison.spigot.commands.PrisonSpigotPrestigeCommands;
import tech.mcprison.prison.spigot.commands.PrisonSpigotRanksCommands;
@@ -78,6 +81,7 @@
import tech.mcprison.prison.spigot.configs.MessagesConfig;
import tech.mcprison.prison.spigot.configs.SellAllConfig;
import tech.mcprison.prison.spigot.customblock.CustomItems;
+import tech.mcprison.prison.spigot.economies.CoinsEngineEconomy;
import tech.mcprison.prison.spigot.economies.EssentialsEconomy;
import tech.mcprison.prison.spigot.economies.GemsEconomy;
import tech.mcprison.prison.spigot.economies.SaneEconomy;
@@ -311,7 +315,10 @@ public void onEnableStartup() {
Bukkit.getPluginManager().registerEvents(new ListenersPrisonManager(),this);
- if ( getConfig().getBoolean( "slime-fun" ) ) {
+ boolean slimeFunEnabled1 = SpigotPrison.getInstance().getConfig().getBoolean("slime-fun");
+ boolean slimeFunEnabled2 = SpigotPrison.getInstance().getConfig().getBoolean("slime-fun.enabled");
+
+ if ( slimeFunEnabled1 || slimeFunEnabled2 ) {
Bukkit.getPluginManager().registerEvents(new SlimeBlockFunEventListener(), this);
}
@@ -330,6 +337,14 @@ public void onEnableStartup() {
// Sellall set to disabled since it will be set to the correct value in enableModulesAndCommands():
isSellAllEnabled = false;
+
+
+ // Load the autoFeaturesConfig.yml and blockConvertersConfig.json files:
+ AutoFeaturesWrapper.getInstance();
+ AutoFeaturesWrapper.getBlockConvertersInstance();
+
+
+
// This is the loader for modules and commands:
enableModulesAndCommands();
@@ -346,6 +361,7 @@ public void onEnableStartup() {
// The BlockBreakEvents must be registered after the mines and ranks modules have been enabled:
+ // Auto features will prevent this if it's disabled.
getBlockBreakEventListeners().registerAllBlockBreakEvents( this );
@@ -403,9 +419,9 @@ public void onEnableStartup() {
- // Setup mine bombs:
+ // Setup mine bombs and validate to spigot version:
PrisonUtilsMineBombs.getInstance().reloadPrisonMineBombs();
-
+ PrisonUtilsMineBombs.getInstance().validateMineBombsSpigotVersion();
// Enable Temp spigot commands:
new SpigotCommand();
@@ -928,6 +944,7 @@ private void initIntegrations() {
registerIntegration(new EssentialsEconomy());
registerIntegration(new SaneEconomy());
registerIntegration(new GemsEconomy());
+ registerIntegration(new CoinsEngineEconomy());
registerIntegration(new VaultPermissions());
registerIntegration(new LuckPerms5());
@@ -1031,14 +1048,18 @@ private void initModulesAndCommands() {
YamlConfiguration modulesConf = loadConfig("modules.yml");
+ boolean isMinesEnabled = false;
boolean isRanksEnabled = false;
// TODO: This business logic needs to be moved to the Module Manager:
if (modulesConf.getBoolean("mines")) {
+ isMinesEnabled = true;
+
Prison.get().getModuleManager()
.registerModule(new PrisonMines(getDescription().getVersion()));
- Prison.get().getCommandHandler().registerCommands( new PrisonSpigotMinesCommands() );
+ // The GUI handler for mines... cannot be hooked up here:
+// Prison.get().getCommandHandler().registerCommands( new PrisonSpigotMinesCommands() );
} else {
Output.get().logInfo("&7Modules: &cPrison Mines are disabled and were not Loaded. ");
@@ -1116,13 +1137,14 @@ private void initModulesAndCommands() {
// Do not enable sellall if ranks is not loaded since it uses player ranks:
if ( isRanksEnabled ) {
- Prison.get().getCommandHandler().registerCommands( new PrisonSpigotRanksCommands() );
+ // enable under GUI:
+// Prison.get().getCommandHandler().registerCommands( new PrisonSpigotRanksCommands() );
- // NOTE: If ranks module is enabled, then try to register prestiges commands if enabled:
- if ( isPrisonConfig( "prestiges") || isPrisonConfig( "prestige.enabled" ) ) {
- // Enable the setup of the prestige related commands only if prestiges is enabled:
- Prison.get().getCommandHandler().registerCommands( new PrisonSpigotPrestigeCommands() );
- }
+// // NOTE: If ranks module is enabled, then try to register prestiges commands if enabled:
+// if ( isPrisonConfig( "prestiges") || isPrisonConfig( "prestige.enabled" ) ) {
+// // Enable the setup of the prestige related commands only if prestiges is enabled:
+// Prison.get().getCommandHandler().registerCommands( new PrisonSpigotPrestigeCommands() );
+// }
}
@@ -1133,11 +1155,46 @@ private void initModulesAndCommands() {
}
- // This registers the admin's /gui commands
- // GUI commands were updated to prevent use of ranks commands when ranks module is not loaded.
- if (getConfig().getString("prison-gui-enabled").equalsIgnoreCase("true")) {
+ // The following will enable all of the GUI related commands. It's important that they
+ // cannot be enabled elsewhere, or at least the 'prison-gui-enabled' must control
+ // their registration:
+ if ( Prison.get().getPlatform().getConfigBooleanFalse( "prison-gui-enabled" ) ) {
+
+ // Prison's primary GUI commands:
Prison.get().getCommandHandler().registerCommands( new PrisonSpigotGUICommands() );
+
+
+ if ( isMinesEnabled ) {
+ // The GUI handler for mines... cannot be hooked up here:
+ Prison.get().getCommandHandler().registerCommands( new PrisonSpigotMinesCommands() );
+ }
+
+
+ if ( isRanksEnabled ) {
+ Prison.get().getCommandHandler().registerCommands( new PrisonSpigotRanksCommands() );
+
+ // NOTE: If ranks module is enabled, then try to register prestiges commands if enabled:
+ if ( isPrisonConfig( "prestiges") || isPrisonConfig( "prestige.enabled" ) ) {
+ // Enable the setup of the prestige related commands only if prestiges is enabled:
+ Prison.get().getCommandHandler().registerCommands( new PrisonSpigotPrestigeCommands() );
+ }
+ }
+
+
+ if ( isBackPacksEnabled ) {
+ Prison.get().getCommandHandler().registerCommands( new PrisonSpigotGUIBackPackCommands() );
+ }
+
+
+ if ( isSellAllEnabled ) {
+ Prison.get().getCommandHandler().registerCommands( new PrisonSpigotGUISellAllCommands() );
+ }
}
+
+// // This registers the admin's /gui commands
+// // GUI commands were updated to prevent use of ranks commands when ranks module is not loaded.
+// if (getConfig().getString("prison-gui-enabled").equalsIgnoreCase("true")) {
+// }
// Register prison utility commands:
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotScheduler.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotScheduler.java
index f290b4cc4..eb992ebd6 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotScheduler.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotScheduler.java
@@ -65,7 +65,9 @@ public void dispatchCommand(Player player, String command) {
if ( player != null && player instanceof SpigotPlayer ) {
SpigotPlayer sPlayer = (SpigotPlayer) player;
- Bukkit.dispatchCommand( sPlayer.getWrapper(), command );
+ sPlayer.dispatchCommand( command );
+
+// Bukkit.dispatchCommand( sPlayer.getWrapper(), command );
}
}
@@ -80,7 +82,9 @@ public void performCommand(Player player, String command) {
SpigotPlayer sPlayer = (SpigotPlayer) p;
- sPlayer.getWrapper().performCommand( command );
+ sPlayer.dispatchCommand( command );
+
+// sPlayer.getWrapper().performCommand( command );
}
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java
index e8fe0f841..c37f9f0c3 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/SpigotUtil.java
@@ -99,7 +99,9 @@ public static XMaterial getXMaterial( String materialName ) {
public static XMaterial getXMaterial( PrisonBlock prisonBlock ) {
- XMaterial xMat = getXMaterial( prisonBlock.getBlockName());
+ XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial(prisonBlock);
+
+// XMaterial xMat = getXMaterial( prisonBlock.getBlockName());
return xMat;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java
index f0e4535e2..d20bf0304 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonMinesBlockBreakEvent.java
@@ -1,5 +1,6 @@
package tech.mcprison.prison.spigot.api;
+import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
@@ -9,16 +10,21 @@
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockBreakEvent;
+import tech.mcprison.prison.Prison;
import tech.mcprison.prison.internal.block.MineTargetPrisonBlock;
import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType;
import tech.mcprison.prison.mines.data.Mine;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.SpigotPrison;
import tech.mcprison.prison.spigot.block.BlockBreakPriority;
import tech.mcprison.prison.spigot.block.SpigotBlock;
import tech.mcprison.prison.spigot.block.SpigotItemStack;
import tech.mcprison.prison.spigot.block.OnBlockBreakMines.MinesEventResults;
import tech.mcprison.prison.spigot.compat.SpigotCompatibility;
import tech.mcprison.prison.spigot.game.SpigotPlayer;
+import tech.mcprison.prison.spigot.sellall.SellAllUtil;
+import tech.mcprison.prison.spigot.utils.tasks.PlayerAutoRankupTask;
/**
* This is an event that prison calls before processing the blocks that
@@ -100,6 +106,12 @@ public class PrisonMinesBlockBreakEvent
private boolean forceAutoSell = false;
+ // If forceBlockRemoval is true, then it will remove the block even if the block
+ // break priority is MONITOR. This setting is only used (so far) with the
+ // BlockConverters Event Triggers to bypass prison processing, but will allow prison
+ // to remove the block and then treat it like a MONITOR event so it gets counted.
+ private boolean forceBlockRemoval = false;
+
private BlockBreakPriority bbPriority;
@@ -129,8 +141,9 @@ public class PrisonMinesBlockBreakEvent
private StringBuilder debugInfo;
-
+ private boolean forceDebugLogging;
+
public PrisonMinesBlockBreakEvent(
MinesEventResults eventResults,
// Block theBlock, Player player,
@@ -175,7 +188,11 @@ public PrisonMinesBlockBreakEvent(
this.bukkitDrops = new ArrayList<>();
- this.debugInfo = debugInfo;
+ this.debugInfo = new StringBuilder();
+ setDebugColorCodeDebug();
+ this.debugInfo.append( debugInfo );
+
+ this.forceDebugLogging = false;
}
@@ -285,6 +302,71 @@ public TreeMap getTargetBlockCounts() {
return results;
}
+
+
+ /**
+ * This will perform a Prison's sellall on a player's inventory.
+ * This tracks how many nanoseconds it took to run and will log this
+ * information if Prison is in debug mode. This info will be appended
+ * to the debug info for the block break handling.
+ *
+ *
+ * @param description
+ */
+ public void performSellAllOnPlayerInventoryLogged( String description ) {
+
+ debugInfo.append( performSellAllOnPlayerInventoryString(description) );
+
+// final long nanoStart = System.nanoTime();
+// boolean success = SellAllUtil.get().sellAllSell( getPlayer(),
+// false, false, false, true, true, false);
+// final long nanoStop = System.nanoTime();
+// double milliTime = (nanoStop - nanoStart) / 1000000d;
+//
+// DecimalFormat dFmt = Prison.get().getDecimalFormat("#,##0.00");
+// debugInfo.append( "(" )
+// .append( description)
+// .append( ": " + (success ? "success" : "failed"))
+// .append( " ms: " + dFmt.format( milliTime ) + ") ");
+
+ PlayerAutoRankupTask.autoSubmitPlayerRankupTask( getSpigotPlayer(), debugInfo );
+
+ }
+ public String performSellAllOnPlayerInventoryString( String description ) {
+ StringBuilder sb = new StringBuilder();
+
+ if ( SpigotPrison.getInstance().isSellAllEnabled() ) {
+
+ final long nanoStart = System.nanoTime();
+
+ boolean isUsingSign = false;
+ boolean completelySilent = false;
+ boolean notifyPlayerEarned = false;
+ boolean notifyPlayerDelay = false;
+ boolean notifyPlayerEarningDelay = true;
+ boolean playSoundOnSellAll = false;
+ boolean notifyNothingToSell = false;
+
+ boolean success = SellAllUtil.get().sellAllSell( getPlayer(),
+ isUsingSign, completelySilent,
+ notifyPlayerEarned, notifyPlayerDelay,
+ notifyPlayerEarningDelay, playSoundOnSellAll,
+ notifyNothingToSell, null );
+ final long nanoStop = System.nanoTime();
+ double milliTime = (nanoStop - nanoStart) / 1000000d;
+
+ DecimalFormat dFmt = Prison.get().getDecimalFormat("#,##0.00");
+
+ sb.append( "(" )
+ .append( description)
+ .append( ": " + (success ? "success" : "failed"))
+ .append( " ms: " + dFmt.format( milliTime ) + ") ");
+ }
+
+ return sb.toString();
+ }
+
+
public Mine getMine() {
return mine;
}
@@ -382,6 +464,13 @@ public boolean isForceAutoSell() {
public void setForceAutoSell( boolean forceAutoSell ) {
this.forceAutoSell = forceAutoSell;
}
+
+ public boolean isForceBlockRemoval() {
+ return forceBlockRemoval;
+ }
+ public void setForceBlockRemoval(boolean forceBlockRemoval) {
+ this.forceBlockRemoval = forceBlockRemoval;
+ }
public BlockBreakPriority getBbPriority() {
return bbPriority;
@@ -433,4 +522,26 @@ public void setDebugInfo(StringBuilder debugInfo) {
this.debugInfo = debugInfo;
}
+ public boolean isForceDebugLogging() {
+ return forceDebugLogging;
+ }
+ public void setForceDebugLogging(boolean forceDebugLogging) {
+ this.forceDebugLogging = forceDebugLogging;
+ }
+
+ public void setDebugColorCodeInfo() {
+ getDebugInfo().append( Output.get().getColorCodeInfo() );
+ }
+
+ public void setDebugColorCodeWarning() {
+ getDebugInfo().append( Output.get().getColorCodeWarning() );
+ }
+
+ public void setDebugColorCodeError() {
+ getDebugInfo().append( Output.get().getColorCodeError() );
+ }
+
+ public void setDebugColorCodeDebug() {
+ getDebugInfo().append( Output.get().getColorCodeDebug() );
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java
index f6a11d90a..3cb826a75 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/api/PrisonSpigotAPI.java
@@ -1,5 +1,6 @@
package tech.mcprison.prison.spigot.api;
+import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
@@ -11,6 +12,7 @@
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
+import org.bukkit.inventory.ItemStack;
import tech.mcprison.prison.Prison;
import tech.mcprison.prison.internal.block.PrisonBlock;
@@ -30,8 +32,10 @@
import tech.mcprison.prison.spigot.SpigotPrison;
import tech.mcprison.prison.spigot.backpacks.BackpacksUtil;
import tech.mcprison.prison.spigot.block.SpigotBlock;
+import tech.mcprison.prison.spigot.block.SpigotItemStack;
import tech.mcprison.prison.spigot.game.SpigotPlayer;
import tech.mcprison.prison.spigot.game.SpigotWorld;
+import tech.mcprison.prison.spigot.sellall.SellAllData;
import tech.mcprison.prison.spigot.sellall.SellAllUtil;
import tech.mcprison.prison.util.ChatColor;
import tech.mcprison.prison.util.Location;
@@ -43,6 +47,10 @@
* Use of these are at your own risk. Misuse can result in corruption of Prison's
* internal data.
*
+ *
+ * If you need something special, then please ask on our discord server and we
+ * can probably provide it for you.
+ *
*
*/
public class PrisonSpigotAPI {
@@ -431,15 +439,36 @@ public double getSellAllMultiplier(Player player){
* @return BackpaacksUtil - Null if Prison Backpacks are disabled.
* */
public BackpacksUtil getPrisonBackpacks(){
- if (SpigotPrison.getInstance().getConfig().getString("backpacks") != null && SpigotPrison.getInstance().getConfig().getString("backpacks").equalsIgnoreCase("true")){
+ if (SpigotPrison.getInstance().getConfig().getString("backpacks") != null &&
+ SpigotPrison.getInstance().getConfig().getString("backpacks").equalsIgnoreCase("true")){
return BackpacksUtil.get();
}
return null;
}
/**
- * Get the whole SellAllUtil of Prison Sellall to manage what you
+ * Get the whole SellAllUtil of Prison Sellall to manage what you
* want of Prison SellAll.
+ *
+ *
+ * WARNING: usage of this object is at your own risk! Functions will change,
+ * and will be eliminated. The majority of the functions that were in, and are
+ * in this object that are `public` were never intended to be used outside
+ * of prison. Many of the functions really should have been marked as private.
+ *
+ *
+ * WARNING: The sellall functions will be undergoing major revisions and
+ * improvements in the near future. As such, do not rely on internal functions
+ * unless otherwise indicated. Some of the features that will be changing, is the
+ * support for all of prison's items and blocks, including custom blocks and items.
+ * Also Prison will be adding a very dynamic shop that will allow customization
+ * for each player rank, if desired. Hence why you should be careful when not using
+ * this API class.
+ *
+ *
+ * It is highly suggested to use the exposed functions within this API class.
+ * As such, more have been added to get a variety of different data out of prison.
+ *
*
* @return SellAllUtil - Null if Prison Sellall's disabled.
* */
@@ -460,20 +489,644 @@ public SellAllUtil getPrisonSellAll(){
*
* @param player
* @return
- * */
+ */
+ @Deprecated
public Double getSellAllMoneyWithMultiplier(Player player){
+ Double results = null;
+
- if (sellAll == null){
- sellAll = SpigotPrison.getInstance().getSellAllUtil();
- }
+ if (getPrisonSellAll() != null) {
+
+ double value = 0;
+
+ List soldItems = getPrisonSellAll().sellPlayerItems( player );
+ for (SellAllData soldItem : soldItems) {
+ if ( soldItem != null ) {
+ value += soldItem.getTransactionAmount();
+ }
+ }
+
+// return sellAll.getSellMoney(player);
+ results = value;
+ }
+
+ return results;
+ }
+
+
+
+ /**
+ * This function will use Prison internals to pay a player a given sum of money as specified
+ * by the amount. If the currency is non-standard, then you can also specify it's name as a
+ * String value; otherwise pass a null or an empty String. Example of non-standard currencies
+ * would be alternative currencies setup on ranks.
+ *
+ *
+ * This function will notify the player each time they are paid of the payment amount
+ * (notifyPlayerEarned). It will also play a payment sound (playSoundOnSellAll), the sound can
+ * be changed within the SellAll config file.
+ *
+ *
+ * If you need to delay player notifications, please use the other `payPlayer()` functions.
+ *
+ *
+ * Prison's internals keep track of the player's balance in the Prison's player cache. It
+ * allows for rapid payments to a player, without overwhelming Vault or the Economy plugins.
+ * Some economy plugins will update their database with each hit, which can result in a
+ * serious performance drain on the system, since such I/O is blocking, and if they run those
+ * updates in bukkit's main thread. Since prison is caching the payments, as soon as it
+ * receives a payment, prison starts a count down to make the payment. Any additional payment
+ * made to a player before that count down reaches zero, will be included in the transaction.
+ * Rapid mining can create TONS of transactions per second, so Prison's payment cache is
+ * an important component to help weaker economy plugins from killing the server's TPS.
+ *
+ *
+ * @param player
+ * @param amount
+ * @param currency - If standard, pass null or an empty String
+ */
+ public void payPlayer( Player player, double amount, String currency ) {
+ payPlayer( player, amount, currency, true, false, false, true );
+ }
+
+ /**
+ * This function will use Prison internals to pay a player a given sum of money as specified
+ * by the amount. This function is the same as the other one that is similar, except that it
+ * provides more options such as delayed notifications. Please see the help on the other
+ * `payPlayer()` functions to better understand what they are doing.
+ *
+ *
+ * The payment amount must be greater than zero. If the amount is zero, or less,
+ * then this function will end silently without any notification.
+ *
+ *
+ * This function has additional parameters for controlling player notifications. If they
+ * are all set to false, then no notifications will be sent to the player (completelySilent).
+ *
+ *
+ * 'notifyPlayerEarned': This function will notify the player each time they are paid
+ * of the payment amount (notifyPlayerEarned). It will also play a payment
+ * sound (playSoundOnSellAll), the sound can be changed within the SellAll config file.
+ *
+ *
+ * 'notifyPlayerDelay' & SellAll Delay (cooldown): If the SellAll configuration
+ * `isSellAllDelayEnabled` is set to `true`, then
+ * the player will be subjected to a cooldown for using the sellall command/feature.
+ * If the have tried to sell within the allocated amount of time, then they will get a
+ * message indicating that there is a rate limit in effect for them. They will get
+ * this notification if the parameter 'notifyPlayerDelay' is set to `true`.
+ *
+ *
+ * Please NOTE: This function, `payPlayer()` only activates the cooldown timer and
+ * the player will be paid. What is impacted is the ability to use the functions
+ * `sellAllSell()`... it is then when the rate limit will kick in. If you use the
+ * other function `sellPlayerItems()` or `sellPlayerItemStacks()` then the
+ * cooldown rate limit will be bypassed and will not inhibit any selling.
+ *
+ *
+ * 'notifyPlayerEarningDelay': If in the SellAll config, the option
+ * `isAutoSellEarningNotificationDelayEnabled` is enabled, then this parameter
+ * `notifyPlayerEarningDelay` will then add the amount the player was paid to
+ * a delayed queue which will gather other payments the player receives during the
+ * delayed period. At the end of this delayed period of time, then the player
+ * will get a message indicating the total amount of money that they earned.
+ * This helps to reduce the amount of spam the player will get on line for their
+ * sales. Please NOTE: This does not delay the player from getting paid. If the
+ * delay is set to 15 seconds and they mine 100 times, they will get only one
+ * message with the total amount that they earned; otherwise they would have been
+ * sent 100 messages each time something was sold.
+ *
+ *
+ * `playSoundOnSellAll`: If enabled, then a sound will be played upon a payment
+ * to the player. Please see the SellAll configuration file for changing
+ * the settings for the sound.
+ *
+ *
+ * `completelySilent`: This is a virtual setting that is generated when all four
+ * of these settings are set to false: `notifyPlayerEarned`, `notifyPlayerDelay`,
+ * `notifyPlayerEarningDelay`, and `playSoundOnSellAll`. When enabled, this
+ * basically shuts off all notifications and the player is paid silently in the
+ * background.
+ *
+ * @param player
+ * @param amount
+ * @param currency
+ * @param notifyPlayerEarned
+ * @param notifyPlayerDelay
+ * @param notifyPlayerEarningDelay
+ * @param playSoundOnSellAll
+ */
+ public void payPlayer( Player player, double amount, String currency,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll ) {
+
+ if ( amount > 0 ) {
+
+ boolean completelySilent = notifyPlayerEarned || notifyPlayerDelay || notifyPlayerEarningDelay || playSoundOnSellAll;
+
+ SpigotPlayer sPlayer = new SpigotPlayer( player );
+ RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName());
+
+ currency = currency != null && currency.equalsIgnoreCase("default") ? null : currency;
+
+// if (!sellInputArrayListOnly) {
+// removeSellableItems(p);
+// }
+ rankPlayer.addBalance(currency, amount);
+
+ if ( getPrisonSellAll().isSellAllDelayEnabled ){
+ getPrisonSellAll().addToDelay(player);
+ }
+
+ if (!completelySilent) {
+ if ( getPrisonSellAll().isSellAllSoundEnabled && playSoundOnSellAll) {
+ player.playSound( player.getLocation(), getPrisonSellAll().sellAllSoundSuccess, 3, 1);
+ }
+
+ if (notifyPlayerEarningDelay && getPrisonSellAll().isAutoSellEarningNotificationDelayEnabled){
+ if (!getPrisonSellAll().isPlayerWaitingAutoSellNotification( player )){
+ getPrisonSellAll().addToAutoSellNotificationDelay( player);
+ } else {
+ getPrisonSellAll().addDelayedEarningAutoSellNotification( player, amount );
+ }
+ }
+ else if (notifyPlayerEarned){
+ DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
+ String amt = fFmt.format( amount );
+
+ String message = getPrisonSellAll().sellallAmountEarnedMsg( amt );
+
+// String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt;
+// new SpigotPlayer(p).setActionBar( message );
+ Output.get().send( sPlayer, message );
+
+ }
+ }
+ }
+ }
+
+
+ /**
+ *
This function will use Prison internals to pay a player a given sum of money as specified
+ * by the amount. This function is the same as the other ones with the same name and similar
+ * parameters. This one differs in that you can pass it a List of `SellAllData` transactions
+ * and it will summarize them all, and pass the total amount to the other
+ * `payPlayer()` function. Please see the help on the other
+ * `payPlayer()` functions to better understand what they are doing.
+ *
+ *
+ * @param player
+ * @param itemsSold
+ * @param currency
+ * @param notifyPlayerEarned
+ * @param notifyPlayerDelay
+ * @param notifyPlayerEarningDelay
+ * @param playSoundOnSellAll
+ */
+ public void payPlayer( Player player, List itemsSold, String currency,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll ) {
+ double amount = 0;
+
+ for (SellAllData item : itemsSold) {
+ amount += item.getTransactionAmount();
+ }
+
+ payPlayer(player, amount, currency,
+ notifyPlayerEarned,
+ notifyPlayerDelay, notifyPlayerEarningDelay,
+ playSoundOnSellAll);
+ }
+
+
+ /**
+ * This function will calculate the value of all sellable items within the player's inventory
+ * and provide a total amount that they earned for the sales.
+ * This includes the calculated player's multipliers.
+ *
+ *
+ * @param player
+ * @return
+ */
+ public double getPlayerInventoryValue(Player player) {
+ double results = 0;
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().getPlayerInventoryValue( new SpigotPlayer(player) );
+ }
+
+ return results;
+ }
+
+ /**
+ * This function will calculate the value of the player's inventory that
+ * are sellable and then will generate
+ * a simple report listing everything that can be sold with their values.
+ *
+ *
+ * Nothing is sold. No notifications are sent to the player.
+ *
+ *
+ * See the function
getPlayerInventoryValueTransactions()
to
+ * gain access to the transaction logs for more information.
+ *
+ *
+ * @param player
+ * @return
+ */
+ public String getPlayerInventoryValueReport(Player player) {
+ String results = null;
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().getPlayerInventoryValueReport( new SpigotPlayer(player) );
+ }
+
+ return results;
+ }
+
+ /**
+ * This function calculates the value of the player's inventory items that are salable,
+ * and returns the transaction log within the collection of SellAllData.
+ *
+ *
+ * Nothing is sold. No notifications are sent to the player.
+ *
+ *
+ * To get the total transaction value, add all elements together.
+ * To generate a transaction report use the static function:
+ *
+ * List itemsSold = prisonApi.getPlayerInventoryValueTransactions(Player player);
+ *SellAllData.itemSoldReport( itemsSold );
+ *
+ * @param player
+ * @return transactionLogs
+ */
+ public List getPlayerInventoryValueTransactions(Player player) {
+ List results = new ArrayList<>();
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().getPlayerInventoryValueTransactions( new SpigotPlayer(player) );
+ }
+
+ return results;
+ }
+
+
+ /**
+ * This function will calculate the value of ItemStack
+ * and provide a total amount that would earn for the sales.
+ * This includes the calculated player's multipliers.
+ *
+ *
+ * @param player
+ * @param itemStack
+ * @return
+ */
+ public double getItemStackValue(Player player, ItemStack itemStack ) {
+ double results = 0;
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().getItemStackValue(
+ new SpigotPlayer(player), new SpigotItemStack(itemStack) );
+
+ }
+
+ return results;
+ }
+
+ /**
+ * This function will calculate the value of the ItemStack that
+ * are sellable and then will generate
+ * a simple report listing everything that can be sold with their values.
+ *
+ *
+ * Nothing is sold. No notifications are sent to the player.
+ *
+ *
+ * See the function
getPlayerInventoryValueTransactions()
to
+ * gain access to the transaction logs for more information.
+ *
+ *
+ * @param player
+ * @param itemStack
+ * @return
+ */
+ public String getItemStackValueReport(Player player, ItemStack itemStack ) {
+ String results = null;
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().getItemStackValueReport(
+ new SpigotPlayer(player), new SpigotItemStack(itemStack) );
+
+ }
+
+ return results;
+ }
+
+ /**
+ * This function calculates the value of the ItemStack that are salable,
+ * and returns the transaction log within the collection of SellAllData.
+ *
+ *
+ * Nothing is sold. No notifications are sent to the player.
+ *
+ *
+ * To get the total transaction value, add all elements together.
+ * To generate a transaction report use the static function:
+ *
+ * List itemsSold = prisonApi.getPlayerInventoryValueTransactions(Player player);
+ *SellAllData.itemSoldReport( itemsSold );
+ *
+ * @param player
+ * @param itemStack
+ * @return
+ */
+ public List getItemStackValueTransactions(Player player, ItemStack itemStack ) {
+ List results = new ArrayList<>();
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().getItemStackValueTransactions(
+ new SpigotPlayer(player), new SpigotItemStack(itemStack) );
+
+ }
+
+ return results;
+ }
- if (sellAll != null){
- return sellAll.getSellMoney(player);
+ /**
+ * This function sells anything within the player's inventory that is
+ * sellable. This function returns a transaction log of soldItems that can
+ * be summarized to get the total sales amount.
+ *
+ * WARNING: This function REMOVES items from the player's inventory, but does
+ * NOT pay them any money!! If you are using this function, then
+ * you must sum all of the transactions and pay the player.
+ *
+ *
+ * This is an exposed internal function that provides sellall capabilities without
+ * all of the complexities of the formal `sellAllSell()` functions.
+ * Use at your own risk.
+ *
+ *
+ * This function does not notify the players, does not pay the players,
+ * does not provide all of the bells-and-whistles of customization within the
+ * sellall config files, and is basically a bare-bones sell it if it can be sold
+ * type of function.
+ *
+ *
+ * @param player
+ * @param itemStack
+ * @return
+ */
+ public List sellPlayerItems(Player player ) {
+ List soldItems = new ArrayList<>();
+
+ if (getPrisonSellAll() != null) {
+
+ soldItems = getPrisonSellAll().sellPlayerItems( player );
}
+
+ return soldItems;
+ }
- return null;
+ /**
+ * This function sells anything within the ItemStack List that is
+ * sellable. This function returns a transaction log of soldItems that can
+ * be summarized to get the total sales amount.
+ *
+ * WARNING: This function REMOVES items from the ItemStack that have been
+ * sold, but does NOT pay the player any money!! If you are
+ * using this function, then you must sum all of the
+ * transactions and pay the player.
+ *
+ *
+ * This is an exposed internal function that provides sellall capabilities without
+ * all of the complexities of the formal `sellAllSell()` functions.
+ * Use at your own risk.
+ *
+ *
+ * This function does not notify the players, does not pay the players,
+ * does not provide all of the bells-and-whistles of customization within the
+ * sellall config files, and is basically a bare-bones sell it if it can be sold
+ * type of function.
+ *
+ *
+ * @param player
+ * @param itemStacks
+ * @return
+ */
+ public List sellPlayerItemStacks(Player player, List itemStacks ) {
+ List soldItems = new ArrayList<>();
+
+ if (getPrisonSellAll() != null) {
+
+ List iStacks = new ArrayList<>();
+ for (ItemStack itemStack : itemStacks) {
+ if ( itemStack != null ) {
+ iStacks.add( new SpigotItemStack( itemStack ));
+ }
+ }
+
+ soldItems = getPrisonSellAll().sellPlayerItemStacks( player, iStacks );
+ }
+
+ return soldItems;
}
+
+ /**
+ * This function will remove all sellable items from the player's Inventories. It will first ensure that a
+ * Player can sell the items. Some of the conditions that are checked are, along with some of the behaviors:
+ *
+ *
+ *
+ * - If player has access to use SellAll signs.
+ * - Provide the amount the player earned if this is not disabled.
+ * - If this actions is silenced, then text and audio notifications are suppressed.
-
+ *
- If configured, the reported earnings amount may be delayed and added to other earnings,
+ * which will reduce flooding the player with notifications.
+ * - If sound notifications are enabled, then they will be played.
+ *
+ *
+ *
+ * Default usage of this method:
+ *
+ * sellAllSell(p, false, false, true, true, false, true);
+ *
+ * @param p - Player.
+ * @param isUsingSign - boolean.
+ * @param completelySilent - boolean.
+ * @param notifyPlayerEarned - boolean.
+ * @param notifyPlayerDelay - boolean.
+ * @param notifyPlayerEarningDelay - boolean.
+ * @param playSoundOnSellAll - boolean.
+ *
+ * @return boolean If successful
+ * */
+ public boolean sellAllSell(Player p,
+ boolean isUsingSign,
+ boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll) {
+ boolean results = false;
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().sellAllSell( p,
+ isUsingSign,
+ completelySilent,
+ notifyPlayerEarned,
+ notifyPlayerDelay,
+ notifyPlayerEarningDelay,
+ playSoundOnSellAll,
+ null );
+ }
+
+ return results;
+ }
+
+ /**
+ * Performs a sellall of the player's inventory.
+ *
+ *
+ * @param p
+ * @param isUsingSign
+ * @param completelySilent
+ * @param notifyPlayerEarned
+ * @param notifyPlayerDelay
+ * @param notifyPlayerEarningDelay
+ * @param playSoundOnSellAll
+ * @param amounts
+ * @return
+ */
+ public boolean sellAllSell(Player p,
+ boolean isUsingSign,
+ boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll,
+ List amounts ){
+ boolean results = false;
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().sellAllSell( p,
+ isUsingSign, completelySilent,
+ notifyPlayerEarned, notifyPlayerDelay,
+ notifyPlayerEarningDelay, playSoundOnSellAll,
+ amounts );
+ }
+
+ return results;
+ }
+
+ /**
+ * This function performs the sellall functions over an ItemStack.
+ *
+ *
+ * @param p
+ * @param itemStack
+ * @param completelySilent
+ * @param notifyPlayerEarned
+ * @param notifyPlayerEarningDelay
+ * @return
+ */
+ public double sellAllSell(Player p,
+ SpigotItemStack itemStack,
+ boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerEarningDelay)
+ {
+ double results = 0;
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().sellAllSell( p,
+ itemStack,
+ completelySilent,
+ notifyPlayerEarned,
+ notifyPlayerEarningDelay );
+ }
+
+ return results;
+ }
+
+
+
+ /**
+ * Sell removing items from Inventories and checking all the possible conditions that a Player must meet to sell
+ * items, this includes method parameters like:
+ * - Is using SellAll Sign.
+ * - If tell the Player how much did he earn (if this's disabled by config, the parameter will be ignored).
+ * - If do this action without making the player notice it, disabling sounds and all messages.
+ * - If tell the Player to wait the end of SellAll Delay if not ended (if this's disabled by config, the parameter will be ignored).
+ * - If tell the Player how much did he earn only after a delay (AutoSell Delay Earnings will use this option for example).
+ * - If play sound on SellAll Sell (If sounds are disabled from the config, this parameter will be ignored.
+ * - If Sell only stuff from the input arrayList and not sell what is in the many Player inventories and supported backpacks.
+ *
+ * NOTE: With this method you can add an ArrayList of ItemStacks to sell, remove sold items (this will return the ArrayList without
+ * sold items), and give money to the player, also note that this will also trigger the usual sellall sell and sell everything sellable
+ * from all inventories and enabled backpacks of the Player.
+ *
+ * Return True if success, False if error or nothing changed or Player not meeting requirements.
+ *
+ * Default usage of this method: sellAllSell(p, itemStacks, false, false, true, false, false, true, false);
+ *
+ * @param p - Player.
+ * @param itemStacks - ArrayList of ItemStacks.
+ * @param isUsingSign - boolean.
+ * @param completelySilent - boolean.
+ * @param notifyPlayerEarned - boolean.
+ * @param notifyPlayerDelay - boolean.
+ * @param notifyPlayerEarningDelay - boolean.
+ * @param playSoundOnSellAll - boolean.
+ * @param sellInputArrayListOnly - boolean.
+ *
+ * @return Array of ItemStacks
+ * */
+ public ArrayList sellAllSell(Player p,
+ ArrayList itemStacks,
+ boolean isUsingSign,
+ boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll,
+ boolean sellInputArrayListOnly){
+
+ ArrayList results = new ArrayList<>();
+
+ if (getPrisonSellAll() != null) {
+
+ results = getPrisonSellAll().sellAllSell( p,
+ itemStacks,
+ isUsingSign,
+ completelySilent,
+ notifyPlayerEarned,
+ notifyPlayerDelay,
+ notifyPlayerEarningDelay,
+ playSoundOnSellAll,
+ sellInputArrayListOnly);
+ }
+
+ return results;
+ }
+
+
+
/**
* Gets a player's current token balance.
*
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerBreakBlockTask.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerBreakBlockTask.java
index cf6ef2e0c..5da51a904 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerBreakBlockTask.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerBreakBlockTask.java
@@ -76,13 +76,16 @@ public void run() {
int count = 0;
for ( SpigotBlock spigotBlock : blocks )
{
- if ( count++ % 10 == 0 && mineStateMutexClone != null &&
- !mine.getMineStateMutex().isValidState( mineStateMutexClone ) ) {
- return;
+ if ( spigotBlock != null && !spigotBlock.isEmpty() ) {
+
+ if ( count++ % 10 == 0 && mineStateMutexClone != null &&
+ !mine.getMineStateMutex().isValidState( mineStateMutexClone ) ) {
+ return;
+ }
+
+ spigotBlock.setPrisonBlock( PrisonBlock.AIR );
+
}
-
- spigotBlock.setPrisonBlock( PrisonBlock.AIR );
-
}
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
index 841fbae06..79da13c74 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/AutoManagerFeatures.java
@@ -8,6 +8,7 @@
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
+import java.util.TreeMap;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@@ -17,15 +18,20 @@
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
+import org.bukkit.event.EventException;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.plugin.RegisteredListener;
import com.cryptomorin.xseries.XMaterial;
+import com.vk2gpz.tokenenchant.api.TokenEnchantAPI;
import tech.mcprison.prison.Prison;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
+import tech.mcprison.prison.autofeatures.BlockConverterOptionEventTrigger;
import tech.mcprison.prison.cache.PlayerCache;
import tech.mcprison.prison.internal.block.PrisonBlock;
import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType;
@@ -33,6 +39,8 @@
import tech.mcprison.prison.output.ChatDisplay;
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.output.Output.DebugTarget;
+import tech.mcprison.prison.ranks.PrisonRanks;
+import tech.mcprison.prison.ranks.data.RankPlayer;
import tech.mcprison.prison.spigot.SpigotPrison;
import tech.mcprison.prison.spigot.SpigotUtil;
import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent;
@@ -152,9 +160,20 @@ protected void printDebugInfo( PrisonMinesBlockBreakEvent pmEvent, double start
if ( pmEvent != null && pmEvent.getDebugInfo().length() > 0 ) {
long stop = System.nanoTime();
- pmEvent.getDebugInfo().append( " [" ).append( (stop - start) / 1000000d ).append( " ms]" );
+ pmEvent.getDebugInfo().append( "{br}|| ### ** End Event Debug Info ** ### [" )
+ .append( (stop - start) / 1000000d )
+ .append( " ms]" );
- Output.get().logDebug( DebugTarget.blockBreak, pmEvent.getDebugInfo().toString() );
+ if ( !Output.get().isDebug() && pmEvent.isForceDebugLogging() ) {
+
+ pmEvent.getDebugInfo().insert(0, Output.get().getColorCodeDebug() );
+
+ Output.get().logInfo( pmEvent.getDebugInfo().toString(), pmEvent.getSpigotPlayer() );
+ }
+ else {
+
+ Output.get().logDebug( DebugTarget.blockBreak, pmEvent.getDebugInfo().toString(), pmEvent.getSpigotPlayer() );
+ }
}
}
@@ -236,7 +255,7 @@ protected EventListenerCancelBy processPMBBEvent(PrisonMinesBlockBreakEvent pmEv
if ( pmEvent.getMine() != null || pmEvent.getMine() == null &&
!isBoolean( AutoFeatures.pickupLimitToMines ) ) {
- pmEvent.getDebugInfo().append( "(normal processing initiating) " );
+ pmEvent.getDebugInfo().append( "(Fire pmEvent) " );
// Set the mine's PrisonBlockTypes for the block. Used to identify custom blocks.
// Needed since processing of the block will lose track of which mine it came from.
@@ -256,8 +275,11 @@ protected EventListenerCancelBy processPMBBEvent(PrisonMinesBlockBreakEvent pmEv
// pmEvent.getMine(), sBlock, explodedBlocks, BlockEventType.blockBreak, triggered );
Bukkit.getServer().getPluginManager().callEvent( pmEvent );
if ( pmEvent.isCancelled() ) {
+
+ pmEvent.setDebugColorCodeWarning();
pmEvent.getDebugInfo().append(
- "(normal processing: PrisonMinesBlockBreakEvent was canceled by another plugin!) " );
+ "(Fire pmEvent: PrisonMinesBlockBreakEvent was canceled by another plugin!) " );
+ pmEvent.setDebugColorCodeDebug();
}
else {
@@ -287,17 +309,19 @@ protected EventListenerCancelBy processPMBBEvent(PrisonMinesBlockBreakEvent pmEv
}
else {
- pmEvent.getDebugInfo().append( "(doAction failed without details) " );
+ pmEvent.setDebugColorCodeWarning();
+ pmEvent.getDebugInfo().append( "(fire pmEvent:doAction failed without details) " );
+ pmEvent.setDebugColorCodeDebug();
}
}
- pmEvent.getDebugInfo().append( "(normal processing completed) " );
+ pmEvent.getDebugInfo().append( "(Fire pmEvent completed) " );
}
else {
- pmEvent.getDebugInfo().append( "(logic bypass) " );
+ pmEvent.getDebugInfo().append( "(Fire pmEvent bypassed) " );
}
return cancelBy;
}
@@ -359,15 +383,35 @@ protected boolean hasFortune(SpigotItemStack itemInHand){
return results;
}
- protected short getFortune(SpigotItemStack itemInHand, StringBuilder debugInfo ){
- short fortLevel = (short) 0;
+ protected int getFortune(SpigotItemStack itemInHand, StringBuilder debugInfo ){
+ int fortLevel = 0;
+ boolean usedTEFortune = false;
+
+ if ( isBoolean( AutoFeatures.isUseTokenEnchantsFortuneLevel ) &&
+ itemInHand != null &&
+ itemInHand.getBukkitStack() != null ) {
+
+ try {
+ if ( TokenEnchantAPI.getInstance() != null ) {
+
+ fortLevel = TokenEnchantAPI.getInstance().getEnchantments( itemInHand.getBukkitStack() )
+ .get( TokenEnchantAPI.getInstance().getEnchantment("Fortune"));
+
+ usedTEFortune = true;
+ }
+ }
+ catch ( Exception e ) {
+ // ignore: could not use TE.
+ }
+ }
try {
- if ( itemInHand != null &&
+ if ( !usedTEFortune &&
+ itemInHand != null &&
itemInHand.getBukkitStack() != null &&
itemInHand.getBukkitStack().containsEnchantment( Enchantment.LOOT_BONUS_BLOCKS ) &&
itemInHand.getBukkitStack().getEnchantments() != null ) {
- fortLevel = (short) itemInHand.getBukkitStack().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS);
+ fortLevel = itemInHand.getBukkitStack().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS);
}
}
catch ( NullPointerException e ) {
@@ -375,14 +419,14 @@ protected short getFortune(SpigotItemStack itemInHand, StringBuilder debugInfo )
// It throws this exception: Caused by: java.lang.NullPointerException: null key in entry: null=5
}
- short results = (short) fortLevel;
+ int results = fortLevel;
// DecimalFormat dFmt = new DecimalFormat( "#,##0.0000" );
DecimalFormat iFmt = new DecimalFormat( "#,##0" );
int maxFortuneLevel = getInteger( AutoFeatures.fortuneMultiplierMax );
String maxFort = "";
if ( maxFortuneLevel > 0 && fortLevel > maxFortuneLevel ) {
- results = (short) maxFortuneLevel;
+ results = maxFortuneLevel;
maxFort = String.format(" max=%s result=%s",
iFmt.format( maxFortuneLevel ),
iFmt.format( results ));
@@ -470,12 +514,13 @@ private int applyAutoEventsDetails( PrisonMinesBlockBreakEvent pmEvent ) {
boolean loreSmelt = isLoreEnabled && checkLore( itemInHand, getMessage( AutoFeatures.loreSmeltValue) );
boolean loreBlock = isLoreEnabled && checkLore( itemInHand, getMessage( AutoFeatures.loreBlockValue ) );
- boolean permPickup = player.isPermissionSet( getMessage( AutoFeatures.permissionAutoPickup ));
- boolean permSmelt = player.isPermissionSet( getMessage( AutoFeatures.permissionAutoSmelt ));
- boolean permBlock = player.isPermissionSet( getMessage( AutoFeatures.permissionAutoBlock ));
-
boolean isAutoFeaturesEnabled = isBoolean( AutoFeatures.isAutoFeaturesEnabled );
+ boolean permPickup = isAutoFeaturesEnabled && player.isPermissionSet( getMessage( AutoFeatures.permissionAutoPickup ));
+ boolean permSmelt = isAutoFeaturesEnabled && player.isPermissionSet( getMessage( AutoFeatures.permissionAutoSmelt ));
+ boolean permBlock = isAutoFeaturesEnabled && player.isPermissionSet( getMessage( AutoFeatures.permissionAutoBlock ));
+
+
boolean configPickup = isAutoFeaturesEnabled && isBoolean( AutoFeatures.autoPickupEnabled );
boolean configSmelt = isAutoFeaturesEnabled && isBoolean( AutoFeatures.autoSmeltEnabled );
boolean configBlock = isAutoFeaturesEnabled && isBoolean( AutoFeatures.autoBlockEnabled );
@@ -504,11 +549,16 @@ private int applyAutoEventsDetails( PrisonMinesBlockBreakEvent pmEvent ) {
if ( Output.get().isDebug( DebugTarget.blockBreak ) ) {
- pmEvent.getDebugInfo().append( "(applyAutoEvents: " )
+ pmEvent.getDebugInfo().append( "{br}|| (applyAutoEvents: " )
.append( pmEvent.getSpigotBlock().getBlockName() );
if ( !isAutoFeaturesEnabled ) {
- pmEvent.getDebugInfo().append("isAutoFeaturesEnabled=false (disabled)");
+ pmEvent.getDebugInfo().append(" isAutoFeaturesEnabled=false (");
+
+ pmEvent.getDebugInfo().append( Output.get().getColorCodeError() );
+ pmEvent.getDebugInfo().append("disabled");
+ pmEvent.getDebugInfo().append( Output.get().getColorCodeDebug() );
+ pmEvent.getDebugInfo().append(")");
}
else {
@@ -563,7 +613,7 @@ private int applyAutoEventsDetails( PrisonMinesBlockBreakEvent pmEvent ) {
if ( configNormalDrop ) {
pmEvent.getDebugInfo()
- .append( "(NormalDrop handling enabled: " )
+ .append( "{br}|| (NormalDrop handling enabled: " )
.append( "normalDropSmelt[" )
.append( configNormalDropSmelt ? "enabled" : "disabled" )
.append( "] " )
@@ -755,7 +805,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
.append( amt );
if ( amt != amtBukkit ) {
sItemStack.setAmount( amt );
- sb.append( "(").append( amtBukkit ).append( ")" );
+ sb.append( "(bukkitAmt:").append( amtBukkit ).append( ")" );
}
}
if ( bukkitDropsMultiplier != 1.0d ) {
@@ -764,7 +814,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
sb.insert( 0, "bukkitDropMult=" );
}
- debugInfo.append( "[autoPickupDrops:: " ).append( sb ).append( "] ");
+ debugInfo.append( " [autoPickupDrops:beforeFortune:: " ).append( sb ).append( "] ");
@@ -779,15 +829,24 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
// Add fortune to the items in the inventory
if ( isBoolean( AutoFeatures.isCalculateFortuneEnabled ) ) {
- short fortuneLevel = getFortune(itemInHand, debugInfo );
+ sb.setLength(0);
+ int fortuneLevel = getFortune(itemInHand, debugInfo );
// debugInfo.append( "(calculateFortune: fort " + fortuneLevel + ")" );
for ( SpigotItemStack itemStack : drops ) {
+ if ( sb.length() > 0 ) {
+ sb.append( "," );
+ }
// calculateFortune directly modifies the quantity on the blocks ItemStack:
calculateFortune( itemStack, fortuneLevel, pmEvent.getDebugInfo() );
+
+ sb.append( itemStack.getName() )
+ .append( ":" )
+ .append( itemStack.getAmount() );
}
+ debugInfo.append( " [totalDrops:afterFortune:: " ).append( sb ).append( "] ");
}
@@ -798,14 +857,14 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
// Smelt
if ( isAutoSmelt ) {
- debugInfo.append( "(autoSmelting: itemStacks)" );
+ debugInfo.append( "(autoSmelting: drops)" );
normalDropSmelt( drops );
}
// Block
if ( isAutoBlock ) {
- debugInfo.append( "(autoBlocking: itemStacks)" );
+ debugInfo.append( "(autoBlocking: drops)" );
normalDropBlock( drops );
}
@@ -831,29 +890,70 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
boolean isSellallEnabled = SpigotPrison.getInstance().isSellAllEnabled();
- // This is true if the player cannot toggle the autosell, and it's
- // true if they can, and the have it enabled:
- boolean isPlayerAutosellEnabled = isSellallEnabled &&
- SellAllUtil.get() != null &&
- SellAllUtil.get().checkIfPlayerAutosellIsActive(
- pmEvent.getSpigotPlayer().getWrapper() )
- ;
+// boolean isPlayerAutoSellTurnedOff = SellAllUtil.get().isAutoSellPerUserToggleable &&
+// !SellAllUtil.get().isSellallPlayerUserToggleEnabled(
+// pmEvent.getSpigotPlayer().getWrapper() );
+//
+// if ( isPlayerAutoSellTurnedOff ) {
+// debugInfo.append( Output.get().getColorCodeWarning() );
+// debugInfo.append( "(Player toggled off autosell) " );
+// debugInfo.append( Output.get().getColorCodeDebug() );
+// }
+//
+// // This will return true (allow autosell) unless players can toggle autosell and they turned it off:
+// // This is to be used with other auto sell setting, but never on it's own:
+// boolean isPlayerAutosellEnabled =
+// isSellallEnabled &&
+// (!SellAllUtil.get().isAutoSellPerUserToggleable ||
+// SellAllUtil.get().isSellallPlayerUserToggleEnabled(
+// pmEvent.getSpigotPlayer().getWrapper() ));
+
+ boolean isPlayerAutosellEnabled = pmEvent.getSpigotPlayer().isAutoSellEnabled( pmEvent.getDebugInfo() );
+
+
+ // In the event, forceAutoSell is enabled, which means the drops must be sold.
+ // The player's toggle cannot disable this.
+ boolean forceAutoSell = isSellallEnabled && pmEvent.isForceAutoSell();
+
+
+ // AutoFeature's autosell per block break - global setting
+ boolean autoSellBySettings =
+ isPlayerAutosellEnabled &&
+ isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled);
+
+ // AutoFeature's autosell per block break - per player perms setting
+// boolean autoSellByPerm =
+// isPlayerAutosellEnabled &&
+// !player.isOp() &&
+// isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) &&
+// !"disable".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) &&
+// !"false".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) &&
+// player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) );
+
+ boolean autoSellByPerm = pmEvent.getSpigotPlayer().isAutoSellByPermEnabled( isPlayerAutosellEnabled );
+
+
+ // Try to autosell if enabled in any of the following ways:
+ boolean autoSell = ( forceAutoSell || autoSellBySettings || autoSellByPerm );
for ( SpigotItemStack itemStack : drops ) {
count += itemStack.getAmount();
- // Try to autosell if enabled:
- if ( isSellallEnabled &&
-
- (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) &&
- isPlayerAutosellEnabled ||
- pmEvent.isForceAutoSell() ||
- !player.isOp() && !"disable".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) &&
- player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) &&
- isPlayerAutosellEnabled ) {
+ // Try to autosell if enabled in any of the following ways:
+ if ( autoSell ) {
+
+// // Try to autosell if enabled:
+// if ( isSellallEnabled &&
+//
+// (isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) &&
+// isPlayerAutosellEnabled ||
+// pmEvent.isForceAutoSell() ||
+// !player.isOp() && !"disable".equalsIgnoreCase( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) ) &&
+// player.hasPermission( getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled ) )) &&
+// isPlayerAutosellEnabled ) {
final long nanoStart = System.nanoTime();
double amount = SellAllUtil.get().sellAllSell( player, itemStack, false, false, true );
@@ -875,7 +975,9 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
else {
// Unable to sell since amount was zero. Not configured to be sold.
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "(unsellable: " + itemStack.getName() + " qty: " + itemStack.getAmount() + ") ");
+ pmEvent.setDebugColorCodeDebug();
autosellUnsellableCount += itemStack.getAmount();
}
@@ -887,13 +989,39 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
// it will have an amount of more than 0.
if ( itemStack.getAmount() > 0 ) {
+
+ // AutoSell failure... some items may be unsellable due to not being setup in the sellall shop:
+ if ( forceAutoSell || autoSellBySettings || autoSellByPerm ) {
+
+ // Force debug printing for this entry even if debug mode is turned off:
+ pmEvent.setForceDebugLogging( true );
+
+ if ( !Output.get().isDebug() &&
+ isBoolean(AutoFeatures.isAutoSellLeftoversForceDebugLogging) ) {
+ pmEvent.setForceDebugLogging( true );
+ }
+
+ pmEvent.setDebugColorCodeError();
+
+ // Just get the calculated value for the drops... do not sell:
+ double amount = SellAllUtil.get().getItemStackValue( pmEvent.getSpigotPlayer(), itemStack );
+ autosellTotal += amount;
+
+ debugInfo.append( "{br}|| (WARNING: autosell leftovers: " + itemStack.getName() +
+ " qty: " + itemStack.getAmount() + " value: " + dFmt.format( amount ) +
+ " - " +
+ ( amount == 0 ? " Items NOT in sellall shop!" : " CouldNotSell?") +
+ ") ");
+ pmEvent.setDebugColorCodeDebug();
+ }
+
if ( Output.get().isDebug() && isSellallEnabled ) {
// Just get the calculated value for the drops... do not sell:
- double amount = SellAllUtil.get().getSellMoney( player, itemStack );
+ double amount = SellAllUtil.get().getItemStackValue( pmEvent.getSpigotPlayer(), itemStack );
autosellTotal += amount;
- debugInfo.append( "(Debug-unsold-value-check: " + itemStack.getName() +
+ debugInfo.append( " (Debug-unsold-value-check: " + itemStack.getName() +
" qty: " + itemStack.getAmount() + " value: " + dFmt.format( amount ) + ") ");
}
@@ -920,7 +1048,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
// }
- dropExtra( extras, player, debugInfo );
+ dropExtra( extras, player, debugInfo, autoSell );
// dropExtra( player.getInventory().addItem(itemStack), player, block );
}
@@ -929,7 +1057,7 @@ protected int autoPickup( PrisonMinesBlockBreakEvent pmEvent,
if ( count > 0 || autosellTotal > 0 ) {
- debugInfo.append( "[autoPickupDrops total: qty: " + count + " value: " + dFmt.format( autosellTotal ) +
+ debugInfo.append( "{br}|| [autoPickupDrops total: qty: " + count + " value: " + dFmt.format( autosellTotal ) +
" unsellableCount: " + autosellUnsellableCount );
if ( nanoTime > 0 ) {
@@ -1012,11 +1140,11 @@ public int calculateNormalDrop( PrisonMinesBlockBreakEvent pmEvent ) {
sb.insert( 0, "bukkitDropMult=" );
}
- pmEvent.getDebugInfo().append( "[normalDrops:: " ).append( sb ).append( "] ");
+ pmEvent.getDebugInfo().append( "{br}|| [normalDrops:: " ).append( sb ).append( "] ");
// Need better drop calculation that is not using the getDrops function.
- short fortuneLevel = getFortune( pmEvent.getItemInHand(), pmEvent.getDebugInfo() );
+ int fortuneLevel = getFortune( pmEvent.getItemInHand(), pmEvent.getDebugInfo() );
// calculateSilkTouch( pmEvent.getItemInHand(), drops );
@@ -1040,13 +1168,13 @@ public int calculateNormalDrop( PrisonMinesBlockBreakEvent pmEvent ) {
if ( isBoolean( AutoFeatures.normalDropSmelt ) ) {
- pmEvent.getDebugInfo().append( "(normSmelting: itemStacks)" );
+ pmEvent.getDebugInfo().append( "(normSmelting: drops)" );
normalDropSmelt( drops );
}
if ( isBoolean( AutoFeatures.normalDropBlock ) ) {
- pmEvent.getDebugInfo().append( "(normBlocking: itemStacks)" );
+ pmEvent.getDebugInfo().append( "(normBlocking: drops)" );
normalDropBlock( drops );
}
@@ -1063,6 +1191,7 @@ public int calculateNormalDrop( PrisonMinesBlockBreakEvent pmEvent ) {
// }
+// pmEvent.getDebugInfo().append( "{br}|| " );
double autosellTotal = 0;
@@ -1072,7 +1201,7 @@ public int calculateNormalDrop( PrisonMinesBlockBreakEvent pmEvent ) {
count += itemStack.getAmount();
// Since this is not auto pickup, then only autosell if set in the pmEvent:
- if ( pmEvent.isForceAutoSell() && SellAllUtil.get() != null ) {
+ if ( pmEvent.isForceAutoSell() && SpigotPrison.getInstance().isSellAllEnabled() ) {
Player player = pmEvent.getPlayer();
@@ -1097,7 +1226,7 @@ public int calculateNormalDrop( PrisonMinesBlockBreakEvent pmEvent ) {
pmEvent.getDebugInfo().append( "(dropping: " + itemStack.getName() + " qty: " + itemStack.getAmount() );
- if ( SellAllUtil.get() != null ) {
+ if ( SpigotPrison.getInstance().isSellAllEnabled() ) {
double amount = SellAllUtil.get().sellAllSell( player, itemStack, true, false, false );
autosellTotal += amount;
@@ -1115,7 +1244,7 @@ public int calculateNormalDrop( PrisonMinesBlockBreakEvent pmEvent ) {
if ( count > 0 || autosellTotal > 0 ) {
- pmEvent.getDebugInfo().append( "[normalDrops total: qty: " + count + " value: " + autosellTotal + ") ");
+ pmEvent.getDebugInfo().append( "{br}|| [normalDrops total: qty: " + count + " value: " + autosellTotal + "] ");
}
@@ -1316,7 +1445,8 @@ protected boolean checkLore( SpigotItemStack itemInHand, String loreValue ) {
* @param player
* @param block
*/
- protected void dropExtra( HashMap extra, Player player, StringBuilder debugInfo ) {
+ protected void dropExtra( HashMap extra,
+ Player player, StringBuilder debugInfo, boolean autoSell ) {
if ( SpigotPrison.getInstance().isSellAllEnabled() && (
extra != null && extra.size() > 0 ||
@@ -1326,17 +1456,39 @@ protected void dropExtra( HashMap extra, Player player
// if ( SpigotPrison.getInstance().isSellAllEnabled() )
{
+ SpigotPlayer sPlayer = new SpigotPlayer( player );
+
+ boolean isPlayerAutosellEnabled = sPlayer.isAutoSellEnabled( debugInfo );
+
+ boolean isPlayerAutoSellByPerm = sPlayer.isAutoSellByPermEnabled( isPlayerAutosellEnabled );
+
+ if ( isPlayerAutosellEnabled || isPlayerAutoSellByPerm ) {
+
+ SellAllUtil sellAllUtil = SellAllUtil.get();
- SellAllUtil sellAllUtil = SellAllUtil.get();
+// boolean isSellallEnabled = sellAllUtil != null &&
+// SpigotPrison.getInstance().isSellAllEnabled();
+//
+// // This will return true (allow autosell) unless players can toggle autosell and they turned it off:
+// // This is to be used with other auto sell setting, but never on it's own:
+// boolean isPlayerAutosellEnabled =
+// isSellallEnabled &&
+// (!sellAllUtil.isAutoSellPerUserToggleable ||
+// sellAllUtil.isSellallPlayerUserToggleEnabled(
+// player ));
+
+
- // On inventory is full, will auto sell if auto sell is enabled in either
- // the sellall configs, or the auto feature configs.
- if (sellAllUtil != null && (
- sellAllUtil.isAutoSellEnabled ||
- isBoolean(AutoFeatures.isAutoSellIfInventoryIsFull) )) {
+// // On inventory is full, will auto sell if auto sell is enabled in either
+// // the sellall configs, or the auto feature configs.
+// if (sellAllUtil != null && (
+// sellAllUtil.isAutoSellEnabled ||
+// autoSell )) {
+//// isBoolean(AutoFeatures.isAutoSellIfInventoryIsFull) )) {
- if ( sellAllUtil.checkIfPlayerAutosellIsActive(player) ) {
+ // if ( isPlayerAutosellEnabled )
+ {
boolean saNote = sellAllUtil.isAutoSellNotificationEnabled;
@@ -1387,7 +1539,7 @@ protected void dropExtra( HashMap extra, Player player
debugInfo.append( " ] " );
- SpigotPlayer sPlayer = new SpigotPlayer( player );
+ //SpigotPlayer sPlayer = new SpigotPlayer( player );
PlayerAutoRankupTask.autoSubmitPlayerRankupTask( sPlayer, debugInfo );
}
@@ -2592,7 +2744,48 @@ else if (
);
debugInfo.append( msg );
}
+
+ else if ( isBoolean( AutoFeatures.isPercentGradientFortuneEnabled ) ) {
+
+ int bonusBlocks = 0;
+ double rnd = 1.0;
+
+ double maxFortune = getInteger( AutoFeatures.percentGradientFortuneMaxFortuneLevel );
+ int maxBonusBlocks = getInteger( AutoFeatures.percentGradientFortuneMaxBonusBlocks );
+ double minPctRnd = getDouble( AutoFeatures.percentGradientFortuneMinPercentRandomness );
+
+ double fortLevel = fortuneLevelOriginal > maxFortune ? maxFortune : fortuneLevelOriginal;
+ if ( maxFortune > 0 && maxBonusBlocks > 1 ) {
+
+ minPctRnd =
+ minPctRnd < 0.0 ? 0.0 :
+ minPctRnd > 100.00 ? 99.0 : minPctRnd;
+
+ rnd = ((1.0 - (minPctRnd / 100)) * getRandom().nextDouble()) + (minPctRnd / 100);
+
+
+ bonusBlocks = (int) Math.round( ( fortLevel / maxFortune ) * maxBonusBlocks );
+
+ bonusBlocks *= rnd;
+ }
+
+ // The count has the final value so set it as the amount:
+ blocks.setAmount( 1 + bonusBlocks );
+
+ String msg = String.format(
+ "(gradientFortune blocks: 1 + bonusBlocks=%s == (fortLevel=%s / maxFortLevel=%s) * "
+ + "maxBonusBlocks=%s * rnd=%s [with minPctRnd=%s]) ",
+ iFmt.format( bonusBlocks ),
+ iFmt.format( fortLevel ),
+ iFmt.format( maxFortune ),
+ iFmt.format( maxBonusBlocks ),
+ dFmt.format( rnd ),
+ dFmt.format( minPctRnd )
+ );
+
+ debugInfo.append( msg );
+ }
}
}
@@ -3075,6 +3268,190 @@ private List calculateDropAdditionsGravelFlint(SpigotItemStack
return adds;
}
+ public boolean checkBlockConverterEventTrigger(PrisonMinesBlockBreakEvent pmEvent, BlockBreakEvent event ) {
+ boolean terminate = false;
+
+ long start = System.currentTimeMillis();
+
+ SpigotPlayer sPlayer = pmEvent.getSpigotPlayer();
+// RankPlayer rPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer( pmEvent.getSpigotPlayer() );
+ String blockName = pmEvent.getSpigotBlock().getBlockName();
+
+ List eventTriggers =
+ AutoFeaturesWrapper.getBlockConvertersInstance().findEventTrigger( sPlayer, blockName );
+
+ if ( eventTriggers != null ) {
+ StringBuilder sb = new StringBuilder();
+
+ for (BlockConverterOptionEventTrigger eventTrigger : eventTriggers) {
+ RegisteredListener listener = null;
+
+ if ( eventTrigger.getExternalResource() == null ) {
+ // Try to hook in to the external resource (the plugin listener):
+ // Adding this listener to the eventTrigger will be like a cache:
+
+ listener = findBlockBreakEventListener(
+ eventTrigger.getEventPluginName(),
+ eventTrigger.getEventPluginPriority(),
+ eventTrigger.getEventPluginClassName() );
+
+ if ( listener != null ) {
+ eventTrigger.setExternalResource( listener );
+ }
+ }
+
+ if ( listener == null && eventTrigger.getExternalResource() != null ) {
+
+ listener = (RegisteredListener) eventTrigger.getExternalResource();
+ }
+
+ if ( listener != null ) {
+
+ try {
+
+ if ( sb.length() > 0 ) {
+ sb.append( " " );
+ }
+ sb.append( eventTrigger.getEventPluginName() );
+
+ // This is where the magic happens... triggers the event listener:
+ listener.callEvent( event );
+
+ if ( !eventTrigger.isAllowPrisonToProccessDrops() ) {
+ terminate = true;
+ }
+
+ if ( eventTrigger.isRemoveBlockWithoutDrops() ) {
+ pmEvent.setForceBlockRemoval( true );
+ pmEvent.setBbPriority( BlockBreakPriority.MONITOR );
+
+ finalizeBreakTheBlocks( pmEvent, pmEvent.getSpigotBlock(), pmEvent.getTargetBlock() );
+ }
+ }
+ catch (EventException e) {
+ }
+ }
+
+ }
+
+ long stop = System.currentTimeMillis();
+ double durationMs = (stop - start) / 1_000_000.0d;
+
+ DecimalFormat dFmt = new DecimalFormat( "#,##0.000" );
+
+ String msg = String.format(
+ "(BlockConverter eventTrigger: %s : %s ms) ",
+ sb,
+ dFmt.format( durationMs ) );
+ pmEvent.getDebugInfo().append( msg );
+ }
+
+ return terminate;
+ }
+
+
+ public void removeBlockForTriggerEvent( PrisonMinesBlockBreakEvent pmEvent) {
+
+ finalizeBreakTheBlocks( pmEvent );
+
+ }
+
+ public void removeEventTriggerBlocksFromExplosions( PrisonMinesBlockBreakEvent pmEvent ) {
+
+ if ( pmEvent.getUnprocessedRawBlocks().size() > 0 &&
+ AutoFeaturesWrapper.getBlockConvertersInstance().getEventTriggerBlockNames().size() > 0 ) {
+
+ long start = System.currentTimeMillis();
+
+// RankPlayer rPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer( pmEvent.getSpigotPlayer() );
+
+
+ TreeMap blockCounts = new TreeMap<>();
+
+ List blockNamesToRemove = AutoFeaturesWrapper.getBlockConvertersInstance().getEventTriggerBlockNames();
+ List removeBlocks = new ArrayList<>();
+
+ for (Block block : pmEvent.getUnprocessedRawBlocks()) {
+ SpigotBlock sBlock = SpigotBlock.getSpigotBlock( block );
+ String blockName = sBlock.getBlockName().toLowerCase();
+
+ if ( blockNamesToRemove.contains( blockName ) ) {
+ removeBlocks.add( block );
+
+ if ( !blockCounts.containsKey(blockName) ) {
+ blockCounts.put( blockName, 1 );
+ }
+ else {
+ int count = blockCounts.get( blockName );
+ blockCounts.put( blockName, ++count );
+ }
+ }
+ }
+
+ if ( removeBlocks.size() > 0 ) {
+ pmEvent.getUnprocessedRawBlocks().removeAll( removeBlocks );
+
+
+// if ( eventTrigger.isRemoveBlockWithoutDrops() ) {
+//// pmEvent.setForceBlockRemoval( true );
+//// pmEvent.setBbPriority( BlockBreakPriority.MONITOR );
+//
+// finalizeBreakTheBlocks( pmEvent, pmEvent.getSpigotBlock(), pmEvent.getTargetBlock() );
+// }
+ }
+
+
+ long stop = System.currentTimeMillis();
+ double durationMs = (stop - start) / 1_000_000.0d;
+
+
+ // Log if blocks were removed, or if duration is >= 0.5:
+ if ( blockCounts.size() > 0 || durationMs > 0.5 ) {
+
+ StringBuilder sb = new StringBuilder();
+
+ Set keys = blockCounts.keySet();
+ for (String key : keys) {
+ if ( sb.length() > 0 ) {
+ sb.append(",");
+ }
+ sb.append( key ).append( ":" ).append( blockCounts.get(key).toString() );
+ }
+
+ if ( sb.length() == 0 ) {
+ sb.append( "none" );
+ }
+ DecimalFormat dFmt = new DecimalFormat( "#,##0.000" );
+
+ String msg = String.format(
+ "(BlockConverter eventTrigger: blocks removed: [%s] %s ms) ",
+ sb,
+ dFmt.format( durationMs ) );
+ pmEvent.getDebugInfo().append( msg );
+ }
+
+ }
+
+ }
+
+ private RegisteredListener findBlockBreakEventListener( String plugin, String priority, String className ) {
+ RegisteredListener results = null;
+
+ for ( RegisteredListener listener : BlockBreakEvent.getHandlerList().getRegisteredListeners() ) {
+
+ if ( plugin.equalsIgnoreCase( listener.getPlugin().getName() ) &&
+ priority.equalsIgnoreCase( listener.getPriority().name() ) &&
+ listener.getListener().getClass().getName().endsWith( className )
+ ) {
+
+ results = listener;
+ break;
+ }
+
+ }
+ return results;
+ }
+
public Random getRandom() {
return random;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerBlockBreakEvents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerBlockBreakEvents.java
index 55dd38947..c5726ea9f 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerBlockBreakEvents.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerBlockBreakEvents.java
@@ -1,5 +1,7 @@
package tech.mcprison.prison.spigot.autofeatures.events;
+import java.util.TreeSet;
+
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -12,6 +14,7 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.EventExecutor;
import org.bukkit.plugin.PluginManager;
+import org.bukkit.scheduler.BukkitRunnable;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
@@ -21,6 +24,7 @@
import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent;
import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures;
import tech.mcprison.prison.spigot.block.BlockBreakPriority;
+import tech.mcprison.prison.spigot.game.SpigotPlayer;
public class AutoManagerBlockBreakEvents
@@ -29,11 +33,19 @@ public class AutoManagerBlockBreakEvents
{
private BlockBreakPriority bbPriority;
+
+ private TreeSet delayedSellallPlayers;
+
+
public AutoManagerBlockBreakEvents() {
super();
+
+ this.delayedSellallPlayers = new TreeSet<>();
}
public AutoManagerBlockBreakEvents( BlockBreakPriority bbPriority ) {
super();
+
+ this.delayedSellallPlayers = new TreeSet<>();
this.bbPriority = bbPriority;
}
@@ -49,7 +61,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
@@ -272,7 +287,7 @@ private void handleBlockBreakEvent( BlockBreakEvent e, BlockBreakPriority bbPrio
StringBuilder debugInfo = new StringBuilder();
- debugInfo.append( String.format( "&9### ** handleBlockBreakEvent ** ### " +
+ debugInfo.append( String.format( "### ** handleBlockBreakEvent ** ### " +
"(event: BlockBreakEvent, config: %s, priority: %s, canceled: %s) ",
bbPriority.name(),
bbPriority.getBukkitEventPriority().name(),
@@ -281,6 +296,8 @@ private void handleBlockBreakEvent( BlockBreakEvent e, BlockBreakPriority bbPrio
debugInfo.append( eventResults.getDebugInfo() );
+
+
// Process all priorities if the event has not been canceled, and
// process the MONITOR priority even if the event was canceled:
if ( !bbPriority.isMonitor() && !e.isCancelled() ||
@@ -318,6 +335,22 @@ private void handleBlockBreakEvent( BlockBreakEvent e, BlockBreakPriority bbPrio
return;
}
+
+ // Check for BlockConverters Event Triggers:
+ // If this function returns a true, then the event should be canceled so no other plugins
+ // process the block after the triggered plugin has processed it.
+ // If the eventTrigger is marked to remove block without drops, then the
+ // block break event priority will be set to MONITOR and will force the
+ // block to be removed by prison.
+ if ( checkBlockConverterEventTrigger( pmEvent, e ) ) {
+
+ e.setCancelled( true );
+
+// printDebugInfo( pmEvent, start );
+// return;
+ }
+
+
// Validate the event.
if ( !validateEvent( pmEvent ) ) {
@@ -338,6 +371,14 @@ private void handleBlockBreakEvent( BlockBreakEvent e, BlockBreakPriority bbPrio
else if ( pmEvent.getBbPriority().isMonitor() ) {
// Stop here, and prevent additional processing.
// Monitors should never process the event beyond this.
+
+ // NOTE: BlockConverters EventTriggers will force processing to MONITOR
+ // plus require the block to be removed with no drops with
+ // no block events.
+ if ( pmEvent.isForceBlockRemoval() ) {
+
+ finalizeBreakTheBlocks( pmEvent );
+ }
}
@@ -460,16 +501,76 @@ else if ( cancelBy == EventListenerCancelBy.drops ) {
// debugInfo.append( "(logic bypass) " );
// }
+
+ boolean isPlayerAutosellEnabled = pmEvent.getSpigotPlayer().isAutoSellEnabled( pmEvent.getDebugInfo() );
+
+
+// // In the event, forceAutoSell is enabled, which means the drops must be sold.
+// // The player's toggle cannot disable this.
+// boolean forceAutoSell = isSellallEnabled && pmEvent.isForceAutoSell();
+//
+
+// // AutoFeature's autosell per block break - global setting
+// boolean autoSellBySettings =
+// isPlayerAutosellEnabled &&
+// isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled);
+
+
+ boolean isPlayerAutoSellByPerm = pmEvent.getSpigotPlayer().isAutoSellByPermEnabled( isPlayerAutosellEnabled );
+
+
+
+
+ if ( isBoolean( AutoFeatures.isForceSellAllOnInventoryWhenBukkitBlockBreakEventFires ) &&
+ ( isPlayerAutosellEnabled || isPlayerAutoSellByPerm )) {
+
+ pmEvent.getDebugInfo().append( Output.get().getColorCodeWarning());
+ pmEvent.performSellAllOnPlayerInventoryLogged( "FORCED BlockBreakEvent sellall");
+ pmEvent.getDebugInfo().append( Output.get().getColorCodeDebug());
+ }
+
+ if ( isBoolean( AutoFeatures.isEnabledDelayedSellAllOnInventoryWhenBukkitBlockBreakEventFires ) &&
+ ( isPlayerAutosellEnabled || isPlayerAutoSellByPerm ) ) {
+
+ if ( !getDelayedSellallPlayers().contains( pmEvent.getSpigotPlayer() ) ) {
+
+ getDelayedSellallPlayers().add( pmEvent.getSpigotPlayer() );
+
+ int ticks = getInteger( AutoFeatures.isEnabledDelayedSellAllOnInventoryDelayInTicks );
+
+ pmEvent.getDebugInfo().append( Output.get().getColorCodeError());
+ pmEvent.getDebugInfo().append( "(BlockBreakEvent delayed sellall submitted: no details available, see sellall debug info) " );
+ pmEvent.getDebugInfo().append( Output.get().getColorCodeDebug());
+
+ final PrisonMinesBlockBreakEvent pmEventFinal = pmEvent;
+
+ new BukkitRunnable() {
+ @Override
+ public void run() {
+
+ String message = pmEventFinal.performSellAllOnPlayerInventoryString("delayed sellall");
+ getDelayedSellallPlayers().remove( pmEventFinal.getSpigotPlayer() );
+
+ Output.get().logDebug(message);
+ }
+ }.runTaskLater( SpigotPrison.getInstance(), ticks );
+ }
+ }
+
+ printDebugInfo( pmEvent, start );
}
-
- printDebugInfo( pmEvent, start );
+
}
+
protected int checkBonusXp( Player player, Block block, ItemStack item ) {
int bonusXp = 0;
return bonusXp;
}
-
+
+ public TreeSet getDelayedSellallPlayers() {
+ return delayedSellallPlayers;
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerCrazyEnchants.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerCrazyEnchants.java
index 7d5b598e9..2a0c9ff00 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerCrazyEnchants.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerCrazyEnchants.java
@@ -13,6 +13,7 @@
import org.bukkit.plugin.PluginManager;
import me.badbones69.crazyenchantments.api.events.BlastUseEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
import tech.mcprison.prison.output.Output;
@@ -56,8 +57,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
@@ -338,6 +341,13 @@ public void handleBlastUseEvent( BlastUseEvent e, BlockBreakPriority bbPriority
}
+ // Check to see if the blockConverter's EventTrigger should have
+ // it's blocks suppressed from explosion events. If they should be
+ // removed, then it's removed within this funciton.
+ removeEventTriggerBlocksFromExplosions( pmEvent );
+
+
+
if ( !validateEvent( pmEvent ) ) {
// The event has not passed validation. All logging and Errors have been recorded
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonEnchants.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonEnchants.java
index 799113caa..f3b5359fe 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonEnchants.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonEnchants.java
@@ -13,6 +13,7 @@
import org.bukkit.plugin.PluginManager;
import me.pulsi_.prisonenchants.events.PEExplosionEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
import tech.mcprison.prison.output.Output;
@@ -48,8 +49,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
/**
@@ -327,6 +330,13 @@ public void handlePEExplosionEvent( PEExplosionEvent e, BlockBreakPriority bbPri
pmEvent.setUnprocessedRawBlocks( e.getExplodedBlocks() );
+ // Check to see if the blockConverter's EventTrigger should have
+ // it's blocks suppressed from explosion events. If they should be
+ // removed, then it's removed within this funciton.
+ removeEventTriggerBlocksFromExplosions( pmEvent );
+
+
+
if ( !validateEvent( pmEvent ) ) {
// The event has not passed validation. All logging and Errors have been recorded
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java
index 64d5c0995..20680ca16 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerPrisonsExplosiveBlockBreakEvents.java
@@ -51,8 +51,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
@@ -321,8 +323,19 @@ protected void handleExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e,
// than one.
if ( e.getMineBomb() != null ) {
pmEvent.setCalculateDurability( false );
+
+ // Set if forced autoSell:
+ pmEvent.setForceAutoSell( e.getMineBomb().isAutosell() );
}
+
+ // Check to see if the blockConverter's EventTrigger should have
+ // it's blocks suppressed from explosion events. If they should be
+ // removed, then it's removed within this funciton.
+ removeEventTriggerBlocksFromExplosions( pmEvent );
+
+
+
if ( !validateEvent( pmEvent ) ) {
// The event has not passed validation. All logging and Errors have been recorded
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java
index 982094061..595c9291a 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsExplosiveEvent.java
@@ -13,6 +13,7 @@
import org.bukkit.plugin.PluginManager;
import me.revils.revenchants.events.ExplosiveEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
import tech.mcprison.prison.output.Output;
@@ -49,8 +50,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
@@ -238,7 +241,12 @@ public void dumpEventListeners( StringBuilder sb ) {
// CrazyEnchants is not loaded... so ignore.
}
catch ( Exception e ) {
- Output.get().logInfo( "AutoManager: RevEnchants ExplosiveEvent failed to load. [%s]", e.getMessage() );
+ String causedBy = e.getCause() == null ? "" : e.getCause().getMessage();
+
+ Output.get().logInfo( "AutoManager: RevEnchants ExplosiveEvent failed to load. "
+ + "[%s] Caused by: [%s]",
+ e.getMessage(),
+ causedBy );
}
}
@@ -333,6 +341,14 @@ public void handleRevEnchantsExplosiveEvent( ExplosiveEvent e, BlockBreakPriorit
}
+
+ // Check to see if the blockConverter's EventTrigger should have
+ // it's blocks suppressed from explosion events. If they should be
+ // removed, then it's removed within this funciton.
+ removeEventTriggerBlocksFromExplosions( pmEvent );
+
+
+
if ( !validateEvent( pmEvent ) ) {
// The event has not passed validation. All logging and Errors have been recorded
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java
index e5c1bc2ee..6af193697 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerRevEnchantsJackHammerEvent.java
@@ -15,6 +15,7 @@
import org.bukkit.plugin.PluginManager;
import me.revils.revenchants.events.JackHammerEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.bombs.MineBombs;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
@@ -54,8 +55,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
@@ -246,7 +249,12 @@ public void dumpEventListeners( StringBuilder sb ) {
// CrazyEnchants is not loaded... so ignore.
}
catch ( Exception e ) {
- Output.get().logInfo( "AutoManager: RevEnchants JackHammerEnchants failed to load. [%s]", e.getMessage() );
+ String causedBy = e.getCause() == null ? "" : e.getCause().getMessage();
+
+ Output.get().logInfo( "AutoManager: RevEnchants JackHammerEnchants failed to load. "
+ + "[%s] Caused by: [%s]",
+ e.getMessage(),
+ causedBy, e.getMessage() );
}
}
@@ -359,6 +367,14 @@ public void handleRevEnchantsJackHammerEvent( JackHammerEvent e, BlockBreakPrior
// pmEvent.getUnprocessedRawBlocks().add( blocks.get( i ) );
// }
+
+
+ // Check to see if the blockConverter's EventTrigger should have
+ // it's blocks suppressed from explosion events. If they should be
+ // removed, then it's removed within this funciton.
+ removeEventTriggerBlocksFromExplosions( pmEvent );
+
+
if ( !validateEvent( pmEvent ) ) {
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerTokenEnchant.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerTokenEnchant.java
index 88240da24..5ea2ff076 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerTokenEnchant.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerTokenEnchant.java
@@ -14,6 +14,7 @@
import com.vk2gpz.tokenenchant.event.TEBlockExplodeEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
import tech.mcprison.prison.output.Output;
@@ -53,7 +54,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
@@ -391,6 +395,16 @@ public void handleTEBlockExplodeEvent( TEBlockExplodeEvent e, BlockBreakPriority
pmEvent.setUnprocessedRawBlocks( e.blockList() );
+
+
+ // Check to see if the blockConverter's EventTrigger should have
+ // it's blocks suppressed from explosion events. If they should be
+ // removed, then it's removed within this funciton.
+ removeEventTriggerBlocksFromExplosions( pmEvent );
+
+
+
+
if ( !validateEvent( pmEvent ) ) {
// The event has not passed validation. All logging and Errors have been recorded
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonExplosionTriggerEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonExplosionTriggerEvent.java
new file mode 100644
index 000000000..758d082b0
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonExplosionTriggerEvent.java
@@ -0,0 +1,442 @@
+package tech.mcprison.prison.spigot.autofeatures.events;
+
+import org.bukkit.Bukkit;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.Listener;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.EventExecutor;
+import org.bukkit.plugin.PluginManager;
+
+import dev.drawethree.xprison.enchants.api.events.ExplosionTriggerEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
+import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent;
+import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures;
+import tech.mcprison.prison.spigot.block.BlockBreakPriority;
+
+public class AutoManagerXPrisonExplosionTriggerEvent
+ extends AutoManagerFeatures
+ implements PrisonEventManager
+{
+
+
+// private ExplosionTriggerEvent ete;
+// private LayerTriggerEvent lte;
+// private NukeTriggerEvent nte;
+
+// dev.drawethree.xprison.enchants.api.events.ExplosionTriggerEvent;
+
+
+
+ private BlockBreakPriority bbPriority;
+
+ public AutoManagerXPrisonExplosionTriggerEvent() {
+ super();
+ }
+
+ public AutoManagerXPrisonExplosionTriggerEvent( BlockBreakPriority bbPriority ) {
+ super();
+
+ this.bbPriority = bbPriority;
+ }
+
+
+ public BlockBreakPriority getBbPriority() {
+ return bbPriority;
+ }
+ public void setBbPriority( BlockBreakPriority bbPriority ) {
+ this.bbPriority = bbPriority;
+ }
+
+ @Override
+ public void registerEvents() {
+
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
+ }
+
+
+ public class AutoManagerXPrisonExplosionTriggerEventListener
+ extends AutoManagerXPrisonExplosionTriggerEvent
+ implements Listener {
+
+ public AutoManagerXPrisonExplosionTriggerEventListener( BlockBreakPriority bbPriority ) {
+ super( bbPriority );
+ }
+
+ @EventHandler(priority=EventPriority.NORMAL)
+ public void onXPrisonExplosionTriggerEvent(
+ ExplosionTriggerEvent e, BlockBreakPriority bbPriority) {
+
+ if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ||
+ bbPriority.isDisabled() ) {
+ return;
+ }
+
+ handleXPrisonExplosionTriggerEvent( e, bbPriority );
+ }
+ }
+
+
+ @Override
+ public void initialize() {
+
+ String eP = getMessage( AutoFeatures.XPrisonExplosionTriggerEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ setBbPriority( bbPriority );
+
+// boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( getBbPriority() == BlockBreakPriority.DISABLED ) {
+ return;
+ }
+
+ // Check to see if the class ExplosionTriggerEvent even exists:
+ try {
+ Output.get().logInfo( "AutoManager: checking if loaded: XPrison ExplosionTriggerEvent" );
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.ExplosionTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+ Output.get().logInfo( "AutoManager: Trying to register XPrison ExplosionTriggerEvent" );
+
+ if ( getBbPriority() != BlockBreakPriority.DISABLED ) {
+ if ( bbPriority.isComponentCompound() ) {
+
+ for (BlockBreakPriority subBBPriority : bbPriority.getComponentPriorities()) {
+
+ createListener( subBBPriority );
+ }
+ }
+ else {
+
+ createListener(bbPriority);
+ }
+
+ }
+ }
+ catch ( ClassNotFoundException e ) {
+ // CrazyEnchants is not loaded... so ignore.
+ Output.get().logInfo( "AutoManager: XPrison ExplosionTriggerEvent is not loaded" );
+ }
+ catch ( Exception e ) {
+ Output.get().logInfo( "AutoManager: XPrison ExplosionTriggerEvent failed to load. [%s]", e.getMessage() );
+ }
+ }
+
+ private void createListener( BlockBreakPriority bbPriority ) {
+
+ SpigotPrison prison = SpigotPrison.getInstance();
+ PluginManager pm = Bukkit.getServer().getPluginManager();
+ EventPriority ePriority = bbPriority.getBukkitEventPriority();
+
+
+ AutoManagerXPrisonExplosionTriggerEventListener autoManagerListener =
+ new AutoManagerXPrisonExplosionTriggerEventListener( bbPriority );
+
+ pm.registerEvent(
+ ExplosionTriggerEvent.class,
+ autoManagerListener, ePriority,
+ new EventExecutor() {
+ public void execute(Listener l, Event e) {
+
+ ExplosionTriggerEvent exEvent = (ExplosionTriggerEvent) e;
+
+ ((AutoManagerXPrisonExplosionTriggerEventListener)l)
+ .onXPrisonExplosionTriggerEvent(exEvent, bbPriority);
+ }
+ },
+ prison);
+ prison.getRegisteredBlockListeners().add( autoManagerListener );
+ }
+
+
+ @Override
+ public void unregisterListeners() {
+
+// super.unregisterListeners();
+ }
+
+ @Override
+ public void dumpEventListeners() {
+
+ StringBuilder sb = new StringBuilder();
+
+ dumpEventListeners( sb );
+
+ if ( sb.length() > 0 ) {
+
+
+ for ( String line : sb.toString().split( "\n" ) ) {
+
+ Output.get().logInfo( line );
+ }
+ }
+
+ }
+
+
+ @Override
+ public void dumpEventListeners( StringBuilder sb ) {
+
+ String eP = getMessage( AutoFeatures.XPrisonExplosionTriggerEventPriority );
+ boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( !isEventEnabled ) {
+ return;
+ }
+
+ // Check to see if the class ExplosionTriggerEvent even exists:
+ try {
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.ExplosionTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+
+ HandlerList handlers = ExplosionTriggerEvent.getHandlerList();
+
+// String eP = getMessage( AutoFeatures.blockBreakEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ dumpEventListenersCore( "XPrison ExplosionTriggerEvent", handlers, bbPriority, sb );
+
+
+//
+// BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+//
+//
+// String title = String.format(
+// "ExplosionTriggerEvent (%s)",
+// ( bbPriority == null ? "--none--" : bbPriority.name()) );
+//
+// ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay(
+// title,
+// new SpigotHandlerList( ExplosionTriggerEvent.getHandlerList()) );
+//
+// if ( eventDisplay != null ) {
+// sb.append( eventDisplay.toStringBuilder() );
+// sb.append( "\n" );
+// }
+//
+//
+// if ( bbPriority.isComponentCompound() ) {
+// StringBuilder sbCP = new StringBuilder();
+// for ( BlockBreakPriority bbp : bbPriority.getComponentPriorities() ) {
+// if ( sbCP.length() > 0 ) {
+// sbCP.append( ", " );
+// }
+// sbCP.append( "'" ).append( bbp.name() ).append( "'" );
+// }
+//
+// String msg = String.format( "Note '%s' is a compound of: [%s]",
+// bbPriority.name(),
+// sbCP );
+//
+// sb.append( msg ).append( "\n" );
+// }
+ }
+ catch ( ClassNotFoundException e ) {
+ // XPrison is not loaded... so ignore.
+ }
+ catch ( Exception e ) {
+ String causedBy = e.getCause() == null ? "" : e.getCause().getMessage();
+
+ Output.get().logInfo( "AutoManager: XPrison ExplosionTriggerEvent failed to load. "
+ + "[%s] Caused by: [%s]",
+ e.getMessage(),
+ causedBy );
+ }
+ }
+
+
+ /**
+ * Since there are multiple blocks associated with this event, pull out the player first and
+ * get the mine, then loop through those blocks to make sure they are within the mine.
+ *
+ *
+ * The logic in this function is slightly different compared to genericBlockEvent() because this
+ * event contains multiple blocks so it's far more efficient to process the player data once.
+ * So that basically needed a slight refactoring.
+ *
+ *
+ * @param e
+ */
+ public void handleXPrisonExplosionTriggerEvent( ExplosionTriggerEvent e, BlockBreakPriority bbPriority ) {
+
+ PrisonMinesBlockBreakEvent pmEvent = null;
+ long start = System.nanoTime();
+
+ // If the event is canceled, it still needs to be processed because of the
+ // MONITOR events:
+ // An event will be "canceled" and "ignored" if the block
+ // BlockUtils.isUnbreakable(), or if the mine is actively resetting.
+ // The event will also be ignored if the block is outside of a mine
+ // or if the targetBlock has been set to ignore all block events which
+ // means the block has already been processed.
+ MinesEventResults eventResults = ignoreMinesBlockBreakEvent( e,
+ e.getPlayer(), e.getOriginBlock(),
+ bbPriority, true );
+
+ if ( eventResults.isIgnoreEvent() ) {
+ return;
+ }
+
+
+ StringBuilder debugInfo = new StringBuilder();
+
+ debugInfo.append( String.format( "### ** handleXPrisonExplosionTriggerEvent ** ### " +
+ "(event: ExplosionTriggerEvent, config: %s, priority: %s, canceled: %s) ",
+ bbPriority.name(),
+ bbPriority.getBukkitEventPriority().name(),
+ (e.isCancelled() ? "TRUE " : "FALSE")
+ ) );
+
+ debugInfo.append( eventResults.getDebugInfo() );
+
+
+ // NOTE that check for auto manager has happened prior to accessing this function.
+
+ // Process all priorities if the event has not been canceled, and
+ // process the MONITOR priority even if the event was canceled:
+ if ( !bbPriority.isMonitor() && !e.isCancelled() ||
+ bbPriority.isMonitor() &&
+ e.getBlocksAffected().size() > 0 ) {
+
+
+
+// Block bukkitBlock = e.getBlocks().get( 0 );
+
+ BlockEventType eventType = BlockEventType.XPrisonExplosionTriggerEvent;
+ String triggered = null;
+
+
+ pmEvent = new PrisonMinesBlockBreakEvent(
+ eventResults,
+// bukkitBlock,
+// e.getPlayer(),
+// eventResults.getMine(),
+// bbPriority,
+ eventType, triggered,
+ debugInfo );
+
+
+ // NOTE: Check for the ACCESS priority and if someone does not have access, then return
+ // with a cancel on the event. Both ACCESSBLOCKEVENTS and ACCESSMONITOR will be
+ // converted to just ACCESS at this point, and the other part will run under either
+ // BLOCKEVENTS or MONITOR.
+ // This check has to be performed after creating the pmEvent object since it uses
+ // a lot of the internal variables and objects. There is not much of an impact since
+ // the validateEvent() has not been ran yet.
+ if ( checkIfNoAccess( pmEvent, start ) ) {
+
+ e.setCancelled( true );
+ return;
+ }
+
+
+ for ( int i = 0; i < e.getBlocksAffected().size(); i++ ) {
+ pmEvent.getUnprocessedRawBlocks().add( e.getBlocksAffected().get( i ) );
+ }
+
+
+
+
+ // Check to see if the blockConverter's EventTrigger should have
+ // it's blocks suppressed from explosion events. If they should be
+ // removed, then it's removed within this funciton.
+ removeEventTriggerBlocksFromExplosions( pmEvent );
+
+
+
+ if ( !validateEvent( pmEvent ) ) {
+
+ // The event has not passed validation. All logging and Errors have been recorded
+ // so do nothing more. This is to just prevent normal processing from occurring.
+
+ if ( pmEvent.isCancelOriginalEvent() ) {
+
+ e.setCancelled( true );
+ }
+
+ debugInfo.append( "(doAction failed validation) " );
+ }
+
+
+
+ // The validation was successful, but stop processing for the MONITOR priorities.
+ // Note that BLOCKEVENTS processing occurred already within validateEvent():
+ else if ( pmEvent.getBbPriority().isMonitor() ) {
+ // Stop here, and prevent additional processing.
+ // Monitors should never process the event beyond this.
+ }
+
+
+
+ // This is where the processing actually happens:
+ else {
+
+// debugInfo.append( "(normal processing initiating) " );
+
+ // check all external events such as mcMMO and EZBlocks:
+// if ( e instanceof BlockBreakEvent ) {
+// processPMBBExternalEvents( pmEvent, debugInfo, e );
+// }
+//
+
+ EventListenerCancelBy cancelBy = EventListenerCancelBy.none;
+
+ cancelBy = processPMBBEvent( pmEvent );
+
+
+ if ( cancelBy != EventListenerCancelBy.none ) {
+
+ e.setCancelled( true );
+ debugInfo.append( "(event canceled) " );
+ }
+// else if ( cancelBy == EventListenerCancelBy.drops ) {
+// try
+// {
+// e.setDropItems( false );
+// debugInfo.append( "(drop canceled) " );
+// }
+// catch ( NoSuchMethodError e1 )
+// {
+// String message = String.format(
+// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " +
+// "is not valid for this version of Spigot. It's only vaid for spigot v1.12.x and higher. " +
+// "Modify the config settings and set this value to `false`. For now, it is temporarily " +
+// "disabled. [%s]",
+// e1.getMessage() );
+// Output.get().logWarn( message );
+//
+// AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig()
+// .setFeature( AutoFeatures.cancelAllBlockEventBlockDrops, false );
+// }
+//
+// }
+ }
+
+
+ }
+
+ printDebugInfo( pmEvent, start );
+ }
+
+ @Override
+ protected int checkBonusXp( Player player, Block block, ItemStack item ) {
+ int bonusXp = 0;
+
+ return bonusXp;
+ }
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonLayerTriggerEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonLayerTriggerEvent.java
new file mode 100644
index 000000000..6043f5a2b
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonLayerTriggerEvent.java
@@ -0,0 +1,443 @@
+package tech.mcprison.prison.spigot.autofeatures.events;
+
+import org.bukkit.Bukkit;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.Listener;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.EventExecutor;
+import org.bukkit.plugin.PluginManager;
+
+import dev.drawethree.xprison.enchants.api.events.LayerTriggerEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
+import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent;
+import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures;
+import tech.mcprison.prison.spigot.block.BlockBreakPriority;
+
+public class AutoManagerXPrisonLayerTriggerEvent
+ extends AutoManagerFeatures
+ implements PrisonEventManager
+{
+
+
+// private ExplosionTriggerEvent ete;
+// private LayerTriggerEvent lte;
+// private NukeTriggerEvent nte;
+
+ //dev.drawethree.xprison.enchants.api.events.LayerTriggerEvent;
+
+
+
+ private BlockBreakPriority bbPriority;
+
+ public AutoManagerXPrisonLayerTriggerEvent() {
+ super();
+ }
+
+ public AutoManagerXPrisonLayerTriggerEvent( BlockBreakPriority bbPriority ) {
+ super();
+
+ this.bbPriority = bbPriority;
+ }
+
+
+ public BlockBreakPriority getBbPriority() {
+ return bbPriority;
+ }
+ public void setBbPriority( BlockBreakPriority bbPriority ) {
+ this.bbPriority = bbPriority;
+ }
+
+ @Override
+ public void registerEvents() {
+
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
+ }
+
+
+ public class AutoManagerXPrisonLayerTriggerEventListener
+ extends AutoManagerXPrisonLayerTriggerEvent
+ implements Listener {
+
+ public AutoManagerXPrisonLayerTriggerEventListener( BlockBreakPriority bbPriority ) {
+ super( bbPriority );
+ }
+
+ @EventHandler(priority=EventPriority.NORMAL)
+ public void onXPrisonLayerTriggerEvent(
+ LayerTriggerEvent e, BlockBreakPriority bbPriority) {
+
+ if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ||
+ bbPriority.isDisabled() ) {
+ return;
+ }
+
+ handleXPrisonLayerTriggerEvent( e, bbPriority );
+ }
+ }
+
+
+ @Override
+ public void initialize() {
+
+ String eP = getMessage( AutoFeatures.XPrisonLayerTriggerEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ setBbPriority( bbPriority );
+
+ // boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( getBbPriority() == BlockBreakPriority.DISABLED ) {
+ return;
+ }
+
+ // Check to see if the class LayerTriggerEvent even exists:
+ try {
+ Output.get().logInfo( "AutoManager: checking if loaded: XPrison LayerTriggerEvent" );
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.LayerTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+ Output.get().logInfo( "AutoManager: Trying to register XPrison LayerTriggerEvent" );
+
+ if ( getBbPriority() != BlockBreakPriority.DISABLED ) {
+ if ( bbPriority.isComponentCompound() ) {
+
+ for (BlockBreakPriority subBBPriority : bbPriority.getComponentPriorities()) {
+
+ createListener( subBBPriority );
+ }
+ }
+ else {
+
+ createListener(bbPriority);
+ }
+
+ }
+ }
+ catch ( ClassNotFoundException e ) {
+ // CrazyEnchants is not loaded... so ignore.
+ Output.get().logInfo( "AutoManager: XPrison LayerTriggerEvent is not loaded" );
+ }
+ catch ( Exception e ) {
+ Output.get().logInfo( "AutoManager: XPrison LayerTriggerEvent failed to load. [%s]", e.getMessage() );
+ }
+ }
+
+ private void createListener( BlockBreakPriority bbPriority ) {
+
+ SpigotPrison prison = SpigotPrison.getInstance();
+ PluginManager pm = Bukkit.getServer().getPluginManager();
+ EventPriority ePriority = bbPriority.getBukkitEventPriority();
+
+
+ AutoManagerXPrisonLayerTriggerEventListener autoManagerListener =
+ new AutoManagerXPrisonLayerTriggerEventListener( bbPriority );
+
+ pm.registerEvent(
+ LayerTriggerEvent.class,
+ autoManagerListener, ePriority,
+ new EventExecutor() {
+ public void execute(Listener l, Event e) {
+
+ LayerTriggerEvent exEvent = (LayerTriggerEvent) e;
+
+ ((AutoManagerXPrisonLayerTriggerEventListener)l)
+ .onXPrisonLayerTriggerEvent(exEvent, bbPriority);
+ }
+ },
+ prison);
+ prison.getRegisteredBlockListeners().add( autoManagerListener );
+ }
+
+
+ @Override
+ public void unregisterListeners() {
+
+ // super.unregisterListeners();
+ }
+
+ @Override
+ public void dumpEventListeners() {
+
+ StringBuilder sb = new StringBuilder();
+
+ dumpEventListeners( sb );
+
+ if ( sb.length() > 0 ) {
+
+
+ for ( String line : sb.toString().split( "\n" ) ) {
+
+ Output.get().logInfo( line );
+ }
+ }
+
+ }
+
+
+@Override
+public void dumpEventListeners( StringBuilder sb ) {
+
+ String eP = getMessage( AutoFeatures.XPrisonLayerTriggerEventPriority );
+ boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( !isEventEnabled ) {
+ return;
+ }
+
+ // Check to see if the class LayerTriggerEvent even exists:
+ try {
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.LayerTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+
+ HandlerList handlers = LayerTriggerEvent.getHandlerList();
+
+// String eP = getMessage( AutoFeatures.blockBreakEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ dumpEventListenersCore( "XPrison LayerTriggerEvent", handlers, bbPriority, sb );
+
+
+//
+// BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+//
+//
+// String title = String.format(
+// "LayerTriggerEvent (%s)",
+// ( bbPriority == null ? "--none--" : bbPriority.name()) );
+//
+// ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay(
+// title,
+// new SpigotHandlerList( LayerTriggerEvent.getHandlerList()) );
+//
+// if ( eventDisplay != null ) {
+// sb.append( eventDisplay.toStringBuilder() );
+// sb.append( "\n" );
+// }
+//
+//
+// if ( bbPriority.isComponentCompound() ) {
+// StringBuilder sbCP = new StringBuilder();
+// for ( BlockBreakPriority bbp : bbPriority.getComponentPriorities() ) {
+// if ( sbCP.length() > 0 ) {
+// sbCP.append( ", " );
+// }
+// sbCP.append( "'" ).append( bbp.name() ).append( "'" );
+// }
+//
+// String msg = String.format( "Note '%s' is a compound of: [%s]",
+// bbPriority.name(),
+// sbCP );
+//
+// sb.append( msg ).append( "\n" );
+// }
+ }
+ catch ( ClassNotFoundException e ) {
+ // XPrison is not loaded... so ignore.
+ }
+ catch ( Exception e ) {
+ String causedBy = e.getCause() == null ? "" : e.getCause().getMessage();
+
+ Output.get().logInfo( "AutoManager: XPrison LayerTriggerEvent failed to load. "
+ + "[%s] Caused by: [%s]",
+ e.getMessage(),
+ causedBy );
+ }
+}
+
+
+/**
+ * Since there are multiple blocks associated with this event, pull out the player first and
+ * get the mine, then loop through those blocks to make sure they are within the mine.
+ *
+ *
+ * The logic in this function is slightly different compared to genericBlockEvent() because this
+ * event contains multiple blocks so it's far more efficient to process the player data once.
+ * So that basically needed a slight refactoring.
+ *
+ *
+ * @param e
+ */
+public void handleXPrisonLayerTriggerEvent( LayerTriggerEvent e, BlockBreakPriority bbPriority ) {
+
+ PrisonMinesBlockBreakEvent pmEvent = null;
+ long start = System.nanoTime();
+
+ // If the event is canceled, it still needs to be processed because of the
+ // MONITOR events:
+ // An event will be "canceled" and "ignored" if the block
+ // BlockUtils.isUnbreakable(), or if the mine is actively resetting.
+ // The event will also be ignored if the block is outside of a mine
+ // or if the targetBlock has been set to ignore all block events which
+ // means the block has already been processed.
+ MinesEventResults eventResults = ignoreMinesBlockBreakEvent( e,
+ e.getPlayer(), e.getOriginBlock(),
+ bbPriority, true );
+
+ if ( eventResults.isIgnoreEvent() ) {
+ return;
+ }
+
+
+ StringBuilder debugInfo = new StringBuilder();
+
+ debugInfo.append( String.format( "### ** handleXPrisonLayerTriggerEvent ** ### " +
+ "(event: LayerTriggerEvent, config: %s, priority: %s, canceled: %s) ",
+ bbPriority.name(),
+ bbPriority.getBukkitEventPriority().name(),
+ (e.isCancelled() ? "TRUE " : "FALSE")
+ ) );
+
+ debugInfo.append( eventResults.getDebugInfo() );
+
+
+ // NOTE that check for auto manager has happened prior to accessing this function.
+
+ // Process all priorities if the event has not been canceled, and
+ // process the MONITOR priority even if the event was canceled:
+ if ( !bbPriority.isMonitor() && !e.isCancelled() ||
+ bbPriority.isMonitor() &&
+ e.getBlocksAffected().size() > 0 ) {
+
+
+
+// Block bukkitBlock = e.getBlocks().get( 0 );
+
+ BlockEventType eventType = BlockEventType.XPrisonLayerTriggerEvent;
+ String triggered = null;
+
+
+ pmEvent = new PrisonMinesBlockBreakEvent(
+ eventResults,
+// bukkitBlock,
+// e.getPlayer(),
+// eventResults.getMine(),
+// bbPriority,
+ eventType, triggered,
+ debugInfo );
+
+
+ // NOTE: Check for the ACCESS priority and if someone does not have access, then return
+ // with a cancel on the event. Both ACCESSBLOCKEVENTS and ACCESSMONITOR will be
+ // converted to just ACCESS at this point, and the other part will run under either
+ // BLOCKEVENTS or MONITOR.
+ // This check has to be performed after creating the pmEvent object since it uses
+ // a lot of the internal variables and objects. There is not much of an impact since
+ // the validateEvent() has not been ran yet.
+ if ( checkIfNoAccess( pmEvent, start ) ) {
+
+ e.setCancelled( true );
+ return;
+ }
+
+
+ for ( int i = 0; i < e.getBlocksAffected().size(); i++ ) {
+ pmEvent.getUnprocessedRawBlocks().add( e.getBlocksAffected().get( i ) );
+ }
+
+
+
+ // Check to see if the blockConverter's EventTrigger should have
+ // it's blocks suppressed from explosion events. If they should be
+ // removed, then it's removed within this funciton.
+ removeEventTriggerBlocksFromExplosions( pmEvent );
+
+
+
+ if ( !validateEvent( pmEvent ) ) {
+
+ // The event has not passed validation. All logging and Errors have been recorded
+ // so do nothing more. This is to just prevent normal processing from occurring.
+
+ if ( pmEvent.isCancelOriginalEvent() ) {
+
+ e.setCancelled( true );
+ }
+
+ pmEvent.setDebugColorCodeWarning();
+ debugInfo.append( "(doAction failed validation) " );
+ pmEvent.setDebugColorCodeDebug();
+ }
+
+
+
+ // The validation was successful, but stop processing for the MONITOR priorities.
+ // Note that BLOCKEVENTS processing occurred already within validateEvent():
+ else if ( pmEvent.getBbPriority().isMonitor() ) {
+ // Stop here, and prevent additional processing.
+ // Monitors should never process the event beyond this.
+ }
+
+
+
+ // This is where the processing actually happens:
+ else {
+
+// debugInfo.append( "(normal processing initiating) " );
+
+ // check all external events such as mcMMO and EZBlocks:
+// if ( e instanceof BlockBreakEvent ) {
+// processPMBBExternalEvents( pmEvent, debugInfo, e );
+// }
+//
+
+ EventListenerCancelBy cancelBy = EventListenerCancelBy.none;
+
+ cancelBy = processPMBBEvent( pmEvent );
+
+
+ if ( cancelBy != EventListenerCancelBy.none ) {
+
+ e.setCancelled( true );
+ debugInfo.append( "(event canceled) " );
+ }
+// else if ( cancelBy == EventListenerCancelBy.drops ) {
+// try
+// {
+// e.setDropItems( false );
+// debugInfo.append( "(drop canceled) " );
+// }
+// catch ( NoSuchMethodError e1 )
+// {
+// String message = String.format(
+// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " +
+// "is not valid for this version of Spigot. It's only vaid for spigot v1.12.x and higher. " +
+// "Modify the config settings and set this value to `false`. For now, it is temporarily " +
+// "disabled. [%s]",
+// e1.getMessage() );
+// Output.get().logWarn( message );
+//
+// AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig()
+// .setFeature( AutoFeatures.cancelAllBlockEventBlockDrops, false );
+// }
+//
+// }
+ }
+
+
+ }
+
+ printDebugInfo( pmEvent, start );
+}
+
+ @Override
+ protected int checkBonusXp( Player player, Block block, ItemStack item ) {
+ int bonusXp = 0;
+
+ return bonusXp;
+ }
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonNukeTriggerEvent.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonNukeTriggerEvent.java
new file mode 100644
index 000000000..2185fc3d5
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerXPrisonNukeTriggerEvent.java
@@ -0,0 +1,443 @@
+package tech.mcprison.prison.spigot.autofeatures.events;
+
+import org.bukkit.Bukkit;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.Listener;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.EventExecutor;
+import org.bukkit.plugin.PluginManager;
+
+import dev.drawethree.xprison.enchants.api.events.NukeTriggerEvent;
+import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
+import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
+import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.api.PrisonMinesBlockBreakEvent;
+import tech.mcprison.prison.spigot.autofeatures.AutoManagerFeatures;
+import tech.mcprison.prison.spigot.block.BlockBreakPriority;
+
+public class AutoManagerXPrisonNukeTriggerEvent
+ extends AutoManagerFeatures
+ implements PrisonEventManager
+{
+
+
+// private ExplosionTriggerEvent ete;
+// private LayerTriggerEvent lte;
+// private NukeTriggerEvent nte;
+
+ //dev.drawethree.xprison.enchants.api.events.NukeTriggerEvent;
+
+
+
+ private BlockBreakPriority bbPriority;
+
+ public AutoManagerXPrisonNukeTriggerEvent() {
+ super();
+ }
+
+ public AutoManagerXPrisonNukeTriggerEvent( BlockBreakPriority bbPriority ) {
+ super();
+
+ this.bbPriority = bbPriority;
+ }
+
+
+ public BlockBreakPriority getBbPriority() {
+ return bbPriority;
+ }
+ public void setBbPriority( BlockBreakPriority bbPriority ) {
+ this.bbPriority = bbPriority;
+ }
+
+ @Override
+ public void registerEvents() {
+
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
+ }
+
+
+public class AutoManagerXPrisonNukeTriggerEventListener
+ extends AutoManagerXPrisonNukeTriggerEvent
+ implements Listener {
+
+ public AutoManagerXPrisonNukeTriggerEventListener( BlockBreakPriority bbPriority ) {
+ super( bbPriority );
+ }
+
+ @EventHandler(priority=EventPriority.NORMAL)
+ public void onXPrisonNukeTriggerEvent(
+ NukeTriggerEvent e, BlockBreakPriority bbPriority) {
+
+ if ( isDisabled( e.getPlayer().getLocation().getWorld().getName() ) ||
+ bbPriority.isDisabled() ) {
+ return;
+ }
+
+ handleXPrisonNukeTriggerEvent( e, bbPriority );
+ }
+}
+
+
+@Override
+public void initialize() {
+
+ String eP = getMessage( AutoFeatures.XPrisonNukeTriggerEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ setBbPriority( bbPriority );
+
+// boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( getBbPriority() == BlockBreakPriority.DISABLED ) {
+ return;
+ }
+
+ // Check to see if the class NukeTriggerEvent even exists:
+ try {
+ Output.get().logInfo( "AutoManager: checking if loaded: XPrison NukeTriggerEvent" );
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.NukeTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+ Output.get().logInfo( "AutoManager: Trying to register XPrison NukeTriggerEvent" );
+
+ if ( getBbPriority() != BlockBreakPriority.DISABLED ) {
+ if ( bbPriority.isComponentCompound() ) {
+
+ for (BlockBreakPriority subBBPriority : bbPriority.getComponentPriorities()) {
+
+ createListener( subBBPriority );
+ }
+ }
+ else {
+
+ createListener(bbPriority);
+ }
+
+ }
+ }
+ catch ( ClassNotFoundException e ) {
+ // CrazyEnchants is not loaded... so ignore.
+ Output.get().logInfo( "AutoManager: XPrison NukeTriggerEvent is not loaded" );
+ }
+ catch ( Exception e ) {
+ Output.get().logInfo( "AutoManager: XPrison NukeTriggerEvent failed to load. [%s]", e.getMessage() );
+ }
+}
+
+private void createListener( BlockBreakPriority bbPriority ) {
+
+ SpigotPrison prison = SpigotPrison.getInstance();
+ PluginManager pm = Bukkit.getServer().getPluginManager();
+ EventPriority ePriority = bbPriority.getBukkitEventPriority();
+
+
+ AutoManagerXPrisonNukeTriggerEventListener autoManagerListener =
+ new AutoManagerXPrisonNukeTriggerEventListener( bbPriority );
+
+ pm.registerEvent(
+ NukeTriggerEvent.class,
+ autoManagerListener, ePriority,
+ new EventExecutor() {
+ public void execute(Listener l, Event e) {
+
+ NukeTriggerEvent exEvent = (NukeTriggerEvent) e;
+
+ ((AutoManagerXPrisonNukeTriggerEventListener)l)
+ .onXPrisonNukeTriggerEvent(exEvent, bbPriority);
+ }
+ },
+ prison);
+ prison.getRegisteredBlockListeners().add( autoManagerListener );
+}
+
+
+@Override
+public void unregisterListeners() {
+
+// super.unregisterListeners();
+}
+
+@Override
+public void dumpEventListeners() {
+
+ StringBuilder sb = new StringBuilder();
+
+ dumpEventListeners( sb );
+
+ if ( sb.length() > 0 ) {
+
+
+ for ( String line : sb.toString().split( "\n" ) ) {
+
+ Output.get().logInfo( line );
+ }
+ }
+
+}
+
+
+@Override
+public void dumpEventListeners( StringBuilder sb ) {
+
+ String eP = getMessage( AutoFeatures.XPrisonNukeTriggerEventPriority );
+ boolean isEventEnabled = eP != null && !"DISABLED".equalsIgnoreCase( eP );
+
+ if ( !isEventEnabled ) {
+ return;
+ }
+
+ // Check to see if the class NukeTriggerEvent even exists:
+ try {
+
+ Class.forName( "dev.drawethree.xprison.enchants.api.events.NukeTriggerEvent", false,
+ this.getClass().getClassLoader() );
+
+
+ HandlerList handlers = NukeTriggerEvent.getHandlerList();
+
+// String eP = getMessage( AutoFeatures.blockBreakEventPriority );
+ BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+
+ dumpEventListenersCore( "XPrison NukeTriggerEvent", handlers, bbPriority, sb );
+
+
+//
+// BlockBreakPriority bbPriority = BlockBreakPriority.fromString( eP );
+//
+//
+// String title = String.format(
+// "NukeTriggerEvent (%s)",
+// ( bbPriority == null ? "--none--" : bbPriority.name()) );
+//
+// ChatDisplay eventDisplay = Prison.get().getPlatform().dumpEventListenersChatDisplay(
+// title,
+// new SpigotHandlerList( NukeTriggerEvent.getHandlerList()) );
+//
+// if ( eventDisplay != null ) {
+// sb.append( eventDisplay.toStringBuilder() );
+// sb.append( "\n" );
+// }
+//
+//
+// if ( bbPriority.isComponentCompound() ) {
+// StringBuilder sbCP = new StringBuilder();
+// for ( BlockBreakPriority bbp : bbPriority.getComponentPriorities() ) {
+// if ( sbCP.length() > 0 ) {
+// sbCP.append( ", " );
+// }
+// sbCP.append( "'" ).append( bbp.name() ).append( "'" );
+// }
+//
+// String msg = String.format( "Note '%s' is a compound of: [%s]",
+// bbPriority.name(),
+// sbCP );
+//
+// sb.append( msg ).append( "\n" );
+// }
+ }
+ catch ( ClassNotFoundException e ) {
+ // XPrison is not loaded... so ignore.
+ }
+ catch ( Exception e ) {
+ String causedBy = e.getCause() == null ? "" : e.getCause().getMessage();
+
+ Output.get().logInfo( "AutoManager: XPrison NukeTriggerEvent failed to load. "
+ + "[%s] Caused by: [%s]",
+ e.getMessage(),
+ causedBy );
+ }
+}
+
+
+/**
+ * Since there are multiple blocks associated with this event, pull out the player first and
+ * get the mine, then loop through those blocks to make sure they are within the mine.
+ *
+ *
+ * The logic in this function is slightly different compared to genericBlockEvent() because this
+ * event contains multiple blocks so it's far more efficient to process the player data once.
+ * So that basically needed a slight refactoring.
+ *
+ *
+ * @param e
+ */
+public void handleXPrisonNukeTriggerEvent( NukeTriggerEvent e, BlockBreakPriority bbPriority ) {
+
+ PrisonMinesBlockBreakEvent pmEvent = null;
+ long start = System.nanoTime();
+
+ // If the event is canceled, it still needs to be processed because of the
+ // MONITOR events:
+ // An event will be "canceled" and "ignored" if the block
+ // BlockUtils.isUnbreakable(), or if the mine is actively resetting.
+ // The event will also be ignored if the block is outside of a mine
+ // or if the targetBlock has been set to ignore all block events which
+ // means the block has already been processed.
+ MinesEventResults eventResults = ignoreMinesBlockBreakEvent( e,
+ e.getPlayer(), e.getOriginBlock(),
+ bbPriority, true );
+
+ if ( eventResults.isIgnoreEvent() ) {
+ return;
+ }
+
+
+ StringBuilder debugInfo = new StringBuilder();
+
+ debugInfo.append( String.format( "### ** handleXPrisonNukeTriggerEvent ** ### " +
+ "(event: NukeTriggerEvent, config: %s, priority: %s, canceled: %s) ",
+ bbPriority.name(),
+ bbPriority.getBukkitEventPriority().name(),
+ (e.isCancelled() ? "TRUE " : "FALSE")
+ ) );
+
+ debugInfo.append( eventResults.getDebugInfo() );
+
+
+ // NOTE that check for auto manager has happened prior to accessing this function.
+
+ // Process all priorities if the event has not been canceled, and
+ // process the MONITOR priority even if the event was canceled:
+ if ( !bbPriority.isMonitor() && !e.isCancelled() ||
+ bbPriority.isMonitor() &&
+ e.getBlocksAffected().size() > 0 ) {
+
+
+
+// Block bukkitBlock = e.getBlocks().get( 0 );
+
+ BlockEventType eventType = BlockEventType.XPrisonNukeTriggerEvent;
+ String triggered = null;
+
+
+ pmEvent = new PrisonMinesBlockBreakEvent(
+ eventResults,
+// bukkitBlock,
+// e.getPlayer(),
+// eventResults.getMine(),
+// bbPriority,
+ eventType, triggered,
+ debugInfo );
+
+
+ // NOTE: Check for the ACCESS priority and if someone does not have access, then return
+ // with a cancel on the event. Both ACCESSBLOCKEVENTS and ACCESSMONITOR will be
+ // converted to just ACCESS at this point, and the other part will run under either
+ // BLOCKEVENTS or MONITOR.
+ // This check has to be performed after creating the pmEvent object since it uses
+ // a lot of the internal variables and objects. There is not much of an impact since
+ // the validateEvent() has not been ran yet.
+ if ( checkIfNoAccess( pmEvent, start ) ) {
+
+ e.setCancelled( true );
+ return;
+ }
+
+
+ for ( int i = 0; i < e.getBlocksAffected().size(); i++ ) {
+ pmEvent.getUnprocessedRawBlocks().add( e.getBlocksAffected().get( i ) );
+ }
+
+
+
+
+ // Check to see if the blockConverter's EventTrigger should have
+ // it's blocks suppressed from explosion events. If they should be
+ // removed, then it's removed within this funciton.
+ removeEventTriggerBlocksFromExplosions( pmEvent );
+
+
+
+
+ if ( !validateEvent( pmEvent ) ) {
+
+ // The event has not passed validation. All logging and Errors have been recorded
+ // so do nothing more. This is to just prevent normal processing from occurring.
+
+ if ( pmEvent.isCancelOriginalEvent() ) {
+
+ e.setCancelled( true );
+ }
+
+ debugInfo.append( "(doAction failed validation) " );
+ }
+
+
+
+ // The validation was successful, but stop processing for the MONITOR priorities.
+ // Note that BLOCKEVENTS processing occurred already within validateEvent():
+ else if ( pmEvent.getBbPriority().isMonitor() ) {
+ // Stop here, and prevent additional processing.
+ // Monitors should never process the event beyond this.
+ }
+
+
+
+ // This is where the processing actually happens:
+ else {
+
+// debugInfo.append( "(normal processing initiating) " );
+
+ // check all external events such as mcMMO and EZBlocks:
+// if ( e instanceof BlockBreakEvent ) {
+// processPMBBExternalEvents( pmEvent, debugInfo, e );
+// }
+//
+
+ EventListenerCancelBy cancelBy = EventListenerCancelBy.none;
+
+ cancelBy = processPMBBEvent( pmEvent );
+
+
+ if ( cancelBy != EventListenerCancelBy.none ) {
+
+ e.setCancelled( true );
+ debugInfo.append( "(event canceled) " );
+ }
+// else if ( cancelBy == EventListenerCancelBy.drops ) {
+// try
+// {
+// e.setDropItems( false );
+// debugInfo.append( "(drop canceled) " );
+// }
+// catch ( NoSuchMethodError e1 )
+// {
+// String message = String.format(
+// "Warning: The autoFeaturesConfig.yml setting `cancelAllBlockEventBlockDrops` " +
+// "is not valid for this version of Spigot. It's only vaid for spigot v1.12.x and higher. " +
+// "Modify the config settings and set this value to `false`. For now, it is temporarily " +
+// "disabled. [%s]",
+// e1.getMessage() );
+// Output.get().logWarn( message );
+//
+// AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig()
+// .setFeature( AutoFeatures.cancelAllBlockEventBlockDrops, false );
+// }
+//
+// }
+ }
+
+
+ }
+
+ printDebugInfo( pmEvent, start );
+}
+
+ @Override
+ protected int checkBonusXp( Player player, Block block, ItemStack item ) {
+ int bonusXp = 0;
+
+ return bonusXp;
+ }
+}
\ No newline at end of file
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerZenchantments.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerZenchantments.java
index 15745d535..23bfb8643 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerZenchantments.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/AutoManagerZenchantments.java
@@ -50,8 +50,10 @@ public void setBbPriority( BlockBreakPriority bbPriority ) {
@Override
public void registerEvents() {
- initialize();
-
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ initialize();
+ }
}
@@ -326,6 +328,14 @@ private void handleZenchantmentsBlockBreakEvent( BlockBreakEvent e, BlockBreakPr
}
+
+ // Check to see if the blockConverter's EventTrigger should have
+ // it's blocks suppressed from explosion events. If they should be
+ // removed, then it's removed within this funciton.
+ removeEventTriggerBlocksFromExplosions( pmEvent );
+
+
+
if ( !validateEvent( pmEvent ) ) {
// The event has not passed validation. All logging and Errors have been recorded
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
index 27981860d..0ddd9ffd0 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/autofeatures/events/PrisonDebugBlockInspector.java
@@ -1,5 +1,6 @@
package tech.mcprison.prison.spigot.autofeatures.events;
+import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
@@ -27,21 +28,41 @@
public class PrisonDebugBlockInspector
// extends OnBlockBreakMines
{
+ private static PrisonDebugBlockInspector instance;
+
private OnBlockBreakMines obbMines;
+ private long lastAccess = 0;
+// private boolean active = false;
+
public enum EventDropsStatus {
normal,
canceled,
notSupported;
}
- public PrisonDebugBlockInspector() {
+ private PrisonDebugBlockInspector() {
super();
obbMines = new OnBlockBreakMines();
+
+ init();
}
+
+ public static PrisonDebugBlockInspector getInstance() {
+ if ( instance == null ) {
+ synchronized ( PrisonDebugBlockInspector.class ) {
+ if ( instance == null ) {
- public void init() {
+ instance = new PrisonDebugBlockInspector();
+
+ }
+ }
+ }
+ return instance;
+ }
+
+ private void init() {
Prison.get().getEventBus().register(this);
@@ -81,6 +102,15 @@ public void init() {
@Subscribe
public void onPlayerInteract( PrisonPlayerInteractEvent e ) {
+ List output = new ArrayList<>();
+
+
+ // Cool down: run no sooner than every 2 seconds... prevents duplicate runs:
+ if ( lastAccess != 0 && (System.currentTimeMillis() - lastAccess) < 2000 ) {
+ return;
+ }
+
+ this.lastAccess = System.currentTimeMillis();
ItemStack ourItem = e.getItemInHand();
ItemStack toolItem = SelectionManager.SELECTION_TOOL;
@@ -107,9 +137,9 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) {
if ( mine == null ) {
- player.sendMessage(
+ output.add(
String.format(
- "&dDebugBlockInfo: &7Not in a mine. &5%s &7%s",
+ "-&dDebugBlockInfo: &7Not in a mine. &5%s &7%s",
sBlock.getBlockName(), location.toWorldCoordinates()) );
}
@@ -125,56 +155,63 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) {
// checkForCustomBlock( sBlock, targetBlock );
String m1 = String.format(
- "&dDebugBlockInfo: &3Mine &7%s &3Rank: &7%s " +
- "&5%s &7%s",
+ "-&dDebugBlockInfo: &3Mine &7%s &3Rank: &7%s " +
+ "&5%s &7%s ",
mine.getName(),
(mine.getRank() == null ? "---" : mine.getRank().getName()),
sBlock.getBlockName(),
location.toWorldCoordinates());
- player.sendMessage( m1 );
- Output.get().logInfo( m1 );
+ output.add( m1 );
+// player.sendMessage( m1 );
+// Output.get().logInfo( m1 );
// Get the mine's targetBlock:
// MineTargetPrisonBlock tBlock = mine.getTargetPrisonBlock( sBlock );
if ( targetBlock == null ) {
- player.sendMessage( "Notice: Unable to get a mine's targetBlock. This could imply " +
+
+
+ output.add( "-Notice: Unable to get a mine's targetBlock. This could imply " +
"that the mine was not reset since the server started up, or that the air-block " +
"check was not ran yet. Use `/mine reset " + mine.getName() + "' to reset the " +
"target blocks." );
}
else {
- String message = String.format( " &3TargetBlock: &7%s " +
- "&3Mined: %s%b &3Broke: &7%b",
+
+ String message = String.format( "- &3TargetBlock: &7%s " +
+ "&3Mined: %s%b &3Broke: &7%b &3Counted: &7%b",
targetBlock.getPrisonBlock().getBlockName(),
(targetBlock.isMined() ? "&d" : "&2"),
targetBlock.isMined(),
- targetBlock.isAirBroke()
+ targetBlock.isAirBroke(),
+ targetBlock.isCounted()
);
- player.sendMessage( message );
- Output.get().logInfo( message );
+ output.add( message );
+// player.sendMessage( message );
+// Output.get().logInfo( message );
- String message2 = String.format( " &3Counted: &7%b &3Edge: &7%b " +
- "&3Exploded: %s%b &3IgnoreAllEvents: &7%b",
- targetBlock.isCounted(),
+ String message2 = String.format( "- &3isEdge: &7%b " +
+ "&3Exploded: %s%b &3IgnoreAllEvents: &7%b",
+
targetBlock.isEdge(),
(targetBlock.isExploded() ? "&d" : "&2"),
targetBlock.isExploded(),
targetBlock.isIgnoreAllBlockEvents()
);
- player.sendMessage( message2 );
- Output.get().logInfo( message2 );
+ output.add( message2 );
+// player.sendMessage( message2 );
+// Output.get().logInfo( message2 );
}
}
if ( !isSneaking ) {
- player.sendMessage(
+ output.add(
String.format(
" &d(&7Sneak to test BlockBreakEvent with block.&d)"
) );
@@ -188,11 +225,22 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) {
// Debug the block break events:
- dumpBlockBreakEvent( player, sBlock, targetBlock );
+ dumpBlockBreakEvent( player, sBlock, targetBlock, output );
}
+
+ output.add( " - - End DebugBlockInfo - - " );
+ for ( String outputLine : output ) {
+ boolean playerMessage = outputLine.startsWith( "-" );
+ if ( playerMessage ) {
+ outputLine = outputLine.substring( 1 );
+
+ player.sendMessage( outputLine );
+ }
+ Output.get().logInfo( outputLine );
+ }
@@ -215,10 +263,15 @@ public void onPlayerInteract( PrisonPlayerInteractEvent e ) {
//
// checkForEvent(e.getPlayer(), sel);
// }
+
+ // disable active prior to exiting function:
+ //this.active = false;
+
}
- public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTargetPrisonBlock targetBlock ) {
- List output = new ArrayList<>();
+ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTargetPrisonBlock targetBlock,
+ List output ) {
+// List output = new ArrayList<>();
SpigotBlock checkBlock = sBlock;
@@ -292,18 +345,33 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTa
) );
- printEventStatus( bbe, "-initial-", "", checkBlock, targetBlock, tool, output, player );
+ EventDropsStatus isNs = isDropCanceled( bbe );
+
+
+ output.add( " &3Legend: &7EP&3: EventPriority &7EC&3: EventCanceled "
+ + "&7DC&3: DropsCanceled &7EB&3: EventBlock &7Ds&3: Drops "
+ + "&7ms&3: dur ms"
+ + ( isNs == EventDropsStatus.notSupported ? " &7NS&3: NotSupported" : "" )
+ );
+
+
+ printEventStatus( bbe, "-initial-", "", checkBlock, targetBlock, tool, output, player, -1 );
for ( RegisteredListener listener : bbe.getHandlers().getRegisteredListeners() ) {
+ long start = 0;
+ long stop = 0;
+
try {
// boolean isPrison = listener.getPlugin().getName().equalsIgnoreCase( "Prison" );
// boolean isSpigotListener = isPrison && listener.getListener() instanceof SpigotListener;
// if ( !isSpigotListener ) {
+ start = System.nanoTime();
listener.callEvent( bbe );
+ stop = System.nanoTime();
// }
}
@@ -316,9 +384,15 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTa
}
+ double durationNano = (stop - start);
+
+ if ( durationNano > 0 ) {
+ durationNano = durationNano / 1_000_000;
+ }
+
printEventStatus( bbe,
listener.getPlugin().getName(), listener.getPriority().name(), checkBlock, targetBlock,
- tool, output, player );
+ tool, output, player, durationNano );
}
@@ -326,10 +400,10 @@ public void dumpBlockBreakEvent( SpigotPlayer player, SpigotBlock sBlock, MineTa
// Put the heldItem back in the player's hand, which should be the prison wand:
SpigotCompatibility.getInstance().setItemInMainHand( player.getWrapper(), heldItem );
- for ( String outputLine : output )
- {
- Output.get().logInfo( outputLine );
- }
+// for ( String outputLine : output )
+// {
+// Output.get().logInfo( outputLine );
+// }
}
@@ -363,9 +437,11 @@ private void printEventStatus( BlockBreakEvent bbe,
MineTargetPrisonBlock targetBlock,
SpigotItemStack tool,
List output,
- SpigotPlayer player ) {
+ SpigotPlayer player,
+ double durationNano ) {
StringBuilder sb = new StringBuilder();
+ StringBuilder sb2 = new StringBuilder();
sb.append( " " );
boolean isCanceled = bbe.isCancelled();
@@ -375,7 +451,7 @@ private void printEventStatus( BlockBreakEvent bbe,
dropStats = "&4" + isDropCanceled.name();
}
else if ( isDropCanceled == EventDropsStatus.notSupported ) {
- dropStats = "&d" + isDropCanceled.name();
+ dropStats = "&dNS"; // + isDropCanceled.name();
}
// Get a fresh copy of the block to ensure we pickup the latest status:
@@ -386,30 +462,13 @@ else if ( isDropCanceled == EventDropsStatus.notSupported ) {
bukkitDrops = obbMines.mergeDrops( bukkitDrops );
- String msg = String.format( " &3Plugin: &7%-15s &2EventPriority: &7%-9s "
- + "&2EventCanceled: &7%5s &2DropsCanceled: &7%s",
- plugin,
- ( priority == null ? "$dnone" : priority ),
- ( isCanceled ? "&4true " : "false" ),
- dropStats
- );
- sb.append( msg );
-
-
-
-
- output.add( sb.toString() );
- sb.setLength( 0 );
-
SpigotBlock eventBlock = SpigotBlock.getSpigotBlock( bbe.getBlock() );
-
- String msg2 = String.format( " &aEventBlock: &b%s ",
- eventBlock == null ?
- "&4none" :
- eventBlock.getBlockNameFormal() );
- sb.append( msg2 );
+ String eventBlockName = eventBlock == null ?
+ "&4none" :
+ eventBlock.getBlockNameFormal();
+
- sb.append( " &aDrops:" );
+ // Build the drops listing:
if ( bukkitDrops.size() > 0 ) {
// List drops = sBlk.getDrops( tool );
@@ -417,20 +476,68 @@ else if ( isDropCanceled == EventDropsStatus.notSupported ) {
{
// SpigotItemStack sis = (SpigotItemStack) itemStack;
- sb.append( " &b" ).append( itemStack.getName() );
+ sb2.append( " &b" ).append( itemStack.getName() );
if ( itemStack.getAmount() > 0 ) {
- sb.append( "&a(&b" ).append( itemStack.getAmount() ).append( "&a)" );
+ sb2.append( "&a(&b" ).append( itemStack.getAmount() ).append( "&a)" );
}
}
}
else {
- sb.append( "&4none" );
+ sb2.append( "&4none" );
}
- if ( sb.length() > 0 ) {
- output.add( sb.toString() );
- sb.setLength( 0 );
- }
+
+ DecimalFormat dFmt = new DecimalFormat("#,##0.000000");
+ String durationNanoStr = durationNano == -1 ? "---" : dFmt.format( durationNano );
+
+
+ String msg = String.format( " &3Plugin: &7%-15s &2EP: &7%-9s "
+ + "&2EC: &7%5s &2DC: &7%s &aEB: &b%s &aDs: %s &ams: &7%s",
+ plugin,
+ ( priority == null ? "$dnone" : priority ),
+ ( isCanceled ? "&4true " : "false" ),
+ dropStats,
+ eventBlockName,
+ sb2,
+ durationNanoStr
+ );
+ sb.append( msg );
+
+
+ output.add( sb.toString() );
+
+
+// sb.setLength( 0 );
+
+
+// String msg2 = String.format( " &aEventBlock: &b%s ",
+// eventBlock == null ?
+// "&4none" :
+// eventBlock.getBlockNameFormal() );
+// sb.append( msg2 );
+
+// sb.append( " &aDrops:" );
+// if ( bukkitDrops.size() > 0 ) {
+//
+//// List drops = sBlk.getDrops( tool );
+// for ( ItemStack itemStack : bukkitDrops )
+// {
+//// SpigotItemStack sis = (SpigotItemStack) itemStack;
+//
+// sb.append( " &b" ).append( itemStack.getName() );
+// if ( itemStack.getAmount() > 0 ) {
+// sb.append( "&a(&b" ).append( itemStack.getAmount() ).append( "&a)" );
+// }
+// }
+// }
+// else {
+// sb.append( "&4none" );
+// }
+
+// if ( sb.length() > 0 ) {
+// output.add( sb.toString() );
+// sb.setLength( 0 );
+// }
}
@@ -438,7 +545,7 @@ private EventDropsStatus isDropCanceled( BlockBreakEvent bbe ) {
EventDropsStatus results = EventDropsStatus.normal;
try {
- if ( bbe.isDropItems() ) {
+ if ( !bbe.isDropItems() ) {
results = EventDropsStatus.canceled;
}
else {
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksListeners.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksListeners.java
index 880241c65..74c95c85d 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksListeners.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/backpacks/BackpacksListeners.java
@@ -11,6 +11,8 @@
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
+
+import tech.mcprison.prison.Prison;
import tech.mcprison.prison.spigot.SpigotPrison;
import tech.mcprison.prison.spigot.SpigotUtil;
import tech.mcprison.prison.spigot.compat.Compatibility;
@@ -130,9 +132,11 @@ private void backpackItemClickAction(PlayerInteractEvent e) {
if (materialConf != null && inHandItem != null && inHandItem.getType() == materialConf.getType() && inHandItem.hasItemMeta() && inHandItem.getItemMeta().hasDisplayName()
&& inHandItem.getItemMeta().getDisplayName().equalsIgnoreCase(SpigotPrison.format(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Item_Title")))) {
if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled"))){
- Bukkit.dispatchCommand(p, "gui backpackslist");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "gui backpackslist" ));
} else {
- Bukkit.dispatchCommand(p, "gui backpack");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "gui backpack" ));
}
e.setCancelled(true);
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
index 760da3281..3017e4ec4 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventCore.java
@@ -1,6 +1,5 @@
package tech.mcprison.prison.spigot.block;
-import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -36,7 +35,6 @@
import tech.mcprison.prison.spigot.game.SpigotPlayer;
import tech.mcprison.prison.spigot.sellall.SellAllUtil;
import tech.mcprison.prison.spigot.utils.BlockUtils;
-import tech.mcprison.prison.spigot.utils.tasks.PlayerAutoRankupTask;
import tech.mcprison.prison.util.Text;
public abstract class OnBlockBreakEventCore
@@ -276,7 +274,7 @@ protected void finalizeBreakTheBlocks( PrisonMinesBlockBreakEvent pmEvent )
int count = 0;
for ( SpigotBlock spigotBlock : blocks ) {
- if ( count++ % 10 == 0 && pmEvent.getMine() != null &&
+ if ( count++ % 20 == 0 && pmEvent.getMine() != null &&
!pmEvent.getMine().getMineStateMutex().isMinable() ) {
SpigotPlayer sPlayer = pmEvent.getSpigotPlayer();
@@ -328,6 +326,30 @@ private List finalizeBreakTheBlocksCollectEm( PrisonMinesBlockBreak
return blocks;
}
+
+ /**
+ * Used with BlockConverters event triggers.
+ *
+ *
+ * @param pmEvent
+ * @param minedBlock
+ * @param targetBlock
+ * @return
+ */
+ protected SpigotBlock finalizeBreakTheBlocks( PrisonMinesBlockBreakEvent pmEvent,
+ SpigotBlock minedBlock, MineTargetPrisonBlock targetBlock ) {
+ SpigotBlock results = null;
+
+ if ( targetBlock.getPrisonBlock().getBlockName().equalsIgnoreCase( minedBlock.getBlockName() ) ) {
+ results = minedBlock;
+ targetBlock.setAirBroke( true );
+
+ // Count the blocks that were mined:
+ countBlocksMined( pmEvent, pmEvent.getTargetBlock() );
+ }
+
+ return results;
+ }
/**
@@ -350,6 +372,8 @@ protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent )
StringBuilder debugInfo = pmEvent.getDebugInfo();
+ debugInfo.append( "{br}|| validateEvent:: " );
+
SpigotBlock sBlockHit = pmEvent.getSpigotBlock();
// Mine should already be set:
@@ -398,7 +422,9 @@ protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent )
// NOTE: I have no idea why 25 blocks and less should be bypassed for validation:
boolean bypassMatchedBlocks = pmEvent.getMine().getBounds().getTotalBlockCount() <= 25;
if ( bypassMatchedBlocks ) {
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "(TargetBlock match requirement is disabled [blocks<=25]) " );
+ pmEvent.setDebugColorCodeDebug();
}
boolean matchedBlocks = isBlockAMatch( targetBlock, sBlockHit );
@@ -407,6 +433,7 @@ protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent )
// and the block has not been mined before, then allow the breakage by
// setting bypassMatchedBlocks to true to allow normal processing:
if ( !matchedBlocks &&
+ targetBlock != null &&
!targetBlock.isMined() &&
sBlockHit.isAir() &&
pmEvent.getBbPriority().isMonitor() ) {
@@ -421,6 +448,8 @@ protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent )
targetBlock.isExploded()) ) {
// debugInfo.setLength( 0 );
+
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "(Primary TargetBlock forcedFastFail validateEvent [ ");
if ( targetBlock.isIgnoreAllBlockEvents() ) {
debugInfo.append( "ignoreAllBlockEvents " );
@@ -429,6 +458,7 @@ protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent )
debugInfo.append( "alreadyExploded" );
}
debugInfo.append( "]) " );
+ pmEvent.setDebugColorCodeDebug();
pmEvent.setForceIfAirBlock( false );
@@ -529,7 +559,9 @@ protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent )
// This block has already been mined and is not a mine bomb, so fail the validation
// and cancel the event since if it's not an air block, it may be another effect that
// is placing a block within the mine, such as a prison util's decay function.
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "VALIDATION_FAILED_BLOCK_ALREADY_MINED " );
+ pmEvent.setDebugColorCodeDebug();
results = false;
@@ -541,7 +573,9 @@ protected boolean validateEvent( PrisonMinesBlockBreakEvent pmEvent )
else {
noTargetBlock++;
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "VALIDATION_FAILED_NO_TARGETBLOCK " );
+ pmEvent.setDebugColorCodeDebug();
results = false;
}
@@ -675,8 +709,10 @@ else if ( targetExplodedBlock.isMined() ) {
}
if ( unbreakable > 0 ) {
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "UNBREAKABLE_BLOCK_UTILS (" + unbreakable +
" blocks, event not canceled) " );
+ pmEvent.setDebugColorCodeDebug();
}
if ( outsideOfMine > 0 ) {
@@ -700,8 +736,10 @@ else if ( targetExplodedBlock.isMined() ) {
}
if ( blockTypeNotExpected > 0 ) {
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "BLOCK_TYPE_NOT_EXPECTED__CANNOT_PROCESS (" + blockTypeNotExpected +
" ) " );
+ pmEvent.setDebugColorCodeDebug();
}
@@ -729,7 +767,9 @@ else if ( targetExplodedBlock.isMined() ) {
// Ignore event and clear debugInfo:
// debugInfo.setLength( 0 );
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "(TargetBlock forcedFastFail validateEvent [BlockAlreadyMined]) " );
+ pmEvent.setDebugColorCodeDebug();
return results;
}
@@ -737,7 +777,7 @@ else if ( targetExplodedBlock.isMined() ) {
}
- debugInfo.append( "blocks(" )
+ debugInfo.append( " blocks(" )
.append( pmEvent.getBlock() == null ? "0" : "1" )
.append( "+" )
.append( pmEvent.getExplodedBlocks().size() )
@@ -753,14 +793,18 @@ else if ( targetExplodedBlock.isMined() ) {
// "&cYour tool is worn-out and cannot be used." );
pmEvent.setCancelOriginalEvent( true );
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "UNUSABLE_TOOL__WORN_OUT (event canceled) " );
+ pmEvent.setDebugColorCodeDebug();
results = false;
}
if ( mine != null && BlockUtils.getInstance().isUnbreakable( sBlockHit ) ) {
// The block is unbreakable because a utility has it locked:
pmEvent.setCancelOriginalEvent( true );
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "UNBREAKABLE_BLOCK_UTILS (event canceled) " );
+ pmEvent.setDebugColorCodeDebug();
results = false;
}
if ( mine != null && (mine.isMineAccessByRank() || mine.isAccessPermissionEnabled()) &&
@@ -772,9 +816,11 @@ else if ( targetExplodedBlock.isMined() ) {
mine.isAccessPermissionEnabled() ? "Perms" : "Other?";
pmEvent.setCancelOriginalEvent( true );
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "ACCESS_DENIED (event canceled - Access by " )
.append( accessType )
.append( ") " );
+ pmEvent.setDebugColorCodeDebug();
results = false;
}
@@ -849,7 +895,9 @@ else if ( targetExplodedBlock.isMined() ) {
else if ( results && pmEvent.getBbPriority().isMonitor() && mine == null ) {
// bypass all processing since the block break is outside any mine:
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "(MONITOR bypassed: no mine) " );
+ pmEvent.setDebugColorCodeDebug();
results = false;
}
@@ -867,32 +915,39 @@ else if ( results && pmEvent.getBbPriority().isMonitor() && mine != null ) {
debugInfo.append( "(BLOCKEVENTS processing) " );
- // This is true if the player cannot toggle the autosell, and it's
- // true if they can, and the have it enabled:
- boolean isPlayerAutosellEnabled = SellAllUtil.get() != null &&
- SellAllUtil.get().checkIfPlayerAutosellIsActive(
- pmEvent.getSpigotPlayer().getWrapper() )
- ;
-
- // AutoSell on full inventory when using BLOCKEVENTS:
- if ( isBoolean( AutoFeatures.isAutoSellIfInventoryIsFullForBLOCKEVENTSPriority ) &&
- SpigotPrison.getInstance().isSellAllEnabled() &&
- isPlayerAutosellEnabled &&
- pmEvent.getSpigotPlayer().isInventoryFull() ) {
+ if ( SpigotPrison.getInstance().isSellAllEnabled() ) {
+ SellAllUtil sellAllUtil = SellAllUtil.get();
- final long nanoStart = System.nanoTime();
- boolean success = SellAllUtil.get().sellAllSell( pmEvent.getPlayer(),
- false, false, false, true, true, false);
- final long nanoStop = System.nanoTime();
- double milliTime = (nanoStop - nanoStart) / 1000000d;
+ // This will return true (allow autosell) unless players can toggle autosell and they turned it off:
+ // This is to be used with other auto sell setting, but never on it's own:
+ boolean isPlayerAutosellEnabled =
+ (!sellAllUtil.isAutoSellPerUserToggleable ||
+ sellAllUtil.isSellallPlayerUserToggleEnabled(
+ pmEvent.getPlayer() ));
- DecimalFormat dFmt = Prison.get().getDecimalFormat("#,##0.00");
- debugInfo.append( "(autosell BLOCKEVENTS: " + (success ? "success" : "failed") +
- " ms: " + dFmt.format( milliTime ) + ") ");
- PlayerAutoRankupTask.autoSubmitPlayerRankupTask( pmEvent.getSpigotPlayer(), debugInfo );
+ // AutoSell on full inventory when using BLOCKEVENTS:
+ if ( isBoolean( AutoFeatures.isAutoSellIfInventoryIsFullForBLOCKEVENTSPriority ) &&
+ isPlayerAutosellEnabled &&
+ pmEvent.getSpigotPlayer().isInventoryFull() ) {
+
+ pmEvent.performSellAllOnPlayerInventoryLogged("BLOCKEVENTS priority sellall");
+
+// final long nanoStart = System.nanoTime();
+// boolean success = SellAllUtil.get().sellAllSell( pmEvent.getPlayer(),
+// false, false, false, true, true, false);
+// final long nanoStop = System.nanoTime();
+// double milliTime = (nanoStop - nanoStart) / 1000000d;
+//
+// DecimalFormat dFmt = Prison.get().getDecimalFormat("#,##0.00");
+// debugInfo.append( "(autosell BLOCKEVENTS: " + (success ? "success" : "failed") +
+// " ms: " + dFmt.format( milliTime ) + ") ");
+//
+// PlayerAutoRankupTask.autoSubmitPlayerRankupTask( pmEvent.getSpigotPlayer(), debugInfo );
+//
+ }
}
}
@@ -969,10 +1024,14 @@ else if ( results && pmEvent.getBbPriority().isMonitor() && mine != null ) {
debugInfo.append( "(PassedValidation) " );
}
else {
+ pmEvent.setDebugColorCodeWarning();
debugInfo.append( "(ValidationFailed) " );
+ pmEvent.setDebugColorCodeDebug();
}
+// debugInfo.append( "{br}|| " );
+
return results;
}
@@ -1233,7 +1292,9 @@ public boolean applyDropsBlockBreakage( PrisonMinesBlockBreakEvent pmEvent, int
success = true;
}
else {
+ pmEvent.setDebugColorCodeWarning();
pmEvent.getDebugInfo().append( "(fail:totalDrops=0) ");
+ pmEvent.setDebugColorCodeDebug();
}
return success;
@@ -1707,7 +1768,8 @@ protected int getDurabilityResistance(SpigotItemStack itemInHand, String itemLor
try {
results += Integer.parseInt(val);
} catch (NumberFormatException e1) {
- Output.get().logError("AutoManager: tool durability failure. lore= [" + s + "] val= [" + val + "] error: " + e1.getMessage());
+ Output.get().logError("AutoManager: tool durability failure. "
+ + "lore= [" + s + "] val= [" + val + "] error: " + e1.getMessage());
}
break;
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
index d7ad293f5..f693a3c41 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakEventListener.java
@@ -17,6 +17,9 @@
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerRevEnchantsExplosiveEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerRevEnchantsJackHammerEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerTokenEnchant;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonExplosionTriggerEvent;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonLayerTriggerEvent;
+import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerXPrisonNukeTriggerEvent;
import tech.mcprison.prison.spigot.autofeatures.events.AutoManagerZenchantments;
import tech.mcprison.prison.spigot.autofeatures.events.PrisonDebugBlockInspector;
@@ -111,10 +114,16 @@ public class OnBlockBreakEventListener
private AutoManagerRevEnchantsExplosiveEvent reEEvents;
private AutoManagerRevEnchantsJackHammerEvent reJHEvents;
-
+ private AutoManagerXPrisonExplosionTriggerEvent xpExpEvents;
+ private AutoManagerXPrisonLayerTriggerEvent xpLayerEvents;
+ private AutoManagerXPrisonNukeTriggerEvent xpNukeEvents;
+
+
private PrisonDebugBlockInspector pdBlockInspector;
+
+
public OnBlockBreakEventListener() {
super();
@@ -208,32 +217,66 @@ public void reloadEventListeners() {
private void registerEvents() {
bbEvents = new AutoManagerBlockBreakEvents();
- bbEvents.registerEvents();
-
+
// Prison's own internal event and listener:
pebbEvents = new AutoManagerPrisonsExplosiveBlockBreakEvents();
- pebbEvents.registerEvents();
-
+
+ ceEvents = new AutoManagerCrazyEnchants();
+
ceEvents = new AutoManagerCrazyEnchants();
- ceEvents.registerEvents();
peEvents = new AutoManagerPrisonEnchants();
- peEvents.registerEvents();
-
+
teEvents = new AutoManagerTokenEnchant();
- teEvents.registerEvents();
zcEvents = new AutoManagerZenchantments();
- zcEvents.registerEvents();
reEEvents = new AutoManagerRevEnchantsExplosiveEvent();
- reEEvents.registerEvents();
reJHEvents = new AutoManagerRevEnchantsJackHammerEvent();
- reJHEvents.registerEvents();
- pdBlockInspector = new PrisonDebugBlockInspector();
- pdBlockInspector.init();
+
+
+ xpExpEvents = new AutoManagerXPrisonExplosionTriggerEvent();
+
+ xpLayerEvents = new AutoManagerXPrisonLayerTriggerEvent();
+
+ xpNukeEvents = new AutoManagerXPrisonNukeTriggerEvent();
+
+
+
+ if ( AutoFeaturesWrapper.getInstance().isBoolean(AutoFeatures.isAutoManagerEnabled) ) {
+
+ bbEvents.registerEvents();
+
+ // Prison's own internal event and listener:
+ pebbEvents.registerEvents();
+
+ ceEvents.registerEvents();
+
+ peEvents.registerEvents();
+
+ teEvents.registerEvents();
+
+ zcEvents.registerEvents();
+
+ reEEvents.registerEvents();
+
+ reJHEvents.registerEvents();
+
+
+ xpExpEvents.registerEvents();
+
+ xpLayerEvents.registerEvents();
+
+ xpNukeEvents.registerEvents();
+
+ }
+
+ pdBlockInspector = PrisonDebugBlockInspector.getInstance();
+ pdBlockInspector.getClass();
+
+// pdBlockInspector.init();
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java
index 382a535fb..a99068edd 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakMines.java
@@ -92,9 +92,9 @@ public void logDebugInfo() {
"" :
getSpigotBlock().getLocation().toWorldCoordinates();
- Output.get().logInfo( "Prison AutoFeatures Fast-Fail: %s %s %s %s %s%s",
+ Output.get().logInfo( "Prison AutoFeatures Fast-Fail: %s %s %s %s%s",
getResultsReason().name(),
- getBbPriority().name(),
+ //getBbPriority().name(),
getSpigotPlayer().getName(),
getMine() == null ? "noMine" : getMine().getName(),
@@ -115,9 +115,9 @@ public String getDebugInfo() {
getSpigotBlock().getLocation().toWorldCoordinates();
return String.format(
- "AutoFeatures: %s %s %s %s %s%s ",
+ "{br}|| EventInfo: %s %s Mine: %s %s %s ",
getResultsReason().name(),
- getBbPriority().name(),
+// getBbPriority().name(),
getSpigotPlayer().getName(),
getMine() == null ? "noMine" : getMine().getName(),
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java
index 4ea130819..5d5e0f551 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/block/OnBlockBreakPlayerManualCore.java
@@ -267,12 +267,13 @@ protected void autoFeatureBlock( Player p, XMaterial source, StringBuilder debug
- protected void autoSmelt( boolean autoSmelt, XMaterial source, XMaterial target, Player p, StringBuilder debugInfo ) {
+ protected void autoSmelt( boolean autoSmelt, XMaterial source, XMaterial target,
+ Player p, StringBuilder debugInfo ) {
if ( autoSmelt && source != null && target != null ) {
HashMap overflow = SpigotUtil.itemStackReplaceItems( p, source, target, 1 );
- dropExtra( overflow, p, debugInfo );
+ dropExtra( overflow, p, debugInfo, false );
}
}
@@ -283,11 +284,12 @@ protected void autoBlock( boolean autoBlock, XMaterial source, XMaterial target,
}
- protected void autoBlock( boolean autoBlock, XMaterial source, XMaterial target, int ratio, Player p, StringBuilder debugInfo ) {
+ protected void autoBlock( boolean autoBlock, XMaterial source, XMaterial target, int ratio,
+ Player p, StringBuilder debugInfo ) {
if ( autoBlock && source != null && target != null ) {
HashMap overflow = SpigotUtil.itemStackReplaceItems( p, source, target, ratio );
- dropExtra( overflow, p, debugInfo );
+ dropExtra( overflow, p, debugInfo, false );
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotBackpackCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotBackpackCommands.java
index 4d07b0d54..5c8648c2c 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotBackpackCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotBackpackCommands.java
@@ -29,8 +29,9 @@ private void backpackMainCommand(CommandSender sender,
description = "Leave empty if you want to open your main backpack, add an ID if you've more than one.") String id){
if (sender.hasPermission("prison.admin") || sender.isOp()){
- String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand("backpack help");
- sender.dispatchCommand(registeredCmd);
+ sender.dispatchCommand("backpack help");
+// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand("backpack help");
+// sender.dispatchCommand(registeredCmd);
return;
}
@@ -277,79 +278,79 @@ private void openBackpackAdminGUI(CommandSender sender){
BackpacksAdminGUI gui = new BackpacksAdminGUI(p);
gui.open();
}
-
- @Command(identifier = "gui backpack", description = "Backpack as a GUI", onlyPlayers = true)
- private void backpackGUIOpenCommand(CommandSender sender,
- @Arg(name = "Backpack-ID", def = "null",
- description = "If user have more than backpack, he'll be able to choose another backpack on ID") String id){
-
- Player p = getSpigotPlayer(sender);
-
- if (p == null) {
- Output.get().sendInfo(sender, SpigotPrison.format( messages.getString(MessagesConfig.StringID.spigot_message_console_error)));
- return;
- }
-
- if (isDisabledWorld(p)) return;
-
- if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled")) && (BackpacksUtil.get().reachedBackpacksLimit(p) && !BackpacksUtil.get().getBackpacksIDs(p).contains(id))){
- Output.get().sendInfo(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_backpack_limit_reached) + " [" + BackpacksUtil.get().getNumberOwnedBackpacks(p) + "]"));
- return;
- }
-
- if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission_Enabled")) && !p.hasPermission(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission"))){
- Output.get().sendWarn(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_missing_permission) + " [" + BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission") + "]"));
- return;
- }
-
- if (!BackpacksUtil.get().canOwnBackpack(p)){
- Output.get().sendInfo(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_backpack_cant_own)));
- return;
- }
-
- // New method.
- if (!id.equalsIgnoreCase("null") && getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled"))){
- BackpacksUtil.get().openBackpack(p, id);
- } else {
- BackpacksUtil.get().openBackpack(p, (String) null );
- }
- }
-
- @Command(identifier = "gui backpackslist", description = "Backpack as a GUI", onlyPlayers = true)
- private void backpackListGUICommand(CommandSender sender){
- Player p = getSpigotPlayer(sender);
-
- if (p == null) {
- Output.get().sendInfo(sender, SpigotPrison.format( messages.getString(MessagesConfig.StringID.spigot_message_console_error)));
- return;
- }
-
- if (isDisabledWorld(p)) return;
-
- // New method.
- if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled"))){
- if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission_Enabled")) && !p.hasPermission(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission"))){
- Output.get().sendWarn(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_missing_permission) + " [" + BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission") + "]"));
- return;
- }
- BackpacksListPlayerGUI gui = new BackpacksListPlayerGUI(p);
- gui.open();
- }
- }
-
- @Command(identifier = "gui backpackadmin", description = "Open backpack admin GUI", permissions = "prison.admin", onlyPlayers = true)
- private void openBackpackAdminCommandGUI(CommandSender sender){
-
- Player p = getSpigotPlayer(sender);
-
- if (p == null) {
- Output.get().sendInfo(sender, SpigotPrison.format( messages.getString(MessagesConfig.StringID.spigot_message_console_error)));
- return;
- }
-
- BackpacksAdminGUI gui = new BackpacksAdminGUI(p);
- gui.open();
- }
+//
+// @Command(identifier = "gui backpack", description = "Backpack as a GUI", onlyPlayers = true)
+// private void backpackGUIOpenCommand(CommandSender sender,
+// @Arg(name = "Backpack-ID", def = "null",
+// description = "If user have more than backpack, he'll be able to choose another backpack on ID") String id){
+//
+// Player p = getSpigotPlayer(sender);
+//
+// if (p == null) {
+// Output.get().sendInfo(sender, SpigotPrison.format( messages.getString(MessagesConfig.StringID.spigot_message_console_error)));
+// return;
+// }
+//
+// if (isDisabledWorld(p)) return;
+//
+// if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled")) && (BackpacksUtil.get().reachedBackpacksLimit(p) && !BackpacksUtil.get().getBackpacksIDs(p).contains(id))){
+// Output.get().sendInfo(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_backpack_limit_reached) + " [" + BackpacksUtil.get().getNumberOwnedBackpacks(p) + "]"));
+// return;
+// }
+//
+// if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission_Enabled")) && !p.hasPermission(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission"))){
+// Output.get().sendWarn(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_missing_permission) + " [" + BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission") + "]"));
+// return;
+// }
+//
+// if (!BackpacksUtil.get().canOwnBackpack(p)){
+// Output.get().sendInfo(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_backpack_cant_own)));
+// return;
+// }
+//
+// // New method.
+// if (!id.equalsIgnoreCase("null") && getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled"))){
+// BackpacksUtil.get().openBackpack(p, id);
+// } else {
+// BackpacksUtil.get().openBackpack(p, (String) null );
+// }
+// }
+//
+// @Command(identifier = "gui backpackslist", description = "Backpack as a GUI", onlyPlayers = true)
+// private void backpackListGUICommand(CommandSender sender){
+// Player p = getSpigotPlayer(sender);
+//
+// if (p == null) {
+// Output.get().sendInfo(sender, SpigotPrison.format( messages.getString(MessagesConfig.StringID.spigot_message_console_error)));
+// return;
+// }
+//
+// if (isDisabledWorld(p)) return;
+//
+// // New method.
+// if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled"))){
+// if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission_Enabled")) && !p.hasPermission(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission"))){
+// Output.get().sendWarn(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_missing_permission) + " [" + BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission") + "]"));
+// return;
+// }
+// BackpacksListPlayerGUI gui = new BackpacksListPlayerGUI(p);
+// gui.open();
+// }
+// }
+//
+// @Command(identifier = "gui backpackadmin", description = "Open backpack admin GUI", permissions = "prison.admin", onlyPlayers = true)
+// private void openBackpackAdminCommandGUI(CommandSender sender){
+//
+// Player p = getSpigotPlayer(sender);
+//
+// if (p == null) {
+// Output.get().sendInfo(sender, SpigotPrison.format( messages.getString(MessagesConfig.StringID.spigot_message_console_error)));
+// return;
+// }
+//
+// BackpacksAdminGUI gui = new BackpacksAdminGUI(p);
+// gui.open();
+// }
private boolean isDisabledWorld(Player p) {
String worldName = p.getWorld().getName();
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUIBackPackCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUIBackPackCommands.java
new file mode 100644
index 000000000..b301ba73e
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUIBackPackCommands.java
@@ -0,0 +1,103 @@
+package tech.mcprison.prison.spigot.commands;
+
+import java.util.List;
+
+import org.bukkit.entity.Player;
+
+import tech.mcprison.prison.commands.Arg;
+import tech.mcprison.prison.commands.Command;
+import tech.mcprison.prison.internal.CommandSender;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.backpacks.BackpacksUtil;
+import tech.mcprison.prison.spigot.configs.MessagesConfig;
+import tech.mcprison.prison.spigot.gui.backpacks.BackpacksAdminGUI;
+import tech.mcprison.prison.spigot.gui.backpacks.BackpacksListPlayerGUI;
+
+public class PrisonSpigotGUIBackPackCommands
+ extends PrisonSpigotBaseCommands
+{
+
+ private final MessagesConfig messages = SpigotPrison.getInstance().getMessagesConfig();
+
+ @Command(identifier = "gui backpack", description = "Backpack as a GUI", onlyPlayers = true)
+ private void backpackGUIOpenCommand(CommandSender sender,
+ @Arg(name = "Backpack-ID", def = "null",
+ description = "If user have more than backpack, he'll be able to choose another backpack on ID") String id){
+
+ Player p = getSpigotPlayer(sender);
+
+ if (p == null) {
+ Output.get().sendInfo(sender, SpigotPrison.format( messages.getString(MessagesConfig.StringID.spigot_message_console_error)));
+ return;
+ }
+
+ if (isDisabledWorld(p)) return;
+
+ if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled")) && (BackpacksUtil.get().reachedBackpacksLimit(p) && !BackpacksUtil.get().getBackpacksIDs(p).contains(id))){
+ Output.get().sendInfo(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_backpack_limit_reached) + " [" + BackpacksUtil.get().getNumberOwnedBackpacks(p) + "]"));
+ return;
+ }
+
+ if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission_Enabled")) && !p.hasPermission(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission"))){
+ Output.get().sendWarn(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_missing_permission) + " [" + BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission") + "]"));
+ return;
+ }
+
+ if (!BackpacksUtil.get().canOwnBackpack(p)){
+ Output.get().sendInfo(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_backpack_cant_own)));
+ return;
+ }
+
+ // New method.
+ if (!id.equalsIgnoreCase("null") && getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled"))){
+ BackpacksUtil.get().openBackpack(p, id);
+ } else {
+ BackpacksUtil.get().openBackpack(p, (String) null );
+ }
+ }
+
+ @Command(identifier = "gui backpackslist", description = "Backpack as a GUI", onlyPlayers = true)
+ private void backpackListGUICommand(CommandSender sender){
+ Player p = getSpigotPlayer(sender);
+
+ if (p == null) {
+ Output.get().sendInfo(sender, SpigotPrison.format( messages.getString(MessagesConfig.StringID.spigot_message_console_error)));
+ return;
+ }
+
+ if (isDisabledWorld(p)) return;
+
+ // New method.
+ if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.Multiple-BackPacks-For-Player-Enabled"))){
+ if (getBoolean(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission_Enabled")) && !p.hasPermission(BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission"))){
+ Output.get().sendWarn(sender, SpigotPrison.format(messages.getString(MessagesConfig.StringID.spigot_message_missing_permission) + " [" + BackpacksUtil.get().getBackpacksConfig().getString("Options.BackPack_Use_Permission") + "]"));
+ return;
+ }
+ BackpacksListPlayerGUI gui = new BackpacksListPlayerGUI(p);
+ gui.open();
+ }
+ }
+
+ @Command(identifier = "gui backpackadmin", description = "Open backpack admin GUI", permissions = "prison.admin", onlyPlayers = true)
+ private void openBackpackAdminCommandGUI(CommandSender sender){
+
+ Player p = getSpigotPlayer(sender);
+
+ if (p == null) {
+ Output.get().sendInfo(sender, SpigotPrison.format( messages.getString(MessagesConfig.StringID.spigot_message_console_error)));
+ return;
+ }
+
+ BackpacksAdminGUI gui = new BackpacksAdminGUI(p);
+ gui.open();
+ }
+
+
+ private boolean isDisabledWorld(Player p) {
+ String worldName = p.getWorld().getName();
+ List disabledWorlds = BackpacksUtil.get().getBackpacksConfig().getStringList("Options.DisabledWorlds");
+ return disabledWorlds.contains(worldName);
+ }
+
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUISellAllCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUISellAllCommands.java
new file mode 100644
index 000000000..e9bfee34c
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotGUISellAllCommands.java
@@ -0,0 +1,78 @@
+package tech.mcprison.prison.spigot.commands;
+
+import org.bukkit.entity.Player;
+
+import tech.mcprison.prison.commands.Arg;
+import tech.mcprison.prison.commands.Command;
+import tech.mcprison.prison.internal.CommandSender;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.sellall.messages.SpigotVariousGuiMessages;
+import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.configs.MessagesConfig;
+import tech.mcprison.prison.spigot.gui.sellall.SellAllAdminBlocksGUI;
+import tech.mcprison.prison.spigot.sellall.SellAllUtil;
+
+public class PrisonSpigotGUISellAllCommands
+ extends PrisonSpigotBaseCommands {
+
+
+ @Command(identifier = "sellall gui",
+ description = "SellAll GUI command",
+// aliases = "gui sellall",
+ permissions = "prison.admin", onlyPlayers = true)
+ private void sellAllGuiCommand(CommandSender sender,
+ @Arg(name = "page", description = "If there are more than 45 items, then they " +
+ "will be shown on multiple pages. The page parameter starts with " +
+ "page 1.", def = "1" ) int page){
+
+ if (!PrisonSpigotSellAllCommands.isEnabled()) return;
+
+ Player p = getSpigotPlayer(sender);
+
+ // Sender must be a Player, not something else like the Console.
+ if (p == null) {
+ Output.get().sendError(sender, getMessages().getString(MessagesConfig.StringID.spigot_message_console_error));
+ return;
+ }
+
+ if ( !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
+
+ if (!sellAllUtil.openSellAllGUI( p, page, "sellall gui", "close" )){
+ // If the sender's an admin (OP or have the prison.admin permission) it'll send an error message.
+ if (p.hasPermission("prison.admin")) {
+
+ new SpigotVariousGuiMessages().sellallGUIIsDisabledMsg(sender);
+// Output.get().sendError(sender,
+// messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_disabled));
+ }
+ }
+ }
+
+ @Command(identifier = "sellall gui blocks",
+ description = "SellAll GUI Blocks command",
+ aliases = "gui sellall",
+ permissions = "prison.admin", onlyPlayers = true)
+ private void sellAllGuiBlocksCommand(CommandSender sender,
+ @Arg(name = "page", description = "If there are more than 45 items, then they " +
+ "will be shown on multiple pages. The page parameter starts with " +
+ "page 1.", def = "1" ) int page){
+
+ if (!PrisonSpigotSellAllCommands.isEnabled()) return;
+
+ Player p = getSpigotPlayer(sender);
+
+ // Sender must be a Player, not something else like the Console.
+ if (p == null) {
+ Output.get().sendError(sender, getMessages().getString(MessagesConfig.StringID.spigot_message_console_error));
+ return;
+ }
+
+ SellAllAdminBlocksGUI saBlockGui = new SellAllAdminBlocksGUI( p, page, "sellall gui blocks", "sellall gui" );
+ saBlockGui.open();
+
+ }
+
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotPrestigeCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotPrestigeCommands.java
index da434a465..688191607 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotPrestigeCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotPrestigeCommands.java
@@ -116,7 +116,8 @@ public void prisonManagerPrestige(CommandSender sender,
// }
//
// if ( PrisonRanks.getInstance().getLadderManager().getLadder("prestiges") == null ) {
-// Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ranks ladder create prestiges");
+// Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
+// Prison.get().getCommandHandler().findRegisteredCommand( "ranks ladder create prestiges" ));
// }
//
// PrisonRanks rankPlugin;
@@ -166,7 +167,8 @@ public void prisonManagerPrestige(CommandSender sender,
// }
// else {
// // Bypassing prestige confirmations:
-// Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "rankup prestiges");
+// Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
+// Prison.get().getCommandHandler().findRegisteredCommand( "rankup prestiges" ));
// }
// }
// }
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
index 9bb582477..cb5c734cc 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/commands/PrisonSpigotSellAllCommands.java
@@ -2,6 +2,7 @@
import java.text.DecimalFormat;
import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
import java.util.TreeMap;
@@ -17,16 +18,18 @@
import tech.mcprison.prison.commands.Wildcard;
import tech.mcprison.prison.integration.EconomyCurrencyIntegration;
import tech.mcprison.prison.internal.CommandSender;
+import tech.mcprison.prison.internal.block.PrisonBlock;
import tech.mcprison.prison.output.ChatDisplay;
import tech.mcprison.prison.output.Output;
-import tech.mcprison.prison.sellall.messages.SpigotVariousGuiMessages;
+import tech.mcprison.prison.ranks.PrisonRanks;
+import tech.mcprison.prison.ranks.data.Rank;
+import tech.mcprison.prison.ranks.data.RankLadder;
import tech.mcprison.prison.spigot.SpigotPlatform;
import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.block.SpigotItemStack;
import tech.mcprison.prison.spigot.compat.Compatibility;
import tech.mcprison.prison.spigot.configs.MessagesConfig;
-import tech.mcprison.prison.spigot.game.SpigotOfflinePlayer;
import tech.mcprison.prison.spigot.game.SpigotPlayer;
-import tech.mcprison.prison.spigot.gui.sellall.SellAllAdminBlocksGUI;
import tech.mcprison.prison.spigot.sellall.SellAllBlockData;
import tech.mcprison.prison.spigot.sellall.SellAllUtil;
import tech.mcprison.prison.spigot.utils.tasks.PlayerAutoRankupTask;
@@ -73,17 +76,18 @@ private void sellAllCurrency(CommandSender sender,
return;
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+ if ( !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (sellAllUtil.setCurrency(currency)){
Output.get().sendInfo(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_currency_edit_success) + " [" + currency + "]");
}
}
- @Command(identifier = "sellall", description = "SellAll main command",
+ @Command(identifier = "sellall",
+ description = "SellAll main command",
altPermissions = {"-none-", "prison.admin"},
onlyPlayers = false)
private void sellAllCommands(CommandSender sender) {
@@ -91,31 +95,37 @@ private void sellAllCommands(CommandSender sender) {
if (!isEnabled()) return;
if (sender.hasPermission("prison.admin")) {
- String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall help" );
- sender.dispatchCommand(registeredCmd);
+ sender.dispatchCommand("sellall help");
+// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall help" );
+// sender.dispatchCommand(registeredCmd);
} else {
- String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall sell" );
- sender.dispatchCommand(registeredCmd);
+ sender.dispatchCommand("sellall sell");
+// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall sell" );
+// sender.dispatchCommand(registeredCmd);
}
}
- @Command(identifier = "sellall delay", description = "SellAll delay.",
+ @Command(identifier = "sellall set delay",
+ description = "Enables or disables a SellAll cooldown delay to prevent "
+ + "players from spamming the sellall command. "
+ + "See `/sellall set delayTime`.",
onlyPlayers = false, permissions = "prison.sellall.delay")
private void sellAllDelay(CommandSender sender,
- @Arg(name = "boolean", description = "True to enable or false to disable.", def = "null") String enable){
+ @Arg(name = "boolean",
+ description = "True to enable or false to disable.",
+ def = "false") String enable){
- if (!isEnabled()) return;
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (!(enable.equalsIgnoreCase("true") || enable.equalsIgnoreCase("false"))){
Output.get().sendInfo(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_boolean_input_invalid));
return;
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
boolean enableBoolean = getBoolean(enable);
if (sellAllUtil.isSellAllDelayEnabled == enableBoolean){
@@ -136,17 +146,17 @@ private void sellAllDelay(CommandSender sender,
}
}
- @Command(identifier = "sellall set delay", description = "Edit SellAll delay.",
+ @Command(identifier = "sellall set delayTime",
+ description = "This sets the sellall cooldown delay to the specified number of seconds.",
onlyPlayers = false, permissions = "prison.sellall.delay")
private void sellAllDelaySet(CommandSender sender,
- @Arg(name = "delay", description = "Set delay value in seconds.", def = "0") String delay){
+ @Arg(name = "delay",
+ description = "Set delay value in seconds. Defaults to a value of 15 seconds.", def = "15") String delay){
- if (!isEnabled()) return;
-
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
int delayValue;
try {
@@ -161,28 +171,32 @@ private void sellAllDelaySet(CommandSender sender,
}
}
- @Command(identifier = "sellall autosell", description = "Enable SellAll AutoSell.",
+ @Command(identifier = "sellall set autosell",
+ description = "Enable SellAll AutoSell. "
+ + "For AutoFeatures based sellall, please see the AutoFeatures configs.",
onlyPlayers = false, permissions = "prison.autosell.edit")
private void sellAllAutoSell(CommandSender sender,
- @Arg(name = "boolean", description = "True to enable or false to disable.", def = "null") String enable){
+ @Arg(name = "boolean",
+ description = "'True' to enable or 'false' to disable. Use 'perUserToggleable' to "
+ + "enable with users being able to turn on/off. Default value is 'true'. "
+ + "[true false perUserToggleable]",
+ def = "true") String enable){
- if (!isEnabled()) return;
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (enable.equalsIgnoreCase("perusertoggleable")){
sellAllAutoSellPerUserToggleable(sender, enable);
return;
}
- if (!(enable.equalsIgnoreCase("true") || enable.equalsIgnoreCase("false"))){
+ if (!enable.equalsIgnoreCase("true") && !enable.equalsIgnoreCase("false") ){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_boolean_input_invalid));
return;
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
-
boolean enableBoolean = getBoolean(enable);
if (sellAllUtil.isAutoSellEnabled == enableBoolean){
if (enableBoolean){
@@ -202,20 +216,26 @@ private void sellAllAutoSell(CommandSender sender,
}
}
- @Command(identifier = "sellall autosell perUserToggleable", description = "Enable AutoSell perUserToggleable.",
+ @Command(identifier = "sellall set autosellPerUserToggleable",
+ description = "Enable AutoSell perUserToggleable. This will "
+ + "enable autosell if it's not already enabled, plus it will allow players to "
+ + "turn autosell on/off when they need to using the "
+ + "command `/sellall autoSellToggle` or the alias `/autosell`. "
+ + "If user toggleable is disabled through this command, it will also disable "
+ + "autosell, so you may need to turn it back on with `/sellall set autosell true`.",
onlyPlayers = false, permissions = "prison.autosell.edit")
private void sellAllAutoSellPerUserToggleable(CommandSender sender,
- @Arg(name = "boolean", description = "True to enable or false to disable", def = "null") String enable){
-
- if (!isEnabled()) return;
+ @Arg(name = "boolean",
+ description = "'True' to enable or 'false' to disable. [true false]",
+ def = "") String enable){
- if (!(enable.equalsIgnoreCase("true") || enable.equalsIgnoreCase("false"))){
- Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_boolean_input_invalid));
- return;
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
}
-
SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+
+ if ( !enable.equalsIgnoreCase("true") && !enable.equalsIgnoreCase("false") ) {
+ Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_boolean_input_invalid));
return;
}
@@ -243,8 +263,8 @@ public void sellAllSellCommand(CommandSender sender,
@Arg(name = "player", def = "", description = "An online player name to sell their inventory - " +
"Only console or prison commands can include this parameter") String playerName,
@Arg(name = "notification", def="",
- description = "Notification about the sellall transaction. Defaults to normal. " +
- "'silent' suppresses results. [silent]") String notification ){
+ description = "Notification behavior for the sellall transaction. Defaults to normal. " +
+ "'silent' suppresses all notifications. [silent]") String notification ){
if (!isEnabled()) return;
@@ -290,12 +310,12 @@ else if (p == null){
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+ if ( !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
if (sellAllUtil.isSellAllSellPermissionEnabled){
String permission = sellAllUtil.permissionSellAllSell;
@@ -313,17 +333,15 @@ else if (p == null){
PlayerAutoRankupTask.autoSubmitPlayerRankupTask( sPlayer, null );
}
- @Command(identifier = "sellall hand", description = "Sell only what is in your hand if sellable.",
+ @Command(identifier = "sellall sellHand",
+ description = "Sell only what is in your hand if it is sellable.",
onlyPlayers = true)
public void sellAllSellHandCommand(CommandSender sender){
- if (!isEnabled()) return;
-
- SellAllUtil sellAllUtil = SellAllUtil.get();
-
- if (sellAllUtil == null){
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (!sellAllUtil.isSellAllHandEnabled){
Output.get().sendWarn(sender, "The command /sellall hand is disabled from the config!");
@@ -337,7 +355,7 @@ public void sellAllSellHandCommand(CommandSender sender){
return;
}
- if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
if (sellAllUtil.isSellAllSellPermissionEnabled){
String permission = sellAllUtil.permissionSellAllSell;
@@ -359,19 +377,18 @@ public void sellAllSellHandCommand(CommandSender sender){
}
public void sellAllSell(Player p){
- if (!isEnabled()) return;
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (p == null){
Output.get().sendInfo(new SpigotPlayer(p), "&cSorry but you can't use that from the console!");
return;
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
- if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
if (sellAllUtil.isSellAllSellPermissionEnabled){
String permission = sellAllUtil.permissionSellAllSell;
@@ -389,7 +406,125 @@ public void sellAllSell(Player p){
}
- @Command(identifier = "sellall delaysell", description = "Like SellAll Sell command but this will be delayed for some " +
+
+
+ @Command(identifier = "sellall valueOf",
+ description = "SellAll valueOf command will report the total value of the player's inventory "
+ + "without selling anything.", onlyPlayers = false)
+ public void sellAllValueOfCommand(CommandSender sender,
+ @Arg(name = "player", def = "", description = "An online player name to get the value of their inventory - " +
+ "Only console or prison commands can include this parameter") String playerName
+ ){
+
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
+
+ Player p = getSpigotPlayer(sender);
+
+
+ boolean isOp = sender.isOp();
+
+ tech.mcprison.prison.internal.Player sPlayerAlt = getOnlinePlayer( sender, playerName );
+// if ( sPlayerAlt == null ){
+// // If sPlayerAlt is null then the value in playerName is really intended for notification:
+// notification = playerName;
+// }
+
+ if ( isOp && !sender.isPlayer() && sPlayerAlt != null ) {
+ // Only if OP and a valid player name was provided, then OP is trying to run this
+ // for another player
+
+ if ( !sPlayerAlt.isOnline() ) {
+ sender.sendMessage( "Player is not online." );
+ return;
+ }
+
+ // Set the active player to who OP specified:
+ p = ((SpigotPlayer) sPlayerAlt).getWrapper();
+ }
+
+
+ else if (p == null){
+
+ if ( getPlayer( sender, playerName ) != null ) {
+
+ Output.get().sendInfo(sender, "&cSorry but the specified player must be online "
+ + "[/sellall valueOf %s]", playerName );
+ }
+ else {
+
+ Output.get().sendInfo(sender, "&cSorry but you can't use that from the console!");
+ }
+
+
+ return;
+ }
+
+
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+
+ if (sellAllUtil.isSellAllSellPermissionEnabled){
+ String permission = sellAllUtil.permissionSellAllSell;
+ if (permission == null || !p.hasPermission(permission)){
+ Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_missing_permission) + " [" + permission + "]");
+ return;
+ }
+ }
+
+ SpigotPlayer sPlayer = new SpigotPlayer( p );
+
+ String report = sellAllUtil.getPlayerInventoryValueReport( sPlayer );
+
+
+ sender.sendMessage(report);
+
+ PlayerAutoRankupTask.autoSubmitPlayerRankupTask( sPlayer, null );
+ }
+
+ @Command(identifier = "sellall valueOfHand",
+ description = "Get the value of what is in your hand if sellable.",
+ onlyPlayers = true)
+ public void sellAllValueOfHandCommand(CommandSender sender){
+
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
+
+ if (!sellAllUtil.isSellAllHandEnabled){
+ Output.get().sendWarn(sender, "The command `/sellall valueOfHand` is disabled from the config! (SellAllHandEnabled)");
+ return;
+ }
+
+ Player p = getSpigotPlayer(sender);
+
+ if (p == null){
+ Output.get().sendInfo(sender, "&cSorry but you can't use that from the console!");
+ return;
+ }
+
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+
+ if (sellAllUtil.isSellAllSellPermissionEnabled){
+ String permission = sellAllUtil.permissionSellAllSell;
+ if (permission == null || !p.hasPermission(permission)){
+ Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_missing_permission) + " [" + permission + "]");
+ return;
+ }
+ }
+
+
+ String report = sellAllUtil.getItemStackValueReport(
+ new SpigotPlayer(p), new SpigotItemStack( compat.getItemInMainHand(p)) );
+
+ sender.sendMessage(report);
+ }
+
+
+ @Command(identifier = "sellall delaysell",
+ description = "Like SellAll Sell command but this will be delayed for some " +
"seconds and if sellall sell commands are triggered during this delay, " +
"they will sum up to the total value that will be visible in a notification at the end of the delay. " +
"Running more of these commands before a delay have been completed won't reset it and will do the same of /sellall sell " +
@@ -397,7 +532,10 @@ public void sellAllSell(Player p){
onlyPlayers = true)
public void sellAllSellWithDelayCommand(CommandSender sender){
- if (!isEnabled()) return;
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
Player p = getSpigotPlayer(sender);
@@ -406,12 +544,8 @@ public void sellAllSellWithDelayCommand(CommandSender sender){
return;
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
- if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
if (sellAllUtil.isSellAllSellPermissionEnabled){
String permission = sellAllUtil.permissionSellAllSell;
@@ -433,11 +567,19 @@ public void sellAllSellWithDelayCommand(CommandSender sender){
}
- @Command(identifier = "sellall auto toggle", description = "Let the user enable or disable sellall auto",
+ @Command(identifier = "sellall autoSellToggle",
+ aliases = {"autosell"},
+ description = "When `perUserToggleable` is enabled with autosell, this "
+ + "command allow the players to enable or disable their own use of autosell. "
+ + "When using this command, autosell will be toggled on/off for the player. "
+ + "Can also use the alias `/autosell` to toggle this setting",
altPermissions = "prison.sellall.toggle", onlyPlayers = true)
private void sellAllAutoEnableUser(CommandSender sender){
- if (!isEnabled()) return;
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
Player p = getSpigotPlayer(sender);
@@ -447,12 +589,8 @@ private void sellAllAutoEnableUser(CommandSender sender){
return;
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
- if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
+// if (sellAllUtil.isPlayerInDisabledWorld(p)) return;
if (!sellAllUtil.isAutoSellPerUserToggleable){
return;
@@ -464,81 +602,90 @@ private void sellAllAutoEnableUser(CommandSender sender){
return;
}
- if (sellAllUtil.setAutoSellPlayer(p, !sellAllUtil.isPlayerAutoSellEnabled(p))){
- if (sellAllUtil.isPlayerAutoSellEnabled(p)){
- Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_auto_enabled));
- } else {
+ boolean isplayerAutosellEnabled = sellAllUtil.isPlayerAutoSellEnabled(p);
+ if (sellAllUtil.setAutoSellPlayer(p, !isplayerAutosellEnabled)){
+ if ( !isplayerAutosellEnabled ){ // Note this variable was negated then saved, so we need to check the negative:
Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_auto_disabled));
+ } else {
+ Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_auto_enabled));
}
}
}
-
- @Command(identifier = "sellall gui",
- description = "SellAll GUI command",
+//
+// @Command(identifier = "sellall gui",
+// description = "SellAll GUI command",
+//// aliases = "gui sellall",
+// permissions = "prison.admin", onlyPlayers = true)
+// private void sellAllGuiCommand(CommandSender sender,
+// @Arg(name = "page", description = "If there are more than 45 items, then they " +
+// "will be shown on multiple pages. The page parameter starts with " +
+// "page 1.", def = "1" ) int page){
+//
+// if (!isEnabled()) return;
+//
+// Player p = getSpigotPlayer(sender);
+//
+// // Sender must be a Player, not something else like the Console.
+// if (p == null) {
+// Output.get().sendError(sender, getMessages().getString(MessagesConfig.StringID.spigot_message_console_error));
+// return;
+// }
+//
+// SellAllUtil sellAllUtil = SellAllUtil.get();
+// if (sellAllUtil == null){
+// return;
+// }
+//
+// if (!sellAllUtil.openSellAllGUI( p, page, "sellall gui", "close" )){
+// // If the sender's an admin (OP or have the prison.admin permission) it'll send an error message.
+// if (p.hasPermission("prison.admin")) {
+//
+// new SpigotVariousGuiMessages().sellallGUIIsDisabledMsg(sender);
+//// Output.get().sendError(sender,
+//// messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_disabled));
+// }
+// }
+// }
+//
+// @Command(identifier = "sellall gui blocks",
+// description = "SellAll GUI Blocks command",
// aliases = "gui sellall",
- permissions = "prison.admin", onlyPlayers = true)
- private void sellAllGuiCommand(CommandSender sender,
- @Arg(name = "page", description = "If there are more than 45 items, then they " +
- "will be shown on multiple pages. The page parameter starts with " +
- "page 1.", def = "1" ) int page){
-
- if (!isEnabled()) return;
-
- Player p = getSpigotPlayer(sender);
-
- // Sender must be a Player, not something else like the Console.
- if (p == null) {
- Output.get().sendError(sender, getMessages().getString(MessagesConfig.StringID.spigot_message_console_error));
- return;
- }
-
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
-
- if (!sellAllUtil.openSellAllGUI( p, page, "sellall gui", "close" )){
- // If the sender's an admin (OP or have the prison.admin permission) it'll send an error message.
- if (p.hasPermission("prison.admin")) {
-
- new SpigotVariousGuiMessages().sellallGUIIsDisabledMsg(sender);
-// Output.get().sendError(sender,
-// messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_disabled));
- }
- }
- }
-
- @Command(identifier = "sellall gui blocks",
- description = "SellAll GUI Blocks command",
- aliases = "gui sellall",
- permissions = "prison.admin", onlyPlayers = true)
- private void sellAllGuiBlocksCommand(CommandSender sender,
- @Arg(name = "page", description = "If there are more than 45 items, then they " +
- "will be shown on multiple pages. The page parameter starts with " +
- "page 1.", def = "1" ) int page){
-
- if (!isEnabled()) return;
-
- Player p = getSpigotPlayer(sender);
-
- // Sender must be a Player, not something else like the Console.
- if (p == null) {
- Output.get().sendError(sender, getMessages().getString(MessagesConfig.StringID.spigot_message_console_error));
- return;
- }
-
- SellAllAdminBlocksGUI saBlockGui = new SellAllAdminBlocksGUI( p, page, "sellall gui blocks", "sellall gui" );
- saBlockGui.open();
-
- }
-
- @Command(identifier = "sellall add", description = "SellAll add an item to the sellAll shop.",
+// permissions = "prison.admin", onlyPlayers = true)
+// private void sellAllGuiBlocksCommand(CommandSender sender,
+// @Arg(name = "page", description = "If there are more than 45 items, then they " +
+// "will be shown on multiple pages. The page parameter starts with " +
+// "page 1.", def = "1" ) int page){
+//
+// if (!isEnabled()) return;
+//
+// Player p = getSpigotPlayer(sender);
+//
+// // Sender must be a Player, not something else like the Console.
+// if (p == null) {
+// Output.get().sendError(sender, getMessages().getString(MessagesConfig.StringID.spigot_message_console_error));
+// return;
+// }
+//
+// SellAllAdminBlocksGUI saBlockGui = new SellAllAdminBlocksGUI( p, page, "sellall gui blocks", "sellall gui" );
+// saBlockGui.open();
+//
+// }
+
+ @Command(identifier = "sellall items add",
+ description = "This will add an item to the SellAll shop. "
+ + "Use `/mines block search help` to find the correct names "
+ + "for blocks to add to the sellall shop. Use "
+ + "`/mines block searchAll help` to search for items too.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllAddCommand(CommandSender sender,
- @Arg(name = "Item_ID", description = "The Item_ID or block to add to the sellAll Shop.") String itemID,
- @Arg(name = "Value", description = "The value of the item.") Double value){
+ @Arg(name = "Item_ID",
+ description = "The Item_ID or block to add to the sellAll Shop.") String itemID,
+ @Arg(name = "Value", description = "The value of the item.") Double value){
- if (!isEnabled()) return;
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (itemID == null){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_missing_name));
@@ -551,10 +698,6 @@ private void sellAllAddCommand(CommandSender sender,
return;
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
if (sellAllUtil.sellAllConfig.getConfigurationSection("Items." + itemID) != null){
Output.get().sendWarn(sender, itemID + " " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_already_added));
@@ -571,7 +714,7 @@ private void sellAllAddCommand(CommandSender sender,
}
if (sellAllUtil.addSellAllBlock(blockAdd, value)){
- Output.get().sendInfo(sender, "&3 ITEM [" + itemID + ", " + value + " " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_add_success));
+ Output.get().sendInfo(sender, "&3 ITEM [" + itemID + ", " + value + "] " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_add_success));
}
} catch (IllegalArgumentException ex){
@@ -591,10 +734,10 @@ public void sellAllAddCommand(XMaterial blockAdd, Double value){
String itemID = blockAdd.name();
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+ if ( !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
// If the block or item was already configured, then skip this:
if (sellAllUtil.sellAllConfig.getConfigurationSection("Items." + itemID) != null){
@@ -606,11 +749,17 @@ public void sellAllAddCommand(XMaterial blockAdd, Double value){
Output.get().logInfo("&3 ITEM [" + itemID + ", " + value + " " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_add_success));
}
- @Command(identifier = "sellall delete", description = "SellAll delete command, remove an item from shop.",
+ @Command(identifier = "sellall items delete",
+ description = "This command will delete an item from the "
+ + "sellall shop. Use `/sellall list` to identify which items to revmove.",
permissions = "prison.admin", onlyPlayers = false)
- private void sellAllDeleteCommand(CommandSender sender, @Arg(name = "Item_ID", description = "The Item_ID you want to remove.") String itemID){
+ private void sellAllDeleteCommand(CommandSender sender,
+ @Arg(name = "Item_ID", description = "The Item_ID you want to remove.") String itemID){
- if (!isEnabled()) return;
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (itemID == null){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_missing_name));
@@ -618,10 +767,6 @@ private void sellAllDeleteCommand(CommandSender sender, @Arg(name = "Item_ID", d
}
itemID = itemID.toUpperCase();
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
if (sellAllUtil.sellAllConfig.getConfigurationSection("Items." + itemID) == null){
Output.get().sendWarn(sender, itemID + " " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_cant_find_item_config));
@@ -635,13 +780,17 @@ private void sellAllDeleteCommand(CommandSender sender, @Arg(name = "Item_ID", d
}
}
- @Command(identifier = "sellall edit", description = "SellAll edit command, edit an item of Shop.",
+ @Command(identifier = "sellall items edit",
+ description = "Edits an existing SellAll shop item.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllEditCommand(CommandSender sender,
- @Arg(name = "Item_ID", description = "The Item_ID or block to add to the sellAll Shop.") String itemID,
- @Arg(name = "Value", description = "The value of the item.") Double value){
+ @Arg(name = "Item_ID", description = "The Item_ID or block to add to the sellAll Shop.") String itemID,
+ @Arg(name = "Value", description = "The value of the item.") Double value){
- if (!isEnabled()) return;
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (itemID == null){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_missing_name));
@@ -654,10 +803,6 @@ private void sellAllEditCommand(CommandSender sender,
return;
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
if (sellAllUtil.sellAllConfig.getConfigurationSection("Items." + itemID) == null){
Output.get().sendWarn(sender, itemID + " " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_not_found));
@@ -674,7 +819,7 @@ private void sellAllEditCommand(CommandSender sender,
}
if (sellAllUtil.editPrice(blockAdd, value)){
- Output.get().sendInfo(sender, "&3ITEM [" + itemID + ", " + value + " " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_edit_success));
+ Output.get().sendInfo(sender, "&3ITEM [" + itemID + ", " + value + "] " + messages.getString(MessagesConfig.StringID.spigot_message_sellall_item_edit_success));
}
} catch (IllegalArgumentException ex){
@@ -682,22 +827,71 @@ private void sellAllEditCommand(CommandSender sender,
}
}
- @Command(identifier = "sellall multiplier list", description = "SellAll multiplier command list",
+
+ @Command(identifier = "sellall multiplier list",
+ description = "Lists all of the SellAll Rank multipliers",
permissions = "prison.admin", onlyPlayers = false)
- private void sellAllMultiplierCommand(CommandSender sender){
+ private void sellAllMultiplierCommand(CommandSender sender,
+ @Wildcard(join=true)
+ @Arg(name = "options",
+ description = "Optionaly, you can control which ladder is displayed. By default, it's "
+ + "all ladders. Just use the ladder's name. You can also change the number of "
+ + "columns in the output by using 'cols=16', where the default is 10 columns. ")
+ String options ) {
- if (!isEnabled()) return;
-
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (!sellAllUtil.isSellAllMultiplierEnabled){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_multiplier_are_disabled));
return;
}
+
+ if ( !PrisonRanks.getInstance().isEnabled() ) {
+ Output.get().sendWarn(sender, "Cannot use command `/sellall multiplier addLadder` since ranks are disabled" );
+ return;
+ }
+
+ int displayColumns = 10;
+ String ladderName = "";
+ RankLadder rLadder = null;
+
+
+ // pull columns out of the options, if it has been specified:
+ String colsStr = extractParameter("cols=", options);
+ if ( colsStr != null ) {
+ options = options.replace( colsStr, "" ).trim();
+ colsStr = colsStr.replace( "cols=", "" ).trim();
+
+ try {
+ displayColumns = Integer.parseInt( colsStr );
+ }
+ catch ( NumberFormatException e ) {
+ // Not a valid int number:
+ }
+ }
+
+
+ // Check to see if the remaining options is a ladder name, if so, then only load that ladder:
+ if ( options.length() > 0 ) {
+ rLadder = PrisonRanks.getInstance().getLadderManager().getLadder( options );
+ }
+
+
+ List ladders = new ArrayList<>();
+
+ if ( rLadder == null ) {
+ ladders = PrisonRanks.getInstance().getLadderManager().getLadders();
+ }
+ else {
+ ladders.add( rLadder );
+ }
+
+
+
// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall multiplier help" );
// sender.dispatchCommand(registeredCmd);
@@ -705,137 +899,365 @@ private void sellAllMultiplierCommand(CommandSender sender){
TreeMap mults = new TreeMap<>( sellAllUtil.getPrestigeMultipliers() );
// TreeMap items = new TreeMap<>( sellAllUtil.getSellAllBlocks() );
- DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
+ DecimalFormat dFmt = Prison.get().getDecimalFormat("#,##0.00");
+ DecimalFormat iFmt = Prison.get().getDecimalFormat("#,##0");
Set keys = mults.keySet();
+ // Need to calculate the maxLenVal so we can properly space all columns:
int maxLenKey = 0;
int maxLenVal = 0;
for ( String key : keys ) {
if ( key.length() > maxLenKey ) {
maxLenKey = key.length();
}
- String val = fFmt.format( mults.get( key ) );
+ String val = dFmt.format( mults.get( key ) );
if ( val.length() > maxLenVal ) {
maxLenVal = val.length();
}
}
+ String multiplierLayout = "%-" + maxLenKey + "s %" + maxLenVal + "s";
- ChatDisplay chatDisplay = new ChatDisplay("&bSellall Prestige Multipliers list: &3(&b" + keys.size() + "&3)" );
+ ChatDisplay chatDisplay = new ChatDisplay("&bSellall Rank Multipliers list: &3(&b" + keys.size() + "&3)" );
- int lines = 0;
- int columns = 0;
- StringBuilder sb = new StringBuilder();
- for ( String key : keys ) {
-// boolean first = sb.length() == 0;
- Double cost = mults.get( key );
-
- if ( columns++ > 0 ) {
- sb.append( " " );
- }
-
- sb.append( String.format( "%-" + maxLenKey + "s %" + maxLenVal + "s",
- key, fFmt.format( cost ) ) );
-// sb.append( String.format( "%-" + maxLenKey + "s %" + maxLenVal + "s %-" + maxLenCode + "s",
-// key.toString(), fFmt.format( cost ), key.name() ) );
-
- if ( columns > 4 ) {
- chatDisplay.addText( sb.toString() );
-
- if ( ++lines % 10 == 0 && lines > 1 ) {
- chatDisplay.addText( " " );
- }
-
- sb.setLength( 0 );
- columns = 0;
- }
- }
- if ( sb.length() > 0 ) {
- chatDisplay.addText( sb.toString() );
- }
-
- chatDisplay.send( sender );
+ for (RankLadder ladder : ladders ) {
+
+ StringBuilder sb = new StringBuilder();
+ int lines = 0;
+ int columns = 0;
+ for ( Rank rank : ladder.getRanks() ) {
+ String key = rank.getName();
+
+ if ( mults.containsKey( key ) ) {
+
+ if ( lines == 0 && sb.length() == 0 ) {
+ chatDisplay.addText( "&3Ladder: &7%s &3Ranks: &7%s",
+ ladder.getName(),
+ iFmt.format( ladder.getRanks().size() ));
+ }
+
+ Double cost = mults.get( key );
+
+ if ( columns++ > 0 ) {
+ sb.append( " " );
+ }
+
+ sb.append( String.format( multiplierLayout,
+ key, dFmt.format( cost ) ) );
+
+ if ( columns >= displayColumns ) {
+ chatDisplay.addText( sb.toString() );
+
+ if ( ++lines % 10 == 0 && lines > 1 ) {
+ chatDisplay.addText( " " );
+ }
+
+ sb.setLength( 0 );
+ columns = 0;
+ }
+
+ }
+ }
+ if ( sb.length() > 0 ) {
+ chatDisplay.addText( sb.toString() );
+ }
+
+ }
+// int columns = 0;
+// for ( String key : keys ) {
+//// boolean first = sb.length() == 0;
+//
+// Double cost = mults.get( key );
+//
+// if ( columns++ > 0 ) {
+// sb.append( " " );
+// }
+//
+// sb.append( String.format( "%-" + maxLenKey + "s %" + maxLenVal + "s",
+// key, fFmt.format( cost ) ) );
+//// sb.append( String.format( "%-" + maxLenKey + "s %" + maxLenVal + "s %-" + maxLenCode + "s",
+//// key.toString(), fFmt.format( cost ), key.name() ) );
+//
+// if ( columns > 7 ) {
+// chatDisplay.addText( sb.toString() );
+//
+// if ( ++lines % 10 == 0 && lines > 1 ) {
+// chatDisplay.addText( " " );
+// }
+//
+// sb.setLength( 0 );
+// columns = 0;
+// }
+// }
+// if ( sb.length() > 0 ) {
+// chatDisplay.addText( sb.toString() );
+// }
+ chatDisplay.send( sender );
+
}
+ private String extractParameter( String key, String options ) {
+ return extractParameter( key, options, true );
+ }
+ private String extractParameter( String key, String options, boolean tryLowerCase ) {
+ String results = null;
+ int idx = options.indexOf( key );
+ if ( idx != -1 ) {
+ int idxEnd = options.indexOf( " ", idx );
+ if ( idxEnd == -1 ) {
+ idxEnd = options.length();
+ }
+ results = options.substring( idx, idxEnd );
+ }
+ else if ( tryLowerCase ) {
+ // try again, but lowercase the key
+ results = extractParameter( key.toLowerCase(), options, false );
+ }
+ return results;
+ }
- @Command(identifier = "sellall multiplier add", description = "SellAll add a multiplier. Permission multipliers for player's prison.sellall.multiplier., example prison.sellall.multiplier.2 will add a 2x multiplier," +
- "There's also another kind of Multiplier called permission multipliers, they're permissions that you can give to players to give them a multiplier, remember that their format is prison.sellall.multiplier.2 (for example), and this example will give you a " +
- "total of 3x multiplier (1x default + 2x permission = 3x).",
+ @Command(identifier = "sellall multiplier add",
+ description = "Add a sellall multiplier based upon the player's rank. " +
+ "All ranks that a player has, could have their own multiplier, that can " +
+ "be combined to help the player increase the value of what they are selling. " +
+ "These multipliers will be combined with all other player mulitpliers to " +
+ "adjust the sales price within sellall. Multipliers can be from these " +
+ "rank multipliers, and also from permission multipliers. " +
+ "All players start off with a default value of a multiplier with a value of 1, which " +
+ "equates to 100% of what they sell: no loss and no gain. From there, multipliers that " +
+ "you give to players can be integers, or doubles. They can be greater than 1, or less than " +
+ "1, or even negative. All multipliers are added together to provide the player's total " +
+ "amount. " +
+ "Permission multipliers for player's `prison.sellall.multiplier.`, "
+ + "example `prison.sellall.multiplier.2` will add a 2x multiplier. "
+ + "The multiplier values do not have to integers, but can be less than one, or "
+ + "doubles. " +
+ "There's also another kind of Multiplier called permission multipliers, they're permissions "
+ + "that you can give to players to give them a multiplier, remember that their format is "
+ + "'prison.sellall.multiplier.2.5' (for example), and this example will give you a " +
+ "total of 3.5x multiplier (1x default + 2.5x permission = 3.5x).",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllAddMultiplierCommand(CommandSender sender,
- @Arg(name = "Prestige", description = "Prestige to hook to the multiplier.") String prestige,
- @Arg(name = "multiplier", description = "Multiplier value.") Double multiplier){
+ @Arg(name = "rank", description = "The rank name for the multiplier.") String rank,
+ @Arg(name = "multiplier", description = "Multiplier value.") Double multiplier) {
- if (!isEnabled()) return;
-
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (!sellAllUtil.isSellAllMultiplierEnabled){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_multiplier_are_disabled));
return;
}
- if (sellAllUtil.addPrestigeMultiplier(prestige, multiplier)){
+ if (sellAllUtil.addSellallRankMultiplier(rank, multiplier)){
Output.get().sendInfo(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_multiplier_add_success));
}
else {
- Output.get().sendInfo( sender, "Failed to add sellall prestige multiplier." );
+ Output.get().sendInfo( sender, "Failed to add sellall rank multiplier." );
}
}
- @Command(identifier = "sellall multiplier delete", description = "SellAll delete a multiplier.",
+ @Command(identifier = "sellall multiplier delete",
+ description = "Remove a SellAll rank multiplier.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllDeleteMultiplierCommand(CommandSender sender,
- @Arg(name = "Prestige", description = "Prestige hooked to the multiplier.") String prestige){
+ @Arg(name = "Rank", description = "The rank name of the multiplier.") String rank){
- if (!isEnabled()) return;
-
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (!sellAllUtil.isSellAllMultiplierEnabled){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_multiplier_are_disabled));
return;
}
- if (prestige == null){
+ if (rank == null){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_command_wrong_format));
return;
}
- if (sellAllUtil.sellAllConfig.getConfigurationSection("Multiplier." + prestige) == null){
- Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_multiplier_cant_find) + " [" + prestige + "]");
+ if (sellAllUtil.sellAllConfig.getConfigurationSection("Multiplier." + rank) == null){
+ Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_multiplier_cant_find) + " [" + rank + "]");
return;
}
- if (sellAllUtil.removePrestigeMultiplier(prestige)){
+ if (sellAllUtil.removeSellallRankMultiplier(rank)){
Output.get().sendInfo(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_multiplier_delete_success));
}
}
+
+
+
+
+ @Command(identifier = "sellall multiplier deleteLadder",
+ description = "Deletes all SellAll Rank multipliers for a ladder.",
+ permissions = "prison.admin", onlyPlayers = false)
+ private void sellAllMultiplierDeleteLadderCommand(
+ CommandSender sender,
+ @Arg(name = "ladder",
+ description = "All ranks with multipliers for this ladder will be removed.") String ladderName
+
+ ) {
+
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
- @Command(identifier = "sellall Trigger",
- description = "Toggle SellAll Shift+Right Click on a tool to trigger the /sellall sell command, "
- + "true -> Enabled or False -> Disabled.",
+ if (!sellAllUtil.isSellAllMultiplierEnabled){
+ Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_multiplier_are_disabled));
+ return;
+ }
+
+ if ( !PrisonRanks.getInstance().isEnabled() ) {
+ Output.get().sendWarn(sender, "Cannot use command `/sellall multiplier deleteLadder` since ranks are disabled" );
+ return;
+ }
+
+ RankLadder ladder = PrisonRanks.getInstance().getLadderManager().getLadder(ladderName);
+
+
+ if ( ladder == null ) {
+ Output.get().sendWarn(sender,
+ "A ladder with the name of '%s' does not exist. Use '/ranks ladder list' "
+ + "to find the correct ladder name.", ladderName );
+
+ return;
+ }
+
+ DecimalFormat iFmt = Prison.get().getDecimalFormat("#,##0");
+
+ int removed = 0;
+ for (Rank rank : ladder.getRanks() ) {
+
+ if (sellAllUtil.removeSellallRankMultiplier( rank.getName() )) {
+ removed++;
+ }
+ }
+
+ sender.sendMessage(
+ String.format(
+ "For ladder %s, there were %s multipliers removed.",
+ ladderName, iFmt.format(removed)) );
+
+ }
+
+
+
+ @Command(identifier = "sellall multiplier addLadder",
+ description = "Adds multipliers for all ranks on the ladder. "
+ + "If they already exist, they will be replaced. The formula used to "
+ + "calculate the multiplier is "
+ + "'multiplier = baseMultiplier + ((rankPosition - 1) * rankMultiplier)'. "
+ + "Example: '/sellall multiplier addLadder presetiges 1.0 0.1' will result in "
+ + "p1=1.0 p2=1.1 p3=1.2 p4=1.3 etc...",
+ permissions = "prison.admin", onlyPlayers = false)
+ private void sellAllMultiplierAddLadderCommand(
+ CommandSender sender,
+ @Arg(name = "ladder",
+ def = "prestiges",
+ description = "Add multipliers for all ranks on this ladder. "
+ + "If multipliers already exist, they will be replaced.")
+ String ladderName,
+ @Arg(name = "baseMultiplier",
+ def = "1.0",
+ description = "The baseMultiplier that will have the rank's "
+ + "position multiplier added to it.")
+ double baseMultiplier,
+ @Arg(name = "rankMultiplier",
+ def = "0.1",
+ description = "The multiplier applied to the rank position.")
+ double rankMultiplier
+
+ ) {
+
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
+
+ if (!sellAllUtil.isSellAllMultiplierEnabled){
+ Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_multiplier_are_disabled));
+ return;
+ }
+
+ if ( !PrisonRanks.getInstance().isEnabled() ) {
+ Output.get().sendWarn(sender, "Cannot use command `/sellall multiplier addLadder` since ranks are disabled" );
+ return;
+ }
+
+ RankLadder ladder = PrisonRanks.getInstance().getLadderManager().getLadder(ladderName);
+
+
+ if ( ladder == null ) {
+ Output.get().sendWarn(sender,
+ "A ladder with the name of '%s' does not exist. Use '/ranks ladder list' "
+ + "to find the correct ladder name.", ladderName );
+
+ return;
+ }
+
+ DecimalFormat iFmt = Prison.get().getDecimalFormat("#,##0");
+
+ int added = 0;
+ int failed = 0;
+ for (Rank rank : ladder.getRanks() ) {
+
+ int rankPos = rank.getPosition();
+
+ double multi = baseMultiplier + (rankPos * rankMultiplier);
+
+ if ( sellAllUtil.addSellallRankMultiplier(rank.getName(), multi) ) {
+ // No message should be sent for each rank, since there could be thousands of prestige ranks
+ added++;
+ }
+ else {
+ failed++;
+ }
+
+ }
+
+ sender.sendMessage(
+ String.format(
+ "For ladder %s, there were %s multipliers added, and %s failed to be added.",
+ ladderName,
+ iFmt.format(added),
+ iFmt.format(failed)
+ ) );
+
+ }
+
+
+
+
+ @Command(identifier = "sellall set trigger",
+ description = "Toggle SellAll trigger to enable/disable the Shift+Right Clicking "
+ + "on a tool to trigger the `/sellall sell` command "
+ + "true = enable, false = disable. "
+ + "[true false].",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllToolsTriggerToggle(CommandSender sender,
- @Arg(name = "Boolean", description = "Enable or disable", def = "null") String enable){
+ @Arg(name = "Boolean", description = "Enable or disable", def = "true") String enable){
- if (!isEnabled()) return;
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
+ return;
+ }
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (enable.equalsIgnoreCase("null")){
- String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall toolsTrigger help" );
- sender.dispatchCommand(registeredCmd);
+ sender.dispatchCommand("sellall toolsTrigger help");
+// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall toolsTrigger help" );
+// sender.dispatchCommand(registeredCmd);
return;
}
@@ -844,10 +1266,6 @@ private void sellAllToolsTriggerToggle(CommandSender sender,
return;
}
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
- return;
- }
boolean enableInput = getBoolean(enable);
if (sellAllUtil.isSellAllItemTriggerEnabled == enableInput) {
@@ -868,18 +1286,16 @@ private void sellAllToolsTriggerToggle(CommandSender sender,
}
}
- @Command(identifier = "sellall Trigger add",
+ @Command(identifier = "sellall set trigger add",
description = "Add an Item to trigger the Shift+Right Click -> /sellall sell command.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllTriggerAdd(CommandSender sender,
@Arg(name = "Item", description = "Item name") String itemID){
- if (!isEnabled()) return;
-
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (!sellAllUtil.isSellAllItemTriggerEnabled){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_trigger_is_disabled));
@@ -909,18 +1325,16 @@ private void sellAllTriggerAdd(CommandSender sender,
}
}
- @Command(identifier = "sellall Trigger delete",
+ @Command(identifier = "sellall set trigger delete",
description = "Delete an Item from the Shift+Right Click trigger -> /sellall sell command.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllTriggerDelete(CommandSender sender,
@Arg(name = "Item", description = "Item name") String itemID){
- if (!isEnabled()) return;
-
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+ if (!isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
if (!sellAllUtil.isSellAllItemTriggerEnabled){
Output.get().sendWarn(sender, messages.getString(MessagesConfig.StringID.spigot_message_sellall_trigger_is_disabled));
@@ -949,7 +1363,9 @@ private void sellAllTriggerDelete(CommandSender sender,
}
}
- @Command(identifier = "sellall setdefault", description = "SellAll default values ready to go.",
+ @Command(identifier = "sellall items setdefaults",
+ description = "This command will setup all of the shop items with "
+ + "the SellAll default items.",
permissions = "prison.admin", onlyPlayers = false)
private void sellAllSetDefaultCommand(CommandSender sender){
@@ -971,29 +1387,27 @@ private void sellAllSetDefaultCommand(CommandSender sender){
permissions = "prison.admin", onlyPlayers = false)
private void sellAllListItems( CommandSender sender ) {
- if (!isEnabled()) return;
-
- SellAllUtil sellAllUtil = SellAllUtil.get();
- if (sellAllUtil == null){
+ if ( !isEnabled() || !SpigotPrison.getInstance().isSellAllEnabled() ){
return;
}
+ SellAllUtil sellAllUtil = SellAllUtil.get();
- TreeMap items = new TreeMap<>( sellAllUtil.getSellAllBlocks() );
+ TreeMap items = new TreeMap<>( sellAllUtil.getSellAllItems() );
DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
- Set keys = items.keySet();
+ Set keys = items.keySet();
int maxLenKey = 0;
int maxLenVal = 0;
int maxLenCode = 0;
- for ( XMaterial key : keys ) {
- if ( key.toString().length() > maxLenKey ) {
- maxLenKey = key.toString().length();
- }
- if ( key.name().length() > maxLenCode ) {
- maxLenCode = key.name().length();
+ for ( String key : keys ) {
+// if ( key.toString().length() > maxLenKey ) {
+// maxLenKey = key.toString().length();
+// }
+ if ( key.length() > maxLenCode ) {
+ maxLenCode = key.length();
}
- String val = fFmt.format( items.get( key ) );
+ String val = fFmt.format( items.get( key ).getSalePrice() );
if ( val.length() > maxLenVal ) {
maxLenVal = val.length();
}
@@ -1004,17 +1418,17 @@ private void sellAllListItems( CommandSender sender ) {
int lines = 0;
StringBuilder sb = new StringBuilder();
- for ( XMaterial key : keys ) {
+ for ( String key : keys ) {
boolean first = sb.length() == 0;
- Double cost = items.get( key );
+ Double cost = items.get( key ).getSalePrice();
if ( !first ) {
sb.append( " " );
}
sb.append( String.format( "%-" + maxLenCode + "s %" + maxLenVal + "s",
- key.name(), fFmt.format( cost ) ) );
+ key, fFmt.format( cost ) ) );
// sb.append( String.format( "%-" + maxLenKey + "s %" + maxLenVal + "s %-" + maxLenCode + "s",
// key.toString(), fFmt.format( cost ), key.name() ) );
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java
index dc3bc50ad..8b1be84a3 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/CompatibilityBlocks.java
@@ -70,4 +70,37 @@ public interface CompatibilityBlocks
public int getMaxY();
+
+
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so return a value of 0.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ public int getCustomModelData( SpigotItemStack itemStack );
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so return a value of 0.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ public int getCustomModelData( ItemStack itemStack );
+
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so do nothing.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ public void setCustomModelData( SpigotItemStack itemStack, int customModelData );
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so do nothing.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ public void setCustomModelData( ItemStack itemStack, int customModelData );
+
+
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/SpigotCompatibility.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/SpigotCompatibility.java
index 6199c23c5..ce98af5fa 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/SpigotCompatibility.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/SpigotCompatibility.java
@@ -27,7 +27,7 @@ private static synchronized void setup() {
if ( bukkitVersion == null ) {
- results = new Spigot113();
+ results = new Spigot_1_13();
}
else {
@@ -35,19 +35,23 @@ private static synchronized void setup() {
if ( svData.compareTo( new BluesSemanticVersionData( "1.9.0" ) ) < 0 ) {
- results = new Spigot18();
+ results = new Spigot_1_8();
}
else if ( svData.compareTo( new BluesSemanticVersionData( "1.13.0" ) ) < 0 ) {
- results = new Spigot19();
+ results = new Spigot_1_9();
+ }
+ else if ( svData.compareTo( new BluesSemanticVersionData( "1.14.0" ) ) < 0 ) {
+
+ results = new Spigot_1_13();
}
else if ( svData.compareTo( new BluesSemanticVersionData( "1.18.0" ) ) < 0 ) {
- results = new Spigot113();
+ results = new Spigot_1_14();
}
else {
- results = new Spigot118();
+ results = new Spigot_1_18();
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_13.java
similarity index 98%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_13.java
index e0d296255..86c3642a8 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_13.java
@@ -12,8 +12,8 @@
import tech.mcprison.prison.spigot.block.SpigotItemStack;
import tech.mcprison.prison.spigot.inventory.SpigotPlayerInventory;
-public class Spigot113
- extends Spigot113GUI
+public class Spigot_1_13
+ extends Spigot_1_13_GUI
implements Compatibility {
@Override
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_13_Blocks.java
similarity index 99%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_13_Blocks.java
index b27af2194..f0d86452b 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113Blocks.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_13_Blocks.java
@@ -19,8 +19,8 @@
import tech.mcprison.prison.spigot.block.SpigotItemStack;
import tech.mcprison.prison.util.Location;
-public abstract class Spigot113Blocks
- extends Spigot19Player
+public abstract class Spigot_1_13_Blocks
+ extends Spigot_1_9_Player
implements CompatibilityBlocks {
// @Override
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113GUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_13_GUI.java
similarity index 77%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113GUI.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_13_GUI.java
index 62acc09b9..94ad8c1c4 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot113GUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_13_GUI.java
@@ -2,8 +2,8 @@
import org.bukkit.event.inventory.InventoryEvent;
-public abstract class Spigot113GUI
- extends Spigot113Blocks
+public abstract class Spigot_1_13_GUI
+ extends Spigot_1_13_Blocks
implements CompatibilityGUI {
@Override
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_14.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_14.java
new file mode 100644
index 000000000..754779bd1
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_14.java
@@ -0,0 +1,6 @@
+package tech.mcprison.prison.spigot.compat;
+
+public class Spigot_1_14
+ extends Spigot_1_14_Blocks {
+
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_14_Blocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_14_Blocks.java
new file mode 100644
index 000000000..9a76d4372
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_14_Blocks.java
@@ -0,0 +1,109 @@
+package tech.mcprison.prison.spigot.compat;
+
+import java.lang.reflect.Method;
+
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import tech.mcprison.prison.spigot.block.SpigotItemStack;
+
+public class Spigot_1_14_Blocks
+ extends Spigot_1_13
+ //implements CompatibilityBlocks
+{
+
+ private static Method SET_CUSTOM_MODEL_DATA = null;
+ private static Method GET_CUSTOM_MODEL_DATA = null;
+
+ static {
+ try {
+ SET_CUSTOM_MODEL_DATA = ItemMeta.class.getDeclaredMethod("setCustomModelData", Integer.class);
+ GET_CUSTOM_MODEL_DATA = ItemMeta.class.getDeclaredMethod("getCustomModelData");
+ }
+ catch (NoSuchMethodException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so return a value of 0.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ @Override
+ public int getCustomModelData( SpigotItemStack itemStack ) {
+ return getCustomModelData( itemStack == null ? null : itemStack.getBukkitStack() );
+ }
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so return a value of 0.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ @Override
+ public int getCustomModelData( ItemStack itemStack ) {
+ int results = 0;
+
+ if ( itemStack != null ) {
+ ItemMeta meta = itemStack.getItemMeta();
+
+ if (meta != null) {
+ try {
+ Integer customModelData = (Integer) GET_CUSTOM_MODEL_DATA.invoke(meta);
+
+ if ( customModelData != null ) {
+ results = customModelData.intValue();
+ }
+ }
+ catch (ReflectiveOperationException ex ) {
+ ex.printStackTrace();
+ }
+ catch ( ClassCastException ex ) {
+ ex.printStackTrace();
+ }
+ }
+ itemStack.setItemMeta(meta);
+ }
+
+ return results;
+ }
+
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so do nothing.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ @Override
+ public void setCustomModelData( SpigotItemStack itemStack, int customModelData ) {
+ if ( itemStack != null ) {
+ setCustomModelData( itemStack.getBukkitStack(), customModelData);
+ }
+ }
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so do nothing.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ @Override
+ public void setCustomModelData( ItemStack itemStack, int customModelData ) {
+
+ if ( itemStack != null ) {
+ ItemMeta meta = itemStack.getItemMeta();
+
+ if (meta != null) {
+ try {
+
+ SET_CUSTOM_MODEL_DATA.invoke( meta, customModelData );
+ }
+ catch (ReflectiveOperationException ex) {
+ ex.printStackTrace();
+ }
+ }
+ itemStack.setItemMeta(meta);
+ }
+
+ }
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot118.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_18.java
similarity index 72%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot118.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_18.java
index f4ef76aab..2ef9cb96b 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot118.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_18.java
@@ -1,7 +1,8 @@
package tech.mcprison.prison.spigot.compat;
-public class Spigot118
- extends Spigot113
+public class Spigot_1_18
+ extends Spigot_1_14
+ implements Compatibility
{
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8.java
similarity index 98%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8.java
index 2c0f89864..ec7cffb74 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8.java
@@ -33,8 +33,8 @@
/**
* @author Faizaan A. Datoo
*/
-public class Spigot18
- extends Spigot18GUI
+public class Spigot_1_8
+ extends Spigot_1_8_GUI
implements Compatibility {
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18Blocks.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8_Blocks.java
similarity index 93%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18Blocks.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8_Blocks.java
index 8594d6924..fbb1b65c6 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18Blocks.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8_Blocks.java
@@ -15,8 +15,8 @@
import tech.mcprison.prison.spigot.block.SpigotItemStack;
import tech.mcprison.prison.util.Location;
-public abstract class Spigot18Blocks
- extends Spigot18Player
+public abstract class Spigot_1_8_Blocks
+ extends Spigot_1_8_Player
implements CompatibilityBlocks {
@@ -275,10 +275,19 @@ public XMaterial getXMaterial( PrisonBlock prisonBlock ) {
results = XMaterial.matchXMaterial( blockName ).orElse( null );
+ // Convert items to their block representation:
if ( results == XMaterial.MELON_SLICE &&
prisonBlock.getBlockName().equalsIgnoreCase( "melon" ) ) {
results = XMaterial.MELON;
}
+ else if ( results == XMaterial.BRICK &&
+ prisonBlock.getBlockName().equalsIgnoreCase( "bricks" ) ) {
+ results = XMaterial.BRICKS;
+ }
+ else if ( results == XMaterial.BRICK &&
+ prisonBlock.getBlockName().equalsIgnoreCase( "brick" ) ) {
+ results = XMaterial.BRICKS;
+ }
putCachedXMaterial( prisonBlock, results );
}
@@ -744,4 +753,51 @@ public int getMaxY() {
return 255;
}
+
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so return a value of 0.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ @Override
+ public int getCustomModelData( SpigotItemStack itemStack ) {
+ return 0;
+ }
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so return a value of 0.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ @Override
+ public int getCustomModelData( ItemStack itemStack ) {
+ return 0;
+ }
+
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so do nothing.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ @Override
+ public void setCustomModelData( SpigotItemStack itemStack, int customModelData ) {
+ if ( itemStack != null ) {
+ setCustomModelData( itemStack.getBukkitStack(), customModelData);
+ }
+ }
+ /**
+ * Not compatible with Spigot 1.8 through 1.13 so do nothing.
+ * Only available with 1.14 and higher.
+ * @param itemStack
+ * @return
+ */
+ @Override
+ public void setCustomModelData( ItemStack itemStack, int customModelData ) {
+
+ }
+
+
+
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18GUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8_GUI.java
similarity index 80%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18GUI.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8_GUI.java
index 7a30037c2..a7a288b31 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18GUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8_GUI.java
@@ -2,8 +2,8 @@
import org.bukkit.event.inventory.InventoryEvent;
-public abstract class Spigot18GUI
- extends Spigot18Blocks
+public abstract class Spigot_1_8_GUI
+ extends Spigot_1_8_Blocks
implements CompatibilityGUI {
@SuppressWarnings( "deprecation" )
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18Player.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8_Player.java
similarity index 98%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18Player.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8_Player.java
index 32de7241f..4e35f8fb6 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot18Player.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_8_Player.java
@@ -7,7 +7,7 @@
import tech.mcprison.prison.util.Text;
-public abstract class Spigot18Player
+public abstract class Spigot_1_8_Player
extends CompatibilityCache
implements CompatibilityPlayer
{
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot19.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_9.java
similarity index 98%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot19.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_9.java
index 5b3a2e2d5..b6fb32c73 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot19.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_9.java
@@ -35,8 +35,8 @@
*
* @author Faizaan A. Datoo
*/
-public class Spigot19
- extends Spigot19GUI
+public class Spigot_1_9
+ extends Spigot_1_9_GUI
implements Compatibility {
@Override
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot19GUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_9_GUI.java
similarity index 80%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot19GUI.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_9_GUI.java
index 3268e52ad..92402b13f 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot19GUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_9_GUI.java
@@ -2,8 +2,8 @@
import org.bukkit.event.inventory.InventoryEvent;
-public class Spigot19GUI
- extends Spigot19Player
+public class Spigot_1_9_GUI
+ extends Spigot_1_9_Player
implements CompatibilityGUI {
@Override
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot19Player.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_9_Player.java
similarity index 96%
rename from prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot19Player.java
rename to prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_9_Player.java
index 370aa8045..ce90aca41 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot19Player.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/compat/Spigot_1_9_Player.java
@@ -9,8 +9,8 @@
import tech.mcprison.prison.util.Text;
-public abstract class Spigot19Player
- extends Spigot18Blocks
+public abstract class Spigot_1_9_Player
+ extends Spigot_1_8_Blocks
{
public void setMaxHealth( Player player, double maxHealth ) {
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/GuiConfig.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/GuiConfig.java
index 1335180ba..bdf924b1b 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/GuiConfig.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/configs/GuiConfig.java
@@ -14,6 +14,8 @@
import tech.mcprison.prison.mines.PrisonMines;
import tech.mcprison.prison.mines.data.Mine;
import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.ranks.PrisonRanks;
+import tech.mcprison.prison.ranks.data.Rank;
import tech.mcprison.prison.spigot.SpigotPrison;
/**
@@ -220,6 +222,95 @@ else if ( conf.get( "Options.Mines.MaterialType.NoMineAccess" ) == null ) {
changeCount++;
}
+
+
+ if ( conf.get( "Options.Ranks.MaterialType" ) == null ) {
+
+ if ( PrisonRanks.getInstance() != null ) {
+
+ LinkedHashMap map = new LinkedHashMap<>();
+
+ map.put("NoRankAccess", XMaterial.REDSTONE_BLOCK.name() );
+
+ // Example to preset all ranks: Only do the first 10:
+ int count = 0;
+ for ( Rank rank : PrisonRanks.getInstance().getRankManager().getRanks() ) {
+ map.put( rank.getName(), XMaterial.TRIPWIRE_HOOK.name() );
+ if ( ++count >= 10 ) {
+ break;
+ }
+ }
+
+ conf.set("Options.Ranks.MaterialType", map);
+ changeCount++;
+ }
+ }
+ else if ( conf.get( "Options.Ranks.MaterialType.NoMineAccess" ) == null ) {
+
+ String noMineAccess = XMaterial.REDSTONE_BLOCK.name();
+
+ conf.set("Options.Ranks.MaterialType.NoMineAccess", noMineAccess );
+ changeCount++;
+ }
+
+
+
+ if ( conf.get( "Options.Mines.GuiItemNameDefault" ) == null ) {
+
+ String defaultName = "{mineTag}";
+
+ conf.set("Options.Mines.GuiItemNameDefault", defaultName );
+ changeCount++;
+ }
+
+ if ( conf.get( "Options.Mines.GuiItemNames" ) == null ) {
+
+ if ( PrisonMines.getInstance() != null ) {
+
+ LinkedHashMap map = new LinkedHashMap<>();
+
+ // Example to preset all mines: Only do the first 10:
+ int count = 0;
+ for ( Mine mine : PrisonMines.getInstance().getMineManager().getMines() ) {
+ map.put( mine.getName(), mine.getTag() );
+ if ( ++count >= 10 ) {
+ break;
+ }
+ }
+
+ conf.set("Options.Mines.GuiItemNames", map);
+ changeCount++;
+ }
+ }
+
+
+ if ( conf.get( "Options.Ranks.GuiItemNameDefault" ) == null ) {
+
+ String defaultName = "{rankTag}";
+
+ conf.set("Options.Ranks.GuiItemNameDefault", defaultName );
+ changeCount++;
+ }
+ if ( conf.get( "Options.Ranks.GuiItemNames" ) == null ) {
+
+ if ( PrisonRanks.getInstance() != null ) {
+
+ LinkedHashMap map = new LinkedHashMap<>();
+
+ // Example to preset all ranks: Only do the first 10:
+ int count = 0;
+ for ( Rank rank : PrisonRanks.getInstance().getRankManager().getRanks() ) {
+ map.put( rank.getName(), rank.getTag() );
+ if ( ++count >= 10 ) {
+ break;
+ }
+ }
+
+ conf.set("Options.Ranks.GuiItemNames", map);
+ changeCount++;
+ }
+ }
+
// Count and save
if (changeCount > 0) {
try {
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/CoinsEngineEconomy.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/CoinsEngineEconomy.java
new file mode 100644
index 000000000..0538d6682
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/CoinsEngineEconomy.java
@@ -0,0 +1,240 @@
+package tech.mcprison.prison.spigot.economies;
+
+import tech.mcprison.prison.integration.EconomyCurrencyIntegration;
+import tech.mcprison.prison.internal.Player;
+
+public class CoinsEngineEconomy
+ extends EconomyCurrencyIntegration {
+
+
+ private CoinsEngineEconomyWrapper wrapper = null;
+ private boolean availableAsAnAlternative = false;
+
+ public CoinsEngineEconomy() {
+ super( "CoinsEngineEconomy", "CoinsEngineEconomy" );
+ }
+
+ /**
+ * If GemsEconomy is registered, always hook this up because this may be needed
+ * to be used instead of the primary economy if they are using a custom currency.
+ *
+ */
+ @Override
+ public void integrate() {
+ addDebugInfo( "1" );
+ if ( isRegistered()) {
+ addDebugInfo( "2" );
+ try {
+ addDebugInfo( "3" );
+ this.wrapper = new CoinsEngineEconomyWrapper();
+ addDebugInfo( "4" );
+ }
+ catch ( java.lang.NoClassDefFoundError | Exception e ) {
+ addDebugInfo( "5:Exception:" + e.getMessage() );
+ e.printStackTrace();
+ }
+ }
+ addDebugInfo( "6" );
+ }
+
+
+ @Override
+ public boolean supportedCurrency( String currencyName ) {
+ boolean supported = false;
+
+ if ( wrapper != null ) {
+ supported = wrapper.supportedCurrency( currencyName );
+ }
+
+ return supported;
+ }
+
+ @Override
+ public double getBalance(Player player) {
+ double amount = 0;
+ if ( wrapper != null ) {
+
+ synchronized ( wrapper ) {
+ amount = wrapper.getBalance(player);
+ }
+ }
+ return amount;
+ }
+
+ @Override
+ public double getBalance(Player player, String currencyName) {
+ double amount = 0;
+ if ( wrapper != null ) {
+
+ synchronized ( wrapper ) {
+ amount = wrapper.getBalance(player, currencyName);
+ }
+ }
+ return amount;
+ }
+
+ @Override
+ public boolean setBalance(Player player, double amount) {
+ boolean results = false;
+
+ if ( wrapper != null ) {
+ synchronized ( wrapper ) {
+
+ double bal = getBalance(player);
+ double remainder = amount - bal;
+
+ if ( remainder > 0 ) {
+ wrapper.addBalance( player, remainder );
+ }
+ else if ( remainder < 0 ) {
+ wrapper.withdraw( player, (remainder * -1) );
+ }
+ double balResults = getBalance(player);
+
+ results = balResults == amount;
+ }
+ }
+ return results;
+ }
+
+ @Override
+ public boolean setBalance(Player player, double amount, String currencyName) {
+ boolean results = false;
+
+ if ( wrapper != null ) {
+
+ synchronized ( wrapper ) {
+
+ double bal = getBalance(player, currencyName);
+ double remainder = amount - bal;
+
+ if ( remainder > 0 ) {
+ wrapper.addBalance( player, remainder, currencyName );
+ }
+ else if ( remainder < 0 ) {
+ wrapper.withdraw( player, (remainder * -1), currencyName );
+ }
+ double balResults = getBalance(player, currencyName);
+
+ results = balResults == amount;
+ }
+ }
+ return results;
+ }
+
+ @Override
+ public boolean addBalance(Player player, double amount) {
+ boolean results = false;
+
+ if ( wrapper != null ) {
+
+ synchronized ( wrapper ) {
+
+ double bal = getBalance(player);
+ wrapper.addBalance(player, amount);
+ double balResults = getBalance(player);
+
+ results = balResults == amount + bal;
+ }
+ }
+
+ return results;
+ }
+
+ @Override
+ public boolean addBalance(Player player, double amount, String currencyName) {
+ boolean results = false;
+
+ if ( wrapper != null ) {
+
+ synchronized ( wrapper ) {
+
+ double bal = getBalance(player, currencyName);
+ wrapper.addBalance(player, amount, currencyName);
+ double balResults = getBalance(player, currencyName);
+
+ results = balResults == amount + bal;
+ }
+ }
+
+ return results;
+ }
+
+ @Override
+ public boolean removeBalance(Player player, double amount) {
+ boolean results = false;
+
+ if ( wrapper != null ) {
+ synchronized ( wrapper ) {
+
+ double bal = getBalance(player);
+ wrapper.withdraw(player, amount);
+ double balResults = getBalance(player);
+
+ results = balResults == bal - amount;
+ }
+ }
+
+ return results;
+ }
+
+ @Override
+ public boolean removeBalance(Player player, double amount, String currencyName) {
+ boolean results = false;
+
+ if ( wrapper != null ) {
+ synchronized ( wrapper ) {
+
+ double bal = getBalance(player, currencyName);
+ wrapper.withdraw(player, amount, currencyName);
+ double balResults = getBalance(player, currencyName);
+
+ results = balResults == bal - amount;
+ }
+ }
+
+ return results;
+ }
+
+ @Override
+ public boolean canAfford(Player player, double amount) {
+ boolean results = false;
+ if ( wrapper != null ) {
+ results = getBalance(player) >= amount;
+ }
+ return results;
+ }
+
+ @Override
+ public boolean canAfford(Player player, double amount, String currencyName) {
+ boolean results = false;
+ if ( wrapper != null ) {
+ results = getBalance(player, currencyName) >= amount;
+ }
+ return results;
+ }
+
+ @Override
+ public boolean hasIntegrated() {
+ return wrapper != null && wrapper.isEnabled();
+ }
+
+ @Override
+ public void disableIntegration() {
+ wrapper = null;
+ }
+
+ @Override
+ public String getDisplayName()
+ {
+ return super.getDisplayName() +
+ ( availableAsAnAlternative ? " (disabled)" : "");
+ }
+
+ @Override
+ public String getPluginSourceURL() {
+ return "https://www.spigotmc.org/resources/coinsengine-economy-and-virtual-currencies.84121/";
+ }
+
+
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/CoinsEngineEconomyWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/CoinsEngineEconomyWrapper.java
new file mode 100644
index 000000000..e1d248e57
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/economies/CoinsEngineEconomyWrapper.java
@@ -0,0 +1,108 @@
+package tech.mcprison.prison.spigot.economies;
+
+import su.nightexpress.coinsengine.api.CoinsEngineAPI;
+import su.nightexpress.coinsengine.api.currency.Currency;
+import tech.mcprison.prison.internal.Player;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.game.SpigotPlayer;
+
+public class CoinsEngineEconomyWrapper {
+
+ private CoinsEngineAPI economy;
+
+ public CoinsEngineEconomyWrapper() {
+ super();
+
+
+ try {
+ this.economy = new CoinsEngineAPI();
+ }
+ catch (Exception e) {
+ // If CoinsEngineAPI does not exist, then ignore this exception:
+ }
+
+
+ }
+
+
+ public boolean isEnabled() {
+ return economy != null;
+ }
+
+ public boolean supportedCurrency( String currencyName ) {
+ boolean supported = ( getCurrency( currencyName ) != null );
+
+ return supported;
+ }
+
+
+ public Currency getCurrency( String currencyNamme ) {
+ return CoinsEngineAPI.getCurrency( currencyNamme );
+ }
+
+
+ public double getBalance(Player player) {
+
+ Output.get().logWarn( "CoinsEngineEconomy getBalance() - Fail: MUST include a currencyName.");
+ return getBalance(player, null);
+ }
+
+ public double getBalance(Player player, String currencyName) {
+ double results = 0;
+ if (economy != null && player instanceof SpigotPlayer ) {
+
+ org.bukkit.entity.Player sPlayer = ((SpigotPlayer) player).getWrapper();
+
+ Currency currency = getCurrency( currencyName );
+ if ( currency != null && sPlayer != null) {
+
+ results = CoinsEngineAPI.getBalance( sPlayer, currency );
+ }
+ }
+ return results;
+ }
+
+ public void addBalance(Player player, double amount) {
+
+ Output.get().logWarn( "CoinsEngineEconomy addBalance() - Fail: MUST include a currencyName.");
+ addBalance(player, amount, null);
+ }
+
+ public void addBalance(Player player, double amount, String currencyName) {
+
+ if (economy != null && player instanceof SpigotPlayer ) {
+
+ org.bukkit.entity.Player sPlayer = ((SpigotPlayer) player).getWrapper();
+
+ Currency currency = getCurrency( currencyName );
+ if ( currency != null && sPlayer != null) {
+
+ CoinsEngineAPI.addBalance( sPlayer, currency, amount );
+ }
+ }
+ }
+
+
+ public void withdraw(Player player, double amount) {
+
+ Output.get().logWarn( "CoinsEngineEconomy withdraw() - Fail: MUST include a currencyName.");
+ withdraw(player, amount, null);
+ }
+
+ public void withdraw(Player player, double amount, String currencyName) {
+
+
+ if (economy != null && player instanceof SpigotPlayer ) {
+
+ org.bukkit.entity.Player sPlayer = ((SpigotPlayer) player).getWrapper();
+
+ Currency currency = getCurrency( currencyName );
+ if ( currency != null && sPlayer != null) {
+
+ CoinsEngineAPI.removeBalance( sPlayer, currency, amount );
+ }
+ }
+
+ }
+
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotCommandSender.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotCommandSender.java
index 26bbb66d4..8e4b0d890 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotCommandSender.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotCommandSender.java
@@ -61,8 +61,16 @@ public String getName() {
return bukkitSender.getName();
}
+ /**
+ * This function will dispatch a command and run it as command sender.
+ * But before it is ran, this function looks up within the Prison command handler
+ * to see if it's commands have been remapped to another command, and if it has,
+ * it then uses the mapped command.
+ *
+ */
@Override public void dispatchCommand(String command) {
- Bukkit.getServer().dispatchCommand(bukkitSender, command);
+ String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( command );
+ Bukkit.getServer().dispatchCommand(bukkitSender, registeredCmd);
}
@Override public boolean doesSupportColors() {
@@ -91,7 +99,8 @@ public void sendMessage(String[] messages) {
}
}
- @Override public void sendRaw(String json) {
+ @Override
+ public void sendRaw(String json) {
if (bukkitSender instanceof org.bukkit.entity.Player) {
json = Text.translateAmpColorCodes(json);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + bukkitSender.getName() + " " + json);
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java
index d1dd9ed9d..453d6bcc6 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayer.java
@@ -46,13 +46,16 @@
import tech.mcprison.prison.internal.inventory.Inventory;
import tech.mcprison.prison.internal.scoreboard.Scoreboard;
import tech.mcprison.prison.mines.data.Mine;
+import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.ranks.PrisonRanks;
import tech.mcprison.prison.ranks.data.RankPlayer;
+import tech.mcprison.prison.spigot.SpigotPrison;
import tech.mcprison.prison.spigot.SpigotUtil;
import tech.mcprison.prison.spigot.block.SpigotBlock;
import tech.mcprison.prison.spigot.compat.SpigotCompatibility;
import tech.mcprison.prison.spigot.inventory.SpigotPlayerInventory;
import tech.mcprison.prison.spigot.scoreboard.SpigotScoreboard;
+import tech.mcprison.prison.spigot.sellall.SellAllUtil;
import tech.mcprison.prison.spigot.utils.tasks.PlayerMessagingTask;
import tech.mcprison.prison.util.Gamemode;
import tech.mcprison.prison.util.Location;
@@ -62,7 +65,7 @@
*/
public class SpigotPlayer
extends SpigotCommandSender
- implements Player {
+ implements Player, Comparable {
private RankPlayer rankPlayer;
@@ -230,7 +233,10 @@ public org.bukkit.entity.Player getWrapper() {
@Override
public Inventory getInventory() {
- return new SpigotPlayerInventory(getWrapper().getInventory());
+ return getSpigotPlayerInventory();
+ }
+ public SpigotPlayerInventory getSpigotPlayerInventory() {
+ return new SpigotPlayerInventory(getWrapper().getInventory());
}
@Override public void updateInventory() {
@@ -303,6 +309,12 @@ public Inventory getInventory() {
// return results;
// }
+ @Override
+ public int compareTo( SpigotPlayer sPlayer) {
+ return getName().compareTo( sPlayer.getName() );
+ }
+
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -835,5 +847,96 @@ public boolean isInventoryFull() {
return results;
}
+ /**
+ * This function will identify if the player is able to have
+ * autosell enabled for them. This will take in to consideration
+ * global settings, and also if they have toggled off their
+ * autosell capabilities ('/sellall autoSellToggle`).
+ *
+ *
+ * @return
+ */
+ public boolean isAutoSellEnabled() {
+ return isAutoSellEnabled( null );
+ }
+ public boolean isAutoSellEnabled( StringBuilder debugInfo ) {
+ boolean results = false;
+
+ if ( SpigotPrison.getInstance().isSellAllEnabled() ) {
+
+ boolean isAutoSellPerUserToggleable = SellAllUtil.get().isAutoSellPerUserToggleable;
+
+ boolean isPlayerAutoSellTurnedOff = isAutoSellPerUserToggleable &&
+ !SellAllUtil.get().isSellallPlayerUserToggleEnabled(
+ getWrapper() );
+
+ if ( debugInfo != null && isPlayerAutoSellTurnedOff ) {
+ debugInfo.append( Output.get().getColorCodeWarning() );
+ debugInfo.append( "(Player toggled off autosell) " );
+ debugInfo.append( Output.get().getColorCodeDebug() );
+ }
+
+ // This will return true (allow autosell) unless players can toggle autosell and they turned it off:
+ // This is to be used with other auto sell setting, but never on it's own:
+ results = !isAutoSellPerUserToggleable ||
+ isPlayerAutoSellTurnedOff;
+ }
+
+ return results;
+ }
+
+
+ /**
+ * This will check to see if the player has the perms enabled
+ * for autosell.
+ *
+ *
+ * If the function 'isAutoSellEnabled()' has already
+ * been called, you can also pass that in as a parameter so it does
+ * not have to be recalculated.
+ *
+ *
+ * @return
+ */
+ public boolean isAutoSellByPermEnabled() {
+ return isAutoSellByPermEnabled( isAutoSellEnabled() );
+ }
+
+ /**
+ * This will check to see if the player has the perms enabled
+ * for autosell.
+ *
+ *
+ * If the function 'isAutoSellEnabled()' has already
+ * been called, you can also pass that in as a parameter so it does
+ * not have to be recalculated.
+ *
+ *
+ * @param isPlayerAutosellEnabled
+ * @return
+ */
+ public boolean isAutoSellByPermEnabled( boolean isPlayerAutosellEnabled ) {
+
+ boolean autoSellByPerm = false;
+
+ AutoFeaturesWrapper afw = AutoFeaturesWrapper.getInstance();
+
+ boolean isSellallEnabled = SpigotPrison.getInstance().isSellAllEnabled();
+
+ if ( isSellallEnabled && isPlayerAutosellEnabled && !isOp() ) {
+
+ String perm = afw.getMessage( AutoFeatures.permissionAutoSellPerBlockBreakEnabled );
+
+ autoSellByPerm =
+
+ afw.isBoolean(AutoFeatures.isAutoSellPerBlockBreakEnabled) &&
+ !"disable".equalsIgnoreCase( perm ) &&
+ !"false".equalsIgnoreCase( perm ) &&
+ hasPermission( perm );
+ }
+
+
+ return autoSellByPerm;
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/ListenersPrisonManager.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/ListenersPrisonManager.java
index ba981046d..cfe91068e 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/ListenersPrisonManager.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/ListenersPrisonManager.java
@@ -700,9 +700,11 @@ else if ( SpigotGUIMenuTools.getInstance().processGUIPage( p, title, e ) ) {
if (parts[0].equalsIgnoreCase("Backpack")){
if (e.isRightClick() && e.isShiftClick()){
if (parts[2].equalsIgnoreCase("default")){
- Bukkit.dispatchCommand(p, "backpack delete " + parts[1]);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "backpack delete " + parts[1] ));
} else {
- Bukkit.dispatchCommand(p, "backpack delete " + parts[1] + " " + parts[2]);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "backpack delete " + parts[1] + " " + parts[2] ));
}
p.closeInventory();
BackpacksAdminListGUI gui = new BackpacksAdminListGUI(p, parts[1]);
@@ -766,7 +768,8 @@ else if ( SpigotGUIMenuTools.getInstance().processGUIPage( p, title, e ) ) {
// }
//
// if ( isPageAction && command != null ) {
-// Bukkit.dispatchCommand(p, command);
+// Bukkit.dispatchCommand(p,
+// Prison.get().getCommandHandler().findRegisteredCommand( command ));
//
// }
// }
@@ -833,7 +836,8 @@ private void backpacksList(Player p, String buttonNameMain, String[] parts) {
}
String finalID = String.valueOf(freeID);
- Bukkit.dispatchCommand(p, "gui backpack " + finalID);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "gui backpack " + finalID ));
}
} else if (buttonNameMain.equalsIgnoreCase("Backpack")){
@@ -1321,7 +1325,8 @@ private boolean guiConditions(InventoryClickEvent e, Player p) {
private void prisonSetupConfirmGUI(InventoryClickEvent e, Player p, String[] parts) {
if (parts[0].equalsIgnoreCase("Confirm:")){
- Bukkit.dispatchCommand(p, "ranks autoConfigure");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "ranks autoConfigure" ));
} else if (parts[0].equalsIgnoreCase("Cancel:")){
Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_event_cancelled));
}
@@ -1406,7 +1411,9 @@ private void mineBlockPercentage(InventoryClickEvent e, Player p, String[] parts
// Execute the command
if (part4 != null) {
- Bukkit.dispatchCommand(p, "mines block set " + part2 + " " + part3 + " " + part4);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines block set " + part2 + " " + part3 + " " + part4 ));
}
// Cancel the event
@@ -1524,7 +1531,9 @@ private void sellAllItemValue(InventoryClickEvent e, Player p, String[] parts) {
if (e.isLeftClick()){
// Execute the command
- Bukkit.dispatchCommand(p,"sellall edit " + part2 + " " + part3);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "sellall edit " + part2 + " " + part3 ));
// Close the inventory
p.closeInventory();
@@ -1731,7 +1740,8 @@ private void laddersGUI(InventoryClickEvent e, Player p, String buttonNameMain,
else {
// Execute the command
- Bukkit.dispatchCommand(p, "ranks ladder delete " + buttonNameMain);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "ranks ladder delete " + buttonNameMain ));
e.setCancelled(true);
p.closeInventory();
SpigotLaddersGUI gui = new SpigotLaddersGUI(p, 1, "gui ladders", "gui" );
@@ -1776,7 +1786,8 @@ private void ranksGUI(InventoryClickEvent e, Player p, String buttonNameMain, St
RankLadder rLadder = rank.getLadder();
// Execute the command.
- Bukkit.dispatchCommand(p, "ranks delete " + buttonNameMain);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "ranks delete " + buttonNameMain ));
e.setCancelled(true);
p.closeInventory();
SpigotRanksGUI gui = new SpigotRanksGUI( p, rLadder, 1, "gui admin ranks", "gui" );
@@ -1802,7 +1813,8 @@ private void playerPrestigesGUI(InventoryClickEvent e, Player p, String buttonNa
// Close the inventory.
p.closeInventory();
// Execute the command.
- Bukkit.dispatchCommand(p, "prestige");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "prestige" ));
}
// Cancel the event.
@@ -1931,7 +1943,9 @@ private void playerRanksGUI(InventoryClickEvent e, Player p, String buttonNameMa
// Check the buttonName and do the actions.
String message = Text.stripColor( messages.getString(MessagesConfig.StringID.spigot_gui_lore_rankup) );
if (buttonNameMain.equals(SpigotPrison.format( message ))){
- Bukkit.dispatchCommand(p, "rankup " + guiConfig.getString("Options.Ranks.Ladder"));
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "rankup " + guiConfig.getString("Options.Ranks.Ladder" )));
p.closeInventory();
}
@@ -1945,7 +1959,8 @@ private void rankUPCommandsGUI(InventoryClickEvent e, Player p, String buttonNam
if (e.isShiftClick() && e.isRightClick()) {
// Execute the command.
- Bukkit.dispatchCommand(p, "ranks command remove " + buttonNameMain);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "ranks command remove " + buttonNameMain ));
// Cancel the event.
e.setCancelled(true);
// Close the inventory.
@@ -1980,7 +1995,8 @@ private void rankPriceGUI(InventoryClickEvent e, Player p, String[] parts) {
if (e.isLeftClick()){
// Execute the command.
- Bukkit.dispatchCommand(p,"ranks set cost " + part2 + " " + part3);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "ranks set cost " + part2 + " " + part3 ));
// Close the inventory.
p.closeInventory();
@@ -2080,7 +2096,8 @@ private void minesGUI(InventoryClickEvent e, Player p, String buttonNameMain, St
// Check the clicks.
if (e.isShiftClick() && e.isRightClick()) {
// Execute the command.
- Bukkit.dispatchCommand(p, "mines delete " + buttonNameMain);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines delete " + buttonNameMain ));
// Cancel the event.
e.setCancelled(true);
// Close the inventory.
@@ -2125,10 +2142,14 @@ private void playerMinesGUI(Player p, InventoryClickEvent e) {
if (errorHasMiningPermission && (p.hasPermission(permission + mineName) ||
p.hasPermission(permission.substring(0, permission.length() - 1)))){
- Bukkit.dispatchCommand(p, SpigotPrison.format(guiConfig.getString("Options.Mines.CommandWarpPlugin") + " " + mineName));
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ SpigotPrison.format(guiConfig.getString("Options.Mines.CommandWarpPlugin") + " " + mineName )));
} else if (hasMiningPermission || p.hasPermission(permission + mineName) ||
p.hasPermission(permission.substring(0, permission.length() - 1))){
- Bukkit.dispatchCommand(p, SpigotPrison.format(guiConfig.getString("Options.Mines.CommandWarpPlugin") + " " + mineName));
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ SpigotPrison.format(guiConfig.getString("Options.Mines.CommandWarpPlugin") + " " + mineName )));
}
}
}
@@ -2155,13 +2176,16 @@ private void mineInfoGUI(InventoryClickEvent e, Player p, String[] parts) {
// Check the clickType and do the actions.
if (e.isLeftClick()) {
// Execute the command.
- Bukkit.dispatchCommand(p, "mines reset " + mineName);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines reset " + mineName ));
} else if (e.isRightClick()){
// Execute the command.
- Bukkit.dispatchCommand(p, "mines set skipReset " + mineName);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines set skipReset " + mineName ));
} else if (e.isRightClick() && e.isShiftClick()){
// Execute the command.
- Bukkit.dispatchCommand(p, "mines set zeroBlockResetDelay " + mineName);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines set zeroBlockResetDelay " + mineName ));
}
// Cancel the event.
@@ -2173,7 +2197,8 @@ private void mineInfoGUI(InventoryClickEvent e, Player p, String[] parts) {
case "Mine_Spawn:":
// Execute the command.
- Bukkit.dispatchCommand(p, "mines set spawn " + mineName);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines set spawn " + mineName ));
// Cancel the event.
e.setCancelled(true);
@@ -2195,7 +2220,8 @@ private void mineInfoGUI(InventoryClickEvent e, Player p, String[] parts) {
p.closeInventory();
// Execute the Command.
- Bukkit.dispatchCommand(p, "mines tp " + mineName);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines tp " + mineName ));
break;
@@ -2245,7 +2271,8 @@ private void minesDeleteGUI(Player p, String[] parts) {
if (buttonname.equals("Confirm:")) {
// Confirm
- Bukkit.dispatchCommand(p, "mines delete " + mineName + " confirm");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines delete " + mineName + " confirm" ));
// Close the Inventory
p.closeInventory();
@@ -2254,7 +2281,8 @@ private void minesDeleteGUI(Player p, String[] parts) {
} else if (buttonname.equals("Cancel:")) {
// Cancel
- Bukkit.dispatchCommand(p, "mines delete " + mineName + " cancel");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( "mines delete " + mineName + " cancel" ));
// Close the inventory
p.closeInventory();
@@ -2281,7 +2309,9 @@ private void blocksGUI(InventoryClickEvent e, Player p, String[] parts) {
if (e.isShiftClick() && e.isRightClick()) {
// Execute the command
- Bukkit.dispatchCommand(p, "mines block remove " + mineName + " " + buttonname);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines block remove " + mineName + " " + buttonname ));
// Cancel the event
e.setCancelled(true);
@@ -2330,7 +2360,9 @@ private void resetTimeGUI(InventoryClickEvent e, Player p, String[] parts) {
if (e.isLeftClick()){
// Execute the command
- Bukkit.dispatchCommand(p,"mines set resettime " + part2 + " " + part3);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines set resettime " + part2 + " " + part3 ));
// Cancel the event
e.setCancelled(true);
@@ -2445,7 +2477,9 @@ private void mineNotificationsGUI(InventoryClickEvent e, Player p, String[] part
typeNotification = "within";
// Execute command
- Bukkit.dispatchCommand(p, "mines set notification " + mineName + " " + typeNotification + " 0");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines set notification " + mineName + " " + typeNotification + " 0" ));
// Cancel the event and close the inventory
e.setCancelled(true);
@@ -2471,7 +2505,9 @@ private void mineNotificationsGUI(InventoryClickEvent e, Player p, String[] part
typeNotification = "disabled";
// Execute the command
- Bukkit.dispatchCommand(p, "mines set notification " + mineName + " " + typeNotification + " 0");
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines set notification " + mineName + " " + typeNotification + " 0" ));
// Cancel the event and close the inventory
e.setCancelled(true);
@@ -2512,7 +2548,9 @@ private void radiusGUI(InventoryClickEvent e, Player p, String[] parts) {
if (e.isLeftClick()){
// Execute the command
- Bukkit.dispatchCommand(p,"mines set notification " + part2 + " " + typeNotification + " " + part3);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand(
+ "mines set notification " + part2 + " " + typeNotification + " " + part3 ));
// Cancel the event
e.setCancelled(true);
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotGUIMenuTools.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotGUIMenuTools.java
index 195fb4b9b..c47c52a46 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotGUIMenuTools.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotGUIMenuTools.java
@@ -11,6 +11,7 @@
import com.cryptomorin.xseries.XMaterial;
+import tech.mcprison.prison.Prison;
import tech.mcprison.prison.spigot.gui.guiutility.Button;
import tech.mcprison.prison.spigot.gui.guiutility.ButtonLore;
import tech.mcprison.prison.spigot.gui.guiutility.PrisonGUI;
@@ -356,7 +357,8 @@ public boolean processGUIPage( Player p, String title, InventoryClickEvent e ) {
if ( command != null ) {
isPageAction = true;
- Bukkit.dispatchCommand(p, command);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( command ));
}
}
@@ -390,7 +392,8 @@ else if ( currentItem != null && currentItem.hasItemMeta() ) {
if ( isMenuToolsPage && command != null ) {
isPageAction = true;
- Bukkit.dispatchCommand(p, command);
+ Bukkit.dispatchCommand(p,
+ Prison.get().getCommandHandler().findRegisteredCommand( command ));
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java
index 33437fced..951149bb1 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotPlayerMinesGUI.java
@@ -100,7 +100,10 @@ public void open() {
// Create GUI but use the gui title as defined within the ConfigGui.yml file:
PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), guiConfig.getString("Options.Titles.PlayerMinesGUI"));
+
+ String guiItemNameDefault = guiConfig.getString( "Options.Mines.GuiItemNameDefault" );
+
// Load the generic mine LORE that would be displayed first:
List configCustomLore = guiConfig.getStringList("EditableLore.Mines");
@@ -122,6 +125,9 @@ public void open() {
for (Mine m : minesDisplay) {
// for (Mine m : mines.getSortedList()) {
+ String guiItemName = guiConfig.getString( "Options.Mines.GuiItemNames." + m.getName() );
+
+
// Init the lore array with default values for ladders
ButtonLore minesLore = new ButtonLore();
@@ -140,8 +146,13 @@ public void open() {
// Material material;
- // Get Mine Name.
- String mineName = m.getName();
+ // Get Mine Name. First use 'guiItemName' if not null, then try to use 'guiItemNameDefault'
+ // if not null, and then use the mine's tag, or if that's null, then use the name:
+ String mineName =
+ guiItemName != null ? guiItemName :
+ guiItemNameDefault != null ? guiItemNameDefault :
+ m.getTag() != null ? m.getTag() :
+ m.getName();
// // Add mineName lore for TP.
// minesLore.addLineLoreAction( "&3" + mineName );
@@ -261,7 +272,8 @@ public void open() {
}
- Button itemMine = new Button(null, xMat, minesLore, "&3" + mineTag);
+ Button itemMine = new Button(null, xMat, minesLore, mineName );
+// Button itemMine = new Button(null, xMat, minesLore, "&3" + mineTag);
String mineTeleportCommand =
Output.stringFormat(
@@ -269,7 +281,7 @@ public void open() {
m.getName(),
p.getName() );
- // Before adding the button, add an NBT tag for the command and rank name:
+ // Before adding the button, add an NBT tag for the command and mine name:
// PrisonNBTUtil nbtUtil = new PrisonNBTUtil();
// NBTItem nbtItem = nbtUtil == null ? null : nbtUtil.getNBT( itemMine.getButtonItem());
PrisonNBTUtil.setNBTBoolean( itemMine.getButtonItem(), SpigotGUIMenuTools.GUI_MENU_TOOLS_NBT_ENABLED, true);
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java
index 4b1cccdb2..7e489f599 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerRanksGUI.java
@@ -157,6 +157,11 @@ public void open() {
PrisonGUI gui = new PrisonGUI(getPlayer(), guiPageData.getDimension(), guiConfig.getString("Options.Titles.PlayerRanksGUI"));
+
+
+ String guiItemNameDefault = guiConfig.getString( "Options.Ranks.GuiItemNameDefault" );
+
+
// Not sure how you want to represent this:
XMaterial materialHas = XMaterial.valueOf(guiConfig.getString("Options.Ranks.Item_gotten_rank"));
XMaterial materialHasNot = XMaterial.valueOf(guiConfig.getString("Options.Ranks.Item_not_gotten_rank"));
@@ -184,9 +189,34 @@ public void open() {
for ( Rank rank : ranksDisplay )
{
- // hasAccess uses access by rank, and access by perm:
- boolean playerHasThisRank = getRankPlayer() != null && getRankPlayer().hasAccessToRank( rank );
-
+
+ String guiItemName = guiConfig.getString( "Options.Ranks.GuiItemNames." + rank.getName() );
+
+ // Get Rank Name. First use 'guiItemName' if not null, then try to use 'guiItemNameDefault'
+ // if not null, and then use the rank's tag, or if that's null, then use the name:
+ String rankName =
+ guiItemName != null ? guiItemName :
+ guiItemNameDefault != null ? guiItemNameDefault :
+ rank.getTag() != null ? rank.getTag() :
+ rank.getName();
+
+
+ // hasAccess uses access by rank, and access by perm:
+ boolean playerHasThisRank = getRankPlayer() != null && getRankPlayer().hasAccessToRank( rank );
+
+
+ // The valid names to use for Options.Ranks.MaterialType. must be
+ // based upon the XMaterial enumeration name, or supported past names.
+ String materialTypeStr = guiConfig.getString("Options.Ranks.MaterialType." + rank.getName());
+ XMaterial materialType =
+ materialTypeStr == null ? null :
+ XMaterial.valueOf( materialTypeStr.toUpperCase() );
+
+ materialType =
+ !playerHasThisRank ? materialHasNot :
+ materialType != null ? materialType :
+ materialHas;
+
String rankLoreKey = "EditableLore.Rank." + ladderName + "." + rank.getName();
List rankLore = new ArrayList<>( configCustomLore );
List rankLore2 = guiConfig.getStringList( rankLoreKey );
@@ -215,7 +245,7 @@ public void open() {
}
for ( String stringValue : rankLore ) {
-
+
String currency = (rank.getCurrency() == null ||
"default".equalsIgnoreCase( rank.getCurrency()) ||
rank.getCurrency().trim().length() == 0 ?
@@ -246,9 +276,10 @@ public void open() {
}
Button itemRank = new Button(null,
- playerHasThisRank ? materialHas : materialHasNot,
+ materialType,
+// playerHasThisRank ? materialHas : materialHasNot,
showNumber ? amount : 1, ranksLore,
- rank.getTag() );
+ rankName );
amount++;
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotPlayerInventory.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotPlayerInventory.java
index 840eab86b..14649eeb5 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotPlayerInventory.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/inventory/SpigotPlayerInventory.java
@@ -23,6 +23,7 @@
import java.util.List;
import tech.mcprison.prison.internal.ItemStack;
+import tech.mcprison.prison.internal.block.PrisonBlock;
import tech.mcprison.prison.internal.inventory.PlayerInventory;
import tech.mcprison.prison.spigot.SpigotUtil;
import tech.mcprison.prison.spigot.block.SpigotItemStack;
@@ -31,20 +32,161 @@
/**
* Created by DMP9 on 04/02/2017.
*/
-public class SpigotPlayerInventory extends SpigotInventory implements PlayerInventory {
+public class SpigotPlayerInventory
+ extends SpigotInventory
+ implements PlayerInventory {
public SpigotPlayerInventory(org.bukkit.inventory.PlayerInventory wrapper) {
super(wrapper);
}
- @Override public ItemStack[] getArmorContents() {
+ /**
+ * This function gets all of the player's contents from the getContents(),
+ * getExtraContents(), and getArmorContents().
+ *
+ *
+ * @return
+ */
+ public List getAllContents() {
+ List results = new ArrayList<>();
+
+ for ( ItemStack iStack : getContents() ) {
+ if ( iStack != null ) {
+ results.add(iStack);
+ }
+ }
+
+ try {
+ for ( ItemStack iStack : getExtraContents() ) {
+ if ( iStack != null ) {
+ results.add(iStack);
+ }
+ }
+ } catch (NoSuchMethodError e) {
+ // Ignore on older versions of spigot... Spigot 1.8.8 does not have this function.
+ }
+
+ // then remove the armor ItemStacks:
+ for ( ItemStack iStack : getArmorContents() ) {
+ if ( iStack != null ) {
+ results.remove(iStack);
+ }
+ }
+
+ return results;
+ }
+
+ @Override
+ public void removeItem( ItemStack... iStack ) {
+ if ( iStack != null ) {
+
+ // Remove all items...
+ super.removeItem(iStack);
+
+ // But since this is a player's inventory, try to remove them from the players slots
+ for (ItemStack itemStack : iStack) {
+ PrisonBlock pBlock = itemStack.getMaterial();
+
+ if ( isPrisonBlockEqual( pBlock, getBoots() ) ) {
+ setBoots( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+ if ( isPrisonBlockEqual( pBlock, getChestplate() ) ) {
+ setChestplate( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+ if ( isPrisonBlockEqual( pBlock, getHelmet() ) ) {
+ setHelmet( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+ if ( isPrisonBlockEqual( pBlock, getLeggings() ) ) {
+ setLeggings( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+
+ try {
+
+ if ( isPrisonBlockEqual( pBlock, getItemInLeftHand() ) ) {
+ setItemInLeftHand( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+ }
+ catch ( Exception e ) {
+ // java 1.8 may not be able to handle this
+ }
+ try {
+
+ if ( isPrisonBlockEqual( pBlock, getItemInRightHand() ) ) {
+ setItemInRightHand( new SpigotItemStack( 0, PrisonBlock.AIR ) );
+ }
+ }
+ catch ( Exception e ) {
+ // java 1.8 may not be able to handle this
+ }
+
+ }
+ }
+ }
+
+
+ private boolean isPrisonBlockEqual( PrisonBlock pBlock, ItemStack iStack ) {
+ boolean results = false;
+
+ if ( pBlock != null && iStack != null ) {
+ results = pBlock.equals( iStack.getMaterial() );
+ }
+
+ return results;
+ }
+
+ @Override
+ public ItemStack[] getContents() {
+ List items = new ArrayList<>();
+ Arrays.asList(((org.bukkit.inventory.PlayerInventory) getWrapper()).getContents())
+ .forEach(x -> items.add(SpigotUtil.bukkitItemStackToPrison(x)));
+ return (ItemStack[]) items.toArray();
+ }
+
+ @Override
+ public void setContents( ItemStack[] items ) {
+ List stacks = new ArrayList<>();
+ Arrays.asList(items).forEach(x -> stacks.add(SpigotUtil.prisonItemStackToBukkit(x)));
+ ((org.bukkit.inventory.PlayerInventory) getWrapper())
+ .setContents((org.bukkit.inventory.ItemStack[]) stacks.toArray());
+ }
+
+ @Override
+ public ItemStack[] getExtraContents() {
+ try {
+ List items = new ArrayList<>();
+ Arrays.asList(((org.bukkit.inventory.PlayerInventory) getWrapper()).getExtraContents())
+ .forEach(x -> items.add(SpigotUtil.bukkitItemStackToPrison(x)));
+ return (ItemStack[]) items.toArray();
+ }
+ catch ( Exception e ) {
+ return null;
+ }
+ }
+ @Override
+ public void setExtraContents( ItemStack[] items ) {
+ try {
+ List stacks = new ArrayList<>();
+ Arrays.asList(items).forEach(x -> stacks.add(SpigotUtil.prisonItemStackToBukkit(x)));
+ ((org.bukkit.inventory.PlayerInventory) getWrapper())
+ .setExtraContents((org.bukkit.inventory.ItemStack[]) stacks.toArray());
+ }
+ catch ( Exception e ) {
+ // extraContents does not exist in spigot 1.8
+ }
+ }
+
+
+
+ @Override
+ public ItemStack[] getArmorContents() {
List items = new ArrayList<>();
Arrays.asList(((org.bukkit.inventory.PlayerInventory) getWrapper()).getArmorContents())
.forEach(x -> items.add(SpigotUtil.bukkitItemStackToPrison(x)));
return (ItemStack[]) items.toArray();
}
- @Override public void setArmorContents(ItemStack[] items) {
+ @Override
+ public void setArmorContents(ItemStack[] items) {
List stacks = new ArrayList<>();
Arrays.asList(items).forEach(x -> stacks.add(SpigotUtil.prisonItemStackToBukkit(x)));
((org.bukkit.inventory.PlayerInventory) getWrapper())
@@ -119,7 +261,8 @@ public SpigotPlayerInventory(org.bukkit.inventory.PlayerInventory wrapper) {
}
}
- @Override public ItemStack getItemInRightHand() {
+ @Override
+ public ItemStack getItemInRightHand() {
return SpigotUtil.bukkitItemStackToPrison(
@@ -127,7 +270,8 @@ public SpigotPlayerInventory(org.bukkit.inventory.PlayerInventory wrapper) {
((org.bukkit.inventory.PlayerInventory) getWrapper()) ));
}
- @Override public void setItemInRightHand(ItemStack stack) {
+ @Override
+ public void setItemInRightHand(ItemStack stack) {
if ( stack instanceof SpigotItemStack ) {
@@ -135,5 +279,5 @@ public SpigotPlayerInventory(org.bukkit.inventory.PlayerInventory wrapper) {
.setItemStackInMainHand( this, ((SpigotItemStack) stack) );
}
}
-
+
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/nbt/PrisonNBTUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/nbt/PrisonNBTUtil.java
index c35f26d5d..415409308 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/nbt/PrisonNBTUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/nbt/PrisonNBTUtil.java
@@ -1,9 +1,12 @@
package tech.mcprison.prison.spigot.nbt;
+import java.util.function.Function;
+
import org.bukkit.inventory.ItemStack;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBT;
+import de.tr7zw.changeme.nbtapi.iface.ReadableItemNBT;
import tech.mcprison.prison.output.Output;
/**
@@ -40,7 +43,10 @@ public static boolean hasNBTString( ItemStack bukkitStack, String key ) {
public static String getNBTString( ItemStack bukkitStack, String key ) {
String results = null;
- results = NBT.get(bukkitStack, nbt -> nbt.getString(key));
+ Function gsFnc = nbt -> nbt.getString(key);
+
+ results = NBT.get(bukkitStack, gsFnc );
+// results = NBT.get(bukkitStack, nbt -> nbt.getString(key));
return results;
}
@@ -59,7 +65,10 @@ public static void setNBTString( ItemStack bukkitStack, String key, String value
public static boolean getNBTBoolean( ItemStack bukkitStack, String key ) {
boolean results = false;
- results = NBT.get(bukkitStack, nbt -> nbt.getBoolean(key));
+ Function gbFnc = nbt -> nbt.getBoolean(key);
+
+ results = NBT.get(bukkitStack, gbFnc );
+// results = NBT.get(bukkitStack, nbt -> nbt.getBoolean(key));
return results;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/SpigotPlaceholders.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/SpigotPlaceholders.java
index d95853d7b..72cb87a07 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/SpigotPlaceholders.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/SpigotPlaceholders.java
@@ -25,6 +25,7 @@
import tech.mcprison.prison.ranks.managers.PlayerManager;
import tech.mcprison.prison.ranks.managers.RankManager;
import tech.mcprison.prison.spigot.SpigotPrison;
+import tech.mcprison.prison.spigot.game.SpigotPlayer;
public class SpigotPlaceholders
implements Placeholders {
@@ -70,6 +71,38 @@ private void initializePlaceholderManagers() {
}
}
+ private boolean ignorePlayerInDisabledWorlds( SpigotPlayer sPlayer ) {
+ boolean results = false;
+
+ String worldName =
+ sPlayer == null ||
+ sPlayer.getLocation() == null ||
+ sPlayer.getLocation().getWorld() == null ?
+ null :
+ sPlayer.getLocation().getWorld().getName();
+
+ if ( worldName != null && sPlayer.isOnline() ) {
+
+ boolean disable = Prison.get().getPlatform().getConfigBooleanFalse(
+ "prisonCommandHandler.disable-player-placeholders-in-excluded-worlds" );
+ if ( disable ) {
+ List excludedWorlds = Prison.get().getPlatform()
+ .getConfigStringArray( "prisonCommandHandler.exclude-worlds" );
+ for (String world : excludedWorlds) {
+ if ( world.trim().equalsIgnoreCase( worldName ) ) {
+ results = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if ( results ) {
+ PlaceholdersStats.getInstance().incrementInvalidWorldCount();
+ }
+
+ return results;
+ }
@Override
public Map getPlaceholderDetailCounts() {
@@ -170,7 +203,7 @@ public int getPlaceholderRegistrationCount() {
/**
* Provides placeholder translation for any placeholder identifier
- * that is provided. This not the full text with one or more placeholders,
+ * that is provided. This not for full text with one or more placeholders,
* but it is strictly just the placeholder.
*
*
@@ -425,6 +458,13 @@ private String replaceAllPlaceholders(UUID playerUuid, String playerName, String
String replacementText = processPlaceholderIdentifier(identifier);
if ( identifier.isFoundAMatch() ) {
+
+ if ( identifier.getPlayer() != null &&
+ identifier.getPlayer() instanceof SpigotPlayer &&
+ ignorePlayerInDisabledWorlds( (SpigotPlayer) identifier.getPlayer() )) {
+ replacementText = "";
+ }
+
results = results.replace( placeholderText, replacementText );
}
@@ -481,6 +521,10 @@ public List placeholderSearch( UUID playerUuid, String playerName, Strin
String value = processPlaceholderHavePlaceholderKey( identifier );
+ if ( ignorePlayerInDisabledWorlds( (SpigotPlayer) identifier.getPlayer() )) {
+ value = "";
+ }
+
// Note: STATSMINES will not work here since the sequence is not being addressed.
// if ( mm != null && (placeHolderKey.getPlaceholder().hasFlag( PlaceholderFlags.MINES ) ||
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
new file mode 100644
index 000000000..9d7555fba
--- /dev/null
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllData.java
@@ -0,0 +1,159 @@
+package tech.mcprison.prison.spigot.sellall;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import tech.mcprison.prison.internal.block.PrisonBlock;
+import tech.mcprison.prison.output.Output;
+import tech.mcprison.prison.spigot.game.SpigotPlayer;
+
+/**
+ * This is a simple class that contains the times that have been sold
+ * and the amount that they were sold for.
+ *
+ *
+ * @author Blue
+ *
+ */
+public class SellAllData {
+
+ private PrisonBlock prisonBlock;
+ private int quantity;
+ private double transactionAmount;
+ private boolean itemsSold;
+
+ public SellAllData( PrisonBlock pBlock, int quantity, double transactionAmount ) {
+ super();
+
+ this.itemsSold = false;
+
+ this.prisonBlock = pBlock;
+ this.quantity = quantity;
+ this.transactionAmount = transactionAmount;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ DecimalFormat dFmt = new DecimalFormat( "#,##0.00" );
+ sb.append( getPrisonBlock().getBlockName() )
+ .append( ":" )
+ .append( getQuantity() )
+ .append( ":" )
+ .append( dFmt.format(getTransactionAmount()) );
+
+ if ( isItemsSold() ) {
+ sb.append( ":SOLD" );
+ }
+
+ return sb.toString();
+ }
+
+
+ public static void debugItemsSold( List soldItems, SpigotPlayer sPlayer, double multiplier ) {
+ if ( Output.get().isDebug() ) {
+ String report = SellAllData.itemsSoldReport( soldItems, sPlayer, multiplier );
+ Output.get().logDebug( report, (sPlayer != null ? sPlayer.getName() : null) );
+ }
+ }
+
+ public static String itemsSoldReport( List soldItems, SpigotPlayer sPlayer, double multiplier ) {
+ StringBuilder sb = new StringBuilder();
+ StringBuilder sbItems = new StringBuilder();
+
+ double totalAmount = 0;
+ int itemCount = 0;
+ int stacks = soldItems.size();
+
+ // Add same blocks together:
+ soldItems = compressSoldItems( soldItems );
+
+ for (SellAllData soldItem : soldItems) {
+ if ( soldItem != null ) {
+
+ totalAmount += soldItem.getTransactionAmount();
+ itemCount += soldItem.getQuantity();
+
+ if ( sbItems.length() > 0 ) {
+
+ sbItems.append( ", " );
+ }
+ sbItems.append( soldItem.toString() );
+ }
+ }
+
+ DecimalFormat dFmt = new DecimalFormat( "#,##0.00" );
+ DecimalFormat iFmt = new DecimalFormat( "#,##0" );
+
+ sb.append( "Transaction log: " )
+ .append( sPlayer.getName() )
+ .append( " multiplier: " )
+ .append( dFmt.format(multiplier) )
+ .append( " ItemStacks: " )
+ .append( stacks )
+ .append( " ItemCount: " )
+ .append( iFmt.format(itemCount) )
+ .append( " TotalAmount: " )
+ .append( dFmt.format( totalAmount ))
+ .append( " [" )
+ .append( sbItems )
+ .append("]");
+
+ return sb.toString();
+ }
+
+ private static List compressSoldItems(List soldItems) {
+ List results = new ArrayList<>();
+
+ for (SellAllData sItem : soldItems) {
+ boolean found = false;
+
+ for (SellAllData result : results) {
+ if ( sItem.getPrisonBlock().equals(result.getPrisonBlock() ) ) {
+ found = true;
+
+ // found a match... add to the result item:
+ result.setQuantity( result.getQuantity() + sItem.getQuantity() );
+ result.setTransactionAmount( result.getTransactionAmount() + sItem.getTransactionAmount() );
+ break;
+ }
+ }
+
+ if ( !found ) {
+ results.add(sItem);
+ }
+ }
+
+ return results;
+ }
+
+ public PrisonBlock getPrisonBlock() {
+ return prisonBlock;
+ }
+ public void setPrisonBlock(PrisonBlock prisonBlock) {
+ this.prisonBlock = prisonBlock;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+
+ public double getTransactionAmount() {
+ return transactionAmount;
+ }
+ public void setTransactionAmount(double transactionAmount) {
+ this.transactionAmount = transactionAmount;
+ }
+
+ public boolean isItemsSold() {
+ return itemsSold;
+ }
+ public void setItemsSold(boolean itemsSold) {
+ this.itemsSold = itemsSold;
+ }
+
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
index ec41604a3..1acf5a8eb 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/sellall/SellAllUtil.java
@@ -9,27 +9,22 @@
import java.util.Optional;
import org.bukkit.Bukkit;
-import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.PlayerInventory;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
-import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack;
import tech.mcprison.prison.Prison;
import tech.mcprison.prison.PrisonAPI;
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.integration.EconomyCurrencyIntegration;
import tech.mcprison.prison.internal.block.PrisonBlock;
-import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType;
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.ranks.PrisonRanks;
import tech.mcprison.prison.ranks.data.PlayerRank;
@@ -37,16 +32,12 @@
import tech.mcprison.prison.ranks.data.RankPlayer;
import tech.mcprison.prison.sellall.messages.SpigotVariousGuiMessages;
import tech.mcprison.prison.spigot.SpigotPrison;
-import tech.mcprison.prison.spigot.backpacks.BackpacksUtil;
import tech.mcprison.prison.spigot.block.SpigotItemStack;
-import tech.mcprison.prison.spigot.compat.Compatibility;
-import tech.mcprison.prison.spigot.compat.SpigotCompatibility;
//import tech.mcprison.prison.spigot.configs.MessagesConfig;
import tech.mcprison.prison.spigot.game.SpigotCommandSender;
import tech.mcprison.prison.spigot.game.SpigotPlayer;
import tech.mcprison.prison.spigot.gui.sellall.SellAllAdminGUI;
import tech.mcprison.prison.spigot.gui.sellall.SellAllPlayerGUI;
-import tech.mcprison.prison.spigot.integrations.IntegrationMinepacksPlugin;
import tech.mcprison.prison.spigot.inventory.SpigotPlayerInventory;
import tech.mcprison.prison.util.Text;
@@ -58,23 +49,25 @@ public class SellAllUtil
private static SellAllUtil instance;
- private final Compatibility compat = SpigotPrison.getInstance().getCompatibility();
+// private final Compatibility compat = SpigotPrison.getInstance().getCompatibility();
- private final ItemStack lapisLazuli = compat.getLapisItemStack();
+// private final ItemStack lapisLazuli = compat.getLapisItemStack();
public Configuration sellAllConfig;
- private HashMap sellAllBlocks;
+ private HashMap sellAllItems;
+// private HashMap sellAllBlocks;
+
private HashMap sellAllPrestigeMultipliers;
private HashMap autoSellEarningsNotificationWaiting = new HashMap<>();
private ArrayList sellAllItemTriggers;
private ArrayList activePlayerDelay = new ArrayList<>();
- private List sellAllDisabledWorlds;
+// private List sellAllDisabledWorlds;
// private MessagesConfig messages;
private double defaultMultiplier;
private int defaultSellAllDelay;
private int defaultAutoSellEarningNotificationDelay;
- private Sound sellAllSoundSuccess;
+ public Sound sellAllSoundSuccess;
private Sound sellAllSoundFail;
public String sellAllSignTag;
public String sellAllCurrency;
@@ -107,6 +100,8 @@ public class SellAllUtil
public boolean isSellAllSignNotifyEnabled;
public boolean isSellAllSignPermissionToUseEnabled;
public boolean isSellAllNotificationEnabled;
+ public boolean isSellAllNotificationByActionBar;
+
public boolean isSellAllSoundEnabled;
public boolean isSellAllBackpackItemsEnabled;
public boolean isSellAllMinesBackpacksPluginEnabled;
@@ -129,16 +124,107 @@ public static SellAllUtil get() {
}
return instance;
}
-
+
/**
- * Return boolean value from String.
- *
- * @return boolean.
+ * Init options that will be cached.
* */
- private static boolean getBoolean(String string) {
- return string != null && string.equalsIgnoreCase("true");
+ private void initCachedData() {
+ sellAllConfig = SpigotPrison.getInstance().updateSellAllConfig();
+// messages = SpigotPrison.getInstance().getMessagesConfig();
+ permissionSellAllSell = sellAllConfig.getString("Options.Sell_Permission");
+ permissionBypassSign = sellAllConfig.getString("Options.SellAll_By_Sign_Bypass_Permission");
+ permissionUseSign = sellAllConfig.getString("Options.SellAll_Sign_Use_Permission");
+ permissionGUI = sellAllConfig.getString("Options.GUI_Permission");
+ permissionPlayerGUI = sellAllConfig.getString("Options.Player_GUI_Permission");
+ permissionPrefixBlocks = sellAllConfig.getString("Options.Sell_Per_Block_Permission");
+ permissionAutoSellPerUserToggleable = sellAllConfig.getString("Options.Full_Inv_AutoSell_PerUserToggleable_Permission");
+ permissionItemTrigger = sellAllConfig.getString("Options.ShiftAndRightClickSellAll.Permission");
+ sellAllCurrency = sellAllConfig.getString("Options.SellAll_Currency");
+ sellAllSoundSuccess = XSound.matchXSound("Options.Sell_Sound_Success_Name").orElse(XSound.ENTITY_PLAYER_LEVELUP).parseSound();
+ sellAllSoundFail = XSound.matchXSound("Options.Sell_Sound_Fail_Name").orElse(XSound.BLOCK_ANVIL_PLACE).parseSound();
+ sellAllSignTag = Text.translateAmpColorCodes(sellAllConfig.getString("Options.SellAll_Sign_Visible_Tag") );
+// sellAllBlocks = initSellAllBlocks();
+ sellAllItems = initSellAllItems();
+
+ sellAllPrestigeMultipliers = initPrestigeMultipliers();
+ sellAllItemTriggers = initSellAllItemTrigger();
+// sellAllDisabledWorlds = initSellAllDisabledWorlds();
+ defaultMultiplier = Double.parseDouble(sellAllConfig.getString("Options.Multiplier_Default"));
+ defaultSellAllDelay = Integer.parseInt(sellAllConfig.getString("Options.Sell_Delay_Seconds"));
+ defaultAutoSellEarningNotificationDelay = Integer.parseInt(sellAllConfig.getString("Options.Full_Inv_AutoSell_EarnedMoneyNotificationDelay_Delay_Seconds"));
+ isPerBlockPermissionEnabled = getBooleanValue("Options.Sell_Per_Block_Permission_Enabled");
+ isAutoSellEnabled = getBooleanValue("Options.Full_Inv_AutoSell");
+ isAutoSellNotificationEnabled = getBooleanValue("Options.Full_Inv_AutoSell_Notification");
+ isAutoSellEarningNotificationDelayEnabled = getBooleanValue("Options.Full_Inv_AutoSell_EarnedMoneyNotificationDelay_Enabled");
+ isAutoSellPerUserToggleable = getBooleanValue("Options.Full_Inv_AutoSell_perUserToggleable");
+ isAutoSellPerUserToggleablePermEnabled = getBooleanValue("Options.Full_Inv_AutoSell_perUserToggleable_Need_Perm");
+ isSellAllNotificationEnabled = getBooleanValue("Options.Sell_Notify_Enabled");
+ isSellAllNotificationByActionBar = getBooleanValue("Options.Sell_Notify_by_ActionBar");
+
+ isSellAllSoundEnabled = getBooleanValue("Options.Sell_Sound_Enabled");
+ isSellAllBackpackItemsEnabled = getBooleanValue("Options.Sell_Prison_BackPack_Items");
+ isSellAllMinesBackpacksPluginEnabled = getBooleanValue("Options.Sell_MinesBackPacks_Plugin_Backpack");
+ isSellAllDelayEnabled = getBooleanValue("Options.Sell_Delay_Enabled");
+
+ isSellAllSellPermissionEnabled = getBooleanValue("Options.Sell_Permission_Enabled");
+ isSellAllItemTriggerEnabled = getBooleanValue("Options.ShiftAndRightClickSellAll.Enabled");
+ isSellAllItemTriggerPermissionEnabled = getBooleanValue("Options.ShiftAndRightClickSellAll.PermissionEnabled");
+ isSellAllGUIEnabled = getBooleanValue("Options.GUI_Enabled");
+ isSellAllPlayerGUIEnabled = getBooleanValue("Options.Player_GUI_Enabled");
+ isSellAllGUIPermissionEnabled = getBooleanValue("Options.GUI_Permission_Enabled");
+ isSellAllPlayerGUIPermissionEnabled = getBooleanValue("Options.Player_GUI_Permission_Enabled");
+ isSellAllMultiplierEnabled = getBooleanValue("Options.Multiplier_Enabled");
+ isSellAllPermissionMultiplierOnlyHigherEnabled = getBooleanValue("Options.Multiplier_Permission_Only_Higher");
+ isSellAllSignEnabled = getBooleanValue("Options.SellAll_Sign_Enabled");
+ isSellAllSignNotifyEnabled = getBooleanValue("Options.SellAll_Sign_Notify");
+ isSellAllSignPermissionToUseEnabled = getBooleanValue("Options.SellAll_Sign_Use_Permission_Enabled");
+ isSellAllBySignOnlyEnabled = getBooleanValue("Options.SellAll_By_Sign_Only");
+ isSellAllHandEnabled = getBooleanValue("Options.SellAll_Hand_Enabled");
+
+ isSellAllIgnoreCustomNames = getBooleanValue("Options.SellAll_ignoreCustomNames", false);
+ }
+
+ private boolean getBooleanValue( String configName ) {
+ return getBooleanValue(configName, false);
+ }
+ private boolean getBooleanValue( String configName, Boolean defaultValue ) {
+ boolean results = (defaultValue == null ? false : defaultValue.booleanValue() );
+
+ if ( configName != null ) {
+ if ( sellAllConfig.isString(configName) ) {
+ String boolVal = sellAllConfig.getString(configName);
+ if ( boolVal != null ) {
+ // Boolean.parseBoolean() also supports yes and no so don't pretest for true/false.
+ try {
+ results = Boolean.parseBoolean(boolVal);
+ } catch (Exception e) {
+ // Not a boolean value, so ignore and let the "defaut" value stand
+ }
+ }
+ else {
+ // ignore since it's not a boolean value and let the "default" value stand
+ }
+ }
+ else if ( sellAllConfig.isBoolean(configName) ) {
+ results = sellAllConfig.getBoolean(configName, results);
+ }
+ else {
+ // Ignore since the config is not boolean or a String that "could" be a boolean
+ }
+ }
+
+ return results;
}
+// /**
+// * Return boolean value from String.
+// *
+// * @return boolean.
+// * */
+// private static boolean getBoolean(String string) {
+// return string != null && string.equalsIgnoreCase("true");
+// }
+
/**
* Get an ArrayList of SellAllItemTriggers as XMaterials.
* These items will trigger sellall when a player hold them and then do shift+right click in the air.
@@ -172,60 +258,68 @@ public ArrayList getItemTriggerXMaterials(){
// return materials;
// }
- /**
- * Get SellAll XMaterial or Lapis (As Lapis is weird) from an ItemStack.
- *
- * @param itemStack - ItemStack.
- *
- * @return XMaterial.
- * */
- private XMaterial getXMaterialOrLapis(ItemStack itemStack) {
- XMaterial results = null;
-
- String altName = null;
-
- if ( itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() ) {
- altName = itemStack.getItemMeta().getDisplayName();
- }
-
- if ( altName == null || isSellAllIgnoreCustomNames ) {
- XMaterial xMat = null;
-
- if (itemStack.isSimilar(lapisLazuli)) {
- xMat = XMaterial.LAPIS_LAZULI;
- }
- else {
-
- try
- {
- xMat = XMaterial.matchXMaterial(itemStack);
- }
- catch ( Exception e )
- {
- // ignore... it is not normal matertial so it cannot be sold
- }
- }
- if ( xMat != null ) {
-
- // When converted over to be based upon a String name, instead of XMaterial,
- // the altName will take priority over the XMaterial name.
- results = xMat;
- }
- }
-
- return results;
- }
+// /**
+// * Get SellAll XMaterial or Lapis (As Lapis is weird) from an ItemStack.
+// *
+// * @param itemStack - ItemStack.
+// *
+// * @return XMaterial.
+// * */
+// private XMaterial getXMaterialOrLapis(ItemStack itemStack) {
+// XMaterial results = null;
+//
+// String altName = null;
+//
+// if ( itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName() ) {
+// altName = itemStack.getItemMeta().getDisplayName();
+// }
+//
+// if ( altName == null || isSellAllIgnoreCustomNames ) {
+// XMaterial xMat = null;
+//
+// if (itemStack.isSimilar(lapisLazuli)) {
+// xMat = XMaterial.LAPIS_LAZULI;
+// }
+// else {
+//
+// try
+// {
+// xMat = XMaterial.matchXMaterial(itemStack);
+// }
+// catch ( Exception e )
+// {
+// // ignore... it is not normal matertial so it cannot be sold
+// }
+// }
+// if ( xMat != null ) {
+//
+// // When converted over to be based upon a String name, instead of XMaterial,
+// // the altName will take priority over the XMaterial name.
+// results = xMat;
+// }
+// }
+//
+// return results;
+// }
- /**
- * Return SellAll Blocks HashMap cached values.
- *
- * @return HashMap of XMaterial-Double.
- * */
- public HashMap getSellAllBlocks() {
- return sellAllBlocks;
- }
+// /**
+// * Return SellAll Blocks HashMap cached values.
+// *
+// * @return HashMap of XMaterial-Double.
+// * */
+// public HashMap getSellAllBlocks() {
+// return sellAllBlocks;
+// }
/**
+ *
+ * @return HashMap
+ */
+ public HashMap getSellAllItems() {
+ return sellAllItems;
+ }
+
+ /**
* Return SellAll Prestige Multiplier HashMap read before from config on init.
*
* HashMap details:
@@ -238,64 +332,64 @@ public HashMap getPrestigeMultipliers() {
return sellAllPrestigeMultipliers;
}
- /**
- * Get HashMap of XMaterials and amounts from an Inventory.
- *
- * @param inv - Inventory.
- *
- * @return HashMap of XMaterials and Integers.
- * */
- public HashMap getXMaterialsHashMapFromInventory(Inventory inv){
-
- HashMap xMaterialIntegerHashMap = new HashMap<>();
- for (ItemStack itemStack : inv.getContents()){
- if (itemStack != null){
- XMaterial xMaterial = getXMaterialOrLapis(itemStack);
- if ( xMaterial != null ) {
-
- if (xMaterialIntegerHashMap.containsKey(xMaterial) && xMaterialIntegerHashMap.get(xMaterial) != 0){
- xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
- }
- else {
- xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
- }
- }
- }
- }
-
- return xMaterialIntegerHashMap;
- }
-
+// /**
+// * Get HashMap of XMaterials and amounts from an Inventory.
+// *
+// * @param inv - Inventory.
+// *
+// * @return HashMap of XMaterials and Integers.
+// * */
+// private HashMap getXMaterialsHashMapFromInventory(Inventory inv){
+//
+// HashMap xMaterialIntegerHashMap = new HashMap<>();
+// for (ItemStack itemStack : inv.getContents()){
+// if (itemStack != null){
+// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
+// if ( xMaterial != null ) {
+//
+// if (xMaterialIntegerHashMap.containsKey(xMaterial) && xMaterialIntegerHashMap.get(xMaterial) != 0){
+// xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
+// }
+// else {
+// xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
+// }
+// }
+// }
+// }
+//
+// return xMaterialIntegerHashMap;
+// }
- /**
- * get HashMap of XMaterials and Amounts from an ArrayList of ItemStacks.
- *
- * @param itemStacks - ArrayList of ItemStacks.
- *
- * @return HashMap of XMaterials and Integers.
- * */
- public HashMap getXMaterialsHashMapFromArrayList(ArrayList itemStacks){
-
- HashMap xMaterialIntegerHashMap = new HashMap<>();
- for (ItemStack itemStack : itemStacks){
- if (itemStack != null){
- try {
- XMaterial xMaterial = getXMaterialOrLapis(itemStack);
- if ( xMaterial != null ) {
-
- if (xMaterialIntegerHashMap.containsKey(xMaterial) && xMaterialIntegerHashMap.get(xMaterial) != 0) {
- xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
- }
- else {
- xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
- }
- }
- } catch (IllegalArgumentException ignored){}
- }
- }
- return xMaterialIntegerHashMap;
- }
+// /**
+// * get HashMap of XMaterials and Amounts from an ArrayList of ItemStacks.
+// *
+// * @param itemStacks - ArrayList of ItemStacks.
+// *
+// * @return HashMap of XMaterials and Integers.
+// * */
+// private HashMap getXMaterialsHashMapFromArrayList(ArrayList itemStacks){
+//
+// HashMap xMaterialIntegerHashMap = new HashMap<>();
+// for (ItemStack itemStack : itemStacks){
+// if (itemStack != null){
+// try {
+// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
+// if ( xMaterial != null ) {
+//
+// if (xMaterialIntegerHashMap.containsKey(xMaterial) && xMaterialIntegerHashMap.get(xMaterial) != 0) {
+// xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
+// }
+// else {
+// xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
+// }
+// }
+// } catch (IllegalArgumentException ignored){}
+// }
+// }
+//
+// return xMaterialIntegerHashMap;
+// }
/**
* Get SellAll Player Multiplier.
@@ -389,259 +483,508 @@ public double getPlayerMultiplier(Player p){
return multiplier;
}
- /**
- * Get SellAll Money to give, it requires Player because of SellAll perBlockPermission as an option.
- * NOTE: This WON'T remove blocks from the HashMap when sold, and won't edit Inventories of Players,
- * but only return the amount of money that the Player would get if he sells now everything from the
- * specified HashMap of XMaterials and Integers.
- *
- * Will also calculate the Multiplier of the Player.
- *
- * Get SellAll Sell value of HashMap values.
- * NOTE: If there aren't blocks in the SellAll shop this will return 0.
- * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
- *
- * @param p - Player.
- * @param xMaterialIntegerHashMap - HashMap of XMaterial-Integer (Blocks of origin).
- *
- * @return double.
- * */
- public double getSellMoney(Player p, HashMap xMaterialIntegerHashMap){
- StringBuilder sb = new StringBuilder();
- boolean debug = Output.get().isDebug();
+// /**
+// * Get SellAll Money to give, it requires Player because of SellAll perBlockPermission as an option.
+// * NOTE: This WON'T remove blocks from the HashMap when sold, and won't edit Inventories of Players,
+// * but only return the amount of money that the Player would get if he sells now everything from the
+// * specified HashMap of XMaterials and Integers.
+// *
+// * Will also calculate the Multiplier of the Player.
+// *
+// * Get SellAll Sell value of HashMap values.
+// * NOTE: If there aren't blocks in the SellAll shop this will return 0.
+// * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
+// *
+// * @param p - Player.
+// * @param xMaterialIntegerHashMap - HashMap of XMaterial-Integer (Blocks of origin).
+// *
+// * @return double.
+// * */
+// private double getSellMoney(Player p, HashMap xMaterialIntegerHashMap){
+// StringBuilder sb = new StringBuilder();
+// boolean debug = Output.get().isDebug();
+//
+// if (sellAllItems.isEmpty()){
+// return 0;
+// }
+//
+// double multiplier = getPlayerMultiplier(p);
+//
+//
+// double earned = 0;
+// for (HashMap.Entry xMatEntry : xMaterialIntegerHashMap.entrySet()){
+//
+// PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( xMatEntry.getKey().name() );
+//
+// String key = pBlockKey.getBlockName();
+//
+// if (sellAllItems.containsKey( key )){
+// // This is stupid but right now I'm too confused, sorry.
+// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + key )){
+// // Nothing will change.
+// }
+// else {
+// PrisonBlock pBlock = sellAllItems.get(key);
+//
+//// XMaterial xMat = xMatEntry.getKey();
+// int qty = xMatEntry.getValue();
+// double value = pBlock.getSalePrice();
+//
+// if ( debug ) {
+//
+// if ( sb.length() > 0 ) {
+// sb.append(", ");
+// }
+// sb.append( key.toLowerCase() ).append(":")
+// .append( qty ).append("@").append(value);
+// }
+//
+// earned += qty * value;
+// }
+// }
+// }
+//
+// double total = earned * multiplier;
+//
+// if ( debug ) {
+// DecimalFormat dFmt = Prison.get().getDecimalFormat( "#,##0.00" );
+// sb.append( " earned: " ).append( dFmt.format(earned) )
+// .append( " mult: " ).append( dFmt.format(multiplier) )
+// .append( " total: " ).append( dFmt.format(total) );
+// String message = String.format(
+// "Sellall.getSellMoney: %s %s",
+// p.getName(), sb.toString() );
+// Output.get().logInfo(message);
+// }
+//
+// return total;
+// }
- if (sellAllBlocks.isEmpty()){
- return 0;
- }
+// /**
+// * Get SellAll Money to give, it requires Player because of SellAll perBlockPermission as an option.
+// * NOTE: This WON'T remove blocks from the ArrayList when sold, and won't edit Inventories of Players,
+// * but only return the amount of money that the Player would get if he sells now everything from the
+// * specified ArrayList of ItemStacks.
+// *
+// * Will also calculate the Multiplier of the Player.
+// *
+// * Get SellAll Sell value of ArrayList of itemstack.
+// * NOTE: If there aren't blocks in the SellAll shop this will return 0.
+// * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
+// *
+// * @param p - Player.
+// * @param itemStacks - ArrayList of ItemStacks (Blocks of origin).
+// *
+// * @return double.
+// * */
+// private double getSellMoney(Player p, ArrayList itemStacks){
+// HashMap xMaterialIntegerHashMap = getXMaterialsHashMapFromArrayList(itemStacks);
+// return getSellMoney(p, xMaterialIntegerHashMap);
+// }
+
+
+ public double getPlayerInventoryValue( SpigotPlayer sPlayer ) {
+ double value = 0;
+
+ double multiplier = getPlayerMultiplier(sPlayer.getWrapper());
- double multiplier = getPlayerMultiplier(p);
-
-
- double earned = 0;
- for (HashMap.Entry xMatEntry : xMaterialIntegerHashMap.entrySet()){
- if (sellAllBlocks.containsKey(xMatEntry.getKey())){
- // This is stupid but right now I'm too confused, sorry.
- if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + xMatEntry.getKey().name())){
- // Nothing will change.
- }
- else {
- XMaterial xMat = xMatEntry.getKey();
- int qty = xMatEntry.getValue();
- double value = sellAllBlocks.get(xMat);
-
- if ( debug ) {
-
- if ( sb.length() > 0 ) {
- sb.append(", ");
- }
- sb.append( xMat.name().toLowerCase() ).append(":")
- .append( qty ).append("@").append(value);
- }
-
- earned += qty * value;
- }
- }
- }
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
- double total = earned * multiplier;
-
- if ( debug ) {
- DecimalFormat dFmt = Prison.get().getDecimalFormat( "#,##0.00" );
- sb.append( " earned: " ).append( dFmt.format(earned) )
- .append( " mult: " ).append( dFmt.format(multiplier) )
- .append( " total: " ).append( dFmt.format(total) );
- String message = String.format(
- "Sellall.getSellMoney: %s %s",
- p.getName(), sb.toString() );
- Output.get().logInfo(message);
- }
-
- return total;
+ List soldItems = valueOfInventoryItems( spInventory, multiplier );
+ for (SellAllData soldItem : soldItems) {
+ value += soldItem.getTransactionAmount();
+ }
+
+ return value;
}
-
- /**
- * Get SellAll Money to give, it requires Player because of SellAll perBlockPermission as an option.
- * NOTE: This WON'T remove blocks from the ArrayList when sold, and won't edit Inventories of Players,
- * but only return the amount of money that the Player would get if he sells now everything from the
- * specified ArrayList of ItemStacks.
- *
- * Will also calculate the Multiplier of the Player.
- *
- * Get SellAll Sell value of ArrayList of itemstack.
- * NOTE: If there aren't blocks in the SellAll shop this will return 0.
- * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
- *
- * @param p - Player.
- * @param itemStacks - ArrayList of ItemStacks (Blocks of origin).
- *
- * @return double.
- * */
- public double getSellMoney(Player p, ArrayList itemStacks){
- HashMap xMaterialIntegerHashMap = getXMaterialsHashMapFromArrayList(itemStacks);
- return getSellMoney(p, xMaterialIntegerHashMap);
+
+ public String getPlayerInventoryValueReport( SpigotPlayer sPlayer ) {
+
+ double multiplier = getPlayerMultiplier(sPlayer.getWrapper());
+
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
+
+ List soldItems = valueOfInventoryItems( spInventory, multiplier );
+
+ String report = SellAllData.itemsSoldReport(soldItems, sPlayer, multiplier);
+
+ return report;
}
-
- /**
- * Get SellAll Sell Money, calculated from all the enabled backpacks (from sellAll config and integrations) and
- * main inventory.
- * NOTE: This WON'T remove blocks from Inventories/Backpacks, but only return their value.
- *
- * Will also calculate the Multiplier of the Player.
- *
- * NOTE: If there aren't blocks in the SellAll shop this will return 0.
- * NOTE: This method WON'T remove blocks from HashMap, but only return a double value.
- *
- * @param p - Player.
- *
- * @return double.
- * */
- public double getSellMoney(Player p){
-
- if (sellAllBlocks.isEmpty()){
- return 0;
- }
-
- return getSellMoney(p, getHashMapOfPlayerInventories(p));
+
+ public List getPlayerInventoryValueTransactions( SpigotPlayer sPlayer ) {
+
+ double multiplier = getPlayerMultiplier(sPlayer.getWrapper());
+
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
+
+ List