diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md
index da604139e..a37f25201 100644
--- a/docs/changelog_v3.3.x.md
+++ b/docs/changelog_v3.3.x.md
@@ -14,7 +14,13 @@
These change logs represent the work that has been going on within prison.
-# 3.3.0-alpha.19j 2026-03-07
+# 3.3.0-alpha.19j 2026-03-15
+
+
+* **Prison Cleanup: prison-spigot: Removed obsolete and unneeded comments and fix indentation where needed.** Second part.
+
+
+* **Prison Cleanup: prison-spigot: Removed obsolete and unneeded comments and fix indentation where needed.** First part.
* **Bug fix in the ChatTest Junit test. When I was cleaning up that source I accidentally introduced a stray '.'.**
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 d417b81da..faca09541 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
@@ -67,10 +67,10 @@ public UUID getUniqueId() {
}
public UUID getUUID() {
- UUID uuid = null;
- if ( isPlayer() ) {
- uuid = ((org.bukkit.entity.Player) bukkitSender).getUniqueId();
- }
+ UUID uuid = null;
+ if ( isPlayer() ) {
+ uuid = ((org.bukkit.entity.Player) bukkitSender).getUniqueId();
+ }
return uuid;
}
@@ -89,10 +89,10 @@ public String getName() {
@Override
public void dispatchCommand(String command) {
- command = CommandHandler.remapRootCmdIdentifiers( command );
-
- String registeredCmd = Prison.get().getCommandHandler()
- .findRegisteredCommand( command );
+ command = CommandHandler.remapRootCmdIdentifiers( command );
+
+ String registeredCmd = Prison.get().getCommandHandler()
+ .findRegisteredCommand( command );
Bukkit.getServer().dispatchCommand(bukkitSender, registeredCmd);
}
@@ -104,11 +104,11 @@ public boolean doesSupportColors() {
@Override
public void sendMessage(String message) {
-
- String[] msgs = Text.translateAmpColorCodes(message).split( "\\{br\\}" );
-
- for ( String msg : msgs ) {
- bukkitSender.sendMessage(msg);
+
+ String[] msgs = Text.translateAmpColorCodes(message).split( "\\{br\\}" );
+
+ for ( String msg : msgs ) {
+ bukkitSender.sendMessage(msg);
}
}
@@ -116,24 +116,24 @@ public void sendMessage(String message) {
public void sendMessage(String[] messages) {
for (String message : messages) {
- String[] msgs = Text.translateAmpColorCodes(message).split( "\\{br\\}" );
- for ( String msg : msgs ) {
-
- sendMessage(msg);
- }
+ String[] msgs = Text.translateAmpColorCodes(message).split( "\\{br\\}" );
+ for ( String msg : msgs ) {
+
+ sendMessage(msg);
+ }
}
}
@Override
public void sendMessage(List messages) {
- for (String message : messages) {
-
- String[] msgs = Text.translateAmpColorCodes(message).split( "\\{br\\}" );
- for ( String msg : msgs ) {
-
- sendMessage(msg);
- }
- }
+ for (String message : messages) {
+
+ String[] msgs = Text.translateAmpColorCodes(message).split( "\\{br\\}" );
+ for ( String msg : msgs ) {
+
+ sendMessage(msg);
+ }
+ }
}
@Override
@@ -146,7 +146,7 @@ public void sendRaw(String json) {
@Override
public boolean isOp() {
- return bukkitSender.isOp();
+ return bukkitSender.isOp();
}
@Override
@@ -163,10 +163,10 @@ public boolean hasPermission(String perm) {
@Override
public List getPermissions() {
- List results = new ArrayList<>();
-
- Set perms = bukkitSender.getEffectivePermissions();
- for ( PermissionAttachmentInfo perm : perms )
+ List results = new ArrayList<>();
+
+ Set perms = bukkitSender.getEffectivePermissions();
+ for ( PermissionAttachmentInfo perm : perms )
{
results.add( perm.getPermission() );
}
@@ -178,128 +178,108 @@ public List getPermissions() {
@Override
public List getPermissions( String prefix ) {
- return getPermissions( prefix, getPermissions() );
+ return getPermissions( prefix, getPermissions() );
}
@Override
public List getPermissions( String prefix, List perms ) {
- List results = new ArrayList<>();
-
- for ( String perm : perms ) {
- if ( perm.startsWith( prefix ) ) {
- results.add( perm );
- }
- }
-
- return results;
+ List results = new ArrayList<>();
+
+ for ( String perm : perms ) {
+ if ( perm.startsWith( prefix ) ) {
+ results.add( perm );
+ }
+ }
+
+ return results;
}
-// @Override
-// public List getPermissions( String prefix ) {
-// List results = new ArrayList<>();
-//
-// for ( String perm : getPermissions() ) {
-// if ( perm.startsWith( prefix ) ) {
-// results.add( perm );
-// }
-// }
-//
-// return results;
-// }
@Override
public double getSellAllMultiplier() {
- double results = 1.0;
-
- if ( isPlayer() ) {
-
- SellAllUtil sellall = SpigotPrison.getInstance().getSellAllUtil();
-
- if ( sellall != null && getWrapper() != null ) {
- results = sellall.getPlayerMultiplier((org.bukkit.entity.Player) getWrapper());
- }
- }
-
- return results;
-
-// Optional oPlayer = Prison.get().getPlatform().getPlayer( getName() );
-//
-// if ( oPlayer.isPresent() ) {
-// results = oPlayer.get().getSellAllMultiplier();
-// }
-//
-// return results;
+ double results = 1.0;
+
+ if ( isPlayer() ) {
+
+ SellAllUtil sellall = SpigotPrison.getInstance().getSellAllUtil();
+
+ if ( sellall != null && getWrapper() != null ) {
+ results = sellall.getPlayerMultiplier((org.bukkit.entity.Player) getWrapper());
+ }
+ }
+
+ return results;
}
@Override
public double getSellAllMultiplierDebug() {
- double results = 1.0;
-
- if ( isPlayer() ) {
-
- SellAllUtil sellall = SpigotPrison.getInstance().getSellAllUtil();
-
- if ( sellall != null && getWrapper() != null ) {
-
- Player player = getPlatformPlayer();
-
- results = sellall.getPlayerMultiplierDebug( player );
- }
- }
-
- return results;
+ double results = 1.0;
+
+ if ( isPlayer() ) {
+
+ SellAllUtil sellall = SpigotPrison.getInstance().getSellAllUtil();
+
+ if ( sellall != null && getWrapper() != null ) {
+
+ Player player = getPlatformPlayer();
+
+ results = sellall.getPlayerMultiplierDebug( player );
+ }
+ }
+
+ return results;
}
@Override
public List getSellAllMultiplierListings() {
- List results = new ArrayList<>();
-
- if ( isPlayer() ) {
-
- SellAllUtil sellall = SpigotPrison.getInstance().getSellAllUtil();
-
- if ( sellall != null && getWrapper() != null ) {
- results.addAll( sellall.getPlayerMultiplierList((org.bukkit.entity.Player) getWrapper()) );
- }
- }
-
-
- return results;
+ List results = new ArrayList<>();
+
+ if ( isPlayer() ) {
+
+ SellAllUtil sellall = SpigotPrison.getInstance().getSellAllUtil();
+
+ if ( sellall != null && getWrapper() != null ) {
+ results.addAll( sellall.getPlayerMultiplierList((org.bukkit.entity.Player) getWrapper()) );
+ }
+ }
+
+
+ return results;
}
public List getPermissionsIntegrations( boolean detailed ) {
- List results = new ArrayList<>();
-
- Optional oPlayer = Prison.get().getPlatform().getPlayer( getName() );
-
- if ( oPlayer.isPresent() ) {
-
- PermissionIntegration perms = PrisonAPI.getIntegrationManager() .getPermission();
- if ( perms != null ) {
- results = perms.getPermissions( oPlayer.get(), detailed );
- }
- }
-
- return results;
+ List results = new ArrayList<>();
+
+ Optional oPlayer = Prison.get().getPlatform().getPlayer( getName() );
+
+ if ( oPlayer.isPresent() ) {
+
+ PermissionIntegration perms = PrisonAPI.getIntegrationManager() .getPermission();
+ if ( perms != null ) {
+ results = perms.getPermissions( oPlayer.get(), detailed );
+ }
+ }
+
+ return results;
}
@Override
public boolean isPlayer() {
- return bukkitSender != null && bukkitSender instanceof org.bukkit.entity.Player;
+ return bukkitSender != null && bukkitSender instanceof org.bukkit.entity.Player;
}
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "SpigotCommandSender: " ).append( getName() )
- .append( " isOp=" ).append( isOp() )
- .append( " isPlayer=" ).append( isPlayer() );
-
- return sb.toString();
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "SpigotCommandSender: " ).append( getName() )
+ .append( " isOp=" ).append( isOp() )
+ .append( " isPlayer=" ).append( isPlayer() );
+
+ return sb.toString();
}
public org.bukkit.command.CommandSender getWrapper() {
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotLocation.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotLocation.java
index 91b95dbd8..dce7ea10e 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotLocation.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotLocation.java
@@ -29,7 +29,6 @@ public org.bukkit.Location getBukkitLocation() {
if ( bukkitLocation == null ) {
bukkitLocation = getBukkitLocation( this );
-// bukkitLocation = createBukkitLocation();
}
return bukkitLocation;
@@ -46,27 +45,9 @@ public static org.bukkit.Location getBukkitLocation( Location location ) {
bLocation.setPitch( location.getPitch() );
-// bLocation.;
-
return bLocation;
}
-// private org.bukkit.Location createBukkitLocation() {
-//
-// org.bukkit.World world = Bukkit.getWorld( getWorld().getName() );
-//
-// org.bukkit.Location bLocation = new org.bukkit.Location(world, getBlockX(), getBlockY(), getBlockZ() );
-//
-// bLocation.setYaw(getYaw());
-//
-// bLocation.setPitch(getPitch());
-//
-// return bLocation;
-// }
-
-// public void setBukkitLocation(org.bukkit.Location bukkitLocation) {
-// this.bukkitLocation = bukkitLocation;
-// }
public org.bukkit.World getBukkitWorld() {
return getBukkitLocation().getWorld();
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotOfflinePlayer.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotOfflinePlayer.java
index dd4b2007b..b5fbb9121 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotOfflinePlayer.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotOfflinePlayer.java
@@ -116,23 +116,17 @@ public void setFileCache(File fileCache) {
public String filenamePlayer()
{
return getFilePlayer().getName();
-// return JsonFileIO.filenamePlayer( this );
}
public String filenameCache()
{
return getFileCache().getName();
-// return JsonFileIO.filenameCache( this );
}
-// public String getPlayerFileName() {
-//
-// return JsonFileIO.filenamePlayer( this );
-// }
@Override
public String toString() {
- return getName();
+ return getName();
}
@@ -154,7 +148,6 @@ public String getDisplayName() {
@Override
public boolean isOnline() {
return offlinePlayer.isOnline();
-// return false;
}
@@ -171,17 +164,10 @@ public long getLastSeenDate() {
*/
@Override
public boolean isPlayer() {
- return ( offlinePlayer != null && offlinePlayer.getPlayer() != null &&
- offlinePlayer.getPlayer() instanceof Player );
-// return false;
+ return ( offlinePlayer != null && offlinePlayer.getPlayer() != null &&
+ offlinePlayer.getPlayer() instanceof Player );
}
-// @Override
-// public boolean hasPermission( String perm ) {
-// Output.get().logError( "SpigotOfflinePlayer.hasPermission: Cannot access permissions for offline players." );
-// return false;
-// }
-
@Override
public void setDisplayName( String newDisplayName ) {
Output.get().logError( "SpigotOfflinePlayer.setDisplayName: Cannot set display names." );
@@ -254,7 +240,7 @@ public tech.mcprison.prison.internal.block.Block getLineOfSightBlock() {
public List getLineOfSightBlocks() {
List results = new ArrayList<>();
- return results;
+ return results;
}
@@ -272,10 +258,6 @@ public Inventory getInventory() {
return null;
}
-// @Override
-// public void printDebugInventoryInformationToConsole() {
-//
-// }
public OfflinePlayer getWrapper() {
return offlinePlayer;
@@ -294,43 +276,43 @@ public void recalculatePermissions() {
@Override
public List getPermissions() {
- List results = new ArrayList<>();
-
- if ( offlinePlayer.getPlayer() != null ) {
-
- Set perms = offlinePlayer.getPlayer().getEffectivePermissions();
- for ( PermissionAttachmentInfo perm : perms )
- {
- results.add( perm.getPermission() );
- }
- }
- else {
- // try to use vault:
-
- // TODO add permission integrations here!!
- }
-
-
- return results;
+ List results = new ArrayList<>();
+
+ if ( offlinePlayer.getPlayer() != null ) {
+
+ Set perms = offlinePlayer.getPlayer().getEffectivePermissions();
+ for ( PermissionAttachmentInfo perm : perms )
+ {
+ results.add( perm.getPermission() );
+ }
+ }
+ else {
+ // try to use vault:
+
+ // TODO add permission integrations here!!
+ }
+
+
+ return results;
}
@Override
public List getPermissions( String prefix ) {
- return getPermissions( prefix, getPermissions() );
+ return getPermissions( prefix, getPermissions() );
}
@Override
public List getPermissions( String prefix, List perms ) {
- List results = new ArrayList<>();
-
- for ( String perm : perms ) {
- if ( perm.startsWith( prefix ) ) {
- results.add( perm );
- }
- }
-
- return results;
+ List results = new ArrayList<>();
+
+ for ( String perm : perms ) {
+ if ( perm.startsWith( prefix ) ) {
+ results.add( perm );
+ }
+ }
+
+ return results;
}
@Override
@@ -347,30 +329,8 @@ public boolean hasPermission( String perm ) {
}
return hasPerm;
-
-// List perms = getPermissions( perm );
-// return perms.contains( perm );
}
-// @Override
-// public List getPermissions() {
-// List results = new ArrayList<>();
-//
-// return results;
-// }
-//
-// @Override
-// public List getPermissions( String prefix ) {
-// List results = new ArrayList<>();
-//
-// for ( String perm : getPermissions() ) {
-// if ( perm.startsWith( prefix ) ) {
-// results.add( perm );
-// }
-// }
-//
-// return results;
-// }
@Override
public List getPermissionsIntegrations( boolean detailed ) {
@@ -391,63 +351,48 @@ public List getPermissionsIntegrations( boolean detailed ) {
*/
@Override
public double getSellAllMultiplier() {
- double results = 1.0;
+ double results = 1.0;
SellAllUtil sellall = SpigotPrison.getInstance().getSellAllUtil();
if ( sellall != null && getWrapper() != null ) {
-// SpigotPlayer sPlayer = new SpigotPlayer( getWrapper() );
-
results = sellall.getPlayerMultiplier( this );
}
-// SpigotPlayer sPlayer = null;
-//
-// if ( getWrapper() != null ) {
-// sPlayer = new SpigotPlayer( getWrapper() );
-//
-// results = sPlayer.getSellAllMultiplier();
-// }
-
- return results;
+ return results;
}
@Override
public double getSellAllMultiplierDebug() {
- double results = 1.0;
+ double results = 1.0;
// NOTE: isPlayer() is a check to see if it's tied to the bukkit Player object, of
// which offline player is not. But the sellall multiplier can still be called.
-// if ( isPlayer() ) {
SellAllUtil sellall = SpigotPrison.getInstance().getSellAllUtil();
if ( sellall != null && getWrapper() != null ) {
-// SpigotPlayer sPlayer = new SpigotPlayer( getWrapper() );
-
results = sellall.getPlayerMultiplierDebug( this );
}
-// }
return results;
}
public List getSellAllMultiplierListings() {
- List results = new ArrayList<>();
-
- if ( isPlayer() ) {
-
- SellAllUtil sellall = SpigotPrison.getInstance().getSellAllUtil();
-
- if ( sellall != null && getWrapper() != null ) {
- results.addAll( sellall.getPlayerMultiplierList((org.bukkit.entity.Player) getWrapper()) );
- }
- }
-
-
- return results;
+ List results = new ArrayList<>();
+
+ if ( isPlayer() ) {
+
+ SellAllUtil sellall = SpigotPrison.getInstance().getSellAllUtil();
+
+ if ( sellall != null && getWrapper() != null ) {
+ results.addAll( sellall.getPlayerMultiplierList((org.bukkit.entity.Player) getWrapper()) );
+ }
+ }
+
+ return results;
}
@Override
@@ -517,16 +462,6 @@ public tech.mcprison.prison.internal.Player getPlatformPlayer() {
SpigotPlayer sPlayer = SpigotPlayer.getSpigotPlayer( getRankPlayer() );
return sPlayer;
-
-// tech.mcprison.prison.internal.Player player = null;
-//
-// Optional oPlayer = Prison.get().getPlatform().getPlayer( getName() );
-//
-// if ( oPlayer.isPresent() ) {
-// player = oPlayer.get();
-// }
-//
-// return player;
}
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 c7c99176a..b2e5ecab5 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
@@ -26,11 +26,9 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
-import org.bukkit.OfflinePlayer;
import org.bukkit.Statistic;
import org.bukkit.block.Block;
import org.bukkit.entity.ExperienceOrb;
-import org.bukkit.inventory.meta.ItemMeta;
import com.cryptomorin.xseries.XMaterial;
@@ -38,7 +36,6 @@
import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.autofeatures.PlayerMessaging.MessageType;
-import tech.mcprison.prison.bombs.MineBombData;
import tech.mcprison.prison.cache.PlayerCache;
import tech.mcprison.prison.cache.PlayerCachePlayerData;
import tech.mcprison.prison.file.JsonFileIO;
@@ -63,7 +60,6 @@
import tech.mcprison.prison.spigot.utils.tasks.PlayerMessagingTask;
import tech.mcprison.prison.util.Gamemode;
import tech.mcprison.prison.util.Location;
-import tech.mcprison.prison.util.Text;
import tech.mcprison.prison.util.Vector;
/**
@@ -120,25 +116,25 @@ public SpigotPlayer(org.bukkit.entity.Player bukkitPlayer) {
*/
public static SpigotPlayer getSpigotPlayer( RankPlayer rankPlayer ) {
- SpigotPlayer result = null;
-
- // We have a RankPlayer object, but we need to connect this SpigotPlayer object
- // to the bukkit player object.
-
- // NOTE: We're directly accessing bukkit here because it's more direct instead of
- // trying to do that through a few different function within the
- // SpigotPlatform.
-
- // First try to load a bukkit online player:
- org.bukkit.entity.Player bPlayer = Bukkit.getPlayer( rankPlayer.getUUID() );
-
- if ( bPlayer != null ) {
- result = new SpigotPlayer( bPlayer );
-
- result.setRankPlayer( rankPlayer );
- }
-
- return result;
+ SpigotPlayer result = null;
+
+ // We have a RankPlayer object, but we need to connect this SpigotPlayer object
+ // to the bukkit player object.
+
+ // NOTE: We're directly accessing bukkit here because it's more direct instead of
+ // trying to do that through a few different function within the
+ // SpigotPlatform.
+
+ // First try to load a bukkit online player:
+ org.bukkit.entity.Player bPlayer = Bukkit.getPlayer( rankPlayer.getUUID() );
+
+ if ( bPlayer != null ) {
+ result = new SpigotPlayer( bPlayer );
+
+ result.setRankPlayer( rankPlayer );
+ }
+
+ return result;
}
@@ -159,7 +155,7 @@ public static SpigotPlayer getSpigotPlayer( RankPlayer rankPlayer ) {
*/
public String getPlayerFileName() {
- return filenamePlayer();
+ return filenamePlayer();
}
@@ -199,20 +195,6 @@ public String filenameCache()
{
return getFileCache().getName();
}
-// public String getPlayerFileName() {
-//
-// return JsonFileIO.filenamePlayer( this );
-// }
-
-// @Override
-// public UUID getUUID() {
-// return bukkitPlayer.getUniqueId();
-// }
-
-// @Override
-// public String getName() {
-// return bukkitPlayer.getName();
-// }
@Override
public String getDisplayName() {
@@ -239,17 +221,6 @@ public void give(ItemStack itemStack) {
bukkitPlayer.getInventory().addItem(SpigotUtil.prisonItemStackToBukkit(itemStack));
}
-// @Override
-// public Location getLocation() {
-// return SpigotUtil.bukkitLocationToPrison(bukkitPlayer.getLocation());
-// }
-
-// @Override public boolean teleport(Location location) {
-//
-//
-// return bukkitPlayer.teleport(SpigotUtil.prisonLocationToBukkit(location),
-// PlayerTeleportEvent.TeleportCause.PLUGIN);
-// }
@Override
public boolean isOnline() {
@@ -273,66 +244,29 @@ public void setGamemode(Gamemode gamemode) {
@Override
public Optional getLocale() {
- Optional results = Optional.empty();
+ Optional results = Optional.empty();
-// if ( SpigotNMSPlayer.getInstance().hasSupport() ) {
-// try {
-// results = Optional.ofNullable(
-// SpigotNMSPlayer.getInstance().getLocale( getWrapper() )
-// );
-// }
-// catch ( Exception ex ) {
-// Output.get().logInfo(
-// "Failed to initialize NMS components -- " +
-// "NMS is not functional - " + ex.getMessage() );
-// }
-// }
return results;
}
@Override
public SpigotBlock getLineOfSightBlock() {
- SpigotBlock results = null;
-
-// org.bukkit.Location eyeLocation = getWrapper().getEyeLocation();
-// org.bukkit.util.Vector lineOfSight = eyeLocation.getDirection().normalize();
-//
-// double maxDistance = 256;
-//
-// for(double i = 0; i < maxDistance; ++i){
-// Block block = eyeLocation.add( lineOfSight.clone().multiply(i) ).getBlock();
-// if( block.getType() != Material.AIR ) {
-//// if( block.getType().isSolid() ) {
-//
-// results = new SpigotBlock( block );
-// break;
-// }
-//
-// }
-//
-// return results;
-//
-
-
-
-// List results = new ArrayList<>();
-
-
-
- List blocks = bukkitPlayer.getLineOfSight( null, 256 );
- for ( Block block : blocks ) {
- if ( block != null && block.getType() != Material.AIR &&
- !SpigotCompatibility.getInstance().isPassable(block) ) {
-
-
- // return the first non-null and non-AIR block, which will
- // be the one the player is looking at:
- results = SpigotBlock.getSpigotBlock( block );
- }
- }
-
- return results;
+ SpigotBlock results = null;
+
+ List blocks = bukkitPlayer.getLineOfSight( null, 256 );
+ for ( Block block : blocks ) {
+ if ( block != null && block.getType() != Material.AIR &&
+ !SpigotCompatibility.getInstance().isPassable(block) ) {
+
+
+ // return the first non-null and non-AIR block, which will
+ // be the one the player is looking at:
+ results = SpigotBlock.getSpigotBlock( block );
+ }
+ }
+
+ return results;
}
@@ -356,27 +290,27 @@ public SpigotBlock getLineOfSightBlock() {
* @return
*/
public Location getLineOfSightExactLocation() {
-
- SpigotLocation eyeLoc = new SpigotLocation( getWrapper().getEyeLocation() );
- Vector eyeVec = eyeLoc.getDirection();
-
- Location loc = eyeLoc.add(eyeVec);
-
- int i = 0;
-
- // Is isPassible also true when isEmpty? If so, then this could be simplified...
- // while ( i++ <= 75 && (loc.getBlockAt().isEmpty() || loc.getBlockAt().isPassible()) ) {
-
- while ( i++ <= 75 && loc.getBlockAt().isEmpty() ) {
-
- loc = loc.add(eyeVec);
- }
-
- if ( loc.getBlockAt().isEmpty() ) {
- loc = null;
- }
-
- return loc;
+
+ SpigotLocation eyeLoc = new SpigotLocation( getWrapper().getEyeLocation() );
+ Vector eyeVec = eyeLoc.getDirection();
+
+ Location loc = eyeLoc.add(eyeVec);
+
+ int i = 0;
+
+ // Is isPassible also true when isEmpty? If so, then this could be simplified...
+ // while ( i++ <= 75 && (loc.getBlockAt().isEmpty() || loc.getBlockAt().isPassible()) ) {
+
+ while ( i++ <= 75 && loc.getBlockAt().isEmpty() ) {
+
+ loc = loc.add(eyeVec);
+ }
+
+ if ( loc.getBlockAt().isEmpty() ) {
+ loc = null;
+ }
+
+ return loc;
}
/**
@@ -389,21 +323,21 @@ public Location getLineOfSightExactLocation() {
@Override
public List getLineOfSightBlocks() {
- List results = new ArrayList<>();
-
- List blocks = bukkitPlayer.getLineOfSight( null, 256 );
- for ( Block block : blocks ) {
- if ( block != null &&
- (results.size() == 0 && block.getType() != Material.AIR ||
- results.size() > 0 && results.size() < 20 )) {
-
- // return the first non-null and non-AIR block, which will
- // be the one the player is looking at:
- results.add( SpigotBlock.getSpigotBlock( block ) );
- }
+ List results = new ArrayList<>();
+
+ List blocks = bukkitPlayer.getLineOfSight( null, 256 );
+ for ( Block block : blocks ) {
+ if ( block != null &&
+ (results.size() == 0 && block.getType() != Material.AIR ||
+ results.size() > 0 && results.size() < 20 )) {
+
+ // return the first non-null and non-AIR block, which will
+ // be the one the player is looking at:
+ results.add( SpigotBlock.getSpigotBlock( block ) );
+ }
}
- return results;
+ return results;
}
@@ -417,7 +351,7 @@ public Inventory getInventory() {
}
public SpigotPlayerInventory getSpigotPlayerInventory() {
- return new SpigotPlayerInventory(getWrapper().getInventory());
+ return new SpigotPlayerInventory(getWrapper().getInventory());
}
@Override
@@ -438,284 +372,33 @@ public boolean isPlayer() {
@Override
public long getLastSeenDate() {
- return bukkitPlayer.getLastPlayed();
+ return bukkitPlayer.getLastPlayed();
}
-// @Override
-// public boolean isOp() {
-// return bukkitPlayer.isOp();
-// }
-
-// @Override
-// public boolean hasPermission( String perm ) {
-// List perms = getPermissions( perm );
-// return perms.contains( perm );
-// }
-
-
-// @Override
-// public List getPermissions() {
-// List results = new ArrayList<>();
-//
-// Set perms = bukkitPlayer.getEffectivePermissions();
-// for ( PermissionAttachmentInfo perm : perms )
-// {
-// results.add( perm.getPermission() );
-// }
-//
-// return results;
-// }
-
-
-// @Override
-// public List getPermissions( String prefix ) {
-// List results = new ArrayList<>();
-//
-// for ( String perm : getPermissions() ) {
-// if ( perm.startsWith( prefix ) ) {
-// results.add( perm );
-// }
-// }
-//
-// return results;
-// }
-
-
-// /**
-// * This uses the sellall configs for the permission name to use to get the list of
-// * multipliers. It then adds all of the multipliers together to ...
-// *
-// *
-// *
-// */
-// @Override
-// public double getSellAllMultiplier() {
-// double results = 1.0;
-//
-// SellAllPrisonCommands sellall = SellAllPrisonCommands.get();
-//
-// if ( sellall != null ) {
-// results = sellall.getMultiplier( this );
-// }
-//
-// return results;
-// }
@Override
public int compareTo( SpigotPlayer sPlayer) {
return getUUID().compareTo( sPlayer.getUUID() );
-// return getName().compareTo( sPlayer.getName() );
}
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "SpigotPlayer: " ).append( getName() )
- .append( " isOp=" ).append( isOp() )
- .append( " isOnline=" ).append( isOnline() )
- .append( " isPlayer=" ).append( isPlayer() )
-
- .append( " hasBukkitPlayer=" ).append( bukkitPlayer != null )
- .append( " hasRankPlayer=" ).append( rankPlayer != null )
- ;
-
- return sb.toString();
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "SpigotPlayer: " ).append( getName() )
+ .append( " isOp=" ).append( isOp() )
+ .append( " isOnline=" ).append( isOnline() )
+ .append( " isPlayer=" ).append( isPlayer() )
+
+ .append( " hasBukkitPlayer=" ).append( bukkitPlayer != null )
+ .append( " hasRankPlayer=" ).append( rankPlayer != null )
+ ;
+
+ return sb.toString();
}
-// /**
-// * This class is an adaptation of the NmsHelper class in the Rosetta library by Max Roncace. The
-// * library is licensed under the New BSD License. See the {@link tech.mcprison.prison.localization}
-// * package for the full license.
-// *
-// * @author Max Roncacé
-// */
-// private static class NmsHelper {
-//
-// private static final boolean SUPPORT;
-//
-// private static final String PACKAGE_VERSION;
-//
-// private static final Method PLAYER_SPIGOT;
-// private static final Method PLAYER$SPIGOT_GETLOCALE;
-// private static final Method CRAFTPLAYER_GETHANDLE;
-//
-// private static final Field ENTITY_PLAYER_LOCALE;
-// private static final Field LOCALE_LANGUAGE_WRAPPED_STRING;
-//
-// static {
-// String[] array = Bukkit.getServer().getClass().getPackage().getName().split("\\.");
-// PACKAGE_VERSION = array.length == 4 ? array[3] + "." : "";
-//
-// Method player_spigot = null;
-// Method player$spigot_getLocale = null;
-// Method craftPlayer_getHandle = null;
-// Field entityPlayer_locale = null;
-// Field localeLanguage_wrappedString = null;
-// try {
-//
-// Class> craftPlayer = getCraftClass("entity.CraftPlayer");
-//
-// // for reasons not known to me Paper decided to make EntityPlayer#locale null by default and have the
-// // fallback defined in CraftPlayer$Spigot#getLocale. Rosetta will use that method if possible and fall
-// // back to accessing the field directly.
-// try {
-// player_spigot = org.bukkit.entity.Player.class.getMethod("spigot");
-// Class> player$spigot = Class.forName("org.bukkit.entity.Player$Spigot");
-// player$spigot_getLocale = player$spigot.getMethod("getLocale");
-// } catch (NoSuchMethodException ignored) { // we're non-Spigot or old
-// }
-//
-// if (player$spigot_getLocale == null) { // fallback for non-Spigot software
-// craftPlayer_getHandle = craftPlayer.getMethod("getHandle");
-//
-// entityPlayer_locale = getNmsClass("EntityPlayer").getDeclaredField("locale");
-// entityPlayer_locale.setAccessible(true);
-// if (entityPlayer_locale.getType().getSimpleName().equals("LocaleLanguage")) {
-// // On versions prior to 1.6, the locale is stored as a LocaleLanguage object.
-// // The actual locale string is wrapped within it.
-// // On 1.5, it's stored in field "e".
-// // On 1.3 and 1.4, it's stored in field "d".
-// try { // try for 1.5
-// localeLanguage_wrappedString =
-// entityPlayer_locale.getType().getDeclaredField("e");
-// } catch (NoSuchFieldException ex) { // we're pre-1.5
-// localeLanguage_wrappedString =
-// entityPlayer_locale.getType().getDeclaredField("d");
-// }
-// }
-// }
-// }
-// catch ( ClassNotFoundException ex ) {
-// Output.get().logInfo(
-// "Cannot initialize NMS components - ClassNotFoundException - " +
-// "NMS is not functional - " + ex.getMessage() );
-//
-// }
-// catch (NoSuchFieldException | NoSuchMethodException ex) {
-// Output.get().logInfo(
-// "Cannot initialize NMS components - per-player localization disabled. - " + ex.getMessage());
-// }
-// PLAYER_SPIGOT = player_spigot;
-// PLAYER$SPIGOT_GETLOCALE = player$spigot_getLocale;
-// CRAFTPLAYER_GETHANDLE = craftPlayer_getHandle;
-// ENTITY_PLAYER_LOCALE = entityPlayer_locale;
-// LOCALE_LANGUAGE_WRAPPED_STRING = localeLanguage_wrappedString;
-// SUPPORT = CRAFTPLAYER_GETHANDLE != null;
-// }
-//
-// private static boolean hasSupport() {
-// return SUPPORT;
-// }
-//
-// private static String getLocale(org.bukkit.entity.Player player)
-// throws IllegalAccessException, InvocationTargetException, ClassNotFoundException {
-// if (PLAYER$SPIGOT_GETLOCALE != null) {
-// return (String) PLAYER$SPIGOT_GETLOCALE.invoke(PLAYER_SPIGOT.invoke(player));
-// }
-//
-// Object entityPlayer = CRAFTPLAYER_GETHANDLE.invoke(player);
-// Object locale = ENTITY_PLAYER_LOCALE.get(entityPlayer);
-// if (LOCALE_LANGUAGE_WRAPPED_STRING != null) {
-// return (String) LOCALE_LANGUAGE_WRAPPED_STRING.get(locale);
-// } else {
-// return (String) locale;
-// }
-// }
-//
-// private static Class> getCraftClass(String className) throws ClassNotFoundException {
-// return Class.forName("org.bukkit.craftbukkit." + PACKAGE_VERSION + className);
-// }
-//
-// private static Class> getNmsClass(String className) throws ClassNotFoundException {
-// return Class.forName("net.minecraft.server." + PACKAGE_VERSION + className);
-// }
-//
-// }
-
-// @SuppressWarnings( "deprecation" )
-// public void printDebugInventoryInformationToConsole() {
-//
-// try {
-// printDebugInfo( bukkitPlayer.getInventory().getContents(), "Inventory Contents");
-// }
-// catch ( java.lang.NoSuchMethodError | Exception e ) {
-// // Ignore: Not supported with that version of spigot:
-// }
-//
-// try {
-// printDebugInfo( bukkitPlayer.getInventory().getExtraContents(), "Inventory Extra Contents");
-// }
-// catch ( java.lang.NoSuchMethodError | Exception e ) {
-// // Ignore: Not supported with that version of spigot:
-// }
-//
-// try {
-// printDebugInfo( bukkitPlayer.getInventory().getArmorContents(), "Inventory Armor Contents");
-// }
-// catch ( java.lang.NoSuchMethodError | Exception e ) {
-// // Ignore: Not supported with that version of spigot:
-// }
-// try {
-// printDebugInfo( bukkitPlayer.getInventory().getStorageContents(), "Inventory Storage Contents");
-// }
-// catch ( java.lang.NoSuchMethodError | Exception e ) {
-// // Ignore: Not supported with that version of spigot:
-// }
-//
-// try {
-// printDebugInfo( bukkitPlayer.getInventory().getItemInHand(), "Inventory Item In Hand (pre 1.13)");
-// }
-// catch ( java.lang.NoSuchMethodError | Exception e ) {
-// // Ignore: Not supported with that version of spigot:
-// }
-//
-// try {
-// printDebugInfo( bukkitPlayer.getInventory().getItemInMainHand(), "Inventory Item in Main Hand");
-// }
-// catch ( java.lang.NoSuchMethodError | Exception e ) {
-// // Ignore: Not supported with that version of spigot:
-// }
-//
-// try {
-// printDebugInfo( bukkitPlayer.getInventory().getItemInOffHand(), "Inventory Item in Off Hand");
-// }
-// catch ( java.lang.NoSuchMethodError | Exception e ) {
-// // Ignore: Not supported with that version of spigot:
-// }
-// }
-
-// private void printDebugInfo( org.bukkit.inventory.ItemStack[] iStacks, String title ) {
-//
-// Output.get().logInfo( "&7%s:", title );
-// for ( int i = 0; i < iStacks.length; i++ ) {
-// org.bukkit.inventory.ItemStack iStack = iStacks[i];
-//
-// if ( iStack != null ) {
-//
-// ItemStack pItemStack = SpigotUtil.bukkitItemStackToPrison(iStack);
-//
-// Output.get().logInfo( " i=%d &3%s &3%d &a[&3%s&a]",
-// i, iStack.getType().name(), iStack.getAmount(),
-// (pItemStack == null ? "" :
-// (pItemStack.getDisplayName() == null ? "" :
-// pItemStack.getDisplayName())) );
-// }
-// }
-// }
-
-// private void printDebugInfo( org.bukkit.inventory.ItemStack iStack, String title ) {
-//
-// Output.get().logInfo( "&7%s:", title );
-// if ( iStack != null ) {
-//
-// Output.get().logInfo( " &3%s &3%d",
-// iStack.getType().name(), iStack.getAmount() );
-// }
-// }
-
public void giveExp( int xp )
{
if ( getWrapper() != null ) {
@@ -860,8 +543,6 @@ public void setActionBar( String actionBar ) {
if ( getWrapper() != null) {
PlayerMessagingTask.submitTask( getWrapper(), MessageType.actionBar, actionBar );
-// SpigotCompatibility.getInstance()
-// .sendActionBar( getWrapper(), actionBar );
}
}
@@ -920,7 +601,6 @@ public boolean addBalance( String currency, double amount ) {
if ( currencyEcon != null ) {
results = currencyEcon.addBalance( this, amount, currency );
-// addCachedRankPlayerBalance( currency, amount );
}
}
return results;
@@ -947,20 +627,6 @@ public boolean enableFlying( Mine mine, float flightSpeed ) {
return enabled;
}
-// public Mine getEffectsMine() {
-// Mine effectsMine = null;
-//
-// if ( lastEffectsMine != null ) {
-//
-// if ( !lastEffectsMine.isInMineExact( getLocation() ) ) {
-// lastEffectsMine = null;
-//
-// // cancel all effects for player
-// }
-// effectsMine = lastEffectsMine;
-// }
-// return effectsMine;
-// }
public boolean isFlying() {
boolean flying = false;
@@ -994,13 +660,7 @@ public boolean isMinecraftStatisticsEnabled() {
@Override
public void incrementMinecraftStatsMineBlock( Player player, String blockName, int quantity) {
-// Statistic.BREAK_ITEM;
-// Statistic.DROP_COUNT;
-// Statistic.MINE_BLOCK;
-// Statistic.PICKUP;
-
XMaterial xMat = XMaterial.matchXMaterial( blockName ).orElse( null );
-// XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial( block );
if ( xMat != null ) {
Material mat = xMat.parseMaterial();
@@ -1012,12 +672,6 @@ public void incrementMinecraftStatsMineBlock( Player player, String blockName, i
}
}
-// Statistic.MINE_BLOCK;
-// player.setStatistic(null, count);
-// player.incrementStatistic(null, null);
-// player.incrementStatistic(null, null, count);
-// player.statistic
-
}
@Override
@@ -1076,9 +730,6 @@ public boolean isInventoryFull() {
*
* @return
*/
-// public boolean isAutoSellEnabled() {
-// return isAutoSellEnabled( null );
-// }
public boolean isAutoSellEnabled( StringBuilder debugInfo ) {
boolean results = false;
@@ -1089,8 +740,6 @@ public boolean isAutoSellEnabled( StringBuilder debugInfo ) {
if ( SellAllUtil.get().isAutoSellPerUserToggleable ) {
debugInfo.append( "(&7sellallEnabled:userToggleable&3)" );
-// boolean isAutoSellPerUserToggleable = SellAllUtil.get().isAutoSellPerUserToggleable;
-
boolean isPlayerAutoSellTurnedOn =
SellAllUtil.get().isSellallPlayerUserToggleEnabled( getWrapper() );
@@ -1136,22 +785,6 @@ public boolean isAutoSellEnabled( StringBuilder debugInfo ) {
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( StringBuilder debugInfo ) {
-// return isAutoSellByPermEnabled( isAutoSellEnabled( debugInfo ), debugInfo );
-// }
/**
* This will check to see if the player has the perms enabled
@@ -1181,8 +814,8 @@ private boolean isAutoSellByPermEnabledAutoFeatures( StringBuilder debugInfo ) {
!"false".equalsIgnoreCase( perm ) ) {
debugInfo.append( "(&7autosellAutoFeaturesByPerm&3: " )
- .append( Output.get().getColorCodeWarning() )
- ;
+ .append( Output.get().getColorCodeWarning() )
+ ;
if ( isOp() ) {
debugInfo.append(
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java
index 5fb7637ad..1fb291529 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotPlayerUtil.java
@@ -365,12 +365,6 @@ private int getEnchantment( String enchant ) {
}
}
-// for ( Enchantment e : Enchantment.values() ) {
-// if (e.getKey().getKey().equalsIgnoreCase( enchant ) ) {
-// enchantment = e;
-// break;
-// }
-// }
if ( enchantment != null ) {
@@ -425,36 +419,6 @@ public int getItemInHandEnchantmentLuck() {
}
-// public String getEnchantments() {
-// StringBuilder sb = new StringBuilder();
-//
-// SpigotItemStack itemStack = getItemInHand();
-//
-// if ( itemStack != null && itemStack.getBukkitStack() != null) {
-// try {
-//
-// Set keys = itemStack.getBukkitStack().getEnchantments().keySet();
-//
-// for ( Enchantment key : keys ) {
-// Integer value = itemStack.getBukkitStack().getEnchantments().get( key );
-//
-// if ( value != null ) {
-// if ( sb.length() > 0 ) {
-// sb.append( ", " );
-// }
-// sb.append( key.getName() ).append( ": " ).append( value );
-// key.getItemTarget().toString()
-// }
-// }
-//
-// }
-// catch ( NullPointerException e ) {
-// // Ignore. This happens when a TokeEnchanted tool is used when TE is not installed anymore.
-// // It throws this exception: Caused by: java.lang.NullPointerException: null key in entry: null=5
-// }
-// }
-// }
-
public String getItemInHandLore() {
StringBuilder sb = new StringBuilder();
@@ -482,6 +446,4 @@ public void setSpigotPlayer( SpigotPlayer spigotPlayer ) {
this.spigotPlayer = spigotPlayer;
}
-
-
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java
index db23cf30f..2da03d031 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/SpigotWorld.java
@@ -82,14 +82,14 @@ public SpigotWorld(org.bukkit.World bukkitWorld) {
@Override
public List getEntities() {
- List results = new ArrayList<>();
-
- for (org.bukkit.entity.Entity bukkitEnitity : getWrapper().getEntities() ) {
-
- results.add( new SpigotEntity( bukkitEnitity) );
+ List results = new ArrayList<>();
+
+ for (org.bukkit.entity.Entity bukkitEnitity : getWrapper().getEntities() ) {
+
+ results.add( new SpigotEntity( bukkitEnitity) );
}
- return results;
+ return results;
}
/**
@@ -99,20 +99,20 @@ public List getEntities() {
* @return
*/
public List getEntities( EntityType eType ) {
- List results = new ArrayList<>();
-
- SpigotEntityType seType = eType == null ? null : (SpigotEntityType) eType;
-
- for (org.bukkit.entity.Entity bukkitEnitity : getWrapper().getEntities() ) {
-
- if ( seType == null ||
- seType.getxEType() == XEntityType.of(bukkitEnitity) ) {
-
- results.add( new SpigotEntity( bukkitEnitity ));
- }
- }
-
- return results;
+ List results = new ArrayList<>();
+
+ SpigotEntityType seType = eType == null ? null : (SpigotEntityType) eType;
+
+ for (org.bukkit.entity.Entity bukkitEnitity : getWrapper().getEntities() ) {
+
+ if ( seType == null ||
+ seType.getxEType() == XEntityType.of(bukkitEnitity) ) {
+
+ results.add( new SpigotEntity( bukkitEnitity ));
+ }
+ }
+
+ return results;
}
/**
@@ -128,42 +128,37 @@ public List getEntities( EntityType eType ) {
@Override
public Block getBlockAt( Location location, boolean containsCustomBlocks ) {
- if ( getBlockAtLocation == null ) {
- getBlockAtLocation = new SpigotBlockGetAtLocation();
- }
-
- return getBlockAtLocation.getBlockAt(location, containsCustomBlocks, this);
+ if ( getBlockAtLocation == null ) {
+ getBlockAtLocation = new SpigotBlockGetAtLocation();
+ }
+
+ return getBlockAtLocation.getBlockAt(location, containsCustomBlocks, this);
}
public Block getBlockAt( Location location ) {
- return getBlockAt( location, false );
+ return getBlockAt( location, false );
}
-// public SpigotBlock getSpigotBlockAt(Location location) {
-// return new SpigotBlock(
-// bukkitWorld.getBlockAt(SpigotUtil.prisonLocationToBukkit(location)));
-// }
-
public org.bukkit.Location getBukkitLocation(Location location) {
- return SpigotUtil.prisonLocationToBukkit(location);
+ return SpigotUtil.prisonLocationToBukkit(location);
}
public org.bukkit.inventory.ItemStack getBukkitItemStack( ItemStack itemStack ) {
- SpigotItemStack sItemStack = (SpigotItemStack) itemStack;
-
- return sItemStack.getBukkitStack();
+ SpigotItemStack sItemStack = (SpigotItemStack) itemStack;
+
+ return sItemStack.getBukkitStack();
}
@Override
public void setBlock( PrisonBlock block, int x, int y, int z ) {
- Location loc = new Location( this, x, y, z );
- org.bukkit.block.Block bukkitBlock =
- bukkitWorld.getBlockAt(SpigotUtil.prisonLocationToBukkit(loc));
-
- SpigotCompatibility.getInstance().updateSpigotBlock( block, bukkitBlock );
+ Location loc = new Location( this, x, y, z );
+ org.bukkit.block.Block bukkitBlock =
+ bukkitWorld.getBlockAt(SpigotUtil.prisonLocationToBukkit(loc));
+
+ SpigotCompatibility.getInstance().updateSpigotBlock( block, bukkitBlock );
}
@@ -209,59 +204,6 @@ public void setBlocksSynchronously( List tBlocks, MineRes
}
-// public String getBlockSignature( Location location ) {
-// String results = null;
-//
-// if ( getWrapper() != null ) {
-//
-// SpigotBlock block = (SpigotBlock) getBlockAt( location );
-//
-// StringBuilder sb = new StringBuilder();
-// sb.append( block.getWrapper().getType().name() )
-// .append( ":" )
-//// .append( location.toWorldCoordinates() )
-//// .append( "::" )
-// .append( block.getWrapper().getBlockData() );
-//
-// results = sb.toString();
-// }
-//
-// return results;
-// }
-
-// public void getTestBlock() {
-//
-// PrisonNBTUtil nbtUtil = new PrisonNBTUtil();
-//
-// NBTItem nbtItemStack = nbtUtil.getNBT( bstack );
-//
-// nbtItemStack.
-// }
-
-// public void setBlockFromString( String blockString, Location location ) {
-//
-// String[] parts = blockString.split("::");
-// String blockNameFormal = parts[0];
-// String worldCoordinates = parts[1];
-// String blockData = parts[2];
-//
-// Location targetLocation = location;
-// if ( targetLocation == null ) {
-// targetLocation = Location.decodeWorldCoordinates(worldCoordinates);
-// }
-//
-// SpigotBlock block = (SpigotBlock) getBlockAt( targetLocation );
-//
-// Prison.get().getPlatform().getPrisonBlock(blockNameFormal);
-//// block.setType(Material.getMaterial(parts[0]));
-//
-// BlockData targetBlockData =
-// SpigotPrison.getInstance().getServer().createBlockData( blockData );
-//
-// block.getWrapper().setBlockData( targetBlockData );
-//
-// }
-
public org.bukkit.World getWrapper() {
return bukkitWorld;
@@ -306,9 +248,6 @@ public org.bukkit.entity.ArmorStand spawnBukkitArmorStand( Location location ) {
Location spawnPoint = new Location( location );
spawnPoint.setY(maxHight);
-// Entity e = spawnEntity( spawnPoint, SpigotEntityType.ENTITY_TYPE_ARMOR_STAND );
-// SpigotEntity sEntity = (SpigotEntity) e;
-
org.bukkit.entity.Entity bEntity = spawnBukkitEntity( spawnPoint, SpigotEntityType.ENTITY_TYPE_ARMOR_STAND );
org.bukkit.entity.ArmorStand armorStand = (org.bukkit.entity.ArmorStand) bEntity;
@@ -316,12 +255,6 @@ public org.bukkit.entity.ArmorStand spawnBukkitArmorStand( Location location ) {
armorStand.teleport( new SpigotLocation( location ).getBukkitLocation() );
-// SpigotArmorStand sArmorStand = new SpigotArmorStand( armorStand );
-
-// sArmorStand.teleport(location);
-
-// testArmorStandPlacement( spawnPoint );
-
return armorStand;
}
@@ -401,22 +334,9 @@ public ArmorStand spawnArmorStand( Location location, String itemType,
as.getHelmet();
as.setHelmet(bItemStack);
-// String msg = "SpigotWorld.spawnArmorStand: itemInHand: " +
-// ( as.getItemInHand() == null ? "null" : as.getItemInHand().toString()) +
-// " hasArmms: " + as.hasArms() +
-// " itemStack( " +
-// (bItemStack == null ? "null" :
-// bItemStack.toString() + " " + bItemStack.getAmount()) + ") " +
-// " name: " + (customName == null ? "noCustomName" : customName);
-//
-// Output.get().logInfo( msg );
-
-// as.teleport( SpigotLocation.getBukkitLocation(location) );
-
// wrap in a SpigotArmorStand:
SpigotArmorStand sas = new SpigotArmorStand( as );
- //sas.teleport( location );
return sas;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/entity/SpigotArmorStand.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/entity/SpigotArmorStand.java
index 2fe6cd813..a07e090a4 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/entity/SpigotArmorStand.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/entity/SpigotArmorStand.java
@@ -23,16 +23,6 @@ public SpigotArmorStand( org.bukkit.entity.ArmorStand bArmorStand ) {
this.bArmorStand = bArmorStand;
}
-// public static ArmorStand spawn( tech.mcprison.prison.util.Location location ) {
-// tech.mcprison.prison.internal.Entity e = location.spawnEntity( SpigotEntityType.ENTITY_TYPE_ARMOR_STAND );
-// SpigotEntity sEntity = (SpigotEntity) e;
-//
-// org.bukkit.entity.ArmorStand armorStand = (org.bukkit.entity.ArmorStand) sEntity.getBukkitEntity();
-// SpigotArmorStand sArmorStand = new SpigotArmorStand( armorStand );
-//
-// return sArmorStand;
-// }
-
public SpigotArmorStand(Entity entity) {
this( (org.bukkit.entity.ArmorStand) ((SpigotEntity) entity).getBukkitEntity() );
@@ -43,58 +33,6 @@ public SpigotArmorStand(Entity entity) {
}
}
-// /**
-// * Sets visibility:false, arms:true, basePlate:false, canPickupItems:false,
-// * removeWhenFar:false, gravity:false, and itemInHand.
-// */
-// @Override
-// public void setupArmorStand( ItemStack item ) {
-//
-// if ( item != null ) {
-//
-// setVisible( false );
-//
-// setArms( true );
-// setBasePlate( false );
-// setCanPickupItems( false );
-//
-// setItemInHand( item );
-//
-// setRemoveWhenFarAway(false);
-//
-// if ( new BluesSemanticVersionComparator().compareMCVersionTo( "1.9.0" ) >= 0 ) {
-//
-// // setGravity is invalid for spigot 1.8.8:
-// setGravity( false );
-// }
-// }
-// }
-
-// @Override
-// public void setupArmorStand( String itemType ) {
-// SpigotItemStack item = null;
-//
-// XMaterial xBomb = XMaterial.matchXMaterial( itemType ).orElse( null );
-//
-// if ( xBomb != null ) {
-// try {
-//
-// // Create the spigot/bukkit ItemStack:
-// org.bukkit.inventory.ItemStack bItemStack = xBomb.parseItem();
-//
-// if ( sItemStack != null ) {
-//
-// item = new SpigotItemStack( bItemStack );
-// }
-// }
-// catch (PrisonItemStackNotSupportedRuntimeException e) {
-// // Ignore
-// }
-// }
-//
-// setupArmorStand( item );
-// }
-
@Override
public boolean isVisible() {
return bArmorStand.isVisible();
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/entity/SpigotEntity.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/entity/SpigotEntity.java
index 95f9b052c..3f3b931f8 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/entity/SpigotEntity.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/game/entity/SpigotEntity.java
@@ -104,7 +104,6 @@ public int getMaxFireTicks() {
* @return
*/
public List getNearbyEntities( int r, EntityType eType ) {
-// Location loc = getLocation();
List bEntities = getBukkitEntity()
.getNearbyEntities( r * 2, r * 2, r * 2 );
@@ -280,15 +279,6 @@ public org.bukkit.entity.Entity getBukkitEntity() {
return bukkitEntity;
}
-
-// @Override
-// public String getName() {
-//
-// return bukkitEntity != null ?
-// bukkitEntity.getName() :
-// rankplayer;
-// }
-
@Override
public boolean isPlayer() {
@@ -296,14 +286,4 @@ public boolean isPlayer() {
}
-
-// @Override
-// public boolean doesSupportColors() {
-// return false;
-// }
-
-
-
-
-
}
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 2d6586434..cc8440ef9 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
@@ -92,7 +92,6 @@ public class ListenersPrisonManager
private final MessagesConfig messages = SpigotPrison.getInstance().getMessagesConfig();
boolean guiNotEnabled = !getBoolean(config.getString("prison-gui-enabled"));
-// private Optional ladder; // makes no sense... not thread safe.
public ChatMode mode;
@@ -238,7 +237,6 @@ public void onPlayerInteractEvent(PlayerInteractEvent e){
// signs, so check if the material name contains "sign":
String matName = clickedBlock.name().toLowerCase();
if ( matName.contains("sign")) {
-// if (clickedBlock == Material.SIGN || clickedBlock == Material.WALL_SIGN) {
// Get the player
Player p = e.getPlayer();
@@ -265,7 +263,6 @@ public void onPlayerInteractEvent(PlayerInteractEvent e){
if (sellAllUtil.isSellAllSignPermissionToUseEnabled && !p.hasPermission(permissionUseSign)) {
Output.get().sendWarn(new SpigotPlayer(p),
messages.getString(MessagesConfig.StringID.spigot_message_missing_permission)
-// + " [&3" + permissionUseSign + "&7]"
);
return;
}
@@ -426,7 +423,7 @@ public void onClick(InventoryClickEvent e){
// If a GUI Tools Page action, then process the request and just exit:
else if ( SpigotGUIMenuTools.getInstance().processGUIPage( p, title, e ) ) {
- return;
+ return;
}
@@ -570,41 +567,7 @@ else if ( SpigotGUIMenuTools.getInstance().processGUIPage( p, title, e ) ) {
break;
}
-// // Check the inventory title and do the actions.
-// case "PrisonManager -> AutoFeatures": {
-//
-// // Call the method
-// autoFeaturesGUI(e, p, parts);
-//
-// break;
-// }
-
-// // Check the title and do the actions.
-// case "AutoFeatures -> AutoPickup": {
-//
-// // Call the method
-// autoPickupGUI(e, p, parts);
-//
-// break;
-// }
-
-// // Check the title and do the actions.
-// case "AutoFeatures -> AutoSmelt": {
-//
-// // Call the method
-// autoSmeltGUI(e, p, parts);
-//
-// break;
-// }
-
-// // Check the title and do the actions.
-// case "AutoFeatures -> AutoBlock": {
-//
-// // Call the method
-// autoBlockGUI(e, p, parts);
-//
-// break;
-// }
+
// Check the title and do the actions.
case "SellAll -> Blocks": {
@@ -744,60 +707,8 @@ else if ( SpigotGUIMenuTools.getInstance().processGUIPage( p, title, e ) ) {
}
-
-
-// private boolean processGUIPage( Player p, String title, InventoryClickEvent e ) {
-// boolean isPageAction = false;
-//
-// ItemStack currentItem = e.getCurrentItem();
-// if ( currentItem != null && currentItem.hasItemMeta() ) {
-//
-// ItemMeta meta = currentItem.getItemMeta();
-//
-// if ( meta.hasLore() ) {
-//
-// String command = null;
-//
-// List lores = meta.getLore();
-//
-// for ( String lore : lores ) {
-//
-// if ( lore.contains( SpigotGUIMenuTools.GUI_MENU_TOOLS_PAGE ) ) {
-// isPageAction = true;
-// }
-// if ( lore.contains( SpigotGUIMenuTools.GUI_MENU_TOOLS_COMMAND ) ) {
-// command = Text.stripColor( lore ).replace( SpigotGUIMenuTools.GUI_MENU_TOOLS_COMMAND, "" ).trim();
-// }
-// }
-//
-// if ( isPageAction && command != null ) {
-// Bukkit.dispatchCommand(p,
-// Prison.get().getCommandHandler().findRegisteredCommand( command ));
-//
-// }
-// }
-//
-// }
-//
-// return isPageAction;
-// }
private void sellAllPlayerGUI(InventoryClickEvent e, Player p, String[] parts) {
-// if (parts[0].equalsIgnoreCase("Prior")){
-//
-// SellAllPlayerGUI gui = new SellAllPlayerGUI(p, Integer.parseInt(parts[1]));
-// gui.open();
-//
-// e.setCancelled(true);
-// return;
-// } else if (parts[0].equalsIgnoreCase("Next")){
-//
-// SellAllPlayerGUI gui = new SellAllPlayerGUI(p, Integer.parseInt(parts[1]));
-// gui.open();
-//
-// e.setCancelled(true);
-// return;
-// }
p.closeInventory();
e.setCancelled(true);
@@ -1401,7 +1312,7 @@ private void mineBlockPercentage(InventoryClickEvent e, Player p, String[] parts
String positionStr = ( parts.length > 5 ? parts[5] : "0" );
int position = 0;
try {
- position = Integer.parseInt( positionStr );
+ position = Integer.parseInt( positionStr );
}
catch(NumberFormatException ignored) {}
@@ -1620,22 +1531,6 @@ private void sellAllItemValue(InventoryClickEvent e, Player p, String[] parts) {
private void sellAllAdminBlocksGUI(InventoryClickEvent e, Player p, String[] parts) {
-// if (parts[0].equalsIgnoreCase("Prior")){
-//
-// SellAllAdminBlocksGUI gui = new SellAllAdminBlocksGUI(p, Integer.parseInt(parts[1]));
-// gui.open();
-//
-// e.setCancelled(true);
-// return;
-// } else if (parts[0].equalsIgnoreCase("Next")){
-//
-// SellAllAdminBlocksGUI gui = new SellAllAdminBlocksGUI(p, Integer.parseInt(parts[1]));
-// gui.open();
-//
-// e.setCancelled(true);
-// return;
-// }
-
if (e.isRightClick()){
String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall delete" );
@@ -1666,19 +1561,6 @@ private void prisonManagerGUI(InventoryClickEvent e, Player p, String buttonName
break;
}
-// // Check the Item display name and do open the right GUI.
-// case "AutoManager": {
-//
-// // Check if the autofeatures config isn't null.
-// if(SpigotGUIComponents.afConfig() != null) {
-// SpigotAutoFeaturesGUI gui = new SpigotAutoFeaturesGUI(p);
-// gui.open();
-// } else {
-// Output.get().sendWarn(new SpigotPlayer(p), "Can't find an autofeatures config, maybe they're disabled.");
-// }
-// break;
-// }
-
// Check the Item display name and do open the right GUI.
case "Mines": {
SpigotMinesGUI gui = new SpigotMinesGUI(p, 1, "gui admin mines", "gui");
@@ -1713,21 +1595,12 @@ private void laddersGUI(InventoryClickEvent e, Player p, String buttonNameMain,
return;
}
-// if (parts[0].equalsIgnoreCase("Next") || parts[0].equalsIgnoreCase("Prior")){
-//
-// // Open a new SpigotLadders GUI page.
-// SpigotLaddersGUI gui = new SpigotLaddersGUI(p, Integer.parseInt(parts[1]), 1);
-// p.closeInventory();
-// gui.open();
-// return;
-// }
-
// Get the ladder by the name of the button got before.
RankLadder rLadder = PrisonRanks.getInstance().getLadderManager().getLadder(buttonNameMain);
if ( rLadder == null ) {
- // Do nothing since it's not a valid ladder name:
- return;
+ // Do nothing since it's not a valid ladder name:
+ return;
}
// ladder = rLadder;
@@ -1735,22 +1608,22 @@ private void laddersGUI(InventoryClickEvent e, Player p, String buttonNameMain,
// to be sure's a right click.
if (e.isShiftClick() && e.isRightClick()) {
- if ( rLadder.getRanks().size() > 0 ) {
-
- SpigotPlayer sPlayer = new SpigotPlayer( p );
- sPlayer.setActionBar( "Cannot delete a non-empty ladder" );
- }
- else {
-
- // Execute the command
- 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" );
- gui.open();
- return;
- }
+ if ( rLadder.getRanks().size() > 0 ) {
+
+ SpigotPlayer sPlayer = new SpigotPlayer( p );
+ sPlayer.setActionBar( "Cannot delete a non-empty ladder" );
+ }
+ else {
+
+ // Execute the command
+ 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" );
+ gui.open();
+ return;
+ }
}
@@ -1765,15 +1638,6 @@ private void laddersGUI(InventoryClickEvent e, Player p, String buttonNameMain,
private void ranksGUI(InventoryClickEvent e, Player p, String buttonNameMain, String[] parts) {
-// if (parts[0].equalsIgnoreCase("Next") || parts[0].equalsIgnoreCase("Prior")){
-//
-// // Open a new SpigotLadders GUI page.
-// SpigotRanksGUI gui = new SpigotRanksGUI(p, ladder, Integer.parseInt(parts[1]));
-// p.closeInventory();
-// gui.open();
-// return;
-// }
-
if ( !PrisonRanks.getInstance().isEnabled() ) {
Output.get().sendWarn(new SpigotPlayer(p), "&cPrison ranks are not enabled.");
@@ -1833,53 +1697,32 @@ private void playerPrestigesGUI(InventoryClickEvent e, Player p, String buttonNa
private void prestigeConfirmationGUI(InventoryClickEvent e, Player p, String buttonNameMain) {
- String playerName = p.getName();
+ String playerName = p.getName();
// Check the button name and do the actions.
if (buttonNameMain.equalsIgnoreCase("Confirm: Prestige")){
- Output.get().logDebug( DebugTarget.rankup, "rankup: /gui prestigeConfirm: Prestige has been Confirmed. "
- + " calling: '/prestige " + playerName + " confirm'" );
-
- // Execute the command.
- String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "prestige" );
-
- String command = registeredCmd + " " + playerName + " confirm";
-
+ Output.get().logDebug( DebugTarget.rankup, "rankup: /gui prestigeConfirm: Prestige has been Confirmed. "
+ + " calling: '/prestige " + playerName + " confirm'" );
+
+ // Execute the command.
+ String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "prestige" );
+
+ String command = registeredCmd + " " + playerName + " confirm";
+
Bukkit.dispatchCommand(p, command );
}
else if (buttonNameMain.equalsIgnoreCase("Cancel: Don't Prestige")){
- Output.get().logDebug( DebugTarget.rankup, "rankup: /gui prestigeConfirm: Prestige has been canceled " +
- "for " + playerName + "." );
+ Output.get().logDebug( DebugTarget.rankup, "rankup: /gui prestigeConfirm: Prestige has been canceled " +
+ "for " + playerName + "." );
- // Send a message to the player.
-// Output.get().sendInfo(new SpigotPlayer(p), "&cCancelled");
}
// Close the inventory.
p.closeInventory();
-// // Check the button name and do the actions.
-// if (buttonNameMain.equalsIgnoreCase("Confirm: Prestige")){
-// Output.get().logDebug( DebugTarget.rankup, "rankup: GUI: 'Confirm: Prestige' calling: '/rankup prestiges'" );
-//
-// // Execute the command.
-// String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "rankup" );
-//
-// Bukkit.dispatchCommand(p, registeredCmd + " prestiges");
-// // Close the inventory.
-// p.closeInventory();
-// } else if (buttonNameMain.equalsIgnoreCase("Cancel: Don't Prestige")){
-// Output.get().logDebug( DebugTarget.rankup, "rankup: GUI/: 'Cancel: Don't Prestige' sendInfo: 'cancelled'" );
-//
-// // Send a message to the player.
-// Output.get().sendInfo(new SpigotPlayer(p), "&cCancelled");
-// // Close the inventory.
-// p.closeInventory();
-// }
-//
// Cancel the event.
e.setCancelled(true);
}
@@ -1957,7 +1800,7 @@ private void rankManagerGUI(InventoryClickEvent e, Player p, String[] parts) {
private void playerRanksGUI(InventoryClickEvent e, Player p, String buttonNameMain) {
// Check the buttonName and do the actions.
- String message = Text.stripColor( messages.getString(MessagesConfig.StringID.spigot_gui_lore_rankup) );
+ String message = Text.stripColor( messages.getString(MessagesConfig.StringID.spigot_gui_lore_rankup) );
if (buttonNameMain.equals(SpigotPrison.format( message ))){
Bukkit.dispatchCommand(p,
Prison.get().getCommandHandler().findRegisteredCommand(
@@ -2096,15 +1939,6 @@ private void rankPriceGUI(InventoryClickEvent e, Player p, String[] parts) {
private void minesGUI(InventoryClickEvent e, Player p, String buttonNameMain, String[] parts) {
-// if (parts[0].equalsIgnoreCase("Next") || parts[0].equalsIgnoreCase("Prior")){
-//
-// // Open a new SpigotLadders GUI page.
-// SpigotMinesGUI gui = new SpigotMinesGUI(p, Integer.parseInt(parts[1]));
-// p.closeInventory();
-// gui.open();
-// return;
-// }
-
// Variables.
PrisonMines pMines = PrisonMines.getInstance();
Mine m = pMines.getMine(buttonNameMain);
@@ -2655,277 +2489,7 @@ private void radiusGUI(InventoryClickEvent e, Player p, String[] parts) {
}
}
-// private void autoFeaturesGUI(InventoryClickEvent e, Player p, String[] parts) {
-//
-// // Get the config
-// AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig();
-//
-// // Output finally the buttonname and the mode explicit out of the array
-// String buttonName = parts[0];
-// String mode = parts[1];
-//
-// boolean enabled = mode.equalsIgnoreCase("Enabled");
-//
-// // Check the clickType and do the actions
-// if ( enabled && e.isRightClick() && e.isShiftClick() ||
-// !enabled && e.isRightClick()){
-//
-// if (buttonName.equalsIgnoreCase("Full-Inventory-Sound")){
-// afConfig.setFeature( AutoFeatures.playSoundIfInventoryIsFull, !enabled );
-// saveConfigAutoFeatures(e, p);
-// }
-//
-// if (buttonName.equalsIgnoreCase("Full-Inventory-ActionBar")){
-// afConfig.setFeature(AutoFeatures.actionBarMessageIfInventoryIsFull, !enabled);
-// saveConfigAutoFeatures(e,p);
-// }
-//
-// if (buttonName.equalsIgnoreCase("All")){
-// afConfig.setFeature(AutoFeatures.isAutoManagerEnabled, !enabled);
-// saveConfigAutoFeatures(e,p);
-// }
-//
-// }
-//
-// // Check the clickType and do the actions
-// if (enabled && e.isRightClick() && e.isShiftClick() || !enabled && e.isRightClick() || enabled && e.isLeftClick()){
-// if (buttonName.equalsIgnoreCase("AutoPickup")){
-// if (e.isLeftClick()){
-// SpigotAutoPickupGUI gui = new SpigotAutoPickupGUI(p);
-// gui.open();
-// return;
-// }
-// afConfig.setFeature(AutoFeatures.autoPickupEnabled, !enabled);
-// saveConfigAutoFeatures(e,p);
-// }
-//
-// if (buttonName.equalsIgnoreCase("AutoSmelt")){
-// if (e.isLeftClick()){
-// SpigotAutoSmeltGUI gui = new SpigotAutoSmeltGUI(p);
-// gui.open();
-// return;
-// }
-// afConfig.setFeature(AutoFeatures.autoSmeltEnabled, !enabled);
-// saveConfigAutoFeatures(e,p);
-// }
-//
-// if (buttonName.equalsIgnoreCase("AutoBlock")){
-// if (e.isLeftClick()){
-// SpigotAutoBlockGUI gui = new SpigotAutoBlockGUI(p);
-// gui.open();
-// return;
-// }
-// afConfig.setFeature(AutoFeatures.autoBlockEnabled, !enabled);
-// saveConfigAutoFeatures(e,p);
-// }
-// }
-// }
-
-// private void autoPickupGUI(InventoryClickEvent e, Player p, String[] parts) {
-//
-// // Get the config
-// AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig();
-//
-// // Output finally the buttonname and the mode explicit out of the array
-// String buttonname = parts[0];
-// String mode = parts[1];
-//
-// boolean enabled = mode.equalsIgnoreCase("Enabled");
-//
-// // Check the click and do the actions, also the buttonName
-// if ( enabled && e.isRightClick() && e.isShiftClick() ||
-// !enabled && e.isRightClick() ){
-//
-// switch (buttonname){
-// case "All_Blocks":{
-// afConfig.setFeature( AutoFeatures.pickupAllBlocks, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// case "Cobblestone":{
-// afConfig.setFeature(AutoFeatures.pickupCobbleStone, !enabled);
-// saveConfigPickup(e,p);
-// break;
-// }
-// case "Gold_Ore":{
-// afConfig.setFeature( AutoFeatures.pickupGoldOre, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// case "Iron_Ore":{
-// afConfig.setFeature( AutoFeatures.pickupIronOre, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// case "Coal_Ore":{
-// afConfig.setFeature( AutoFeatures.pickupCoalOre, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// case "Diamond_Ore":{
-// afConfig.setFeature( AutoFeatures.pickupDiamondOre, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// case "Redstone_Ore":{
-// afConfig.setFeature( AutoFeatures.pickupRedStoneOre, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// case "Emerald_Ore":{
-// afConfig.setFeature( AutoFeatures.pickupEmeraldOre, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// case "Quartz_Ore":{
-// afConfig.setFeature( AutoFeatures.pickupQuartzOre, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// case "Lapis_Ore":{
-// afConfig.setFeature( AutoFeatures.pickupLapisOre, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// case "Snow_Ball":{
-// afConfig.setFeature( AutoFeatures.pickupSnowBall, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// case "Glowstone_Dust":{
-// afConfig.setFeature( AutoFeatures.pickupGlowstoneDust, !enabled );
-// saveConfigPickup(e, p);
-// break;
-// }
-// default:{
-// break;
-// }
-//
-// }
-// }
-// }
-//
-// private void autoSmeltGUI(InventoryClickEvent e, Player p, String[] parts) {
-//
-// // Get the config
-// AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig();
-//
-// // Output finally the buttonname and the mode explicit out of the array
-// String buttonname = parts[0];
-// String mode = parts[1];
-//
-// boolean enabled = mode.equalsIgnoreCase("Enabled");
-//
-// // Check the clickType and do the actions
-// if ( enabled && e.isRightClick() && e.isShiftClick() ||
-// !enabled && e.isRightClick()){
-//
-// switch (buttonname){
-// case "Gold_Ore":{
-// afConfig.setFeature( AutoFeatures.smeltGoldOre, !enabled );
-// saveConfigSmelt(e, p);
-// break;
-// }
-// case "Iron_Ore":{
-// afConfig.setFeature( AutoFeatures.smeltIronOre, !enabled );
-// saveConfigSmelt(e, p);
-// break;
-// }
-// case "All_Ores":{
-// afConfig.setFeature( AutoFeatures.smeltAllBlocks, !enabled );
-// saveConfigSmelt(e, p);
-// break;
-// }
-// default:{
-// break;
-// }
-// }
-// }
-// }
-//
-// private void autoBlockGUI(InventoryClickEvent e, Player p, String[] parts) {
-//
-// // Get the config
-// AutoFeaturesFileConfig afConfig = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig();
-//
-// // Output finally the buttonname and the mode explicit out of the array
-// String buttonname = parts[0];
-// String mode = parts[1];
-//
-// boolean enabled = mode.equalsIgnoreCase("Enabled");
-//
-// // Check the clickType and do the actions
-// if ( enabled && e.isRightClick() && e.isShiftClick() ||
-// !enabled && e.isRightClick()){
-//
-// switch (buttonname){
-// case "Gold_Block":{
-// afConfig.setFeature( AutoFeatures.blockGoldBlock, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "Iron_Block":{
-// afConfig.setFeature( AutoFeatures.blockIronBlock, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "Coal_Block":{
-// afConfig.setFeature( AutoFeatures.blockCoalBlock, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "Diamond_Block":{
-// afConfig.setFeature( AutoFeatures.blockDiamondBlock, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "Redstone_Block":{
-// afConfig.setFeature( AutoFeatures.blockRedstoneBlock, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "Emerald_Block":{
-// afConfig.setFeature( AutoFeatures.blockEmeraldBlock, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "Quartz_Block":{
-// afConfig.setFeature( AutoFeatures.blockQuartzBlock, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "Prismarine_Block":{
-// afConfig.setFeature( AutoFeatures.blockPrismarineBlock, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "Lapis_Block":{
-// afConfig.setFeature( AutoFeatures.blockLapisBlock, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "Snow_Block":{
-// afConfig.setFeature( AutoFeatures.blockSnowBlock, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "Glowstone_Block":{
-// afConfig.setFeature( AutoFeatures.blockGlowstone, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// case "All_Blocks":{
-// afConfig.setFeature( AutoFeatures.blockAllBlocks, !enabled );
-// saveConfigBlock(e, p);
-// break;
-// }
-// default:{
-// break;
-// }
-// }
-// }
-//
-// }
+
private void modeAction(AsyncPlayerChatEvent e, Player p, String message) {
@@ -2955,7 +2519,7 @@ private void modeAction(AsyncPlayerChatEvent e, Player p, String message) {
private void sellAllCurrencyChat(AsyncPlayerChatEvent e, Player p, String message) {
// Check message and do the action
- String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall set currency" );
+ String registeredCmd = Prison.get().getCommandHandler().findRegisteredCommand( "sellall set currency" );
if (message.equalsIgnoreCase("cancel")){
Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_event_cancelled));
} else if (message.equalsIgnoreCase("default")){
@@ -2970,21 +2534,6 @@ private void sellAllCurrencyChat(AsyncPlayerChatEvent e, Player p, String messag
isChatEventActive = false;
}
-// private void prestigeAction(AsyncPlayerChatEvent e, Player p, String message) {
-//
-// // Check the chat message and do the actions
-// if (message.equalsIgnoreCase("cancel")) {
-// Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_prestiges_cancelled));
-// } else if (message.equalsIgnoreCase("confirm")) {
-// Bukkit.getScheduler().runTask(SpigotPrison.getInstance(), () -> Bukkit.getServer().dispatchCommand(p, "rankup prestiges"));
-// } else {
-// Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_prestiges_cancelled_wrong_keyword));
-// }
-// // Cancel the event
-// e.setCancelled(true);
-// // Set the event to false, because it got deactivated
-// isChatEventActive = false;
-// }
private void mineAction(AsyncPlayerChatEvent e, Player p, String message) {
@@ -3011,45 +2560,4 @@ private void rankAction(AsyncPlayerChatEvent e, Player p, String message) {
isChatEventActive = false;
}
-// /**
-// * Save the auto features, and then cancel the event and close the inventory.
-// *
-// * @param e
-// * @param player
-// */
-// private boolean saveAutoFeatures( InventoryClickEvent e, Player player ) {
-// boolean success = AutoFeaturesWrapper.getInstance().getAutoFeaturesConfig().saveConf();
-// e.setCancelled(true);
-// player.closeInventory();
-// return success;
-// }
-//
-//
-// private boolean saveConfigBlock(InventoryClickEvent e, Player p) {
-// boolean success = saveAutoFeatures( e, p );
-// SpigotAutoBlockGUI gui = new SpigotAutoBlockGUI(p);
-// gui.open();
-// return success;
-// }
-//
-// private boolean saveConfigSmelt(InventoryClickEvent e, Player p) {
-// boolean success = saveAutoFeatures( e, p );
-// SpigotAutoSmeltGUI gui = new SpigotAutoSmeltGUI(p);
-// gui.open();
-// return success;
-// }
-//
-// private boolean saveConfigPickup(InventoryClickEvent e, Player p) {
-// boolean success = saveAutoFeatures( e, p );
-// SpigotAutoPickupGUI gui = new SpigotAutoPickupGUI(p);
-// gui.open();
-// return success;
-// }
-//
-// private boolean saveConfigAutoFeatures(InventoryClickEvent e, Player p) {
-// boolean success = saveAutoFeatures( e, p );
-// SpigotAutoFeaturesGUI gui = new SpigotAutoFeaturesGUI(p);
-// gui.open();
-// return success;
-// }
}
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 4ddb6322c..a9f7eb41c 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
@@ -49,8 +49,6 @@ public class SpigotGUIMenuTools
private boolean useDisabledButtons;
-// private String loreCommand;
-
private SpigotGUIMenuTools() {
super();
@@ -66,8 +64,6 @@ private SpigotGUIMenuTools() {
this.menuGoBack = XMaterial.BARRIER;
-// this.menuStateOff1 = XMaterial.BLACK_STAINED_GLASS_PANE;
-// this.menuStateOff2 = XMaterial.GRAY_STAINED_GLASS_PANE;
}
@@ -155,7 +151,6 @@ public GUIMenuPageData( int totalArraySize, int currentPage, String commandToRun
posStart = (page - 1) * pageSize;
posEnd = posStart + pageSize;
-// posEnd = posStart + pageSize - 1;
if ( posEnd > totalArraySize ) {
posEnd = totalArraySize;
@@ -305,29 +300,6 @@ public void setButtons( List buttons ) {
*/
private void internalInitalize() {
-
-// this.loreCommand = SpigotPrison.getInstance().getMessagesConfig()
-// .getString(MessagesConfig.StringID.spigot_gui_lore_command);
-
-
-
-// String bukkitVersion = new BluesSpigetSemVerComparator().getBukkitVersion();
-// if ( bukkitVersion != null ) {
-//
-// BluesSemanticVersionData svData = new BluesSemanticVersionData( bukkitVersion );
-//
-// // If Spigot version is < 1.9.0... ie 1.8...
-// if ( svData.compareTo( new BluesSemanticVersionData( "1.9.0" ) ) < 0 ) {
-//
-//// // glass panes do not work well in 1.8 so setup alternatives:
-////
-//// this.menuStateOff = XMaterial.PINK_STAINED_GLASS;
-//// this.menuStateOn = XMaterial.GREEN_STAINED_GLASS;
-//
-// }
-// }
-
-
}
@@ -425,8 +397,6 @@ private void addButtonNBT( Button guiButton, GUIMenuPageData pageData, int page
{
String command = pageData.getCommandToRun() +
( page <= 0 ? "" : " " + page);
-// String command = GUI_MENU_TOOLS_COMMAND + pageData.getCommandToRun() +
-// ( page <= 0 ? "" : " " + page);
PrisonNBTUtil.setNBTBoolean( guiButton.getButtonItem(), GUI_MENU_TOOLS_NBT_ENABLED, true);
PrisonNBTUtil.setNBTString( guiButton.getButtonItem(), GUI_MENU_TOOLS_NBT_COMMAND, command );
@@ -436,36 +406,6 @@ private void addButtonNBT( Button guiButton, GUIMenuPageData pageData, int page
}
-// private ButtonLore createButtonLore( boolean enableCmd, // String message,
-// GUIMenuPageData pageData, int page ) {
-//
-// ButtonLore buttonLore = new ButtonLore();
-//
-//// if ( message != null ) {
-//// buttonLore.addLineLoreDescription( message );
-//// }
-//
-//
-// if ( enableCmd && pageData != null ) {
-//
-// buttonLore.addLineLoreAction( "&0" +
-// GUI_MENU_TOOLS_PAGE );
-//
-// if ( pageData.getCommandToRun() != null ) {
-// buttonLore.addLineLoreAction( "&0" +
-// GUI_MENU_TOOLS_COMMAND + pageData.getCommandToRun() +
-// ( page <= 0 ? "" : " " + page) );
-// }
-//
-//// if ( pageData.getCommandsBack() != null ) {
-//// buttonLore.addLineLoreDescription( "&0" +
-//// GUI_MENU_TOOLS_COMMANDS_BACK + pageData.getCommandsBack() );
-//// }
-//
-// }
-// return buttonLore;
-// }
-
public Button createButtonBack( GUIMenuPageData pageData, int position ) {
@@ -484,7 +424,6 @@ public Button createButtonBack( GUIMenuPageData pageData, int position ) {
String message = pageData.getCommandGoBack().equalsIgnoreCase( "close" ) ?
msgClose : msgGoBack;
-// ButtonLore buttonLore = createButtonLore( true, newPageData, 0 );
ButtonLore buttonLore = null;
int pos = pageData.getMenuPosition( position );
@@ -507,9 +446,7 @@ public Button createButtonPageOne( GUIMenuPageData pageData, int position ) {
int pageNumber = 1;
String msg = guiPageToolsFirstPageMsg( pageData.getPage(), pageData.getPageLast() );
-// String message = "Page 1 of " + pageData.getPageLast();
-// ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber );
ButtonLore buttonLore = null;
int pos = pageData.getMenuPosition( position );
@@ -540,9 +477,6 @@ public Button createButtonPagePrior( GUIMenuPageData pageData, int position ) {
return createButtonMenuBackground( pageData, position );
}
-// String message = "Page " + pageNumber + " of " + lastPageNumber;
-
-// ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber );
ButtonLore buttonLore = null;
int pos = pageData.getMenuPosition( position );
@@ -563,9 +497,6 @@ public Button createButtonPageCurrent( GUIMenuPageData pageData, int position )
String msg = guiPageToolsCurrentPageMsg( pageData.getPage(), pageData.getPageLast() );
-// String message = "Page " + pageNumber + " of " + pageData.getPageLast();
-
-// ButtonLore buttonLore = createButtonLore( false, pageData, pageNumber );
ButtonLore buttonLore = null;
int pos = pageData.getMenuPosition( position );
@@ -596,9 +527,6 @@ public Button createButtonPageNext( GUIMenuPageData pageData, int position ) {
return createButtonMenuBackground( pageData, position );
}
-// String message = "Page " + pageNumber + " of " + lastPageNumber;
-
-// ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber );
ButtonLore buttonLore = null;
int pos = pageData.getMenuPosition( position );
@@ -622,10 +550,8 @@ public Button createButtonPageLast( GUIMenuPageData pageData, int position ) {
int pageNumber = pageData.getPageLast() < 1 ?
pageData.getPageLast() : pageData.getPageLast();
-// String message = "Page " + pageNumber + " of " + pageData.getPageLast();
ButtonLore buttonLore = null;
-// ButtonLore buttonLore = createButtonLore( active, pageData, pageNumber );
int pos = pageData.getMenuPosition( position );
@@ -642,7 +568,6 @@ public Button createButtonPageLast( GUIMenuPageData pageData, int position ) {
public Button createButtonMenuBackground( GUIMenuPageData pageData, int position ) {
ButtonLore buttonLore = null;
-// ButtonLore buttonLore = createButtonLore( false, null, 1 );
int pos = pageData.getMenuPosition( position );
@@ -682,7 +607,6 @@ public void addMenuPageButtonsWideLayout( PrisonGUI gui, GUIMenuPageData pageDat
gui.addButton( createButtonPagePrior( pageData, 2 ) );
gui.addButton( createButtonMenuBackground( pageData, 3 ) );
-// gui.addButton( createButtonMenuBackground( pageData, 4 ) );
gui.addButton( createButtonBack( pageData, 4 ) );
gui.addButton( createButtonPageCurrent( pageData, 5 ) );
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java
index 3149cb2b4..3ade9928b 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/SpigotPrisonGUI.java
@@ -32,17 +32,13 @@ public void open() {
-// int dimension = 45;
PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3PrisonManager");
// Create and add buttons.
gui.addButton(new Button(10, XMaterial.TRIPWIRE_HOOK, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_ranks_button_description)), "&3Ranks - Ladders" ));
-// gui.addButton(new Button(13, XMaterial.IRON_PICKAXE, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_autofeatures_button_description)), "&3AutoManager" ));
gui.addButton(new Button(16, XMaterial.DIAMOND_ORE, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_mines_button_description)), "&3Mines" ));
gui.addButton(new Button(29, XMaterial.CHEST, new ButtonLore( guiLeftClickToOpenMsg(), messages.getString(MessagesConfig.StringID.spigot_gui_lore_sellall_button_description)), "&3SellAll" ));
- // gui.addButton(new Button(33, XMaterial.CHEST_MINECART, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_open), messages.getString(MessagesConfig.StringID.spigot_gui_lore_backpacks_button_description)), "&3Backpacks" ));
-// gui.addButton(new Button(44, XMaterial.RED_STAINED_GLASS_PANE, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_close), null), "&cClose"));
// Add the page controls:
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksPlayerGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksPlayerGUI.java
index 29054d546..d04656f84 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksPlayerGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/backpacks/BackpacksPlayerGUI.java
@@ -28,7 +28,6 @@ public BackpacksPlayerGUI(Player p, int id){
public void open(){
BackpacksUtil backpacksUtil = BackpacksUtil.get();
-// NewBackpacksUtil backpacksUtil = NewBackpacksUtil.get();
if (backpacksUtil == null){
return;
@@ -37,16 +36,12 @@ public void open(){
SpigotPlayer sPlayer = new SpigotPlayer(p);
Inventory inv = backpacksUtil.getBackpack(p, Integer.toString( id ));
-// Inventory inv = backpacksUtil.getBackpack(p, id);
if (inv != null){
PrisonGUI gui = new PrisonGUI(p, inv.getSize(), "&3" + p.getName() + " -> Backpack-" + id);
Output.get().sendInfo(sPlayer, "Backpack" + id + " open with success!");
-// if (backpacksUtil.isBackpackOpenSoundEnabled()){
-// p.playSound(p.getLocation(), backpacksUtil.getBackpackOpenSound(),3,1);
-// }
gui.open();
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java
index 272829cf4..e6c26661d 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/Button.java
@@ -105,25 +105,6 @@ public Button(Integer position, XMaterial buttonMaterial, int amount, String tit
}
}
-// /**
-// * Bug: Cannot correctly create a button with Material variants with spigot versions less than 1.13:
-// *
-// * Create button.
-// *
-// * @param position - int.
-// * @param buttonMaterial - Material.
-// * @param amount - int.
-// * @param title - String.
-// * */
-// public Button(Integer position, Material buttonMaterial, int amount, String title){
-// if ( amount > 64 ) {
-// amount = 1;
-// }
-// if ((position == null || position < 54) && amount <= 64) {
-// this.position = position;
-// this.buttonItem = createButton(buttonMaterial, amount, null, SpigotPrison.format(title));
-// }
-// }
/**
* Create button.
@@ -135,9 +116,9 @@ public Button(Integer position, XMaterial buttonMaterial, int amount, String tit
* @param title - String.
* */
public Button(Integer position, XMaterial buttonMaterial, int amount, ButtonLore lore, String title){
- if ( amount > 64 ) {
- amount = 1;
- }
+ if ( amount > 64 ) {
+ amount = 1;
+ }
if (position == null || position < 54) {
this.position = position;
this.buttonItem = createButton(buttonMaterial.parseItem(), amount,
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/ButtonLore.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/ButtonLore.java
index dce686f4a..2c8b0a523 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/ButtonLore.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/ButtonLore.java
@@ -110,8 +110,7 @@ public void addLineLoreAction(String line){
public void setLoreDescription(List description){
this.description.clear();
for (String descriptionLore : description) {
- addLineLoreDescription( descriptionLore );
-// this.description.add( Text.translateAmpColorCodes(colorIDDescription + descriptionLore) );
+ addLineLoreDescription( descriptionLore );
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java
index 9d7dccdda..d7d6e545a 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/guiutility/SpigotGUIComponents.java
@@ -35,38 +35,18 @@
public abstract class SpigotGUIComponents
extends PrisonCoreGuiMessages {
- public static MessagesConfig messages = getMessages();
- public static Configuration guiConfig = getGuiConfig();
-
- public static Configuration sellAllConfig;
-
- static {
- updateSellAllConfig();
+ public static MessagesConfig messages = getMessages();
+ public static Configuration guiConfig = getGuiConfig();
+
+ public static Configuration sellAllConfig;
+
+ static {
+ updateSellAllConfig();
}
-// /**
-// * Bug: Cannot correctly create a button with Material variants with spigot versions less than 1.13:
-// *
-// * Create a button for the GUI using Material.
-// *
-// * @param id
-// * @param amount
-// * @param lore
-// * @param display
-// * */
-// protected ItemStack createButton(Material id, int amount, List lore, String display) {
-//
-// if (id == null){
-// id = XMaterial.BARRIER.parseMaterial();
-// }
-//
-// ItemStack item = new ItemStack(id, amount);
-// ItemMeta meta = item.getItemMeta();
-// return getItemStack(item, lore, SpigotPrison.format(display), meta);
-// }
protected ItemStack createButton(ItemStack item, List lore, String display) {
- return createButton( item, 1, lore, display );
+ return createButton( item, 1, lore, display );
}
/**
* Create a button for the GUI using ItemStack.
@@ -83,7 +63,7 @@ protected ItemStack createButton(ItemStack item, int amount, List lore,
item.setAmount( amount );
- ItemMeta meta = item.getItemMeta();
+ ItemMeta meta = item.getItemMeta();
if (meta == null){
meta = XMaterial.BARRIER.parseItem().getItemMeta();
@@ -177,13 +157,6 @@ protected static MessagesConfig getMessages(){
return SpigotPrison.getInstance().getMessagesConfig();
}
-// /**
-// * Get SellAll config.
-// * */
-// protected static Configuration getSellAll(){
-// return SpigotPrison.getInstance().updateSellAllConfig();
-// }
-
/**
* Get GUI config.
* */
@@ -220,15 +193,11 @@ public static void updateMessages(){
* */
public static void updateSellAllConfig() {
- if ( SellAllUtil.isAutoSellEnabled() ) {
-
- sellAllConfig = SellAllUtil.get().initCachedData();
- }
+ if ( SellAllUtil.isAutoSellEnabled() ) {
+
+ sellAllConfig = SellAllUtil.get().initCachedData();
+ }
-// SellAllUtil util = SpigotPrison.getInstance().getSellAllUtil();
-// if ( util != null ) {
-// sellAllConfig = util.sellAllConfig;
-// }
}
public static void updateGUIConfig(){
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksListGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksListGUI.java
index 8261be131..a22192fd4 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksListGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotBlocksListGUI.java
@@ -43,33 +43,33 @@ public void open(){
ButtonLore lore = new ButtonLore(guiRanksLoreClickToStartBlockSetupMsg(), null);
// This will skip all BlockTypes that are invalid for the versions of MC that the server is running:
- PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes();
+ PrisonBlockTypes prisonBlockTypes = Prison.get().getPlatform().getPrisonBlockTypes();
List blockTypes = prisonBlockTypes.getBlockTypes();
// Only loop over the blocks that we need to show:
int i = counter;
for ( ; i < blockTypes.size() && i < counter + pageSize; i++ ) {
- PrisonBlock prisonBlock = blockTypes.get( i );
-
- XMaterial xMat = SpigotUtil.getXMaterial( prisonBlock );
-
- if ( PrisonBlock.IGNORE.equals( prisonBlock )) {
- xMat = XMaterial.BARRIER;
- }
- if ( xMat == null ) {
- xMat = XMaterial.STONE;
- }
-
- gui.addButton(new Button(null, xMat, lore, "&a" +
- prisonBlock.getBlockName().toUpperCase() + " &0" + mineName + " " + counter));
+ PrisonBlock prisonBlock = blockTypes.get( i );
+
+ XMaterial xMat = SpigotUtil.getXMaterial( prisonBlock );
+
+ if ( PrisonBlock.IGNORE.equals( prisonBlock )) {
+ xMat = XMaterial.BARRIER;
+ }
+ if ( xMat == null ) {
+ xMat = XMaterial.STONE;
+ }
+
+ gui.addButton(new Button(null, xMat, lore, "&a" +
+ prisonBlock.getBlockName().toUpperCase() + " &0" + mineName + " " + counter));
}
if ( i < blockTypes.size() ) {
- gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore(
- guiPageNextMsg(), null), "&7Next &0" + mineName + " " + (i + 1)));
+ gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore(
+ guiPageNextMsg(), null), "&7Next &0" + mineName + " " + (i + 1)));
}
if ( i >= (pageSize * 2) ) {
- gui.addButton(new Button(51, XMaterial.BOOK, new ButtonLore(
- guiPagePriorMsg(), null), "&7Prior &0" + mineName + " " + (i - (pageSize * 2) - 1)));
+ gui.addButton(new Button(51, XMaterial.BOOK, new ButtonLore(
+ guiPagePriorMsg(), null), "&7Prior &0" + mineName + " " + (i - (pageSize * 2) - 1)));
}
// Open the inventory
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java
index 87af6340c..c578e6d74 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesBlocksGUI.java
@@ -52,33 +52,33 @@ public void open(){
// For every block makes a button
for (PrisonBlock block : m.getPrisonBlocks()) {
- // Get the block material as a string and displayname
- String blockmaterial = block.getBlockName();
- String blockmaterialdisplay = blockmaterial;
-
- // Check if a block's air and changed the item of it to BARRIER
- if (blockmaterial.equalsIgnoreCase("air")){
- blockmaterial = "BARRIER";
- blockmaterialdisplay = blockmaterial;
- }
-
- // Get XMaterial.
- XMaterial xMat = SpigotUtil.getXMaterial(blockmaterial);
- if (PrisonBlock.IGNORE.getBlockName().equalsIgnoreCase(blockmaterial)) {
- xMat = XMaterial.BARRIER;
- }
- if (xMat == null ) {
- xMat = XMaterial.STONE;
- }
-
- ButtonLore blocksLore = new ButtonLore(createLore(loreClickToEditBlock, loreShiftRightClickToDelete), createLore(loreInfo));
-
- // Add a lore
- blocksLore.addLineLoreDescription( loreChance + block.getChance() + "%" );
- blocksLore.addLineLoreDescription( loreBlockType + blockmaterial );
-
- // Add the button to the GUI.
- gui.addButton(new Button(null, xMat, blocksLore, "&3" + blockmaterialdisplay + " " + mineName + " " + block.getChance()));
+ // Get the block material as a string and displayname
+ String blockmaterial = block.getBlockName();
+ String blockmaterialdisplay = blockmaterial;
+
+ // Check if a block's air and changed the item of it to BARRIER
+ if (blockmaterial.equalsIgnoreCase("air")){
+ blockmaterial = "BARRIER";
+ blockmaterialdisplay = blockmaterial;
+ }
+
+ // Get XMaterial.
+ XMaterial xMat = SpigotUtil.getXMaterial(blockmaterial);
+ if (PrisonBlock.IGNORE.getBlockName().equalsIgnoreCase(blockmaterial)) {
+ xMat = XMaterial.BARRIER;
+ }
+ if (xMat == null ) {
+ xMat = XMaterial.STONE;
+ }
+
+ ButtonLore blocksLore = new ButtonLore(createLore(loreClickToEditBlock, loreShiftRightClickToDelete), createLore(loreInfo));
+
+ // Add a lore
+ blocksLore.addLineLoreDescription( loreChance + block.getChance() + "%" );
+ blocksLore.addLineLoreDescription( loreBlockType + blockmaterial );
+
+ // Add the button to the GUI.
+ gui.addButton(new Button(null, xMat, blocksLore, "&3" + blockmaterialdisplay + " " + mineName + " " + block.getChance()));
}
// Open the inventory
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java
index 3493c0a1e..8f9555394 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/mine/SpigotMinesGUI.java
@@ -30,7 +30,6 @@ public class SpigotMinesGUI
extends SpigotGUIMessages {
private final Player p;
-// private int counter;
private int page = 0;
private String cmdPage;
@@ -43,7 +42,6 @@ public SpigotMinesGUI(Player p, int page, String cmdPage, String cmdReturn ) {
this.cmdPage = cmdPage;
this.cmdReturn = cmdReturn;
-// this.counter = counter;
}
public void open(){
@@ -70,9 +68,6 @@ public void open(){
- // Get the dimensions and if needed increases them
-// int dimension = 54;
-// int pageSize = 45;
// Create GUI.
PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3MinesManager -> Mines");
@@ -116,12 +111,12 @@ public void open(){
double totalChance = 0.0d;
for (PrisonBlock block : m.getPrisonBlocks()) {
- double chance = Math.round(block.getChance() * 100.0d) / 100.0d;
- totalChance += chance;
-
- String blockName =
- StringUtils.capitalize(block.getBlockName().replaceAll("_", " ").toLowerCase());
- minesLore.addLineLoreDescription("&7" + chance + "% - " + block.getBlockName() + " (" + blockName + ")");
+ double chance = Math.round(block.getChance() * 100.0d) / 100.0d;
+ totalChance += chance;
+
+ String blockName =
+ StringUtils.capitalize(block.getBlockName().replaceAll("_", " ").toLowerCase());
+ minesLore.addLineLoreDescription("&7" + chance + "% - " + block.getBlockName() + " (" + blockName + ")");
}
if (totalChance < 100.0d) {
@@ -133,67 +128,11 @@ public void open(){
}
-// // Only loop over the blocks that we need to show:
-// int i = counter;
-// for ( ; i < mines.getSortedList().size() && i < counter + pageSize; i++ ) {
-//
-// Mine m = mines.getSortedList().get(i);
-//
-// ButtonLore minesLore = new ButtonLore(createLore(
-// loreLeftClickOpen,
-// loreShiftRightClickToDelete
-// ), createLore(loreInfo));
-//
-// // Add a lore
-// minesLore.addLineLoreDescription("&7" + loreWorld + " &b" + m.getWorldName());
-// String spawnPoint = m.getSpawn() != null ? m.getSpawn().toBlockCoordinates() : "&cnot set";
-// minesLore.addLineLoreDescription("&7" + loreSpawnPoint + " &b" + spawnPoint);
-// minesLore.addLineLoreDescription("&7" + loreResetTime + " &b" + m.getResetTime());
-//
-// if (!m.isVirtual()) {
-// // Add a lore
-// minesLore.addLineLoreDescription("&7" + loreSizeOfMine + " &b" + m.getBounds().getDimensions());
-// minesLore.addLineLoreDescription("&7" + loreVolume + " &b" + m.getBounds().getTotalBlockCount());
-// }
-//
-// // Add a lore
-// minesLore.addLineLoreDescription("&7" + loreBlocks);
-//
-// // Init some variables and do the actions
-// DecimalFormat dFmt = Prison.get().getDecimalFormat("##0.00");
-// double totalChance = 0.0d;
-//
-//
-// for (PrisonBlock block : m.getPrisonBlocks()) {
-// double chance = Math.round(block.getChance() * 100.0d) / 100.0d;
-// totalChance += chance;
-//
-// String blockName =
-// StringUtils.capitalize(block.getBlockName().replaceAll("_", " ").toLowerCase());
-// minesLore.addLineLoreDescription("&7" + chance + "% - " + block.getBlockName() + " (" + blockName + ")");
-// }
-//
-// if (totalChance < 100.0d) {
-// minesLore.addLineLoreDescription("&e " + dFmt.format(100.0d - totalChance) + "% - Air");
-// }
-//
-// gui.addButton(new Button(null, XMaterial.COAL_ORE, minesLore, "&3" + m.getName()));
-// }
-
-// if (i < mines.getSortedList().size()) {
-// gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_next_page), null), "&7Next " + (i + 1)));
-// }
-// if (i >= (pageSize * 2)) {
-// gui.addButton(new Button(51, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_prior_page), null), "&7Prior " + (i - (pageSize * 2) - 1)));
-// }
-
-
// Add the page controls:
// The controls for the standard menu are in positions: 4, 5, and 6:
SpigotGUIMenuTools.getInstance().addMenuPageButtonsStandard( gui, guiPageData );
-
// Open the GUI.
gui.open();
}
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 a86dea2c8..cc6324722 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
@@ -74,24 +74,6 @@ public void open() {
List minesDisplay = mines.getSortedList().subList( guiPageData.getPosStart(), guiPageData.getPosEnd() );
-
-
-// // Get the dimensions and if needed increases them
-// int dimension = (int) Math.ceil(mines.getSortedList().size() / 9D) * 9;
-//
-// // If the inventory is empty
-// if (dimension == 0){
-// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_gui_mines_empty));
-// p.closeInventory();
-// return;
-// }
-//
-// // If the dimension's too big, don't open the GUI
-// if (dimension > 54){
-// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_gui_mines_too_many));
-// p.closeInventory();
-// return;
-// }
GuiConfig guiConfigClass = new GuiConfig();
guiConfig = guiConfigClass.getFileGuiConfig();
@@ -109,7 +91,7 @@ public void open() {
String noMineAccessBlockType = guiConfig.getString( "Options.Mines.MaterialType.NoMineAccess" );
if ( noMineAccessBlockType == null ) {
- noMineAccessBlockType = XMaterial.REDSTONE_BLOCK.name();
+ noMineAccessBlockType = XMaterial.REDSTONE_BLOCK.name();
}
else {
// Validate that it is valid, otherwise use redstone_block:
@@ -123,7 +105,6 @@ public void open() {
// Make the buttons for every Mine with info
for (Mine m : minesDisplay) {
-// for (Mine m : mines.getSortedList()) {
String guiItemName = guiConfig.getString( "Options.Mines.GuiItemNames." + m.getName() );
@@ -133,14 +114,13 @@ public void open() {
// If a mine has custom LORE, then try to load it:
- String mineLoreKey = "EditableLore.Mine." + m.getName();
- List mineLore = new ArrayList<>( configCustomLore );
- List mineLore2 = guiConfig.getStringList( mineLoreKey );
- mineLore.addAll( mineLore2 );
+ String mineLoreKey = "EditableLore.Mine." + m.getName();
+ List mineLore = new ArrayList<>( configCustomLore );
+ List mineLore2 = guiConfig.getStringList( mineLoreKey );
+ mineLore.addAll( mineLore2 );
XMaterial xMat = XMaterial.matchXMaterial( noMineAccessBlockType ).orElse(null);
-// XMaterial xMat = XMaterial.REDSTONE_BLOCK;
// Bug: Cannot safely use Material due to variants prior to bukkit v1.13:
// Material material;
@@ -160,9 +140,6 @@ public void open() {
m.getTag() != null ? m.getTag() :
m.getName();
-// // Add mineName lore for TP.
-// minesLore.addLineLoreAction( "&3" + mineName );
-
boolean hasMineAccess = m.hasMiningAccess(spigotPlayer);
String permMineAccess = permission + m.getName();
@@ -179,68 +156,61 @@ public void open() {
hasPerm )
{
- if ( !hasMineAccess ) {
- Output.get().logInfo(
- "GUI Player Mines: Has access to mine %s through perms: %s=%s OR %s=%s",
- m.getName(),
- permMineAccess, Boolean.toString(hasPermMine),
- permAccess, Boolean.toString(hasPerm)
- );
- }
+ if ( !hasMineAccess ) {
+ Output.get().logInfo(
+ "GUI Player Mines: Has access to mine %s through perms: %s=%s OR %s=%s",
+ m.getName(),
+ permMineAccess, Boolean.toString(hasPermMine),
+ permAccess, Boolean.toString(hasPerm)
+ );
+ }
- // Default to COAL_ORE since the player has access to the mine:
- {
- xMat = XMaterial.COAL_ORE;
-
- String defaultMineAccessXmat = guiConfig.getString(
- "Options.Mines.MaterialType.HasMineAccess","COAL_ORE");
- try {
- XMaterial xMatTemp = SpigotUtil.getXMaterial( defaultMineAccessXmat );
- if ( xMatTemp != null ) {
- xMat = xMatTemp;
+ // Default to COAL_ORE since the player has access to the mine:
+ {
+ xMat = XMaterial.COAL_ORE;
+
+ String defaultMineAccessXmat = guiConfig.getString(
+ "Options.Mines.MaterialType.HasMineAccess","COAL_ORE");
+ try {
+ XMaterial xMatTemp = SpigotUtil.getXMaterial( defaultMineAccessXmat );
+ if ( xMatTemp != null ) {
+ xMat = xMatTemp;
+ }
+ }
+ catch (Exception e) {
}
- }
- catch (Exception e) {
- }
- }
- // xMat = XMaterial.COAL_ORE;
+ }
- // The valid names to use for Options.Mines.MaterialType. must be
- // based upon the XMaterial enumeration name, or supported past names.
-// Material mineMaterial = null;
- String materialTypeStr = guiConfig.getString("Options.Mines.MaterialType." + m.getName());
-
- if ( materialTypeStr != null && materialTypeStr.trim().length() > 0 ) {
-
- XMaterial xMatTemp = SpigotUtil.getXMaterial( materialTypeStr );
- if ( xMatTemp == null ) {
- Output.get().logInfo( "Warning: A block was specified for mine '%s' but it was " +
- "unable to be mapped to a valid XMaterial type. Key = " +
- "[Options.Mines.MaterialType.%s] value = " +
- "[%s] Please use valid material names as found in the XMaterial " +
- "source on git hub: " +
- "https://github.com/CryptoMorin/XSeries/blob/master/src/main/java/" +
- "com/cryptomorin/xseries/XMaterial.java ",
- m.getName(), m.getName(), materialTypeStr );
- }
- else {
- xMat = xMatTemp;
- }
- }
-
- lockStatus = statusUnlockedMine;
+ // The valid names to use for Options.Mines.MaterialType. must be
+ // based upon the XMaterial enumeration name, or supported past names.
+ String materialTypeStr = guiConfig.getString("Options.Mines.MaterialType." + m.getName());
+
+ if ( materialTypeStr != null && materialTypeStr.trim().length() > 0 ) {
+
+ XMaterial xMatTemp = SpigotUtil.getXMaterial( materialTypeStr );
+ if ( xMatTemp == null ) {
+ Output.get().logInfo( "Warning: A block was specified for mine '%s' but it was " +
+ "unable to be mapped to a valid XMaterial type. Key = " +
+ "[Options.Mines.MaterialType.%s] value = " +
+ "[%s] Please use valid material names as found in the XMaterial " +
+ "source on git hub: " +
+ "https://github.com/CryptoMorin/XSeries/blob/master/src/main/java/" +
+ "com/cryptomorin/xseries/XMaterial.java ",
+ m.getName(), m.getName(), materialTypeStr );
+ }
+ else {
+ xMat = xMatTemp;
+ }
+ }
+
+ lockStatus = statusUnlockedMine;
- // material = ( mineMaterial == null ? Material.COAL_ORE : mineMaterial);
-// minesLore.addLineLoreDescription( statusUnlockedMine );
-// minesLore.addLineLoreAction( clickToTeleport );
}
else {
- xMat = XMaterial.REDSTONE_BLOCK;
+ xMat = XMaterial.REDSTONE_BLOCK;
-// material = XMaterial.REDSTONE_BLOCK.parseMaterial();
-// minesLore.addLineLoreDescription( statusLockedMine );
}
// Get mine Tag, but make sure it is valid and the mine's name is not null:
@@ -248,36 +218,36 @@ public void open() {
if ( m.getTag() != null &&
!m.getTag().equalsIgnoreCase("null") &&
!m.getTag().equalsIgnoreCase("none") ) {
- mineTag = m.getTag();
+ mineTag = m.getTag();
}
DecimalFormat iFmt = Prison.get().getDecimalFormatInt();
for (String stringValue : mineLore) {
-
- double volume = ( m.isVirtual() ? 0 : m.getBounds().getTotalBlockCount() );
- double remaining = volume * m.getPercentRemainingBlockCount() / 100.0;
-
- String dimensions = ( m.isVirtual() ? "virtual" : m.getBounds().getDimensions() );
-
- stringValue = stringValue.replace( "{mineName}", mineName );
- stringValue = stringValue.replace( "{mineTag}", mineTag );
- stringValue = stringValue.replace( "{mineSize}", dimensions );
- stringValue = stringValue.replace( "{mineVolume}", iFmt.format( volume ));
- stringValue = stringValue.replace( "{mineRemaining}", iFmt.format( remaining ));
- stringValue = stringValue.replace( "{mineRemainingPercent}", iFmt.format( m.getPercentRemainingBlockCount() ));
-
- stringValue = stringValue.replace( "{clickToTeleport}", clickToTeleport );
- stringValue = stringValue.replace( "{lockStatus}", lockStatus );
-
- stringValue = stringValue.replace( "{playerCount}", iFmt.format( m.getPlayerCount()) );
-
- if ( m.getRank() == null ) {
- stringValue = stringValue.replace( "{linkedRank}", "Not linked" );
- }
- else {
- stringValue = stringValue.replace( "{linkedRank}", m.getRank().getTag() );
- }
+
+ double volume = ( m.isVirtual() ? 0 : m.getBounds().getTotalBlockCount() );
+ double remaining = volume * m.getPercentRemainingBlockCount() / 100.0;
+
+ String dimensions = ( m.isVirtual() ? "virtual" : m.getBounds().getDimensions() );
+
+ stringValue = stringValue.replace( "{mineName}", mineName );
+ stringValue = stringValue.replace( "{mineTag}", mineTag );
+ stringValue = stringValue.replace( "{mineSize}", dimensions );
+ stringValue = stringValue.replace( "{mineVolume}", iFmt.format( volume ));
+ stringValue = stringValue.replace( "{mineRemaining}", iFmt.format( remaining ));
+ stringValue = stringValue.replace( "{mineRemainingPercent}", iFmt.format( m.getPercentRemainingBlockCount() ));
+
+ stringValue = stringValue.replace( "{clickToTeleport}", clickToTeleport );
+ stringValue = stringValue.replace( "{lockStatus}", lockStatus );
+
+ stringValue = stringValue.replace( "{playerCount}", iFmt.format( m.getPlayerCount()) );
+
+ if ( m.getRank() == null ) {
+ stringValue = stringValue.replace( "{linkedRank}", "Not linked" );
+ }
+ else {
+ stringValue = stringValue.replace( "{linkedRank}", m.getRank().getTag() );
+ }
minesLore.addLineLoreAction( stringValue );
@@ -294,7 +264,6 @@ public void open() {
Button itemMine = new Button(null, xMat, minesLore, mineName );
-// Button itemMine = new Button(null, xMat, minesLore, "&3" + mineTag);
String mineTeleportCommand =
Output.stringFormat(
@@ -313,21 +282,6 @@ public void open() {
// Add the button to the inventory.
gui.addButton( itemMine );
-
-// String mineTag = m.getTag();
-//
-// // Check if mineName's null (which shouldn't be) and do actions.
-// if (mineName != null) {
-//
-// if (mineTag == null || mineTag.equalsIgnoreCase("null")){
-// mineTag = mineName;
-// }
-//
-// // Add the button to the inventory.
-// gui.addButton(new Button(null, xMat, minesLore, "&3" + mineTag));
-//// gui.addButton(new Button(null, XMaterial.matchXMaterial(material), minesLore, "&3" + mineTag));
-// }
-
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java
index 95c3b9a6a..36355ed0a 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotConfirmPrestigeGUI.java
@@ -26,42 +26,21 @@ public SpigotConfirmPrestigeGUI(Player player, List lore ) {
public void open(){
- // Create the inventory
- int dimension = 9;
- PrisonGUI gui = new PrisonGUI( player, dimension, "&3Prestige -> Confirmation");
-
- ButtonLore confirmLore = new ButtonLore(createLore(
- guiClickToConfirmMsg()), lore );
-
- ButtonLore cancelLore = new ButtonLore( guiClickToCancelMsg(), null);
-
-
- // Create the button, set up the material, amount, lore and name
- gui.addButton(new Button(2, XMaterial.EMERALD_BLOCK, confirmLore, "&3Confirm: Prestige" ));
- gui.addButton(new Button(6, XMaterial.REDSTONE_BLOCK, cancelLore, "&3Cancel: Don't Prestige" ));
-
- gui.open();
+ // Create the inventory
+ int dimension = 9;
+ PrisonGUI gui = new PrisonGUI( player, dimension, "&3Prestige -> Confirmation");
+
+ ButtonLore confirmLore = new ButtonLore(createLore(
+ guiClickToConfirmMsg()), lore );
+
+ ButtonLore cancelLore = new ButtonLore( guiClickToCancelMsg(), null);
+
+
+ // Create the button, set up the material, amount, lore and name
+ gui.addButton(new Button(2, XMaterial.EMERALD_BLOCK, confirmLore, "&3Confirm: Prestige" ));
+ gui.addButton(new Button(6, XMaterial.REDSTONE_BLOCK, cancelLore, "&3Cancel: Don't Prestige" ));
+
+ gui.open();
}
-// public void open(){
-//
-// // Create the inventory
-// int dimension = 9;
-// PrisonGUI gui = new PrisonGUI(p, dimension, "&3Prestige -> Confirmation");
-//
-// ButtonLore confirmLore = new ButtonLore(createLore(
-// guiClickToConfirmMsg()), createLore(
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_prestige_warning_1),
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_prestige_warning_2),
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_prestige_warning_3)));
-//
-// ButtonLore cancelLore = new ButtonLore( guiClickToCancelMsg(), null);
-//
-//
-// // Create the button, set up the material, amount, lore and name
-// gui.addButton(new Button(2, XMaterial.EMERALD_BLOCK, confirmLore, "&3Confirm: Prestige" ));
-// gui.addButton(new Button(6, XMaterial.REDSTONE_BLOCK, cancelLore, "&3Cancel: Don't Prestige" ));
-//
-// gui.open();
-// }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java
index f74411182..953f6bfae 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotLaddersGUI.java
@@ -27,7 +27,6 @@ public class SpigotLaddersGUI
private int page;
private String cmdPage;
private String cmdReturn;
-// private int counter;
public SpigotLaddersGUI(Player p, int page, String cmdPage, String cmdReturn ) {
this.p = p;
@@ -35,7 +34,6 @@ public SpigotLaddersGUI(Player p, int page, String cmdPage, String cmdReturn ) {
this.page = page;
this.cmdPage = cmdPage;
this.cmdReturn = cmdReturn;
-// this.counter = counter;
}
public void open(){
@@ -50,11 +48,10 @@ public void open(){
// If the inventory is empty
if (lm == null || lm.getLadders().size() == 0){
- guiRanksLadderIsEmptyMsg( new SpigotPlayer(p), "" );
+ guiRanksLadderIsEmptyMsg( new SpigotPlayer(p), "" );
p.closeInventory();
return;
}
-
int totalArraySize = lm.getLadders().size();
@@ -65,11 +62,6 @@ public void open(){
List laddersDisplay = lm.getLadders().subList( guiPageData.getPosStart(), guiPageData.getPosEnd() );
-
-
-// // Get the dimensions and if needed increases them
-// int dimension = 54;
-// int pageSize = 45;
PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3RanksManager -> Ladders");
@@ -79,7 +71,7 @@ public void open(){
for ( RankLadder ladder : laddersDisplay ) {
- gui.addButton(new Button(null, XMaterial.LADDER, laddersLore, "&3" + ladder.getName() ));
+ gui.addButton(new Button(null, XMaterial.LADDER, laddersLore, "&3" + ladder.getName() ));
}
@@ -89,27 +81,6 @@ public void open(){
-// // Only loop over the blocks that we need to show:
-// int i = counter;
-// for ( ; i < lm.getLadders().size() && i < counter + pageSize; i++ ) {
-//
-// // WARNING: This is wrong... a ladder's ID is NOT the same as it's position in a collection.
-// // The ladder ID is a damn magic number and cannot be predictable!
-//
-//// RankLadder ladder = lm.getLadder(i);
-//
-// // Add the button to the inventory
-// gui.addButton(new Button(null, XMaterial.LADDER, laddersLore, "&3" + ladder.getName())));
-// }
-
-// if (i < lm.getLadders().size()) {
-// gui.addButton(new Button(53, XMaterial.BOOK, 1, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_next_page), null), "&7Next " + (i + 1)));
-// }
-// if (i >= (pageSize * 2)) {
-// gui.addButton(new Button(51, XMaterial.BOOK, 1, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_prior_page), null),
-// "&7Prior " + (i - (pageSize * 2) - 1)));
-// }
-
// Open the inventory
gui.open();
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerPrestigesGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerPrestigesGUI.java
index 7d311f3e9..1512c433b 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerPrestigesGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotPlayerPrestigesGUI.java
@@ -138,11 +138,6 @@ public void open() {
-
-
-// Create the inventory and set up the owner, dimensions or number of slots, and title
-// int dimension = (int) (Math.ceil(ladder.getRanks().size() / 9D) * 9) + 9;
-
PrisonGUI gui = new PrisonGUI(getPlayer(), guiPageData.getDimension(),
guiConfig.getString("Options.Titles.PlayerPrestigesGUI"));
@@ -150,22 +145,12 @@ public void open() {
String guiItemNameDefaultSetting = guiConfig.getString( "Options.Ranks.GuiItemNameDefault" );
-
- // dead code:
-// if ( ladder == null ){
-// Output.get().sendWarn(new SpigotPlayer(player), messages.getString("Message.LadderPrestigesNotFound"));
-// return;
-// }
-
if (!ladder.getLowestRank().isPresent()){
guiRanksPrestigesLadderIsEmptyMsg( new SpigotPlayer(player) );
return;
}
-// Rank rank = ladder.getLowestRank().get();
RankPlayerFactory rankPlayerFactory = new RankPlayerFactory();
-// PlayerRank prestigePlayerRank = rankPlayerFactory.getRank( getRankPlayer(), "prestiges");
-// Rank playerRank = prestigePlayerRank == null ? null : prestigePlayerRank.getRank();
XMaterial materialHas;
XMaterial materialHasNot;
@@ -184,12 +169,10 @@ public void open() {
}
// Variables.
-// boolean playerHasThisRank = true;
int hackyCounterEnchant = 0;
// Global strings.
String loreInfo = guiRanksLoreInfoMsg();
-// String lorePrice3 = messages.getString(MessagesConfig.StringID.spigot_gui_lore_price);
// Global boolean.
boolean enchantmentEffectEnabled = getBoolean(guiConfig.getString("Options.Ranks.Enchantment_effect_current_rank"));
@@ -219,13 +202,6 @@ public void open() {
// hasAccess uses access by rank, and access by perm:
boolean playerHasThisRank = getRankPlayer() != null && getRankPlayer().hasAccessToRank( rank );
-// int amount = 1;
-// while ( rank != null ) {
-
- // Need to create a new PlayerRank specifically for the player which takes in to consideration
- // all of their multipliers.
-// PlayerRank pRank = rankPlayerFactory.createPlayerRank( rank );
-// PlayerRank targetPlayerRank = pRank.getTargetPlayerRankForPlayer( rankPlayer, rank );
PlayerRank pRank = rankPlayerFactory.getRank( getRankPlayer(), rank.getLadder() );
@@ -241,9 +217,6 @@ public void open() {
}
}
-// if (playerRank != null && playerRank.equals( rank )){
-// playerHasThisRank = false;
-// }
XMaterial hasRankMsg = playerHasThisRank ? materialHas : materialHasNot;
@@ -260,18 +233,13 @@ public void open() {
gui.addButton(itemrank);
rank = rank.getRankNext();
-// if (amount > 45){
-// break;
-// }
}
-
// Add the page controls:
// The controls for the standard menu are in positions: 4, 5, and 6:
SpigotGUIMenuTools.getInstance().addMenuPageButtonsStandard( gui, guiPageData );
-
if (Prison.get().getPlatform().getConfigBooleanTrue( "ranks.gui-prestiges-include-rankup-button") ) {
@@ -282,7 +250,6 @@ public void open() {
gui.addButton( guiPageData.setButtonNextAvailable( rankupButton ) );
}
-
// Open GUI.
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 c2d46b010..3d8d1b85b 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
@@ -48,9 +48,8 @@ public class SpigotPlayerRanksGUI
private PrisonRanks rankPlugin;
private RankPlayer rankPlayer;
private final boolean placeholderAPINotNull =
- Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null ||
- Bukkit.getPluginManager().getPlugin("PlaceholdersAPI") != null;
-// private final List configCustomLore = guiConfig.getStringList("EditableLore.Ranks");
+ Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null ||
+ Bukkit.getPluginManager().getPlugin("PlaceholdersAPI") != null;
private String ladderName;
private int page = 0;
@@ -88,7 +87,7 @@ public SpigotPlayerRanksGUI(Player player, String ladderName, int page, String c
}
PlayerManager playerManager = rankPlugin.getPlayerManager();
- rPlayer = playerManager.getPlayer( player.getUniqueId(), player.getName() );
+ rPlayer = playerManager.getPlayer( player.getUniqueId(), player.getName() );
Plugin plugin = server.getPluginManager().getPlugin( PrisonRanks.MODULE_NAME );
if (plugin instanceof PrisonRanks) {
@@ -124,7 +123,6 @@ public void open() {
LadderManager lm = getRankPlugin().getLadderManager();
RankLadder ladder = lm.getLadder( ladderName );
-// RankLadder ladder = lm.getLadder(guiConfig.getString("Options.Ranks.Ladder"));
// Ensure ladder is present and that it has a rank:
if ( ladder == null || !ladder.getLowestRank().isPresent()){
@@ -147,13 +145,6 @@ public void open() {
List ranksDisplay = ladder.getRanks().subList( guiPageData.getPosStart(), guiPageData.getPosEnd() );
- // Get many parameters
-// RankPlayerFactory rankPlayerFactory = new RankPlayerFactory();
-// Rank rank = ladder.getLowestRank().get();
-// PlayerRank playerRankRank = rankPlayerFactory.getRank( getRankPlayer(), guiConfig.getString("Options.Ranks.Ladder"));
-
-
-// Rank playerRank = playerRankRank == null ? null : playerRankRank.getRank();
PrisonGUI gui = new PrisonGUI(getPlayer(), guiPageData.getDimension(), guiConfig.getString("Options.Titles.PlayerRanksGUI"));
@@ -181,7 +172,6 @@ public void open() {
int amount = guiPageData.getPosStart();
-// int amount = 1;
// Global booleans.
boolean enchantmentEffectEnabled = getBoolean(guiConfig.getString("Options.Ranks.Enchantment_effect_current_rank"));
@@ -219,27 +209,26 @@ public void open() {
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.matchXMaterial( materialTypeStr ).orElse(null);
-
- materialType =
- !playerHasThisRank ? materialHasNot :
- materialType != null ? materialType :
- materialHas;
-
- String rankLoreKey = "EditableLore.Rank." + ladderName + "." + rank.getName();
- List rankLore = new ArrayList<>( configCustomLore );
- List rankLore2 = guiConfig.getStringList( rankLoreKey );
- rankLore.addAll( rankLore2 );
-
+ // 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.matchXMaterial( materialTypeStr ).orElse(null);
+
+ materialType =
+ !playerHasThisRank ? materialHasNot :
+ materialType != null ? materialType :
+ materialHas;
+
+ String rankLoreKey = "EditableLore.Rank." + ladderName + "." + rank.getName();
+ List rankLore = new ArrayList<>( configCustomLore );
+ List rankLore2 = guiConfig.getStringList( rankLoreKey );
+ rankLore.addAll( rankLore2 );
+
ButtonLore ranksLore = new ButtonLore();
PlayerRank calPRank = rankPlayer.calculateTargetPlayerRank( rank );
-// PlayerRank calPRank = pRank.getTargetPlayerRankForPlayer( rankPlayer, rank );
double rankPrice = calPRank.getRankCost();
double rankMultiplier = calPRank.getRankMultiplier();
@@ -247,24 +236,24 @@ public void open() {
StringBuilder sbMines = new StringBuilder();
if ( rank.getMines() != null && rank.getMines().size() > 0 ) {
- for (ModuleElement mine : rank.getMines() ) {
- if ( sbMines.length() > 0 ) {
- sbMines.append( " " );
- }
- sbMines.append( mine.getTag() );
- }
+ for (ModuleElement mine : rank.getMines() ) {
+ if ( sbMines.length() > 0 ) {
+ sbMines.append( " " );
+ }
+ sbMines.append( mine.getTag() );
+ }
}
else {
- sbMines.append( "&3None" );
+ sbMines.append( "&3None" );
}
for ( String stringValue : rankLore ) {
- String currency = (rank.getCurrency() == null ||
- "default".equalsIgnoreCase( rank.getCurrency()) ||
- rank.getCurrency().trim().length() == 0 ?
- "" : " " + rank.getCurrency() );
-
+ String currency = (rank.getCurrency() == null ||
+ "default".equalsIgnoreCase( rank.getCurrency()) ||
+ rank.getCurrency().trim().length() == 0 ?
+ "" : " " + rank.getCurrency() );
+
stringValue = stringValue.replace("{rankPrice}",
PlaceholdersUtil.formattedKmbtSISize(
rankPrice, formatDecimal, "") + currency
@@ -282,9 +271,9 @@ public void open() {
if ( placeholderAPINotNull ) {
- List lores = PlaceholderAPI.setPlaceholders(
- Bukkit.getOfflinePlayer(player.getUniqueId()),
- ranksLore.getLoreAction());
+ List lores = PlaceholderAPI.setPlaceholders(
+ Bukkit.getOfflinePlayer(player.getUniqueId()),
+ ranksLore.getLoreAction());
ranksLore.setLoreAction( lores );
}
@@ -297,9 +286,6 @@ public void open() {
amount++;
-// if (playerRank != null && playerRank.equals(rank)){
-// playerHasThisRank = false;
-// }
if (!(playerHasThisRank)){
if (hackyCounterEnchant <= 0) {
@@ -323,7 +309,6 @@ public void open() {
gui.addButton(itemRank);
-// rank = rank.getRankNext();
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java
index 5a183d174..7cd046958 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankPriceGUI.java
@@ -35,8 +35,6 @@ public void open() {
PrisonGUI gui = new PrisonGUI(p, dimension, "&3RankManager -> RankPrice");
ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null);
-// ButtonLore changeDecreaseValueLore = new ButtonLore(
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null);
ButtonLore confirmButtonLore = new ButtonLore(createLore(
guiLeftClickToConfirmMsg(),
@@ -44,8 +42,6 @@ public void open() {
createLore( guiPriceMsg(val) ));
ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null);
-// ButtonLore changeIncreaseValueLore = new ButtonLore(
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null);
XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK;
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java
index c8f398838..b2f0a6518 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRankUPCommandsGUI.java
@@ -46,14 +46,14 @@ public void open() {
// If the inventory is empty
if (dimension == 0){
- guiRanksErrorEmptyMsg( new SpigotPlayer(p) );
+ guiRanksErrorEmptyMsg( new SpigotPlayer(p) );
p.closeInventory();
return;
}
// If the dimension's too big, don't open the GUI
if (dimension > 54){
- guiRanksRankupCommandsTooManyMsg( new SpigotPlayer(p) );
+ guiRanksRankupCommandsTooManyMsg( new SpigotPlayer(p) );
p.closeInventory();
return;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java
index cb392ec87..b39d2f6d3 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/rank/SpigotRanksGUI.java
@@ -26,7 +26,6 @@ public class SpigotRanksGUI
private final Player p;
private final RankLadder ladder;
-// private int counter;
private int page = 0;
private String cmdPage;
@@ -40,7 +39,6 @@ public SpigotRanksGUI( Player p, RankLadder ladder, int page, String cmdPage, St
this.cmdPage = cmdPage;
this.cmdReturn = cmdReturn;
-// this.counter = counter;
}
public void open(){
@@ -66,10 +64,6 @@ public void open(){
- // Get the dimensions and if required increases them
-// int dimension = 54;
-// int pageSize = 45;
-
PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3Ladders -> Ranks");
// Global Strings.
@@ -79,7 +73,6 @@ public void open(){
String loreId = guiRanksLoreIdMsg();
String loreName = guiRanksLoreNameMsg();
String loreTag2 = guiRanksLoreRankTagMsg();
-// String lorePrice3 = messages.getString(MessagesConfig.StringID.spigot_gui_lore_price);
String lorePlayersWithRank = guiRanksLorePlayersWithRankMsg();
// Decimal Rank cost format.
@@ -89,9 +82,6 @@ public void open(){
for ( Rank rank : ranksDisplay )
{
-// int i = counter;
-// for ( ; i < ladder.get().getRanks().size() && i < counter + pageSize; i++ ) {
-
ButtonLore ranksLore = new ButtonLore(createLore(
loreShiftRightClickDelete,
loreClickToManageRank), createLore(loreInfo));
@@ -119,26 +109,14 @@ public void open(){
// Init a variable
int playerCount = rank.getPlayers().size();
-// List players =
-// PrisonRanks.getInstance().getPlayerManager().getPlayers().stream()
-// .filter(rankPlayer -> rankPlayer.getLadderRanks().containsValue(rank))
-// .collect(Collectors.toList());
// Add the number of players with this rank
ranksLore.addLineLoreDescription( lorePlayersWithRank + " " + playerCount );
// Add the button to the inventory
gui.addButton(new Button( null, XMaterial.TRIPWIRE_HOOK, ranksLore, "&3" + rank.getName() ));
-// gui.addButton(new Button(i - counter, XMaterial.TRIPWIRE_HOOK, ranksLore, "&3" + rank.getName() ));
}
-// if (i < ladder.get().getRanks().size()) {
-// gui.addButton(new Button(53, XMaterial.BOOK, 1, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_next_page), null), "&7Next " + (i + 1)));
-// }
-// if (i >= (pageSize * 2)) {
-// gui.addButton(new Button(51, XMaterial.BOOK, 1, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_prior_page), null),
-// "&7Prior " + (i - (pageSize * 2) - 1)));
-// }
// Add the page controls:
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java
index 90ab2541c..a4ae14404 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminBlocksGUI.java
@@ -24,7 +24,6 @@
public class SellAllAdminBlocksGUI extends SpigotGUIComponents {
private final Player p;
-// private final int startingItem;
private int page = 0;
private String cmdPage;
@@ -37,7 +36,6 @@ public SellAllAdminBlocksGUI( Player p, int page, String cmdPage, String cmdRetu
this.cmdPage = cmdPage;
this.cmdReturn = cmdReturn;
-// this.startingItem = startingItem;
}
public void open() {
@@ -59,10 +57,8 @@ public void open() {
}
if (emptyInv){
- new SpigotVariousGuiMessages().sellallYouHaveNothingToSellMsg( new SpigotCommandSender(p) );
+ new SpigotVariousGuiMessages().sellallYouHaveNothingToSellMsg( new SpigotCommandSender(p) );
-// SpigotPlayer spigotPlayer = new SpigotPlayer(p);
-// Output.get().sendWarn(spigotPlayer, messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_empty));
return;
}
@@ -84,35 +80,32 @@ public void open() {
// Global strings.
String loreLine1 = guiRightClickToDeleteMsg();
String loreLine2 = guiLeftClickToEditMsg();
-// String lorePermission = messages.getString(MessagesConfig.StringID.spigot_gui_lore_permission);
String permissionSellAllBlock = sellAllConfig.getString("Options.Sell_Per_Block_Permission");
-// String loreValue = messages.getString(MessagesConfig.StringID.spigot_gui_lore_value);
boolean sellAllPerBlockPermissionEnabled = getBoolean(sellAllConfig.getString("Options.Sell_Per_Block_Permission_Enabled"));
-// int itemsAdded = 0, itemsRead = 0;
for (String key : itemsDisplay) {
- String itemValue = sellAllConfig.getString("Items." + key + ".ITEM_VALUE");
- String loreValue = guiValueMsg( itemValue );
-
- ButtonLore itemsLore = new ButtonLore(createLore(loreLine1, loreLine2),
- createLore( loreValue ));
-
- String sellallPerm = permissionSellAllBlock + sellAllConfig.getString("Items." + key + ".ITEM_ID");
- String lorePermission = guiPermissionMsg( sellallPerm );
-
- if (sellAllPerBlockPermissionEnabled) {
- itemsLore.addLineLoreDescription( lorePermission );
- }
-
- String xMatIdName = "Items." + key + ".ITEM_ID";
- String xMatId = sellAllConfig.getString( xMatIdName );
-
- XMaterial xMat = SpigotUtil.getXMaterial( xMatId );
-
- if ( xMat == null ) {
+ String itemValue = sellAllConfig.getString("Items." + key + ".ITEM_VALUE");
+ String loreValue = guiValueMsg( itemValue );
+
+ ButtonLore itemsLore = new ButtonLore(createLore(loreLine1, loreLine2),
+ createLore( loreValue ));
+
+ String sellallPerm = permissionSellAllBlock + sellAllConfig.getString("Items." + key + ".ITEM_ID");
+ String lorePermission = guiPermissionMsg( sellallPerm );
+
+ if (sellAllPerBlockPermissionEnabled) {
+ itemsLore.addLineLoreDescription( lorePermission );
+ }
+
+ String xMatIdName = "Items." + key + ".ITEM_ID";
+ String xMatId = sellAllConfig.getString( xMatIdName );
+
+ XMaterial xMat = SpigotUtil.getXMaterial( xMatId );
+
+ if ( xMat == null ) {
// Unable to add match XMaterials:
String message = String.format(
"SellAll Admin Blocks: Unable to match '%s' to a valid XMaterial. Use the command " +
@@ -125,32 +118,12 @@ public void open() {
// Default to cobble
xMat = XMaterial.COBBLESTONE;
- }
-
- gui.addButton(new Button( null, xMat, itemsLore, "&3" + xMatId ));
-
+ }
-// itemsRead++;
-//
-// if (itemsRead >= startingItem) {
-//
-// if (startingItem != 0){
-// gui.addButton(new Button(45, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_prior_page), null), "&7Prior " + (startingItem - 45)));
-// }
-//
-// else if (itemsAdded >= 45){
-// gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_next_page), null), "&7Next " + (startingItem + itemsAdded)));
-// }
-//
-// else if (itemsAdded < 45) {
-// itemsAdded++;
-// }
-// }
+ gui.addButton(new Button( null, xMat, itemsLore, "&3" + xMatId ));
}
-
-
// Add the page controls:
// The controls for the standard menu are in positions: 4, 5, and 6:
SpigotGUIMenuTools.getInstance().addMenuPageButtonsStandard( gui, guiPageData );
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java
index 214fc1a87..978af96e1 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllAdminGUI.java
@@ -23,7 +23,6 @@
public class SellAllAdminGUI extends SpigotGUIComponents {
private final Player p;
-// int dimension = 27;
private int page = 0;
private String cmdPage;
@@ -43,17 +42,14 @@ public void open() {
if ( !SpigotPrison.getInstance().isSellAllEnabled() ){
- new SpigotVariousGuiMessages().sellallIsDisabledMsg( new SpigotCommandSender(p) );
+ new SpigotVariousGuiMessages().sellallIsDisabledMsg( new SpigotCommandSender(p) );
-// Output.get().sendWarn(new SpigotPlayer(p),
-// messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_disabled));
return;
}
updateSellAllConfig();
-
int totalArraySize = 27;
GUIMenuPageData guiPageData = SpigotGUIMenuTools.getInstance()
.createGUIPageObject( totalArraySize, page, cmdPage, cmdReturn );
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java
index 51bde973f..e359386bb 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllDelayGUI.java
@@ -44,12 +44,9 @@ public void open() {
.createGUIPageObject( totalArraySize, page, cmdPage, cmdReturn );
-// int dimension = 45;
PrisonGUI gui = new PrisonGUI(p, guiPageData.getDimension(), "&3SellAll -> Delay");
ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null);
-// ButtonLore changeDecreaseValueLore = new ButtonLore(
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null);
ButtonLore confirmButtonLore = new ButtonLore(createLore(
guiLeftClickToConfirmMsg(),
guiRightClickToCancelMsg() ),
@@ -57,8 +54,6 @@ public void open() {
createLore( guiDelayMsg( val ) ));
ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null);
-// ButtonLore changeIncreaseValueLore = new ButtonLore(
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null);
XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK;
XMaterial increaseMat = XMaterial.EMERALD_BLOCK;
@@ -86,7 +81,6 @@ public void open() {
SpigotGUIMenuTools.getInstance().addMenuPageButtonsNoPaging( gui, guiPageData );
-
gui.open();
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPlayerGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPlayerGUI.java
index df4207bfb..c6b2a7329 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPlayerGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPlayerGUI.java
@@ -21,7 +21,6 @@
public class SellAllPlayerGUI extends SpigotGUIComponents {
private final Player p;
-// private final int startingItem;
private int page = 0;
private String cmdPage;
@@ -34,7 +33,6 @@ public SellAllPlayerGUI( Player p, int page, String cmdPage, String cmdReturn ){
this.cmdPage = cmdPage;
this.cmdReturn = cmdReturn;
-// this.startingItem = startingItem;
}
public void open() {
@@ -54,9 +52,7 @@ public void open() {
if (emptyInv){
- new SpigotVariousGuiMessages().sellallYouHaveNothingToSellMsg( new SpigotCommandSender(p) );
-// Output.get().sendWarn(new SpigotPlayer(p),
-// messages.getString(MessagesConfig.StringID.spigot_message_gui_sellall_empty));
+ new SpigotVariousGuiMessages().sellallYouHaveNothingToSellMsg( new SpigotCommandSender(p) );
return;
}
@@ -79,10 +75,6 @@ public void open() {
- // Global strings.
-// String loreValue = messages.getString(MessagesConfig.StringID.spigot_gui_lore_value);
-
-// int itemsAdded = 0, itemsRead = 0;
for ( String key : itemsDisplay ) {
String itemId = sellAllConfig.getString("Items." + key + ".ITEM_ID");
@@ -95,31 +87,12 @@ public void open() {
new ButtonLore(null, loreValue),
"&3" + itemId));
-
-// itemsRead++;
-
-// if (itemsRead >= startingItem) {
-//
-// if (startingItem != 0){
-// gui.addButton(new Button(45, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_prior_page), null), "&7Prior " + (startingItem - 45)));
-// }
-//
-// if (itemsAdded >= 45){
-// gui.addButton(new Button(53, XMaterial.BOOK, new ButtonLore(messages.getString(MessagesConfig.StringID.spigot_gui_lore_next_page), null), "&7Next " + (startingItem + itemsAdded)));
-// }
-//
-// if (itemsAdded < 45) {
-// gui.addButton(new Button(null, SpigotUtil.getXMaterial(sellAllConfig.getString("Items." + key + ".ITEM_ID")), new ButtonLore(null, loreValue + " " + sellAllConfig.getString("Items." + key + ".ITEM_VALUE")), "&3" + sellAllConfig.getString("Items." + key + ".ITEM_ID")));
-// itemsAdded++;
-// }
-// }
}
// Add the page controls:
// The controls for the standard menu are in positions: 4, 5, and 6:
SpigotGUIMenuTools.getInstance().addMenuPageButtonsStandard( gui, guiPageData );
-
gui.open();
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java
index 3af452f10..91151333f 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesMultiplierGUI.java
@@ -33,8 +33,6 @@ public void open() {
int pageSize = 45;
// Global strings.
-// String lorePrestigeName = messages.getString(MessagesConfig.StringID.spigot_gui_lore_prestige_name);
-// String lorePrestigeMultiplier = messages.getString(MessagesConfig.StringID.spigot_gui_lore_multiplier);
String loreClickToEdit = guiClickToEditMsg();
String loreClickToDelete = guiRightClickToDeleteMsg();
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java
index 5df4b43dd..235737cfa 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPrestigesSetMultiplierGUI.java
@@ -32,8 +32,6 @@ public void open() {
PrisonGUI gui = new PrisonGUI(p, dimension, "&3Edit -> Multiplier");
ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null);
-// ButtonLore changeDecreaseValueLore = new ButtonLore(
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null);
ButtonLore confirmButtonLore = new ButtonLore(createLore(
guiLeftClickToConfirmMsg(),
@@ -41,8 +39,6 @@ public void open() {
createLore( guiMultiplierMsg( val ) ));
ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null);
-// ButtonLore changeIncreaseValueLore = new ButtonLore(
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null);
XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK;
XMaterial increaseMat = XMaterial.EMERALD_BLOCK;
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java
index 1149a5817..a1a6892ec 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/gui/sellall/SellAllPriceGUI.java
@@ -33,8 +33,6 @@ public void open() {
PrisonGUI gui = new PrisonGUI(p, dimension, "&3SellAll -> ItemValue");
ButtonLore changeDecreaseValueLore = new ButtonLore( guiClickToDecreaseMsg(), null);
-// ButtonLore changeDecreaseValueLore = new ButtonLore(
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_decrease), null);
ButtonLore confirmButtonLore = new ButtonLore(createLore(
guiLeftClickToConfirmMsg(),
@@ -42,8 +40,6 @@ public void open() {
createLore( guiPriceMsg( val ) ));
ButtonLore changeIncreaseValueLore = new ButtonLore( guiClickToIncreaseMsg(), null);
-// ButtonLore changeIncreaseValueLore = new ButtonLore(
-// messages.getString(MessagesConfig.StringID.spigot_gui_lore_click_to_increase), null);
XMaterial decreaseMat = XMaterial.REDSTONE_BLOCK;
XMaterial increaseMat = XMaterial.EMERALD_BLOCK;
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationBackpackAPI.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationBackpackAPI.java
index deee9502a..217178307 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationBackpackAPI.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationBackpackAPI.java
@@ -134,182 +134,179 @@ public void setRegisteredListenersCount(int registeredListenersCount) {
public HashMap addItems( Player player, HashMap items ) {
- HashMap extras = new HashMap<>();
-
- if ( items != null && items.size() > 0 && isEnabled() ) {
-
- BackpackEvent bpEvent = new BackpackEvent( player );
- bpEvent.setAction( BackpackAction.addItems );
-
- if ( bpEvent.fireBackpackEvent() ) {
-
- boolean changedBackpack = false;
-
- for ( Inventory inv : bpEvent.getInventory() ) {
+ HashMap extras = new HashMap<>();
+
+ if ( items != null && items.size() > 0 && isEnabled() ) {
+
+ BackpackEvent bpEvent = new BackpackEvent( player );
+ bpEvent.setAction( BackpackAction.addItems );
+
+ if ( bpEvent.fireBackpackEvent() ) {
+
+ boolean changedBackpack = false;
- if ( inv != null ) {
+ for ( Inventory inv : bpEvent.getInventory() ) {
- for ( SpigotItemStack spigotItemStack : items.values() ) {
+ if ( inv != null ) {
- ItemStack iStack = SpigotUtil.prisonItemStackToBukkit( spigotItemStack );
-// ItemStack iStack = spigotItemStack.getBukkitStack();
-
- if ( iStack != null ) {
-
-// extras.putAll( inv.addItem( iStack ));
+ for ( SpigotItemStack spigotItemStack : items.values() ) {
- HashMap extra = inv.addItem( iStack );
+ ItemStack iStack = SpigotUtil.prisonItemStackToBukkit( spigotItemStack );
- Set keys = extra.keySet();
- for ( Integer key : keys ) {
- ItemStack entry = extra.get(key);
+ if ( iStack != null ) {
+
+ HashMap extra = inv.addItem( iStack );
+
+ Set keys = extra.keySet();
+ for ( Integer key : keys ) {
+ ItemStack entry = extra.get(key);
+
+ extras.put( key, new SpigotItemStack(entry) );
+
+ changedBackpack = true;
+ }
+
- extras.put( key, new SpigotItemStack(entry) );
-
- changedBackpack = true;
}
-
-
}
+
}
+
+ // Since we are processing multiple occurrences of inventories, then
+ // we need to reset items to extras so they can be processed in the
+ // next inventory.
+
+ items.clear();
+ items.putAll( extras );
+ extras.clear();
}
+ if ( changedBackpack ) {
+ bpEvent.setResults( BackpackResults.contentsChanged );
+
+ bpEvent.getCallback().run();
+ }
- // Since we are processing multiple occurrences of inventories, then
- // we need to reset items to extras so they can be processed in the
- // next inventory.
-
- items.clear();
- items.putAll( extras );
- extras.clear();
- }
-
- if ( changedBackpack ) {
- bpEvent.setResults( BackpackResults.contentsChanged );
-
- bpEvent.getCallback().run();
}
-
- }
- }
-
-
- // All extras will be in items, so move them back to extras:
- extras.putAll( items );
-
- return extras;
+ }
+
+
+ // All extras will be in items, so move them back to extras:
+ extras.putAll( items );
+
+ return extras;
}
public HashMap addItemsBukkit( Player player, HashMap items ) {
- HashMap extras = new HashMap<>();
-
- if ( items != null && items.size() > 0 && isEnabled() ) {
-
- BackpackEvent bpEvent = new BackpackEvent( player );
- bpEvent.setAction( BackpackAction.addItems );
-
- if ( bpEvent.fireBackpackEvent() ) {
-
- boolean changedBackpack = false;
-
- for ( Inventory inv : bpEvent.getInventory() ) {
+ HashMap extras = new HashMap<>();
+
+ if ( items != null && items.size() > 0 && isEnabled() ) {
+
+ BackpackEvent bpEvent = new BackpackEvent( player );
+ bpEvent.setAction( BackpackAction.addItems );
+
+ if ( bpEvent.fireBackpackEvent() ) {
- if ( inv != null ) {
+ boolean changedBackpack = false;
+
+ for ( Inventory inv : bpEvent.getInventory() ) {
- for ( ItemStack itemStack : items.values() ) {
+ if ( inv != null ) {
- if ( itemStack != null ) {
+ for ( ItemStack itemStack : items.values() ) {
- extras.putAll( inv.addItem( itemStack ));
-
- changedBackpack = true;
+ if ( itemStack != null ) {
+
+ extras.putAll( inv.addItem( itemStack ));
+
+ changedBackpack = true;
+ }
}
+
}
+ // Since we are processing multiple occurrences of inventories, then
+ // we need to reset items to extras so they can be processed in the
+ // next inventory.
+
+ items.clear();
+ items.putAll( extras );
+ extras.clear();
}
- // Since we are processing multiple occurrences of inventories, then
- // we need to reset items to extras so they can be processed in the
- // next inventory.
-
- items.clear();
- items.putAll( extras );
- extras.clear();
- }
-
- if ( changedBackpack ) {
- bpEvent.setResults( BackpackResults.contentsChanged );
-
- bpEvent.getCallback().run();
+ if ( changedBackpack ) {
+ bpEvent.setResults( BackpackResults.contentsChanged );
+
+ bpEvent.getCallback().run();
+ }
}
- }
- }
-
- // All extras will be in items, so put them back in extras:
- extras.putAll( items );
-
- return extras;
+ }
+
+ // All extras will be in items, so put them back in extras:
+ extras.putAll( items );
+
+ return extras;
}
public HashMap smeltItems( Player player, XMaterial source, SpigotItemStack destStack ) {
- HashMap extras = new HashMap<>();
-
- SpigotItemStack sourceStack = new SpigotItemStack( source.parseItem() );
-
- if ( isEnabled() && sourceStack != null && destStack != null ) {
-
- BackpackEvent bpEvent = new BackpackEvent( player );
- bpEvent.setAction( BackpackAction.smeltItems );
-
- if ( bpEvent.fireBackpackEvent() ) {
-
- boolean changedBackpack = false;
-
- for ( Inventory inv : bpEvent.getInventory() ) {
+ HashMap extras = new HashMap<>();
+
+ SpigotItemStack sourceStack = new SpigotItemStack( source.parseItem() );
+
+ if ( isEnabled() && sourceStack != null && destStack != null ) {
+
+ BackpackEvent bpEvent = new BackpackEvent( player );
+ bpEvent.setAction( BackpackAction.smeltItems );
+
+ if ( bpEvent.fireBackpackEvent() ) {
- if ( inv != null ) {
+ boolean changedBackpack = false;
+
+ for ( Inventory inv : bpEvent.getInventory() ) {
- if ( inv.containsAtLeast( sourceStack.getBukkitStack(), 1 ) ) {
+ if ( inv != null ) {
- int count = SpigotUtil.itemStackCount( source, inv );
- if ( count > 0 ) {
- sourceStack.setAmount( count );
- destStack.setAmount( count );
+ if ( inv.containsAtLeast( sourceStack.getBukkitStack(), 1 ) ) {
- inv.remove( sourceStack.getBukkitStack() );
-
- HashMap temp = new HashMap<>();
- temp.put( Integer.valueOf( 0 ), destStack );
-
- extras.putAll( addItems( player, temp ) );
+ int count = SpigotUtil.itemStackCount( source, inv );
+ if ( count > 0 ) {
+ sourceStack.setAmount( count );
+ destStack.setAmount( count );
+
+ inv.remove( sourceStack.getBukkitStack() );
+
+ HashMap temp = new HashMap<>();
+ temp.put( Integer.valueOf( 0 ), destStack );
+
+ extras.putAll( addItems( player, temp ) );
+
+ changedBackpack = true;
+ }
- changedBackpack = true;
}
-
}
+
+
+ // Since we are smeltings, extras will be the results of the smelt,
+ // and as such, for multiple inventories, they can be combined in to
+ // one extras object without having to reset it each time.
+
}
-
- // Since we are smeltings, extras will be the results of the smelt,
- // and as such, for multiple inventories, they can be combined in to
- // one extras object without having to reset it each time.
+ if ( changedBackpack ) {
+ bpEvent.setResults( BackpackResults.contentsChanged );
+
+ bpEvent.getCallback().run();
+ }
}
-
- if ( changedBackpack ) {
- bpEvent.setResults( BackpackResults.contentsChanged );
- bpEvent.getCallback().run();
- }
-
- }
-
- }
-
- return extras;
+ }
+
+ return extras;
}
/**
@@ -362,38 +359,38 @@ public int itemStackRemoveAll(Player player, XMaterial xMat) {
public List sellInventoryItems( Player player, double multiplier ) {
List soldItems = new ArrayList<>();
- if ( isEnabled() ) {
-
- BackpackEvent bpEvent = new BackpackEvent( player );
- bpEvent.setAction( BackpackAction.removeAll );
-
- if ( bpEvent.fireBackpackEvent() ) {
-
- boolean changedBackpack = false;
-
- for ( Inventory inv : bpEvent.getInventory() ) {
+ if ( isEnabled() ) {
+
+ BackpackEvent bpEvent = new BackpackEvent( player );
+ bpEvent.setAction( BackpackAction.removeAll );
+
+ if ( bpEvent.fireBackpackEvent() ) {
- if ( inv != null ) {
-
- SpigotInventory sInventory = new SpigotInventory( inv );
-
- soldItems.addAll( SellAllUtil.get().sellInventoryItems( sInventory, multiplier ) );
+ boolean changedBackpack = false;
+
+ for ( Inventory inv : bpEvent.getInventory() ) {
- if ( soldItems.size() > 0 ) {
-
- changedBackpack = true;
+ if ( inv != null ) {
+
+ SpigotInventory sInventory = new SpigotInventory( inv );
+
+ soldItems.addAll( SellAllUtil.get().sellInventoryItems( sInventory, multiplier ) );
+
+ if ( soldItems.size() > 0 ) {
+
+ changedBackpack = true;
+ }
}
}
- }
-
- if ( changedBackpack ) {
- bpEvent.setResults( BackpackResults.contentsChanged );
- bpEvent.getCallback().run();
+ if ( changedBackpack ) {
+ bpEvent.setResults( BackpackResults.contentsChanged );
+
+ bpEvent.getCallback().run();
+ }
}
- }
-
- }
+
+ }
return soldItems;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationCrazyEnchantmentsPickaxes.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationCrazyEnchantmentsPickaxes.java
index e90efe657..09c02b1ca 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationCrazyEnchantmentsPickaxes.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationCrazyEnchantmentsPickaxes.java
@@ -31,7 +31,6 @@ private IntegrationCrazyEnchantmentsPickaxes() {
if ( bukkitPlugin != null ) {
-// Bukkit.getPluginManager().registerEvents( this, bukkitPlugin);
ce = CrazyEnchantments.getInstance();
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java
index 670c03796..31220e55c 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/integrations/IntegrationMinepacksPlugin.java
@@ -75,7 +75,7 @@ public MinepacksPlugin getMinepacks() {
@Override
public boolean hasIntegrated() {
- return isEnabled();
+ return isEnabled();
}
/**
@@ -84,7 +84,7 @@ public boolean hasIntegrated() {
*/
@Override
public void disableIntegration() {
- minepacks = null;
+ minepacks = null;
}
@Override
@@ -102,120 +102,119 @@ public String getPluginSourceURL() {
public HashMap addItems( Player player, HashMap items ) {
- HashMap extras = new HashMap<>();
-
- if ( items != null && items.size() > 0 && isEnabled() ) {
- Backpack bp = getMinepacks().getBackpackCachedOnly(player);
-
- if ( bp != null ) {
-
- boolean changedBackpack = false;
-
- for ( SpigotItemStack spigotItemStack : items.values() ) {
-
- ItemStack iStack = SpigotUtil.prisonItemStackToBukkit( spigotItemStack );
-// ItemStack iStack = spigotItemStack.getBukkitStack();
-
- if ( iStack != null ) {
- ItemStack extra = bp.addItem( iStack );
- extras.put( Integer.valueOf( extras.size() ), new SpigotItemStack(extra) );
-
- changedBackpack = true;
- }
- }
-
- if ( changedBackpack ) {
-
- bp.setChanged();
- bp.save();
- }
- }
- else {
- extras.putAll( items );
- }
- }
- else {
- extras.putAll( items );
- }
-
- return extras;
+ HashMap extras = new HashMap<>();
+
+ if ( items != null && items.size() > 0 && isEnabled() ) {
+ Backpack bp = getMinepacks().getBackpackCachedOnly(player);
+
+ if ( bp != null ) {
+
+ boolean changedBackpack = false;
+
+ for ( SpigotItemStack spigotItemStack : items.values() ) {
+
+ ItemStack iStack = SpigotUtil.prisonItemStackToBukkit( spigotItemStack );
+
+ if ( iStack != null ) {
+ ItemStack extra = bp.addItem( iStack );
+ extras.put( Integer.valueOf( extras.size() ), new SpigotItemStack(extra) );
+
+ changedBackpack = true;
+ }
+ }
+
+ if ( changedBackpack ) {
+
+ bp.setChanged();
+ bp.save();
+ }
+ }
+ else {
+ extras.putAll( items );
+ }
+ }
+ else {
+ extras.putAll( items );
+ }
+
+ return extras;
}
public HashMap addItemsBukkit( Player player, HashMap items ) {
- HashMap extras = new HashMap<>();
-
- if ( items != null && items.size() > 0 && isEnabled() ) {
- Backpack bp = getMinepacks().getBackpackCachedOnly(player);
-
- if ( bp != null ) {
-
- boolean changedBackpack = false;
-
- for ( ItemStack itemStack : items.values() ) {
-
- if ( itemStack != null ) {
- ItemStack extra = bp.addItem( itemStack );
- extras.put( Integer.valueOf( extras.size() ), extra );
-
- changedBackpack = true;
- }
- }
-
- if ( changedBackpack ) {
-
- bp.setChanged();
- bp.save();
- }
- }
- else {
- extras.putAll( items );
- }
- }
- else {
- extras.putAll( items );
- }
-
- return extras;
+ HashMap extras = new HashMap<>();
+
+ if ( items != null && items.size() > 0 && isEnabled() ) {
+ Backpack bp = getMinepacks().getBackpackCachedOnly(player);
+
+ if ( bp != null ) {
+
+ boolean changedBackpack = false;
+
+ for ( ItemStack itemStack : items.values() ) {
+
+ if ( itemStack != null ) {
+ ItemStack extra = bp.addItem( itemStack );
+ extras.put( Integer.valueOf( extras.size() ), extra );
+
+ changedBackpack = true;
+ }
+ }
+
+ if ( changedBackpack ) {
+
+ bp.setChanged();
+ bp.save();
+ }
+ }
+ else {
+ extras.putAll( items );
+ }
+ }
+ else {
+ extras.putAll( items );
+ }
+
+ return extras;
}
public HashMap smeltItems( Player player, XMaterial source, SpigotItemStack destStack ) {
- HashMap extras = new HashMap<>();
-
- SpigotItemStack sourceStack = new SpigotItemStack( source.parseItem() );
-
- if ( isEnabled() && sourceStack != null && destStack != null ) {
- Backpack bp = getMinepacks().getBackpackCachedOnly(player);
-
- if ( bp != null ) {
-
- Inventory inv = bp.getInventory();
-
- if ( inv.containsAtLeast( sourceStack.getBukkitStack(), 1 ) ) {
-
- int count = SpigotUtil.itemStackCount( source, inv );
- if ( count > 0 ) {
- sourceStack.setAmount( count );
- destStack.setAmount( count );
-
- inv.remove( sourceStack.getBukkitStack() );
-
- HashMap temp = new HashMap<>();
- temp.put( Integer.valueOf( 0 ), destStack );
-
- extras.putAll( addItems( player, temp ) );
-
- bp.setChanged();
- bp.save();
- }
-
- }
-
- }
- }
-
- return extras;
+ HashMap extras = new HashMap<>();
+
+ SpigotItemStack sourceStack = new SpigotItemStack( source.parseItem() );
+
+ if ( isEnabled() && sourceStack != null && destStack != null ) {
+ Backpack bp = getMinepacks().getBackpackCachedOnly(player);
+
+ if ( bp != null ) {
+
+ Inventory inv = bp.getInventory();
+
+ if ( inv.containsAtLeast( sourceStack.getBukkitStack(), 1 ) ) {
+
+ int count = SpigotUtil.itemStackCount( source, inv );
+ if ( count > 0 ) {
+ sourceStack.setAmount( count );
+ destStack.setAmount( count );
+
+ inv.remove( sourceStack.getBukkitStack() );
+
+ HashMap temp = new HashMap<>();
+ temp.put( Integer.valueOf( 0 ), destStack );
+
+ extras.putAll( addItems( player, temp ) );
+
+ bp.setChanged();
+ bp.save();
+ }
+
+ }
+
+ }
+ }
+
+ return extras;
}
/**
@@ -252,40 +251,26 @@ public int itemStackRemoveAll(Player player, XMaterial xMat) {
public List sellInventoryItems( Player player, double multiplier ) {
List soldItems = new ArrayList<>();
-
- if ( isEnabled() ) {
- Backpack bp = getMinepacks().getBackpackCachedOnly( player );
-
- if ( bp != null ) {
-
- Inventory inv = bp.getInventory();
-
- SpigotInventory sInventory = new SpigotInventory( inv );
-
- soldItems.addAll( SellAllUtil.get().sellInventoryItems( sInventory, multiplier ) );
-
- if ( soldItems.size() > 0 ) {
- bp.setChanged();
- bp.save();
- }
- }
- }
+
+ if ( isEnabled() ) {
+ Backpack bp = getMinepacks().getBackpackCachedOnly( player );
+
+ if ( bp != null ) {
+
+ Inventory inv = bp.getInventory();
+
+ SpigotInventory sInventory = new SpigotInventory( inv );
+
+ soldItems.addAll( SellAllUtil.get().sellInventoryItems( sInventory, multiplier ) );
+
+ if ( soldItems.size() > 0 ) {
+ bp.setChanged();
+ bp.save();
+ }
+ }
+ }
return soldItems;
}
-// private int itemCount(XMaterial source, Inventory inv ) {
-// int count = 0;
-// if ( source != null ) {
-// ItemStack testStack = source.parseItem();
-//
-// for (ItemStack is : inv.getContents() ) {
-// if ( is != null && is.isSimilar( testStack ) ) {
-// count += is.getAmount();
-// }
-// }
-// }
-// return count;
-// }
-
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPermissions.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPermissions.java
index 7b80a6102..144f86192 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPermissions.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPermissions.java
@@ -36,7 +36,7 @@ public class LuckPermissions
private LuckPermissionsWrapper permsWrapper;
public LuckPermissions() {
- super( "LuckPerms-Legacy", "LuckPerms" );
+ super( "LuckPerms-Legacy", "LuckPerms" );
}
@Override
@@ -60,40 +60,40 @@ public void integrate() {
@Override
public void addPermission(Player holder, String permission) {
- if ( permsWrapper != null ) {
- permsWrapper.addPermission( holder, permission );
- }
+ if ( permsWrapper != null ) {
+ permsWrapper.addPermission( holder, permission );
+ }
}
@Override
public void removePermission(Player holder, String permission) {
- if ( permsWrapper != null ) {
- permsWrapper.removePermission( holder, permission );
- }
+ if ( permsWrapper != null ) {
+ permsWrapper.removePermission( holder, permission );
+ }
}
@Override
public void addGroupPermission(Player holder, String groupPermission) {
- if ( permsWrapper != null ) {
- permsWrapper.addGroupPermission( holder, groupPermission );
- }
+ if ( permsWrapper != null ) {
+ permsWrapper.addGroupPermission( holder, groupPermission );
+ }
}
@Override
public void removeGroupPermission(Player holder, String groupPermission) {
- if ( permsWrapper != null ) {
- permsWrapper.removeGroupPermission( holder, groupPermission );
- }
+ if ( permsWrapper != null ) {
+ permsWrapper.removeGroupPermission( holder, groupPermission );
+ }
}
@Override
public List getPermissions(Player holder, boolean detailed) {
- List results = new ArrayList<>();
-
- if ( permsWrapper != null ) {
- results = permsWrapper.getPermissions(holder, detailed);
- }
-
- return results;
+ List results = new ArrayList<>();
+
+ if ( permsWrapper != null ) {
+ results = permsWrapper.getPermissions(holder, detailed);
+ }
+
+ return results;
}
@@ -105,7 +105,7 @@ public boolean hasIntegrated() {
@Override
public void disableIntegration() {
- permsWrapper = null;
+ permsWrapper = null;
}
@Override
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPermissionsWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPermissionsWrapper.java
index 39975c8e7..7c053f320 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPermissionsWrapper.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPermissionsWrapper.java
@@ -45,10 +45,10 @@ protected void removePermission(Player holder, String permission) {
editPermission(holder.getUUID(), permission, LPPermissionType.PERM_REMOVE );
}
protected void addGroupPermission(Player holder, String permission) {
- editPermission(holder.getUUID(), permission, LPPermissionType.PERM_GROUP_ADD );
+ editPermission(holder.getUUID(), permission, LPPermissionType.PERM_GROUP_ADD );
}
protected void removeGroupPermission(Player holder, String permission) {
- editPermission(holder.getUUID(), permission, LPPermissionType.PERM_GROUP_REMOVE );
+ editPermission(holder.getUUID(), permission, LPPermissionType.PERM_GROUP_REMOVE );
}
@SuppressWarnings( "deprecation" )
@@ -91,11 +91,6 @@ protected void editPermission(UUID uuid, String permission, LPPermissionType per
break;
}
-// if(add) {
-// result = user.setPermission(node);
-// } else {
-// result = user.unsetPermission(node);
-// }
// wasn't successful.
// they most likely already have (or didn't have if add = false) the permission
@@ -119,64 +114,64 @@ protected void editPermission(UUID uuid, String permission, LPPermissionType per
public List getPermissions(Player holder, boolean detailed) {
- List results = new ArrayList<>();
-
- UUID uuid = holder.getUUID();
-
+ List results = new ArrayList<>();
+
+ UUID uuid = holder.getUUID();
+
// get the user
User user = api.getUser(uuid);
if (user != null) {
- // user loaded
-
- SortedSet extends Node> permNodes = user.getPermissions();
-
- for ( Node node : permNodes ) {
- String perm = node.getPermission();
- StringBuilder details = new StringBuilder();
-
- if ( detailed ) {
-
- if ( node.isTemporary() ) {
- long seconds = node.getSecondsTilExpiry();
- String expiry = PlaceholdersUtil.formattedTime( seconds );
-
- details.append(expiry);
- }
-
- if ( node.isGroupNode() ) {
- if ( details.length() > 0 ) {
- details.append( ":" );
- }
- details.append( "group=" ).append( node.getGroupName() );
- }
-
- if ( node.isWorldSpecific() ) {
- if ( details.length() > 0 ) {
- details.append( ":" );
- }
- details.append( "world=" ).append( node.getWorld() );
- }
-
- if ( node.isMeta() ) {
- if ( details.length() > 0 ) {
- details.append( ":" );
- }
-
- Entry meta = node.getMeta();
-
- details.append( "meta={" ).append( meta.getKey() )
- .append( "=" ).append( meta.getValue() ).append( "}" );
- }
-
- if ( details.length() > 0 ) {
- details.insert( 0, "::" );
- }
-
- }
- details.insert( 0, perm );
-
- results.add( details.toString() );
- }
+ // user loaded
+
+ SortedSet extends Node> permNodes = user.getPermissions();
+
+ for ( Node node : permNodes ) {
+ String perm = node.getPermission();
+ StringBuilder details = new StringBuilder();
+
+ if ( detailed ) {
+
+ if ( node.isTemporary() ) {
+ long seconds = node.getSecondsTilExpiry();
+ String expiry = PlaceholdersUtil.formattedTime( seconds );
+
+ details.append(expiry);
+ }
+
+ if ( node.isGroupNode() ) {
+ if ( details.length() > 0 ) {
+ details.append( ":" );
+ }
+ details.append( "group=" ).append( node.getGroupName() );
+ }
+
+ if ( node.isWorldSpecific() ) {
+ if ( details.length() > 0 ) {
+ details.append( ":" );
+ }
+ details.append( "world=" ).append( node.getWorld() );
+ }
+
+ if ( node.isMeta() ) {
+ if ( details.length() > 0 ) {
+ details.append( ":" );
+ }
+
+ Entry meta = node.getMeta();
+
+ details.append( "meta={" ).append( meta.getKey() )
+ .append( "=" ).append( meta.getValue() ).append( "}" );
+ }
+
+ if ( details.length() > 0 ) {
+ details.insert( 0, "::" );
+ }
+
+ }
+ details.insert( 0, perm );
+
+ results.add( details.toString() );
+ }
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPerms5.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPerms5.java
index 02c8ef482..813a26b77 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPerms5.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPerms5.java
@@ -67,27 +67,27 @@ public void removePermission( Player holder, String permission ) {
@Override
public void addGroupPermission(Player holder, String groupPermission) {
- if ( permsWrapper != null ) {
- permsWrapper.addGroupPermission( holder, groupPermission );
- }
+ if ( permsWrapper != null ) {
+ permsWrapper.addGroupPermission( holder, groupPermission );
+ }
}
@Override
public void removeGroupPermission(Player holder, String groupPermission) {
- if ( permsWrapper != null ) {
- permsWrapper.removeGroupPermission( holder, groupPermission );
- }
+ if ( permsWrapper != null ) {
+ permsWrapper.removeGroupPermission( holder, groupPermission );
+ }
}
@Override
public List getPermissions(Player holder, boolean detailed) {
- List results = new ArrayList<>();
-
- if ( permsWrapper != null ) {
- results = permsWrapper.getPermissions(holder, detailed);
- }
-
- return results;
+ List results = new ArrayList<>();
+
+ if ( permsWrapper != null ) {
+ results = permsWrapper.getPermissions(holder, detailed);
+ }
+
+ return results;
}
@Override
@@ -97,7 +97,7 @@ public boolean hasIntegrated() {
@Override
public void disableIntegration() {
- permsWrapper = null;
+ permsWrapper = null;
}
@Override
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPerms5Wrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPerms5Wrapper.java
index 1299f6072..9d07bbe3a 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPerms5Wrapper.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/permissions/LuckPerms5Wrapper.java
@@ -51,7 +51,6 @@ private enum LPPermissionType {
public LuckPerms5Wrapper(RegisteredServiceProvider provider) {
super();
-// LuckPerms api = provider.getProvider();
api = provider.getProvider();
}
@@ -62,19 +61,12 @@ protected void removePermission(Player holder, String permission) {
editPermission(holder.getUUID(), permission, LPPermissionType.PERM_REMOVE );
}
protected void addGroupPermission(Player holder, String permission) {
- editPermission(holder.getUUID(), permission, LPPermissionType.PERM_GROUP_ADD );
+ editPermission(holder.getUUID(), permission, LPPermissionType.PERM_GROUP_ADD );
}
protected void removeGroupPermission(Player holder, String permission) {
- editPermission(holder.getUUID(), permission, LPPermissionType.PERM_GROUP_REMOVE );
+ editPermission(holder.getUUID(), permission, LPPermissionType.PERM_GROUP_REMOVE );
}
-// public void addPermission( Player holder, String permission ) {
-// editPermission(holder.getUUID(), permission, true);
-// }
-//
-// public void removePermission( Player holder, String permission ) {
-// editPermission(holder.getUUID(), permission, false);
-// }
/**
* This function does not return anything, nor is there anything waiting for its
@@ -95,179 +87,145 @@ protected void removeGroupPermission(Player holder, String permission) {
* @param add
*/
private void editPermission(UUID uuid, String permission, LPPermissionType permissionType) {
- if ( api != null ) {
-
- UserManager um = api.getUserManager();
- User user = um.getUser(uuid);
- CompletableFuture userFuture = (user == null ?
- um.loadUser(uuid) : CompletableFuture.completedFuture(user));
-
- userFuture
- .thenAcceptAsync(lpUser -> {
- changePermission(lpUser, permission, permissionType);
- });
- }
+ if ( api != null ) {
+
+ UserManager um = api.getUserManager();
+ User user = um.getUser(uuid);
+ CompletableFuture userFuture = (user == null ?
+ um.loadUser(uuid) : CompletableFuture.completedFuture(user));
+
+ userFuture
+ .thenAcceptAsync(lpUser -> {
+ changePermission(lpUser, permission, permissionType);
+ });
+ }
}
private void changePermission( User user, String permission, LPPermissionType permissionType ) {
- boolean dirty = false;
-
- // build a permission node now so we don't have to pass around
- // the raw components, just this node.
-// PermissionNode newNode = null; // PermissionNode.builder(permission).build();
-
- Node newNode = null;
- boolean enable = permissionType == LPPermissionType.PERM_ADD ||
- permissionType == LPPermissionType.PERM_GROUP_ADD;
-
- switch ( permissionType )
- {
- case PERM_ADD:
- case PERM_REMOVE:
- newNode = PermissionNode.builder(permission).build();
- break;
-
- case PERM_GROUP_ADD:
- case PERM_GROUP_REMOVE:
- newNode = InheritanceNode.builder(permission).build();
- break;
-
- default:
- break;
- }
-
-
- // Try to remove the perm if it exists. Even if adding a perm, try to remove it
- // to prevent possible duplicates.
- if ( user.data().remove( newNode ) == DataMutateResult.SUCCESS ) {
- dirty = true;
- }
-
- // If the node is to be added/enabled, then try to add it:
- if ( enable && user.data().add( newNode ) == DataMutateResult.SUCCESS ) {
- dirty = true;
- }
-
+ boolean dirty = false;
+
+ // build a permission node now so we don't have to pass around
+ // the raw components, just this node.
+ // PermissionNode newNode = null; // PermissionNode.builder(permission).build();
+
+ Node newNode = null;
+ boolean enable = permissionType == LPPermissionType.PERM_ADD ||
+ permissionType == LPPermissionType.PERM_GROUP_ADD;
+
+ switch ( permissionType )
+ {
+ case PERM_ADD:
+ case PERM_REMOVE:
+ newNode = PermissionNode.builder(permission).build();
+ break;
+
+ case PERM_GROUP_ADD:
+ case PERM_GROUP_REMOVE:
+ newNode = InheritanceNode.builder(permission).build();
+ break;
+
+ default:
+ break;
+ }
+
+
+ // Try to remove the perm if it exists. Even if adding a perm, try to remove it
+ // to prevent possible duplicates.
+ if ( user.data().remove( newNode ) == DataMutateResult.SUCCESS ) {
+ dirty = true;
+ }
+
+ // If the node is to be added/enabled, then try to add it:
+ if ( enable && user.data().add( newNode ) == DataMutateResult.SUCCESS ) {
+ dirty = true;
+ }
+
if ( dirty ) {
api.getUserManager().saveUser( user );
}
}
-
-
+
+
public List getPermissions(Player holder, boolean detailed) {
- List results = new ArrayList<>();
-
- UUID uuid = holder.getUUID();
-
- if ( api != null ) {
-
+ List results = new ArrayList<>();
+
+ UUID uuid = holder.getUUID();
+
+ if ( api != null ) {
+
UserManager um = api.getUserManager();
- User user = um.getUser(uuid);
-
- if (user != null) {
-
- SortedSet permNodes = user.resolveDistinctInheritedNodes( QueryOptions.nonContextual() );
-// SortedSet permNodes = user.getDistinctNodes();
-
- for ( Node node : permNodes ) {
-
- String perm = node.getKey();
-
-// String perm = node.getPermission();
- StringBuilder details = new StringBuilder();
-
- if ( detailed ) {
-
- if ( node.hasExpiry() ) {
- double seconds = (System.currentTimeMillis() - node.getExpiry().toEpochMilli()) / 1000.0;
- String expiry = PlaceholdersUtil.formattedTime( seconds );
-
- details.append(expiry);
- }
-
- if ( node.hasExpired() ) {
- if ( details.length() > 0 ) {
- details.append( ":" );
- }
- details.append( "expired" );
- }
-
- // Group node: Redundant since groups are prefixed with "group."
- if ( node.getType() == NodeType.INHERITANCE ) {
- //if ( details.length() > 0 ) {
- // details.append( ":" );
- //}
- //details.append( "group=" ).append( node.getKey() );
- }
-
-// // Permission node:
-// if ( node.getType() == NodeType.PERMISSION ) {
-// if ( details.length() > 0 ) {
-// details.append( ":" );
-// }
-// details.append( "permission=" ).append( node.getKey() );
-// }
-
-
- // Weighted node:
- if ( node.getType() == NodeType.WEIGHT ) {
- if ( details.length() > 0 ) {
- details.append( ":" );
- }
- WeightNode weighted = (WeightNode) node;
-
- details.append( "weighted=" ).append( weighted.getWeight() );
- }
-
- // Weighted node:
- if ( node.getContexts().containsKey( DefaultContextKeys.WORLD_KEY ) ) {
- if ( details.length() > 0 ) {
- details.append( ":" );
- }
- details.append( "Worlds=" ).append(
- String.join( ",",
- node.getContexts().getValues( DefaultContextKeys.WORLD_KEY ) ));
- }
-
-// if ( node.getType() == NodeType.PERMISSION ) {
-// node.get
-// }
-//
-// if ( node.isWorldSpecific() ) {
-// if ( details.length() > 0 ) {
-// details.append( ":" );
-// }
-// details.append( "world=" ).append( node.getWorld() );
-// }
-//
-// if ( node.isMeta() ) {
-// if ( details.length() > 0 ) {
-// details.append( ":" );
-// }
-//
-// Entry meta = node.getMeta();
-//
-// details.append( "meta={" ).append( meta.getKey() )
-// .append( "=" ).append( meta.getValue() ).append( "}" );
-// }
-
- if ( details.length() > 0 ) {
- details.insert( 0, "::" );
- }
-
- }
- details.insert( 0, perm );
-
- results.add( details.toString() );
- }
- }
- }
-
-
+ User user = um.getUser(uuid);
+
+ if (user != null) {
+
+ SortedSet permNodes = user.resolveDistinctInheritedNodes( QueryOptions.nonContextual() );
+
+ for ( Node node : permNodes ) {
+
+ String perm = node.getKey();
+
+ StringBuilder details = new StringBuilder();
+
+ if ( detailed ) {
+
+ if ( node.hasExpiry() ) {
+ double seconds = (System.currentTimeMillis() - node.getExpiry().toEpochMilli()) / 1000.0;
+ String expiry = PlaceholdersUtil.formattedTime( seconds );
+
+ details.append(expiry);
+ }
+
+ if ( node.hasExpired() ) {
+ if ( details.length() > 0 ) {
+ details.append( ":" );
+ }
+ details.append( "expired" );
+ }
+
+ // Group node: Redundant since groups are prefixed with "group."
+ if ( node.getType() == NodeType.INHERITANCE ) {
+ //if ( details.length() > 0 ) {
+ // details.append( ":" );
+ //}
+ //details.append( "group=" ).append( node.getKey() );
+ }
+
+
+
+ // Weighted node:
+ if ( node.getType() == NodeType.WEIGHT ) {
+ if ( details.length() > 0 ) {
+ details.append( ":" );
+ }
+ WeightNode weighted = (WeightNode) node;
+
+ details.append( "weighted=" ).append( weighted.getWeight() );
+ }
+
+ // Weighted node:
+ if ( node.getContexts().containsKey( DefaultContextKeys.WORLD_KEY ) ) {
+ if ( details.length() > 0 ) {
+ details.append( ":" );
+ }
+ details.append( "Worlds=" ).append(
+ String.join( ",",
+ node.getContexts().getValues( DefaultContextKeys.WORLD_KEY ) ));
+ }
+
+
+ if ( details.length() > 0 ) {
+ details.insert( 0, "::" );
+ }
+
+ }
+ details.insert( 0, perm );
+
+ results.add( details.toString() );
+ }
+ }
+ }
-
-
return results;
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegration.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegration.java
index 44c020524..1d99f8283 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegration.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegration.java
@@ -18,186 +18,8 @@
*/
public class MVdWPlaceholderIntegration
// extends PlaceholderIntegration
- {
+{
+
+ // Purged commented out code. See github's history to see what it was.
-// private MVdWPlaceholderIntegrationWrapper placeholderWrapper;
-//
-// public MVdWPlaceholderIntegration() {
-// super( "MVdWPlaceholderAPI", "MVdWPlaceholderAPI" );
-// }
-
-// @Override
-// public void integrate() {
-// if ( isRegistered()) {
-// try {
-// if ( Bukkit.getPluginManager().isPluginEnabled(getProviderName())) {
-//
-//
-// // The integration was written for MVdW v3.0.0, but if used with older versions
-// // it will fail.
-//
-// // This will fail if the version of mvdw is v2.x.x, which is what we want:
-// Class.forName("be.maximvdw.placeholderapi.PlaceholderAPI", false, getClass().getClassLoader());
-//
-// MVdWPlaceholderIntegrationWrapper wrap = new MVdWPlaceholderIntegrationWrapper(getProviderName());
-//
-// placeholderWrapper = wrap;
-//
-// PrisonAPI.getIntegrationManager().addDeferredInitialization( this );
-// }
-// }
-// catch ( NoClassDefFoundError e ) {
-// // ignore this exception since it means the plugin was not loaded
-// Output.get().logWarn( "Attempted to enable the MVdWPlaceholderIntegration but it failed to find the " +
-// "class 'be.maximvdw.placeholderapi.PlaceholderAPI'. This could happen when using " +
-// "MVdWPlaceholderApi v2.x.x. Prison ONLY support MVdW v3.x.x. " +
-// "&c****&7 Try using PlaceholderAPI (papi) instead. &c****" );
-// }
-// catch ( IllegalStateException e ) {
-// // ignore ... plugin is not loaded
-// }
-// catch ( Exception e ) {
-// e.printStackTrace();
-// }
-// }
-// }
-
-
-// /**
-// * Register both the player and mines placeholders with the MVdW plugin.
-// *
-// */
-// @Override
-// public void deferredInitialization()
-// {
-// boolean registered = false;
-// if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) {
-//
-// PlayerManager pm = PrisonRanks.getInstance().getPlayerManager();
-// if ( pm != null ) {
-// List placeholderPlayerKeys = pm.getTranslatedPlaceHolderKeys();
-//
-// for ( PlaceHolderKey placeHolderKey : placeholderPlayerKeys ) {
-// if ( !placeHolderKey.getPlaceholder().isSuppressed() ) {
-//
-//
-// registerPlaceholder(placeHolderKey.getKey(),
-// player -> {
-//
-// PlaceholderIdentifier identifier = new PlaceholderIdentifier( placeHolderKey.getPlaceholder().name() );
-// identifier.setPlayer( player.getUUID(), player.getName() );
-//
-// if ( identifier.checkPlaceholderKey(placeHolderKey) ) {
-//
-// pm.getTranslatePlayerPlaceHolder( identifier );
-// }
-//
-//
-// return Text.translateAmpColorCodes( identifier.getText() );
-// });
-// if ( !registered ) {
-// registered = true;
-// }
-// }
-// }
-// }
-//
-// RankManager rm = PrisonRanks.getInstance().getRankManager();
-// if ( rm != null ) {
-// List placeholderPlayerKeys = rm.getTranslatedPlaceHolderKeys();
-//
-// for ( PlaceHolderKey placeHolderKey : placeholderPlayerKeys ) {
-// if ( !placeHolderKey.getPlaceholder().isSuppressed() ) {
-//
-//
-// registerPlaceholder(placeHolderKey.getKey(),
-// player -> {
-//
-// PlaceholderIdentifier identifier = new PlaceholderIdentifier( placeHolderKey.getPlaceholder().name() );
-// identifier.setPlayer( player.getUUID(), player.getName() );
-//
-// if ( identifier.checkPlaceholderKey(placeHolderKey) ) {
-//
-// rm.getTranslateRanksPlaceHolder( identifier );
-// }
-//
-//
-// return Text.translateAmpColorCodes( identifier.getText() );
-// });
-// if ( !registered ) {
-// registered = true;
-// }
-// }
-// }
-// }
-// }
-//
-//
-// if ( PrisonMines.getInstance() != null && PrisonMines.getInstance().isEnabled() ) {
-// MineManager mm = PrisonMines.getInstance().getMineManager();
-// if ( mm != null ) {
-// List placeholderMinesKeys = mm.getTranslatedPlaceHolderKeys();
-//
-// for ( PlaceHolderKey placeHolderKey : placeholderMinesKeys ) {
-// if ( !placeHolderKey.getPlaceholder().isSuppressed() ) {
-//
-// registerPlaceholder(placeHolderKey.getKey(),
-// player -> {
-//
-// PlaceholderIdentifier identifier = new PlaceholderIdentifier( placeHolderKey.getPlaceholder().name() );
-// identifier.setPlayer( player.getUUID(), player.getName() );
-//
-// if ( identifier.checkPlaceholderKey(placeHolderKey) ) {
-//
-// mm.getTranslateMinesPlaceholder( identifier );
-// }
-//
-// return Text.translateAmpColorCodes( identifier.getText() );
-// } );
-// if ( !registered ) {
-// registered = true;
-// }
-// }
-// }
-// }
-// }
-//
-//// if ( registered ) {
-//// Output.get().logWarn( "Prison registered all placeholders with MVdWPlaceholderAPI, " +
-//// "but unfortunately MVdWPlaceholderAPI does not support dynamic placeholders " +
-//// "that are available for customizations within prison. Please try adding " +
-//// "Vault and PlaceholderAPI (papi) to your setup, if they do not already exist, " +
-//// "to enable these features.");
-//// }
-// }
-//
-//
-// @Override
-// public void registerPlaceholder(String placeholder, Function action) {
-// if (placeholderWrapper != null) {
-// placeholderWrapper.registerPlaceholder( placeholder, action );
-// }
-// }
-//
-// @Override
-// public boolean hasIntegrated() {
-// return (placeholderWrapper != null);
-// }
-//
-// @Override
-// public void disableIntegration() {
-// placeholderWrapper = null;
-// }
-//
-// @Override
-// public String getAlternativeInformation() {
-// return null;
-// }
-//
-//
-// @Override
-// public String getPluginSourceURL() {
-// return "https://www.spigotmc.org/resources/mvdwplaceholderapi.11182/";
-// }
-
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegrationWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegrationWrapper.java
index 187005edc..7b9389c2e 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegrationWrapper.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/MVdWPlaceholderIntegrationWrapper.java
@@ -5,15 +5,6 @@
*/
public class MVdWPlaceholderIntegrationWrapper
{
+ // Purged commented out code. See github's history to see what it was.
-// public MVdWPlaceholderIntegrationWrapper(String providerName) {
-// super();
-// }
-//
-// public void registerPlaceholder(String placeholder, Function action) {
-// PlaceholderAPI.registerPlaceholder(
-// Bukkit.getPluginManager().getPlugin("Prison"), placeholder,
-// e -> action.apply(new SpigotPlayer(e.getPlayer())));
-// }
-
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java
index da133e074..2f16b20a1 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationUppercaseWrapper.java
@@ -19,10 +19,6 @@ public PlaceHolderAPIIntegrationUppercaseWrapper() {
}
-// public void registerPlaceholder(String placeholder, Function action) {
-// this.register();
-// }
-
/**
* This method should always return true unless we
* have a dependency we need to make sure is on the server
@@ -78,14 +74,9 @@ public String getVersion(){
@Override
public String onRequest(OfflinePlayer player, String identifier) {
-// if ( !identifier.toLowerCase().startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED ) ) {
-// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier;
-// }
-
UUID playerUuid = player == null ? null : player.getUniqueId();
String results = Prison.get().getPlatform().getPlaceholders()
.placeholderTranslate( playerUuid, player.getName(), identifier );
-
return ChatColor.translateAlternateColorCodes( '&', results);
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java
index 48593a814..00670b018 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/placeholder/PlaceHolderAPIIntegrationWrapper.java
@@ -19,10 +19,6 @@ public PlaceHolderAPIIntegrationWrapper() {
}
-// public void registerPlaceholder(String placeholder, Function action) {
-// this.register();
-// }
-
/**
* This method should always return true unless we
* have a dependency we need to make sure is on the server
@@ -79,10 +75,6 @@ public String getVersion(){
public String onRequest(OfflinePlayer player, String identifier) {
String results = null;
-// if ( !identifier.toLowerCase().startsWith( PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED ) ) {
-// identifier = PlaceholderManager.PRISON_PLACEHOLDER_PREFIX_EXTENDED + identifier;
-// }
-
if( player != null ) {
UUID playerUuid = player.getUniqueId();
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 0eb1ada54..5e8c2937d 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
@@ -267,21 +267,6 @@ public String placeholderTranslate( UUID playerUuid, String playerName, String p
return processPlaceholderIdentifier( identifier );
}
- // NOTE: This is obsolete since the player should always be included:
-// /**
-// * This function is used in this class's placeholderTranslateText() and
-// * also in tech.mcprison.prison.mines.MinesChatHandler.onPlayerChat().
-// *
-// *
-// */
-// @Override
-// public String placeholderTranslateText( String text) {
-// PlaceholderIdentifier identifier = new PlaceholderIdentifier( text );
-//
-//
-// return placeholderTranslateText( identifier );
-// }
-
private String processPlaceholderIdentifier( PlaceholderIdentifier identifier ) {
long nanoStart = System.nanoTime();
@@ -444,25 +429,6 @@ else if ( rm != null &&
return identifier.getText();
}
-// /**
-// * This provides for a case insensitive replacement of placeholders.
-// *
-// * String target = "FOOBar";
-// * target = target.replaceAll("(?i)foo", "");
-// *
-// * @param text The full text that contains one or more placeholders. This is also the value that
-// * will be returned, with the replacement of the contained placeholder.
-// * @param placeholder The individual placeholder that should be replaced. This should be the
-// * raw value of the identifier, including escape chaacters and placeholder attributes.
-// * @param target The text that should replace the whole placeholder.
-// * @return
-// */
-// private String placeholderReplace( String text, String placeholder, String target ) {
-//
-// return text == null || placeholder == null || target == null ?
-// text : text.replaceAll( "(?i)" + Pattern.quote(placeholder) , target );
-// }
-
/**
* The rawText passed to this function may have zero, one, or more placeholders included
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
index 7f00c1fb6..16591013f 100644
--- 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
@@ -59,48 +59,48 @@ public static void debugItemsSold( List soldItems, SpigotPlayer sPl
}
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();
+ 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) {
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 5cf73c06a..13f8a5731 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
@@ -56,24 +56,18 @@ public class SellAllUtil
private static SellAllUtil instance;
-
-// private final Compatibility compat = SpigotPrison.getInstance().getCompatibility();
-
-// private final ItemStack lapisLazuli = compat.getLapisItemStack();
public Configuration sellAllConfig;
private static Boolean isAutoSellEnabled = null;
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 MessagesConfig messages;
+
private double defaultMultiplier;
private int defaultSellAllDelay;
private int defaultAutoSellEarningNotificationDelay;
@@ -135,13 +129,13 @@ public static SellAllUtil get() {
}
public static boolean isAutoSellEnabled() {
-
- if ( isAutoSellEnabled == null ) {
-
- isAutoSellEnabled = SpigotPrison.getInstance().isSellAllEnabled();
- }
-
- return isAutoSellEnabled == null ? false : isAutoSellEnabled;
+
+ if ( isAutoSellEnabled == null ) {
+
+ isAutoSellEnabled = SpigotPrison.getInstance().isSellAllEnabled();
+ }
+
+ return isAutoSellEnabled == null ? false : isAutoSellEnabled;
}
/**
@@ -161,7 +155,6 @@ public Configuration initCachedData() {
private void refreshClassVariablesFromConfig() {
-// 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");
@@ -172,19 +165,15 @@ private void refreshClassVariablesFromConfig() {
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).get();
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).get();
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"));
@@ -221,35 +210,35 @@ private void refreshClassVariablesFromConfig() {
}
private boolean getBooleanValue( String configName ) {
- return getBooleanValue(configName, false);
+ 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;
+ 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;
}
@@ -265,9 +254,9 @@ public void setSellAllItemTriggers(ArrayList sellAllItemTriggers) {
public PrisonBlock getSellallItem( PrisonBlock blockKey ) {
- PrisonBlock pBlockSellAll = sellAllItems.get( blockKey.getBlockNameSearch() );
-
- return pBlockSellAll;
+ PrisonBlock pBlockSellAll = sellAllItems.get( blockKey.getBlockNameSearch() );
+
+ return pBlockSellAll;
}
public void putSellallItem( PrisonBlock pBlockKey ) {
sellAllItems.put( pBlockKey.getBlockNameSearch(), pBlockKey );
@@ -303,25 +292,16 @@ public HashMap getPrestigeMultipliers() {
public PrisonBlock getSellAllPrisonBlockKey( String itemID ) {
- PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( itemID );
- if ( pBlockKey == null ) {
- Output.get().logDebug( "sellall add: invalid block name (%s)", itemID);
- return null;
- }
-
- return pBlockKey;
+ PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( itemID );
+ if ( pBlockKey == null ) {
+ Output.get().logDebug( "sellall add: invalid block name (%s)", itemID);
+ return null;
+ }
+
+ return pBlockKey;
}
-// /**
-// * 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.
@@ -332,141 +312,9 @@ public ArrayList getItemTriggerXMaterials(){
return sellAllItemTriggers;
}
-// /**
-// * BUG: With Spigot versions less than 1.13 bukkit's Material will not work on all Materials since
-// * varient data is stored in the ItemStack. SO must use the XMaterial version of this function.
-// *
-// * Get an ArrayList of SellAllItemTriggers as Materials.
-// * This will essentially do a conversion of the cached internal XMaterial ArrayList of SellAllItemTriggers.
-// *
-// * @return ArrayList of Materials.
-// * */
-// public ArrayList getItemTriggerMaterials(){
-// if (sellAllItemTriggers == null || sellAllItemTriggers.isEmpty()){
-// return new ArrayList<>();
-// }
-//
-// ArrayList materials = new ArrayList<>();
-//
-// for (XMaterial xMaterial : sellAllItemTriggers){
-// materials.add(xMaterial.parseMaterial());
-// }
-//
-// 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;
-// }
-
-// /**
-// * Return SellAll Blocks HashMap cached values.
-// *
-// * @return HashMap of XMaterial-Double.
-// * */
-// public HashMap getSellAllBlocks() {
-// return sellAllBlocks;
-// }
-
-
-// /**
-// * 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.
-// * */
-// 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.
@@ -476,7 +324,7 @@ public ArrayList getItemTriggerXMaterials(){
* @return double.
* */
public double getPlayerMultiplier( Player player ) {
- return getPlayerMultiplier( new SpigotPlayer( player ));
+ return getPlayerMultiplier( new SpigotPlayer( player ));
}
public double getPlayerMultiplier( tech.mcprison.prison.internal.Player sPlayer ) {
@@ -488,10 +336,6 @@ public double getPlayerMultiplier( tech.mcprison.prison.internal.Player sPlayer
}
-// long tPoint1 = System.nanoTime();
-
-// SpigotPlayer sPlayer = new SpigotPlayer(p);
-
double multiplier = 0d;
double rankMultiplers = 0;
@@ -518,44 +362,12 @@ public double getPlayerMultiplier( tech.mcprison.prison.internal.Player sPlayer
}
if ( rankMultiplers == 0 ) {
- multiplier = defaultMultiplier;
+ multiplier = defaultMultiplier;
}
else {
multiplier = rankMultiplers;
}
-
-
-
-
-// long tPoint2 = System.nanoTime();
-
- // Get multiplier depending on Player + Prestige. NOTE that prestige multiplier will replace
- // the actual default multiplier.
-// if (module != null) {
-// PrisonRanks rankPlugin = (PrisonRanks) module;
-// if (rankPlugin.getPlayerManager().getPlayer(sPlayer) != null) {
-// String playerRankName;
-// try {
-//
-// RankPlayerFactory rankPlayerFactory = new RankPlayerFactory();
-//
-// RankPlayer rankPlayer = rankPlugin.getPlayerManager().getPlayer(sPlayer);
-// PlayerRank pRank = rankPlayer == null ? null : rankPlayerFactory.getRank( rankPlayer, "prestiges");
-// Rank rank = pRank == null ? null : pRank.getRank();
-//
-// playerRankName = rank == null ? null : rank.getName();
-// } catch (NullPointerException ex) {
-// playerRankName = null;
-// }
-// if (playerRankName != null) {
-// String multiplierRankString = sellAllConfig.getString("Multiplier." + playerRankName + ".MULTIPLIER");
-// if (multiplierRankString != null && sellAllPrestigeMultipliers.containsKey(playerRankName)){
-// multiplier = sellAllPrestigeMultipliers.get(playerRankName);
-// }
-// }
-// }
-// }
// Get Multiplier from multipliers permission's if there's any.
String permPattern = "prison.sellall.multiplier.";
@@ -563,517 +375,378 @@ public double getPlayerMultiplier( tech.mcprison.prison.internal.Player sPlayer
// If the player is off line, then try to use the snapshot of the last group of perms:
- if ( perms.size() == 0 && sPlayer.getRankPlayer() != null ) {
- perms.addAll( sPlayer.getPermissions( permPattern, sPlayer.getRankPlayer().getPermsSnapShot() ));
- }
+ if ( perms.size() == 0 && sPlayer.getRankPlayer() != null ) {
+ perms.addAll( sPlayer.getPermissions( permPattern, sPlayer.getRankPlayer().getPermsSnapShot() ));
+ }
double multiplierExtraByPerms = 0;
for (String multByPerm : perms) {
- String multStr = multByPerm.replace(permPattern, "");
- if ( multStr.contains( "_" ) ) {
- multStr = multStr.substring( 0, multStr.indexOf("_") );
- }
-
+ String multStr = multByPerm.replace(permPattern, "");
+ if ( multStr.contains( "_" ) ) {
+ multStr = multStr.substring( 0, multStr.indexOf("_") );
+ }
+
double multByPermDouble = Double.parseDouble( multStr );
boolean highest = multByPermDouble > multiplierExtraByPerms;
-
+
if ( !isSellAllPermissionMultiplierOnlyHigherEnabled ) {
multiplierExtraByPerms += multByPermDouble;
}
else {
-
- if ( highest ) {
- multiplierExtraByPerms = multByPermDouble;
- }
+
+ if ( highest ) {
+ multiplierExtraByPerms = multByPermDouble;
+ }
}
}
-
multiplier += multiplierExtraByPerms;
-
-// long tPoint3 = System.nanoTime();
-// DecimalFormat dFmt = Prison.get().getDecimalFormat( "0.0000" );
-// String debugMsg = "{sellallMult::" + dFmt.format( multiplier ) + ":t1=" +
-// dFmt.format( (tPoint2 - tPoint1)/1000000d ) +
-// ":t2=" + dFmt.format( (tPoint3 - tPoint2)/1000000 ) + "}";
-// Output.get().logDebug( debugMsg );
-
return multiplier;
}
public double getPlayerMultiplierDebug( tech.mcprison.prison.internal.Player sPlayer ) {
- StringBuilder sb = new StringBuilder();
-
- long tPoint1 = System.nanoTime();
-
- sb.append( "&dCalculate Sellall Player Multipliers: &6" )
- .append( sPlayer.getName() );
-
- if (!isSellAllMultiplierEnabled) {
-
- sb.append( " &cSellall Multipliers are disabled." );
- if ( Output.get().isDebug() ) {
- Output.get().logInfo( sb.toString() );
- }
-
- return 1d;
- }
-
-
- sb.append( " &aEnabled &6DefaultMult: &c" )
- .append( defaultMultiplier );
-
- if ( isSellAllPermissionMultiplierOnlyHigherEnabled ) {
- sb.append( " &a(Use only the highest perm multiplier) " );
- }
-
-
-
-
-// SpigotPlayer sPlayer = new SpigotPlayer(p);
-
- double multiplier = 0d;
- double rankMultiplers = 0;
-
- sb.append( "&6RankMulipliers: &a[ &6" );
-
- if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) {
-
-
- RankPlayer rPlayer = sPlayer.getRankPlayer();
-
- Set keys = rPlayer.getLadderRanks().keySet();
- for (RankLadder ladderKey : keys) {
- PlayerRank pRank = rPlayer.getLadderRanks().get(ladderKey);
- String rankName = pRank.getRank().getName();
-
- String multiplierRankString = sellAllConfig.getString("Multiplier." + rankName + ".MULTIPLIER");
-
- if (multiplierRankString != null && sellAllPrestigeMultipliers.containsKey( rankName )){
-
- double rankMult = sellAllPrestigeMultipliers.get( rankName );
- rankMultiplers += rankMult;
-
- sb.append( rankMult ).append( " " );
- }
- }
- }
-
- if ( rankMultiplers == 0 ) {
- multiplier = defaultMultiplier;
- sb.append( "&cnone " );
- }
- else {
- multiplier = rankMultiplers;
- }
-
- sb.append( "&a] " );
-
-
- sb.append( "&6Base multiplier: &c" )
- .append( multiplier ).append( " " );
-
-
-
- long tPoint2 = System.nanoTime();
-
- // Get multiplier depending on Player + Prestige. NOTE that prestige multiplier will replace
- // the actual default multiplier.
-// if (module != null) {
-// PrisonRanks rankPlugin = (PrisonRanks) module;
-// if (rankPlugin.getPlayerManager().getPlayer(sPlayer) != null) {
-// String playerRankName;
-// try {
-//
-// RankPlayerFactory rankPlayerFactory = new RankPlayerFactory();
-//
-// RankPlayer rankPlayer = rankPlugin.getPlayerManager().getPlayer(sPlayer);
-// PlayerRank pRank = rankPlayer == null ? null : rankPlayerFactory.getRank( rankPlayer, "prestiges");
-// Rank rank = pRank == null ? null : pRank.getRank();
-//
-// playerRankName = rank == null ? null : rank.getName();
-// } catch (NullPointerException ex) {
-// playerRankName = null;
-// }
-// if (playerRankName != null) {
-// String multiplierRankString = sellAllConfig.getString("Multiplier." + playerRankName + ".MULTIPLIER");
-// if (multiplierRankString != null && sellAllPrestigeMultipliers.containsKey(playerRankName)){
-// multiplier = sellAllPrestigeMultipliers.get(playerRankName);
-// }
-// }
-// }
-// }
-
- // Get Multiplier from multipliers permission's if there's any.
- String permPattern = "prison.sellall.multiplier.";
- List perms = sPlayer.getPermissions( permPattern );
- List debugRejected = new ArrayList<>();
- String debugHighest = null;
-
- if ( perms.size() == 0 && sPlayer.getRankPlayer() != null ) {
- sb.append( "&cNoBukkkitPerms " );
-
- perms.addAll( sPlayer.getPermissions( permPattern, sPlayer.getRankPlayer().getPermsSnapShot() ));
-
- if ( perms.size() > 0 ) {
-
- sb.append( "&c(Using &6" );
- sb.append( perms.size() );
- sb.append( " &csnapshotPerms) " );
- }
- }
-
- sb.append( "&6PermissionMulipliers: &a[ &6" );
-
-
- double multiplierExtraByPerms = 0;
- for (String multByPerm : perms) {
-
- String multStr = multByPerm.replace(permPattern, "");
- if ( multStr.contains( "_" ) ) {
- multStr = multStr.substring( 0, multStr.indexOf("_") );
- }
-
- double multByPermDouble = Double.parseDouble( multStr );
-
- boolean highest = multByPermDouble > multiplierExtraByPerms;
-
- String debugMult = multByPermDouble + ":" + multByPerm + "&r ";
-
- if ( !isSellAllPermissionMultiplierOnlyHigherEnabled ) {
- multiplierExtraByPerms += multByPermDouble;
-
- sb.append( "&6" )
- .append( debugMult );
- }
- else {
-
- if ( highest ) {
- multiplierExtraByPerms = multByPermDouble;
-
- if ( debugHighest != null ) {
- debugRejected.add( debugHighest );
- }
- debugHighest = debugMult;
- }
- else {
- debugRejected.add( debugMult );
- }
-
- }
-
- }
-
- if ( debugHighest != null ) {
- sb.append( "&6" ) // Green
- .append( debugHighest );
- }
-
- for (String rejected : debugRejected) {
- sb.append( "&m&c" ) // Strike through & red
- .append( rejected );
- }
-
- sb.append( " &a] " );
-
-
- multiplier += multiplierExtraByPerms;
-
- sb.append( "&6PermissionTotal: &a[ &6" )
- .append( multiplierExtraByPerms )
- .append( " &a] " );
-
- sb.append( "&6TotalMultiplier: &a[ &6" )
- .append( multiplier )
- .append( " &a] " );
-
- long tPoint3 = System.nanoTime();
- DecimalFormat dFmt = Prison.get().getDecimalFormat( "0.0000" );
- String debugMsg = " :t1=" +
- dFmt.format( (tPoint2 - tPoint1)/1000000d ) +
- " :t2=" +
- dFmt.format( (tPoint3 - tPoint2)/1000000 ) + "}";
-
- sb.append( debugMsg );
-
-
- Output.get().logInfo( sb.toString() );
-
- return multiplier;
+ StringBuilder sb = new StringBuilder();
+
+ long tPoint1 = System.nanoTime();
+
+ sb.append( "&dCalculate Sellall Player Multipliers: &6" )
+ .append( sPlayer.getName() );
+
+ if (!isSellAllMultiplierEnabled) {
+
+ sb.append( " &cSellall Multipliers are disabled." );
+ if ( Output.get().isDebug() ) {
+ Output.get().logInfo( sb.toString() );
+ }
+
+ return 1d;
+ }
+
+
+ sb.append( " &aEnabled &6DefaultMult: &c" )
+ .append( defaultMultiplier );
+
+ if ( isSellAllPermissionMultiplierOnlyHigherEnabled ) {
+ sb.append( " &a(Use only the highest perm multiplier) " );
+ }
+
+
+
+ double multiplier = 0d;
+ double rankMultiplers = 0;
+
+ sb.append( "&6RankMulipliers: &a[ &6" );
+
+ if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) {
+
+
+ RankPlayer rPlayer = sPlayer.getRankPlayer();
+
+ Set keys = rPlayer.getLadderRanks().keySet();
+ for (RankLadder ladderKey : keys) {
+ PlayerRank pRank = rPlayer.getLadderRanks().get(ladderKey);
+ String rankName = pRank.getRank().getName();
+
+ String multiplierRankString = sellAllConfig.getString("Multiplier." + rankName + ".MULTIPLIER");
+
+ if (multiplierRankString != null && sellAllPrestigeMultipliers.containsKey( rankName )){
+
+ double rankMult = sellAllPrestigeMultipliers.get( rankName );
+ rankMultiplers += rankMult;
+
+ sb.append( rankMult ).append( " " );
+ }
+ }
+ }
+
+ if ( rankMultiplers == 0 ) {
+ multiplier = defaultMultiplier;
+ sb.append( "&cnone " );
+ }
+ else {
+ multiplier = rankMultiplers;
+ }
+
+ sb.append( "&a] " );
+
+
+ sb.append( "&6Base multiplier: &c" )
+ .append( multiplier ).append( " " );
+
+
+ long tPoint2 = System.nanoTime();
+
+
+ // Get Multiplier from multipliers permission's if there's any.
+ String permPattern = "prison.sellall.multiplier.";
+ List perms = sPlayer.getPermissions( permPattern );
+ List debugRejected = new ArrayList<>();
+ String debugHighest = null;
+
+ if ( perms.size() == 0 && sPlayer.getRankPlayer() != null ) {
+ sb.append( "&cNoBukkkitPerms " );
+
+ perms.addAll( sPlayer.getPermissions( permPattern, sPlayer.getRankPlayer().getPermsSnapShot() ));
+
+ if ( perms.size() > 0 ) {
+
+ sb.append( "&c(Using &6" );
+ sb.append( perms.size() );
+ sb.append( " &csnapshotPerms) " );
+ }
+ }
+
+ sb.append( "&6PermissionMulipliers: &a[ &6" );
+
+
+ double multiplierExtraByPerms = 0;
+ for (String multByPerm : perms) {
+
+ String multStr = multByPerm.replace(permPattern, "");
+ if ( multStr.contains( "_" ) ) {
+ multStr = multStr.substring( 0, multStr.indexOf("_") );
+ }
+
+ double multByPermDouble = Double.parseDouble( multStr );
+
+ boolean highest = multByPermDouble > multiplierExtraByPerms;
+
+ String debugMult = multByPermDouble + ":" + multByPerm + "&r ";
+
+ if ( !isSellAllPermissionMultiplierOnlyHigherEnabled ) {
+ multiplierExtraByPerms += multByPermDouble;
+
+ sb.append( "&6" )
+ .append( debugMult );
+ }
+ else {
+
+ if ( highest ) {
+ multiplierExtraByPerms = multByPermDouble;
+
+ if ( debugHighest != null ) {
+ debugRejected.add( debugHighest );
+ }
+ debugHighest = debugMult;
+ }
+ else {
+ debugRejected.add( debugMult );
+ }
+
+ }
+
+ }
+
+ if ( debugHighest != null ) {
+ sb.append( "&6" ) // Green
+ .append( debugHighest );
+ }
+
+ for (String rejected : debugRejected) {
+ sb.append( "&m&c" ) // Strike through & red
+ .append( rejected );
+ }
+
+ sb.append( " &a] " );
+
+
+ multiplier += multiplierExtraByPerms;
+
+ sb.append( "&6PermissionTotal: &a[ &6" )
+ .append( multiplierExtraByPerms )
+ .append( " &a] " );
+
+ sb.append( "&6TotalMultiplier: &a[ &6" )
+ .append( multiplier )
+ .append( " &a] " );
+
+ long tPoint3 = System.nanoTime();
+ DecimalFormat dFmt = Prison.get().getDecimalFormat( "0.0000" );
+ String debugMsg = " :t1=" +
+ dFmt.format( (tPoint2 - tPoint1)/1000000d ) +
+ " :t2=" +
+ dFmt.format( (tPoint3 - tPoint2)/1000000 ) + "}";
+
+ sb.append( debugMsg );
+
+
+ Output.get().logInfo( sb.toString() );
+
+ return multiplier;
}
public List getPlayerMultiplierList( Player p ) {
- List results = new ArrayList<>();
-
-
- if (!isSellAllMultiplierEnabled) {
- results.add( "1.0 - Sellall multipler is disabled. Default value." );
-
- return results;
- }
-
- DecimalFormat dFmt = Prison.getDecimalFormatStaticDouble();
-
- SpigotPlayer sPlayer = new SpigotPlayer(p);
-
- if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) {
-
- RankPlayer rPlayer = sPlayer.getRankPlayer();
-
- Set keys = rPlayer.getLadderRanks().keySet();
- for (RankLadder ladderKey : keys) {
- PlayerRank pRank = rPlayer.getLadderRanks().get(ladderKey);
- String rankName = pRank.getRank().getName();
-
- String multiplierRankString = sellAllConfig.getString("Multiplier." + rankName + ".MULTIPLIER");
- if (multiplierRankString != null && sellAllPrestigeMultipliers.containsKey( rankName )){
- double mult = sellAllPrestigeMultipliers.get( rankName );
- String msg = String.format(
- "%s - %s rank Sellall multiplier",
- dFmt.format(mult), rankName
- );
- results.add( msg );
- }
- }
- }
-
- if ( results.size() == 0 ) {
- String msg = String.format(
- "%s - default Sellall multiplier - no rank mulitiplers",
- dFmt.format(defaultMultiplier)
- );
- results.add(msg);
- }
-
-
- // Get Multiplier from multipliers permission's if there's any.
- List perms = sPlayer.getPermissions("prison.sellall.multiplier.");
- double multiplierExtraByPerms = 0;
- int count = 0;
- String greatestPerm = "";
- for (String multByPerm : perms) {
-
- double multByPermDouble = Double.parseDouble(multByPerm.substring(26));
-
- if ( !isSellAllPermissionMultiplierOnlyHigherEnabled ) {
- multiplierExtraByPerms += multByPermDouble;
-
- String msg = String.format(
- "%s - Sellall permission multiplier - %s",
- dFmt.format(multByPermDouble), multByPerm
- );
- results.add(msg);
- }
- else if (multByPermDouble > multiplierExtraByPerms) {
- multiplierExtraByPerms = multByPermDouble;
- count++;
- greatestPerm = multByPerm;
- }
- }
-
- if ( isSellAllPermissionMultiplierOnlyHigherEnabled ) {
-
- String msg = String.format(
- "%s - Sellall permission multiplier - greatest out of %d - %s",
- dFmt.format(multiplierExtraByPerms), count, greatestPerm
- );
- results.add(msg);
- }
-
- return results;
+ List results = new ArrayList<>();
+
+
+ if (!isSellAllMultiplierEnabled) {
+ results.add( "1.0 - Sellall multipler is disabled. Default value." );
+
+ return results;
+ }
+
+ DecimalFormat dFmt = Prison.getDecimalFormatStaticDouble();
+
+ SpigotPlayer sPlayer = new SpigotPlayer(p);
+
+ if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) {
+
+ RankPlayer rPlayer = sPlayer.getRankPlayer();
+
+ Set keys = rPlayer.getLadderRanks().keySet();
+ for (RankLadder ladderKey : keys) {
+ PlayerRank pRank = rPlayer.getLadderRanks().get(ladderKey);
+ String rankName = pRank.getRank().getName();
+
+ String multiplierRankString = sellAllConfig.getString("Multiplier." + rankName + ".MULTIPLIER");
+ if (multiplierRankString != null && sellAllPrestigeMultipliers.containsKey( rankName )){
+ double mult = sellAllPrestigeMultipliers.get( rankName );
+ String msg = String.format(
+ "%s - %s rank Sellall multiplier",
+ dFmt.format(mult), rankName
+ );
+ results.add( msg );
+ }
+ }
+ }
+
+ if ( results.size() == 0 ) {
+ String msg = String.format(
+ "%s - default Sellall multiplier - no rank mulitiplers",
+ dFmt.format(defaultMultiplier)
+ );
+ results.add(msg);
+ }
+
+
+ // Get Multiplier from multipliers permission's if there's any.
+ List perms = sPlayer.getPermissions("prison.sellall.multiplier.");
+ double multiplierExtraByPerms = 0;
+ int count = 0;
+ String greatestPerm = "";
+ for (String multByPerm : perms) {
+
+ double multByPermDouble = Double.parseDouble(multByPerm.substring(26));
+
+ if ( !isSellAllPermissionMultiplierOnlyHigherEnabled ) {
+ multiplierExtraByPerms += multByPermDouble;
+
+ String msg = String.format(
+ "%s - Sellall permission multiplier - %s",
+ dFmt.format(multByPermDouble), multByPerm
+ );
+ results.add(msg);
+ }
+ else if (multByPermDouble > multiplierExtraByPerms) {
+ multiplierExtraByPerms = multByPermDouble;
+ count++;
+ greatestPerm = multByPerm;
+ }
+ }
+
+ if ( isSellAllPermissionMultiplierOnlyHigherEnabled ) {
+
+ String msg = String.format(
+ "%s - Sellall permission multiplier - greatest out of %d - %s",
+ dFmt.format(multiplierExtraByPerms), count, greatestPerm
+ );
+ results.add(msg);
+ }
+
+ return results;
}
-// /**
-// * 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;
-// }
-
-// /**
-// * 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 = sPlayer.getSellAllMultiplier();
-
- SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
-
- List soldItems = valueOfInventoryItems( spInventory, multiplier );
- for (SellAllData soldItem : soldItems) {
- value += soldItem.getTransactionAmount();
- }
-
- return value;
+ double value = 0;
+
+ double multiplier = sPlayer.getSellAllMultiplier();
+
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
+
+ List soldItems = valueOfInventoryItems( spInventory, multiplier );
+ for (SellAllData soldItem : soldItems) {
+ value += soldItem.getTransactionAmount();
+ }
+
+ return value;
}
public String getPlayerInventoryValueReport( SpigotPlayer sPlayer ) {
- double multiplier = sPlayer.getSellAllMultiplier();
-
- SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
-
- List soldItems = valueOfInventoryItems( spInventory, multiplier );
-
- String report = SellAllData.itemsSoldReport(soldItems, sPlayer, multiplier);
-
- return report;
+ double multiplier = sPlayer.getSellAllMultiplier();
+
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
+
+ List soldItems = valueOfInventoryItems( spInventory, multiplier );
+
+ String report = SellAllData.itemsSoldReport(soldItems, sPlayer, multiplier);
+
+ return report;
}
public List getPlayerInventoryValueTransactions( SpigotPlayer sPlayer ) {
- double multiplier = sPlayer.getSellAllMultiplier();
-// double multiplier = getPlayerMultiplier(sPlayer.getWrapper());
-
- SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
-
- List soldItems = valueOfInventoryItems( spInventory, multiplier );
-
- return soldItems;
+ double multiplier = sPlayer.getSellAllMultiplier();
+
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
+
+ List soldItems = valueOfInventoryItems( spInventory, multiplier );
+
+ return soldItems;
}
public double getItemStackValue( SpigotPlayer sPlayer, SpigotItemStack itemStack ) {
- double multiplier = sPlayer.getSellAllMultiplier();
-
- SellAllData sad = sellItemStack( itemStack, multiplier );
-
- return sad == null ? 0 : sad.getTransactionAmount();
+ double multiplier = sPlayer.getSellAllMultiplier();
+
+ SellAllData sad = sellItemStack( itemStack, multiplier );
+
+ return sad == null ? 0 : sad.getTransactionAmount();
}
public String getItemStackValueReport( SpigotPlayer sPlayer, SpigotItemStack itemStack ) {
- double multiplier = sPlayer.getSellAllMultiplier();
-
- List soldItems = new ArrayList<>();
-
- SellAllData sad = sellItemStack( itemStack, multiplier );
- if ( sad != null ) {
-
- soldItems.add( sad );
- }
-
- String report = SellAllData.itemsSoldReport(soldItems, sPlayer, multiplier);
-
- return report;
+ double multiplier = sPlayer.getSellAllMultiplier();
+
+ List soldItems = new ArrayList<>();
+
+ SellAllData sad = sellItemStack( itemStack, multiplier );
+ if ( sad != null ) {
+
+ soldItems.add( sad );
+ }
+
+ String report = SellAllData.itemsSoldReport(soldItems, sPlayer, multiplier);
+
+ return report;
}
public List getItemStackValueTransactions( SpigotPlayer sPlayer, SpigotItemStack itemStack ) {
- double multiplier = sPlayer.getSellAllMultiplier();
-
- List soldItems = new ArrayList<>();
-
- SellAllData sad = sellItemStack( itemStack, multiplier );
- if ( sad != null ) {
-
- soldItems.add( sad );
- }
-
- return soldItems;
+ double multiplier = sPlayer.getSellAllMultiplier();
+
+ List soldItems = new ArrayList<>();
+
+ SellAllData sad = sellItemStack( itemStack, multiplier );
+ if ( sad != null ) {
+
+ soldItems.add( sad );
+ }
+
+ return soldItems;
}
/**
@@ -1086,62 +759,62 @@ public List getItemStackValueTransactions( SpigotPlayer sPlayer, Sp
*/
public List sellPlayerItems(Player p) {
- SpigotPlayer sPlayer = new SpigotPlayer( p );
-
- double multiplier = sPlayer.getSellAllMultiplier();
-
-
- // Remove player's off-hand and helmet slots since those don't always sell correctly:
- boolean invDirty = false;
- ItemStack offHandItemStack = SpigotCompatibility.getInstance().getItemInOffHandStrict( p );
-
- if ( offHandItemStack != null ) {
- // 1.8 will always be null, so it will never hit this.
- ItemStack itemStack = null;
- SpigotCompatibility.getInstance().setItemStackInOffHandStrict( p, itemStack );
-
- invDirty = true;
- }
-
- ItemStack helmetItemStack = p.getInventory().getHelmet();
-
- if ( helmetItemStack != null ) {
- p.getInventory().setHelmet( null );
-
- invDirty = true;
- }
-
-
-
- SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
-
-
- List soldData = sellInventoryItems( spInventory, multiplier );
-
-
-
- // Since the inventory is done being sold, add back the offHand and helmet:
- if ( offHandItemStack != null ) {
- // 1.8 will always be null, so it will never hit this.
- SpigotCompatibility.getInstance().setItemStackInOffHandStrict( p, offHandItemStack );
- }
-
- if ( helmetItemStack != null ) {
- p.getInventory().setHelmet( helmetItemStack );
- }
-
- if ( invDirty ) {
- p.updateInventory();
- }
-
-
- if ( isSellAllBackpackItemsEnabled && BackpacksUtil.getInstance().isEnabled() ) {
- BackpacksUtil bpUtil = BackpacksUtil.get();
-
- soldData.addAll( bpUtil.sellInventoryItems( p, multiplier ) );
- }
-
- // Enable sellall for the Minepacks plugin:
+ SpigotPlayer sPlayer = new SpigotPlayer( p );
+
+ double multiplier = sPlayer.getSellAllMultiplier();
+
+
+ // Remove player's off-hand and helmet slots since those don't always sell correctly:
+ boolean invDirty = false;
+ ItemStack offHandItemStack = SpigotCompatibility.getInstance().getItemInOffHandStrict( p );
+
+ if ( offHandItemStack != null ) {
+ // 1.8 will always be null, so it will never hit this.
+ ItemStack itemStack = null;
+ SpigotCompatibility.getInstance().setItemStackInOffHandStrict( p, itemStack );
+
+ invDirty = true;
+ }
+
+ ItemStack helmetItemStack = p.getInventory().getHelmet();
+
+ if ( helmetItemStack != null ) {
+ p.getInventory().setHelmet( null );
+
+ invDirty = true;
+ }
+
+
+
+ SpigotPlayerInventory spInventory = sPlayer.getSpigotPlayerInventory();
+
+
+ List soldData = sellInventoryItems( spInventory, multiplier );
+
+
+
+ // Since the inventory is done being sold, add back the offHand and helmet:
+ if ( offHandItemStack != null ) {
+ // 1.8 will always be null, so it will never hit this.
+ SpigotCompatibility.getInstance().setItemStackInOffHandStrict( p, offHandItemStack );
+ }
+
+ if ( helmetItemStack != null ) {
+ p.getInventory().setHelmet( helmetItemStack );
+ }
+
+ if ( invDirty ) {
+ p.updateInventory();
+ }
+
+
+ if ( isSellAllBackpackItemsEnabled && BackpacksUtil.getInstance().isEnabled() ) {
+ BackpacksUtil bpUtil = BackpacksUtil.get();
+
+ soldData.addAll( bpUtil.sellInventoryItems( p, multiplier ) );
+ }
+
+ // Enable sellall for the Minepacks plugin:
if ( isSellAllMinesBackpacksPluginEnabled && IntegrationMinepacksPlugin.getInstance().isEnabled() ) {
soldData.addAll( IntegrationMinepacksPlugin.getInstance().sellInventoryItems( p, multiplier ) );
}
@@ -1151,7 +824,7 @@ public List sellPlayerItems(Player p) {
soldData.addAll( IntegrationBackpackAPI.getInstance().sellInventoryItems( p, multiplier ) );
}
- return soldData;
+ return soldData;
}
/**
@@ -1171,37 +844,37 @@ public List sellPlayerItems(Player p) {
public List sellPlayerItemStacks(Player p,
List itemStacks ) {
- double multiplier = getPlayerMultiplier(p);
-
- List soldItems = new ArrayList<>();
-
- if ( itemStacks != null ) {
-
- List removable = new ArrayList<>();
-
- // Go through all of the player's inventory and identify what can be sold.
- // 1. if it can be sold, then create a SellAllData "receipt"
- // 2. Add sad to the soldItems List
- // 3. Add the ItemStack to the removable List to be removed later
- for ( SpigotItemStack inv : itemStacks ) {
-
- SellAllData sad = sellItemStack( inv, multiplier );
-
- if ( sad != null ) {
-
- sad.setItemsSold( true );
-
- soldItems.add(sad);
-
- removable.add(inv);
- }
- }
-
- // We've identified all that could be sold, now remove them from the player's inventory
- for (tech.mcprison.prison.internal.ItemStack itemStack : removable) {
- itemStacks.remove( itemStack );
- }
- }
+ double multiplier = getPlayerMultiplier(p);
+
+ List soldItems = new ArrayList<>();
+
+ if ( itemStacks != null ) {
+
+ List removable = new ArrayList<>();
+
+ // Go through all of the player's inventory and identify what can be sold.
+ // 1. if it can be sold, then create a SellAllData "receipt"
+ // 2. Add sad to the soldItems List
+ // 3. Add the ItemStack to the removable List to be removed later
+ for ( SpigotItemStack inv : itemStacks ) {
+
+ SellAllData sad = sellItemStack( inv, multiplier );
+
+ if ( sad != null ) {
+
+ sad.setItemsSold( true );
+
+ soldItems.add(sad);
+
+ removable.add(inv);
+ }
+ }
+
+ // We've identified all that could be sold, now remove them from the player's inventory
+ for (tech.mcprison.prison.internal.ItemStack itemStack : removable) {
+ itemStacks.remove( itemStack );
+ }
+ }
return soldItems;
}
@@ -1209,56 +882,56 @@ public List sellPlayerItemStacks(Player p,
public List sellInventoryItems( tech.mcprison.prison.internal.inventory.Inventory inventory,
double multiplier ) {
- List soldItems = new ArrayList<>();
-
- if ( inventory != null ) {
-
- List removable = new ArrayList<>();
-
- // Go through all of the player's inventory and identify what can be sold.
- // 1. if it can be sold, then create a SellAllData "receipt"
- // 2. Add sad to the soldItems List
- // 3. Add the ItemStack to the removable List to be removed later
- for ( tech.mcprison.prison.internal.ItemStack inv : inventory.getItems() ) {
-
- SellAllData sad = sellItemStack( (SpigotItemStack)inv, multiplier );
-
- if ( sad != null ) {
-
- sad.setItemsSold( true );
-
- soldItems.add(sad);
-
- removable.add(inv);
- }
- }
-
- // We've identified all that could be sold, now remove them from the player's inventory
- for (tech.mcprison.prison.internal.ItemStack itemStack : removable) {
- inventory.removeItem( itemStack );
- }
- }
+ List soldItems = new ArrayList<>();
+
+ if ( inventory != null ) {
+
+ List removable = new ArrayList<>();
+
+ // Go through all of the player's inventory and identify what can be sold.
+ // 1. if it can be sold, then create a SellAllData "receipt"
+ // 2. Add sad to the soldItems List
+ // 3. Add the ItemStack to the removable List to be removed later
+ for ( tech.mcprison.prison.internal.ItemStack inv : inventory.getItems() ) {
+
+ SellAllData sad = sellItemStack( (SpigotItemStack)inv, multiplier );
+
+ if ( sad != null ) {
+
+ sad.setItemsSold( true );
+
+ soldItems.add(sad);
+
+ removable.add(inv);
+ }
+ }
+
+ // We've identified all that could be sold, now remove them from the player's inventory
+ for (tech.mcprison.prison.internal.ItemStack itemStack : removable) {
+ inventory.removeItem( itemStack );
+ }
+ }
return soldItems;
}
private List valueOfInventoryItems(
tech.mcprison.prison.internal.inventory.Inventory inventory, double multiplier ) {
- List soldItems = new ArrayList<>();
-
- if ( inventory != null ) {
-
- for ( tech.mcprison.prison.internal.ItemStack inv : inventory.getItems() ) {
-
- SellAllData sad = sellItemStack( (SpigotItemStack)inv, multiplier );
-
- if ( sad != null ) {
- soldItems.add(sad);
- }
- }
- }
-
- return soldItems;
+ List soldItems = new ArrayList<>();
+
+ if ( inventory != null ) {
+
+ for ( tech.mcprison.prison.internal.ItemStack inv : inventory.getItems() ) {
+
+ SellAllData sad = sellItemStack( (SpigotItemStack)inv, multiplier );
+
+ if ( sad != null ) {
+ soldItems.add(sad);
+ }
+ }
+ }
+
+ return soldItems;
}
/**
@@ -1275,257 +948,54 @@ private List valueOfInventoryItems(
* @return
*/
private SellAllData sellItemStack( SpigotItemStack iStack, double multiplier ) {
- SellAllData soldItem = null;
-
- if ( iStack != null ) {
-
- // This converts a bukkit ItemStack to a PrisonBlock, and it also sets up the
- // displayName if that is set on the itemStack.
- PrisonBlock pBlockInv = iStack.getMaterial();
-
- PrisonBlock pBlockSellAll = getSellallItem( pBlockInv );
-
- if ( pBlockSellAll != null ) {
-
- if ( iStack != null && iStack.getEnchantments() != null && iStack.getEnchantments().size() > 0 ) {
- // Cannot sell enchanted items:
- if ( Output.get().isDebug() ) {
- String msg = String.format(
- "Sellall: Cannot sell item '%s' (qty %s) because it has enchantments which is not allowed. ",
- (iStack.getDisplayName() != null ? iStack.getDisplayName() : iStack.getName() ),
- Integer.toString( iStack.getAmount() )
- );
- Output.get().logInfo( msg );
- }
- }
-
- else if ( !pBlockSellAll.isLoreAllowed() && iStack.getLore().size() > 0 ) {
- if ( Output.get().isDebug() ) {
- String msg = String.format(
- "Sellall: Cannot sell item '%s' (qty %s) because it has lore which is not allowed. ",
- (iStack.getDisplayName() != null ? iStack.getDisplayName() : iStack.getName() ),
- Integer.toString( iStack.getAmount() )
- );
- Output.get().logInfo( msg );
- }
-
- }
- else {
-
- double amount = iStack.getAmount() * pBlockSellAll.getSalePrice() * multiplier;
- soldItem = new SellAllData( pBlockSellAll, iStack.getAmount(), amount );
- }
- }
- }
-
- return soldItem;
+ SellAllData soldItem = null;
+
+ if ( iStack != null ) {
+
+ // This converts a bukkit ItemStack to a PrisonBlock, and it also sets up the
+ // displayName if that is set on the itemStack.
+ PrisonBlock pBlockInv = iStack.getMaterial();
+
+ PrisonBlock pBlockSellAll = getSellallItem( pBlockInv );
+
+ if ( pBlockSellAll != null ) {
+
+ if ( iStack != null && iStack.getEnchantments() != null && iStack.getEnchantments().size() > 0 ) {
+ // Cannot sell enchanted items:
+ if ( Output.get().isDebug() ) {
+ String msg = String.format(
+ "Sellall: Cannot sell item '%s' (qty %s) because it has enchantments which is not allowed. ",
+ (iStack.getDisplayName() != null ? iStack.getDisplayName() : iStack.getName() ),
+ Integer.toString( iStack.getAmount() )
+ );
+ Output.get().logInfo( msg );
+ }
+ }
+
+ else if ( !pBlockSellAll.isLoreAllowed() && iStack.getLore().size() > 0 ) {
+ if ( Output.get().isDebug() ) {
+ String msg = String.format(
+ "Sellall: Cannot sell item '%s' (qty %s) because it has lore which is not allowed. ",
+ (iStack.getDisplayName() != null ? iStack.getDisplayName() : iStack.getName() ),
+ Integer.toString( iStack.getAmount() )
+ );
+ Output.get().logInfo( msg );
+ }
+
+ }
+ else {
+
+ double amount = iStack.getAmount() * pBlockSellAll.getSalePrice() * multiplier;
+ soldItem = new SellAllData( pBlockSellAll, iStack.getAmount(), amount );
+ }
+ }
+ }
+
+ return soldItem;
}
-// /**
-// * 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 (sellAllItems.isEmpty()){
-// return 0;
-// }
-//
-// return getSellMoney(p, getHashMapOfPlayerInventories(p));
-// }
-
-// /**
-// * This sells a specific item stack. Actually it returns the value of an item stack,
-// * its up to the calling function to dispose of the contents if the result is non-zero.
-// *
-// * @param p
-// * @param itemStack
-// * @return
-// */
-// private double getSellMoney( Player p, SpigotItemStack itemStack )
-// {
-// double results = 0d;
-//
-// // Either ignore custom names, or if isSellAllIgnoreCustomNames is set, then allow them
-// // to be processed as they used to be processed.
-//
-// // For now, do not sell custom blocks since this sellall is based upon
-// // XMaterial and custom blocks cannot be represented by XMaterial so
-// // it will sell it as the wrong material
-// if ( isSellAllIgnoreCustomNames ||
-// itemStack.getMaterial().getBlockType() == null ||
-// itemStack.getMaterial().getBlockType() == PrisonBlockType.minecraft ) {
-//
-// HashMap xMaterialIntegerHashMap = new HashMap<>();
-//
-// PrisonBlock pBlock = itemStack.getMaterial();
-//
-// XMaterial xMat = SpigotCompatibility.getInstance().getXMaterial( pBlock );
-//
-// if ( xMat != null ) {
-// xMaterialIntegerHashMap.put( xMat, itemStack.getAmount() );
-//
-// results = getSellMoney( p, xMaterialIntegerHashMap );
-// }
-// }
-//
-//
-// return results;
-// }
-
-
-// /**
-// * This gets the player's inventory, ignoring the armor slots.
-// *
-// * @param p
-// * @return
-// */
-// private List getPlayerInventory( Player p ) {
-//
-// return getPlayerInventory( p.getInventory() );
-//
-//// List results = new ArrayList<>();
-////
-//// PlayerInventory inv = p.getInventory();
-////
-//// for ( ItemStack iStack : inv.getStorageContents() ) {
-//// if ( iStack != null ) {
-//// results.add(iStack);
-//// }
-//// }
-//// for ( ItemStack iStack : inv.getExtraContents() ) {
-//// if ( iStack != null ) {
-//// results.add(iStack);
-//// }
-//// }
-////
-//// return results;
-// }
-// private List getPlayerInventory( PlayerInventory inv ) {
-// List results = new ArrayList<>();
-//
-// for ( ItemStack iStack : inv.getContents() ) {
-// if ( iStack != null ) {
-// results.add(iStack);
-// }
-// }
-//
-// try {
-// for ( ItemStack iStack : inv.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 : inv.getArmorContents() ) {
-// if ( iStack != null ) {
-// results.remove(iStack);
-// }
-// }
-//
-// return results;
-// }
-
-// /**
-// * Get HashMap with all the items of a Player.
-// *
-// * Return HashMap of XMaterial-Integer.
-// *
-// * @param p - Player.
-// *
-// * @return HashMap - XMaterial-Integer.
-// * */
-// private HashMap getHashMapOfPlayerInventories(Player p) {
-//
-// HashMap xMaterialIntegerHashMap = new HashMap<>();
-//
-// if (isSellAllBackpackItemsEnabled && getBoolean(SpigotPrison.getInstance().getConfig().getString("backpacks"))){
-//
-// BackpacksUtil backpacksUtil = BackpacksUtil.get();
-// if (backpacksUtil.isMultipleBackpacksEnabled()){
-// for (String id : backpacksUtil.getBackpacksIDs(p)){
-// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, backpacksUtil.getBackpack(p, id));
-// }
-// } else {
-// String id = null;
-// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap,
-// backpacksUtil.getBackpack(p, id));
-// }
-// }
-//
-// if (isSellAllMinesBackpacksPluginEnabled && IntegrationMinepacksPlugin.getInstance().isEnabled()){
-// Backpack backpack = IntegrationMinepacksPlugin.getInstance().getMinepacks().getBackpackCachedOnly(p);
-// if (backpack != null) {
-// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, backpack.getInventory());
-// backpack.setChanged();
-// backpack.save();
-// }
-// }
-//
-// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, getPlayerInventory( p ));
-//// xMaterialIntegerHashMap = addInventoryToHashMap(xMaterialIntegerHashMap, p.getInventory());
-// return xMaterialIntegerHashMap;
-// }
-
-// /**
-// * If autosell is enabled, and if user toggleable is enabled, then
-// * it will check to see if the player has the perm or
-// *
-// * Get AutoSell Player toggle if available.
-// * If he enabled it, AutoSell will work, otherwise it won't.
-// * If he never used the toggle command, this will return true, just like if he enabled it in the first place.
-// *
-// * @param p - Player.
-// *
-// * @return boolean.
-// * */
-// public boolean isPlayerAutoSellEnabled(Player p){
-// boolean results = false;
-//
-// // If autosell isn't enabled, then return false
-// if ( isAutoSellEnabled ) {
-//
-// results = isSellallPlayerUserToggleEnabled( p );
-//// if ( !isAutoSellPerUserToggleablePermEnabled ||
-//// isAutoSellPerUserToggleablePermEnabled &&
-//// p.hasPermission(permissionAutoSellPerUserToggleable)){
-////
-//// String settingName = "Users." + p.getUniqueId() + ".isEnabled";
-////
-//// results = sellAllConfig.getString(settingName) == null ||
-//// getBooleanValue( settingName );
-//// }
-// }
-//
-//
-//// if (isAutoSellPerUserToggleablePermEnabled &&
-//// !p.hasPermission(permissionAutoSellPerUserToggleable)){
-//// return false;
-//// }
-////
-//// if (sellAllConfig.getString("Users." + p.getUniqueId() + ".isEnabled") == null){
-//// return true;
-//// }
-//
-//// return getBooleanValue("Users." + p.getUniqueId() + ".isEnabled");
-// return results;
-// }
/**
* This function only checks to see if the user can toggle autosell
@@ -1562,30 +1032,7 @@ public boolean isSellallPlayerUserToggleEnabled( Player p ) {
return results;
}
-// public boolean checkIfPlayerAutosellIsActive(Player p) {
-// boolean results = isAutoSellEnabled;
-//
-// if ( isAutoSellPerUserToggleable ) {
-// results = isPlayerAutoSellEnabled(p);
-// }
-//
-// return results;
-// }
-
-// /**
-// * WARNING: Obsolete because disabled worlds are set in config.yml and
-// * the command handler shuts down in those worlds. So it will
-// * never run any sellall commands in a diabled world.
-// *
-// * Check if Player is in a disabled world, where he can't use sellall sell.
-// *
-// * Return True if he's in a disabled world, False if not.
-// *
-// * @return boolean.
-// * */
-// public boolean isPlayerInDisabledWorld(Player p){
-// return sellAllDisabledWorlds.contains(p.getWorld().getName());
-// }
+
/**
* Check if Player is waiting for the end of SellAll Sell Delay.
@@ -1624,16 +1071,6 @@ public boolean isValidItem(String item){
return XMaterial.matchXMaterial(item).isPresent();
}
-// /**
-// * Update SellAll Cached config.
-// * */
-// public void updateConfig(){
-//
-// initCachedData();
-//
-//// sellAllConfig = SpigotPrison.getInstance().updateSellAllConfig();
-// }
-
/**
@@ -1644,9 +1081,8 @@ public boolean isValidItem(String item){
* */
public HashMap initSellAllItems(){
- HashMap sellAllItems = new HashMap<>();
+ HashMap sellAllItems = new HashMap<>();
-// HashMap sellAllXMaterials = new HashMap<>();
if (sellAllConfig.getConfigurationSection("Items") == null){
return sellAllItems;
@@ -1662,77 +1098,64 @@ public HashMap initSellAllItems(){
PrisonBlock pBlock = Prison.get().getPlatform().getPrisonBlock(itemID);
if ( pBlock == null ) {
- // create a prison block for this sellall item:
- pBlock = new PrisonBlock( key.trim().toLowerCase() );
-
-
- // Prevent this item from being used within mines:
- pBlock.setSellallOnly( true );
-
- // Add it:
- List newBlockTypes = new ArrayList<>();
- newBlockTypes.add( pBlock );
- Prison.get().getPlatform().getPrisonBlockTypes().addBlockTypes( newBlockTypes );
+ // create a prison block for this sellall item:
+ pBlock = new PrisonBlock( key.trim().toLowerCase() );
+
+
+ // Prevent this item from being used within mines:
+ pBlock.setSellallOnly( true );
+
+ // Add it:
+ List newBlockTypes = new ArrayList<>();
+ newBlockTypes.add( pBlock );
+ Prison.get().getPlatform().getPrisonBlockTypes().addBlockTypes( newBlockTypes );
}
if ( pBlock != null ) {
- String itemDisplayName = sellAllConfig.getString( itemPrefix + ".ITEM_DISPLAY_NAME");
- if ( itemDisplayName != null ) {
- pBlock.setDisplayName( itemDisplayName );
- }
-
- String saleValueString = sellAllConfig.getString( itemPrefix + ".ITEM_VALUE");
- if ( saleValueString != null ) {
-
- try {
- double value = Double.parseDouble(saleValueString);
- pBlock.setSalePrice( value );
- } catch (NumberFormatException ignored) {
- }
- }
-
- String purchaseValueString = sellAllConfig.getString( itemPrefix + ".PURCHASE_PRICE");
- if ( purchaseValueString != null ) {
-
- try {
- double value = Double.parseDouble(purchaseValueString);
- pBlock.setPurchasePrice( value );
- }
- catch (NumberFormatException ignored) {
- }
- }
-
- String isLoreAllowedString = sellAllConfig.getString( itemPrefix + ".IS_LORE_ALLOWED");
- boolean isLoreAllowed = false;
- if ( isLoreAllowedString != null ) {
-
- try {
- isLoreAllowed = Boolean.parseBoolean(isLoreAllowedString);
- }
- catch (NumberFormatException ignored) {
- }
- }
- pBlock.setLoreAllowed( isLoreAllowed );
-
-
- sellAllItems.put( pBlock.getBlockNameSearch(), pBlock );
+ String itemDisplayName = sellAllConfig.getString( itemPrefix + ".ITEM_DISPLAY_NAME");
+ if ( itemDisplayName != null ) {
+ pBlock.setDisplayName( itemDisplayName );
+ }
+
+ String saleValueString = sellAllConfig.getString( itemPrefix + ".ITEM_VALUE");
+ if ( saleValueString != null ) {
+
+ try {
+ double value = Double.parseDouble(saleValueString);
+ pBlock.setSalePrice( value );
+ } catch (NumberFormatException ignored) {
+ }
+ }
+
+ String purchaseValueString = sellAllConfig.getString( itemPrefix + ".PURCHASE_PRICE");
+ if ( purchaseValueString != null ) {
+
+ try {
+ double value = Double.parseDouble(purchaseValueString);
+ pBlock.setPurchasePrice( value );
+ }
+ catch (NumberFormatException ignored) {
+ }
+ }
+
+ String isLoreAllowedString = sellAllConfig.getString( itemPrefix + ".IS_LORE_ALLOWED");
+ boolean isLoreAllowed = false;
+ if ( isLoreAllowedString != null ) {
+
+ try {
+ isLoreAllowed = Boolean.parseBoolean(isLoreAllowedString);
+ }
+ catch (NumberFormatException ignored) {
+ }
+ }
+ pBlock.setLoreAllowed( isLoreAllowed );
+
+
+ sellAllItems.put( pBlock.getBlockNameSearch(), pBlock );
}
-// Optional iMatOptional = XMaterial.matchXMaterial(itemID);
-// XMaterial itemMaterial = iMatOptional.orElse(null);
-
-// if (itemMaterial != null) {
-// String valueString = sellAllConfig.getString("Items." + key.trim().toUpperCase() + ".ITEM_VALUE");
-// if (valueString != null) {
-// try {
-// double value = Double.parseDouble(valueString);
-// sellAllXMaterials.put(itemMaterial, value);
-// } catch (NumberFormatException ignored) {
-// }
-// }
-// }
}
return sellAllItems;
}
@@ -1784,13 +1207,6 @@ public ArrayList initSellAllItemTrigger(){
return xMaterials;
}
-// /**
-// * Get List of names of disabled worlds.
-// * If a Player is in one of these worlds, he won't be able to use SellAll.
-// * */
-// public List initSellAllDisabledWorlds(){
-// return sellAllConfig.getStringList("Options.DisabledWorlds");
-// }
/**
* Add a block to SellAll config.
@@ -1803,7 +1219,7 @@ public ArrayList initSellAllItemTrigger(){
* @return boolean.
* */
public boolean addSellAllBlock(XMaterial xMaterial, double value) {
- return addSellAllBlock( xMaterial.name(), null, value );
+ return addSellAllBlock( xMaterial.name(), null, value );
}
/**
@@ -1819,41 +1235,40 @@ public boolean addSellAllBlock(XMaterial xMaterial, double value) {
*/
public boolean addSellAllBlock( String itemID, String displayName, double value) {
- PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( itemID );
- if ( pBlockKey == null ) {
- Output.get().logDebug( "sellall add: invalid block name (%s)", itemID);
- return false;
- }
-
- // Add the displayName to the block on it can be properly setup in sellall:
- if ( displayName != null && displayName.trim().length() > 0 ) {
- pBlockKey.setDisplayName( displayName );
- }
-
- PrisonBlock pBlock = getSellallItem( pBlockKey );
-
- // If that is an invalid PrisonBlock, then exit
- if ( pBlock != null ) {
- Output.get().logDebug( "sellall add: block already exists (%s)", itemID);
- return false;
- }
-
-
- // pBlock is null, but it's being used below. So clone the key:
- pBlock = pBlockKey.clone();
-
+ PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( itemID );
+ if ( pBlockKey == null ) {
+ Output.get().logDebug( "sellall add: invalid block name (%s)", itemID);
+ return false;
+ }
+
+ // Add the displayName to the block on it can be properly setup in sellall:
+ if ( displayName != null && displayName.trim().length() > 0 ) {
+ pBlockKey.setDisplayName( displayName );
+ }
+
+ PrisonBlock pBlock = getSellallItem( pBlockKey );
+
+ // If that is an invalid PrisonBlock, then exit
+ if ( pBlock != null ) {
+ Output.get().logDebug( "sellall add: block already exists (%s)", itemID);
+ return false;
+ }
+
+
+ // pBlock is null, but it's being used below. So clone the key:
+ pBlock = pBlockKey.clone();
+
try {
- File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
- FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
-
- String itemName = pBlockKey.getBlockNameSearch().toUpperCase();
- String confKey = "Items." + itemName;
-
-// String itemName = pBlockKey.getBlockName().toUpperCase(); // BUG!!
-
- conf.set( confKey + ".ITEM_ID", itemID );
- conf.set( confKey + ".ITEM_VALUE", value);
+ File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
+ FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
+
+ String itemName = pBlockKey.getBlockNameSearch().toUpperCase();
+ String confKey = "Items." + itemName;
+
+
+ conf.set( confKey + ".ITEM_ID", itemID );
+ conf.set( confKey + ".ITEM_VALUE", value);
conf.set( confKey + ".IS_LORE_ALLOWED", pBlock.isLoreAllowed() );
if ( displayName != null ) {
@@ -1869,7 +1284,6 @@ public boolean addSellAllBlock( String itemID, String displayName, double value)
pBlockKey.setSalePrice( value );
putSellallItem( pBlockKey );
-// sellAllItems.put( pBlockKey.getBlockNameSearch(), pBlockKey );
}
catch (IOException e) {
@@ -1879,7 +1293,6 @@ public boolean addSellAllBlock( String itemID, String displayName, double value)
}
-// sellAllBlocks.put(xMaterial, value);
return true;
}
@@ -1900,109 +1313,83 @@ public boolean addSellAllBlock( String itemID, String displayName, double value)
*/
public boolean addSellAllBlock( String itemNameSearch, double value, PrisonBlock pBlock ) {
- PrisonBlock pBlockKey = getPrisonBlock( itemNameSearch );
-
- PrisonBlock pBlockSellall = pBlockKey == null ? null : getSellallItem( pBlockKey );
-
- // If that is an invalid PrisonBlock, then exit
- if ( pBlockSellall != null ) {
- Output.get().logDebug( "sellall add: block already exists (%s)", itemNameSearch );
- return false;
- }
-
-
- // pBlock is null, but it's being used below. So clone the key:
-// pBlock = pBlockKey.clone();
-
- try {
-
- if ( pBlockSellall == null ) {
-
- pBlockSellall = pBlock.clone();
- }
-
-// String itemName = itemNameSearch.toUpperCase();
- String displayName = pBlockSellall.getDisplayName();
-
-
- File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
- FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
-
- String itemName = pBlockSellall.getBlockNameSearch().toUpperCase();
- String confKey = "Items." + itemName;
-
- conf.set(confKey + ".ITEM_ID", pBlockSellall.getBlockNameSearch() );
- conf.set(confKey + ".ITEM_VALUE", value);
- conf.set(confKey + ".IS_LORE_ALLOWED", pBlockSellall.isLoreAllowed() );
-
- if ( displayName != null ) {
- conf.set(confKey + ".ITEM_DISPLAY_NAME", displayName );
- }
-
- if (getBooleanValue("Options.Sell_Per_Block_Permission_Enabled")) {
- conf.set(confKey + ".ITEM_PERMISSION", sellAllConfig.getString("Options.Sell_Per_Block_Permission") + itemNameSearch );
- }
-
- conf.save(sellAllFile);
- refreshClassVariablesFromConfig();
-
- pBlockSellall.setSalePrice( value );
-
-
- // NOTE: If PrisonBlock Key was null, then that means that prison does not have this setup as a
- // valid block, so we must create a new prison block and add it.
-// PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( itemNameSearch );
- if ( pBlockKey == null ) {
- List pbList = new ArrayList<>();
-
-// pBlockKey = pBlockSellall.clone();
-
- pbList.add( pBlockSellall.clone() );
-
- Prison.get().getPlatform().getPrisonBlockTypes().addBlockTypes( pbList );
- }
-
- putSellallItem( pBlockSellall );
-// sellAllItems.put( itemNameSearch, pBlock );
-
- }
- catch (IOException e) {
-
- String msg = String.format(
- "SellAllUtil.addSellAllBlock: Failed to add a new block to SellAll. " +
- "itemSearch: [%s] value: %s PrisonBlock: %s [%s]",
- itemNameSearch, Prison.get().getDecimalFormatDouble().format( value ),
- pBlock.getBlockNameSearch(), e.getMessage() );
- Output.get().logWarn( msg );
-
- return false;
- }
-
-
-// sellAllBlocks.put(xMaterial, value);
- return true;
+ PrisonBlock pBlockKey = getPrisonBlock( itemNameSearch );
+
+ PrisonBlock pBlockSellall = pBlockKey == null ? null : getSellallItem( pBlockKey );
+
+ // If that is an invalid PrisonBlock, then exit
+ if ( pBlockSellall != null ) {
+ Output.get().logDebug( "sellall add: block already exists (%s)", itemNameSearch );
+ return false;
+ }
+
+
+ try {
+
+ if ( pBlockSellall == null ) {
+
+ pBlockSellall = pBlock.clone();
+ }
+
+ String displayName = pBlockSellall.getDisplayName();
+
+
+ File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
+ FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
+
+ String itemName = pBlockSellall.getBlockNameSearch().toUpperCase();
+ String confKey = "Items." + itemName;
+
+ conf.set(confKey + ".ITEM_ID", pBlockSellall.getBlockNameSearch() );
+ conf.set(confKey + ".ITEM_VALUE", value);
+ conf.set(confKey + ".IS_LORE_ALLOWED", pBlockSellall.isLoreAllowed() );
+
+ if ( displayName != null ) {
+ conf.set(confKey + ".ITEM_DISPLAY_NAME", displayName );
+ }
+
+ if (getBooleanValue("Options.Sell_Per_Block_Permission_Enabled")) {
+ conf.set(confKey + ".ITEM_PERMISSION", sellAllConfig.getString("Options.Sell_Per_Block_Permission") + itemNameSearch );
+ }
+
+ conf.save(sellAllFile);
+ refreshClassVariablesFromConfig();
+
+ pBlockSellall.setSalePrice( value );
+
+
+ // NOTE: If PrisonBlock Key was null, then that means that prison does not have this setup as a
+ // valid block, so we must create a new prison block and add it.
+ if ( pBlockKey == null ) {
+ List pbList = new ArrayList<>();
+
+ pbList.add( pBlockSellall.clone() );
+
+ Prison.get().getPlatform().getPrisonBlockTypes().addBlockTypes( pbList );
+ }
+
+ putSellallItem( pBlockSellall );
+
+ }
+ catch (IOException e) {
+
+ String msg = String.format(
+ "SellAllUtil.addSellAllBlock: Failed to add a new block to SellAll. " +
+ "itemSearch: [%s] value: %s PrisonBlock: %s [%s]",
+ itemNameSearch, Prison.get().getDecimalFormatDouble().format( value ),
+ pBlock.getBlockNameSearch(), e.getMessage() );
+ Output.get().logWarn( msg );
+
+ return false;
+ }
+
+
+ return true;
}
-// /**
-// *
-// * BUG: With Spigot versions less than 1.13 bukkit's Material will not work on all Materials since
-// * varient data is stored in the ItemStack. SO must use the XMaterial version of this function.
-// *
-// * Add a block to SellAll config.
-// *
-// * Return True if no error occurred, false if error.
-// *
-// * @param material - Material of block to add.
-// * @param value - Value of the block to add.
-// *
-// * @return boolean.
-// * */
-// public boolean addSellAllBlock(Material material, double value){
-// return addSellAllBlock(XMaterial.matchXMaterial(material), value);
-// }
public boolean addSellallRankMultiplier(String rankName, double multiplier){
- return addSellallRankMultiplier(rankName, multiplier, false);
+ return addSellallRankMultiplier(rankName, multiplier, false);
}
/**
@@ -2040,25 +1427,25 @@ public boolean addSellallRankMultiplier(String rankName, double multiplier, bool
if ( applyToHigherRanks ) {
- Rank nextRank = rank.getRankNext();
- while ( nextRank != null && !getPrestigeMultipliers().containsKey(nextRank.getName()) ) {
-
- setRankMultiplier(nextRank, multiplier, conf);
- nextRank = nextRank.getRankNext();
- }
+ Rank nextRank = rank.getRankNext();
+ while ( nextRank != null && !getPrestigeMultipliers().containsKey(nextRank.getName()) ) {
+
+ setRankMultiplier(nextRank, multiplier, conf);
+ nextRank = nextRank.getRankNext();
+ }
}
conf.save(sellAllFile);
}
catch (IOException e) {
- String msg = String.format(
- "SellAllUtil.addSellAllMultiplier: Failed to add a new rank multiplier to SellAll. " +
- "rankName: [%s] multiplier: %s applyToHigherRanks: %s [%s]",
- rankName, Prison.get().getDecimalFormatDouble().format( multiplier ),
- Boolean.toString( applyToHigherRanks ),
- e.getMessage() );
- Output.get().logWarn( msg );
+ String msg = String.format(
+ "SellAllUtil.addSellAllMultiplier: Failed to add a new rank multiplier to SellAll. " +
+ "rankName: [%s] multiplier: %s applyToHigherRanks: %s [%s]",
+ rankName, Prison.get().getDecimalFormatDouble().format( multiplier ),
+ Boolean.toString( applyToHigherRanks ),
+ e.getMessage() );
+ Output.get().logWarn( msg );
return false;
}
@@ -2109,21 +1496,6 @@ public boolean addItemTrigger(XMaterial xMaterial){
return true;
}
-// /**
-// * BUG: With Spigot versions less than 1.13 bukkit's Material will not work on all Materials since
-// * variant data is stored in the ItemStack. SO must use the XMaterial version of this function.
-// *
-// * Add SellAll Item Trigger.
-// *
-// * Return true if success, false if error or already added item.
-// *
-// * @param material - Material to add.
-// *
-// * @return boolean.
-// * */
-// public boolean addItemTrigger(Material material){
-// return addItemTrigger(XMaterial.matchXMaterial(material));
-// }
/**
* Add Player to active delay.
@@ -2178,54 +1550,7 @@ public void addDelayedEarningAutoSellNotification(Player p, double value){
}
}
-// private HashMap addInventoryToHashMap(HashMap xMaterialIntegerHashMap, Inventory inv) {
-//
-// List inventory = new ArrayList<>();
-//
-// for (ItemStack itemStack : inv.getContents()){
-// if (itemStack != null){
-// inventory.add(itemStack);
-// }
-// }
-//
-// return addInventoryToHashMap( xMaterialIntegerHashMap, inventory );
-//
-//// for (ItemStack itemStack : inv.getContents()){
-//// if (itemStack != null){
-//// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
-////
-//// if ( xMaterial != null ) {
-////
-//// if (xMaterialIntegerHashMap.containsKey(xMaterial)){
-//// xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
-//// }
-//// else {
-//// xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
-//// }
-//// }
-//// }
-//// }
-//// return xMaterialIntegerHashMap;
-// }
-// private HashMap addInventoryToHashMap(HashMap xMaterialIntegerHashMap, List inv) {
-// for (ItemStack itemStack : inv){
-// if (itemStack != null){
-// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
-//
-// if ( xMaterial != null ) {
-//
-// if (xMaterialIntegerHashMap.containsKey(xMaterial)){
-// xMaterialIntegerHashMap.put(xMaterial, xMaterialIntegerHashMap.get(xMaterial) + itemStack.getAmount());
-// }
-// else {
-// xMaterialIntegerHashMap.put(xMaterial, itemStack.getAmount());
-// }
-// }
-// }
-// }
-// return xMaterialIntegerHashMap;
-// }
/**
* Check if Player meets requirements to use SellAll.
@@ -2250,10 +1575,6 @@ public boolean canPlayerSell(Player p, boolean isUsingSign){
return false;
}
-// if (isPlayerInDisabledWorld(p)){
-// return false;
-// }
-
if (isSellAllSignEnabled && isSellAllBySignOnlyEnabled && !isUsingSign && !p.hasPermission(permissionBypassSign)){
return false;
}
@@ -2277,226 +1598,130 @@ public boolean canPlayerSell(Player p, boolean isUsingSign){
* @return boolean.
* */
public boolean editPrice(XMaterial xMaterial, double value) {
- return editPrice( xMaterial, null, value );
+ return editPrice( xMaterial, null, value );
}
public boolean editPrice(XMaterial xMaterial, String displayName, double value) {
- return editPrice( xMaterial.name(), displayName, value );
-
-// PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( xMaterial.name() );
-// String key = pBlockKey.getBlockNameSearch();
-//
-// PrisonBlock pBlock = sellAllItems.get( key );
-//
-// // Do not allow an edit price if the material does not exist, or if the value has not changed:
-// if ( pBlock == null ){
-//
-// Output.get().logDebug( "sellall edit: item does not exist in shop so it cannot be edited (%s)", pBlockKey.getBlockName());
-// return false;
-// }
-// if ( pBlock.getSalePrice() == value ){
-// DecimalFormat dFmt = new DecimalFormat("#,##0.00");
-// Output.get().logDebug( "sellall edit: No change in price (%s:%s)",
-// pBlockKey.getBlockName(), dFmt.format(value) );
-// return false;
-// }
-//
-// pBlock.setSalePrice( value );
-//
-// try {
-// File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
-// FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
-//
-// String itemName = key.toUpperCase();
-// conf.set("Items." + itemName + ".ITEM_ID", key );
-// conf.set("Items." + itemName + ".ITEM_VALUE", value);
-// conf.set("Items." + itemName + ".IS_LORE_ALLOWED", pBlock.isLoreAllowed() );
-//
-// if ( displayName != null ) {
-// conf.set("Items." + itemName + ".ITEM_DISPLAY_NAME", value);
-// }
-// else {
-// //conf.set("Items." + itemName + ".ITEM_DISPLAY_NAME", null);
-// }
-//
-//
-// if ( pBlock.getPurchasePrice() != null ) {
-//
-// conf.set("Items." + itemName + ".PURCHASE_PRICE", pBlock.getPurchasePrice().doubleValue() );
-// }
-//
-// if (getBooleanValue("Options.Sell_Per_Block_Permission_Enabled")) {
-// conf.set("Items." + itemName + ".ITEM_PERMISSION", sellAllConfig.getString("Options.Sell_Per_Block_Permission") + itemName );
-// }
-// conf.save(sellAllFile);
-//
-// // Update only if successful
-// refreshClassVariablesFromConfig();
-// } catch (IOException e) {
-// e.printStackTrace();
-// return false;
-// }
-//
-// // pBlock is still in the sellAllItems collection so no need to readd it
-//// sellAllBlocks.put(xMaterial, value);
-//
-// return true;
+ return editPrice( xMaterial.name(), displayName, value );
}
public boolean editPrice( String itemID, String displayName, double value) {
- PrisonBlock pBlockKey = getPrisonBlock( itemID );
- PrisonBlock pBlock = getSellallItem( pBlockKey );
-
-// PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( itemID );
-// String key = pBlockKey.getBlockNameSearch();
-//
-// PrisonBlock pBlock = sellAllItems.get( key );
-
- // Do not allow an edit price if the material does not exist, or if the value has not changed:
- if ( pBlock == null ){
-
- Output.get().logDebug( "sellall edit: item does not exist in shop so it cannot be edited (%s)", pBlockKey.getBlockName());
- return false;
- }
- if ( pBlock.getSalePrice() == value ){
- DecimalFormat dFmt = new DecimalFormat("#,##0.00");
- Output.get().logDebug( "sellall edit: No change in price (%s:%s)",
- pBlockKey.getBlockName(), dFmt.format(value) );
- return false;
- }
-
- pBlock.setSalePrice( value );
-
- try {
- File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
- FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
-
- String itemName = pBlockKey.getBlockNameSearch().toUpperCase();
- String confKey = "Items." + itemName;
-
-// ConfigurationSection confSection = conf.getConfigurationSection( confKey );
-
-
- conf.set( confKey + ".ITEM_ID", pBlockKey.getBlockNameSearch() );
- conf.set( confKey + ".ITEM_VALUE", value);
- conf.set( confKey + ".IS_LORE_ALLOWED", pBlock.isLoreAllowed() );
-
- if ( displayName != null && displayName.trim().length() > 0 ) {
- conf.set( confKey + ".ITEM_DISPLAY_NAME", displayName.trim() );
- }
- else {
- //confSection.set("ITEM_DISPLAY_NAME", null);
- }
-
-
- if ( pBlock.getPurchasePrice() != null ) {
-
- conf.set( confKey + ".PURCHASE_PRICE", pBlock.getPurchasePrice().doubleValue() );
- }
-
- if (getBooleanValue("Options.Sell_Per_Block_Permission_Enabled")) {
- conf.set( confKey + ".ITEM_PERMISSION", sellAllConfig.getString("Options.Sell_Per_Block_Permission") + itemName );
- }
- conf.save(sellAllFile);
-
- // Update only if successful
- refreshClassVariablesFromConfig();
- }
- catch (IOException e) {
-
- String msg = String.format(
- "SellAllUtil.editPrice: Failed to edit an item price. " +
- "itemID: [%s] DisplayName: %s&r value: %s [%s]",
- itemID, (displayName == null ? "" : displayName ),
- Prison.get().getDecimalFormatDouble().format( value ),
- e.getMessage() );
- Output.get().logWarn( msg );
-
- return false;
- }
-
- // pBlock is still in the sellAllItems collection so no need to readd it
-// sellAllBlocks.put(xMaterial, value);
-
- return true;
+ PrisonBlock pBlockKey = getPrisonBlock( itemID );
+ PrisonBlock pBlock = getSellallItem( pBlockKey );
+
+
+ // Do not allow an edit price if the material does not exist, or if the value has not changed:
+ if ( pBlock == null ){
+
+ Output.get().logDebug( "sellall edit: item does not exist in shop so it cannot be edited (%s)", pBlockKey.getBlockName());
+ return false;
+ }
+ if ( pBlock.getSalePrice() == value ){
+ DecimalFormat dFmt = new DecimalFormat("#,##0.00");
+ Output.get().logDebug( "sellall edit: No change in price (%s:%s)",
+ pBlockKey.getBlockName(), dFmt.format(value) );
+ return false;
+ }
+
+ pBlock.setSalePrice( value );
+
+ try {
+ File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
+ FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
+
+ String itemName = pBlockKey.getBlockNameSearch().toUpperCase();
+ String confKey = "Items." + itemName;
+
+ conf.set( confKey + ".ITEM_ID", pBlockKey.getBlockNameSearch() );
+ conf.set( confKey + ".ITEM_VALUE", value);
+ conf.set( confKey + ".IS_LORE_ALLOWED", pBlock.isLoreAllowed() );
+
+ if ( displayName != null && displayName.trim().length() > 0 ) {
+ conf.set( confKey + ".ITEM_DISPLAY_NAME", displayName.trim() );
+ }
+ else {
+ //confSection.set("ITEM_DISPLAY_NAME", null);
+ }
+
+
+ if ( pBlock.getPurchasePrice() != null ) {
+
+ conf.set( confKey + ".PURCHASE_PRICE", pBlock.getPurchasePrice().doubleValue() );
+ }
+
+ if (getBooleanValue("Options.Sell_Per_Block_Permission_Enabled")) {
+ conf.set( confKey + ".ITEM_PERMISSION", sellAllConfig.getString("Options.Sell_Per_Block_Permission") + itemName );
+ }
+ conf.save(sellAllFile);
+
+ // Update only if successful
+ refreshClassVariablesFromConfig();
+ }
+ catch (IOException e) {
+
+ String msg = String.format(
+ "SellAllUtil.editPrice: Failed to edit an item price. " +
+ "itemID: [%s] DisplayName: %s&r value: %s [%s]",
+ itemID, (displayName == null ? "" : displayName ),
+ Prison.get().getDecimalFormatDouble().format( value ),
+ e.getMessage() );
+ Output.get().logWarn( msg );
+
+ return false;
+ }
+
+ return true;
}
public boolean editAllowLore( PrisonBlock pBlock, boolean value) {
-// public boolean editAllowLore(XMaterial xMaterial, boolean value) {
-
-// PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( xMaterial.name() );
-// String key = pBlockKey.getBlockNameSearch();
-
-// PrisonBlock pBlock = sellAllItems.get( key );
-
- // Use the block that is stored in sellall:
- pBlock = getSellallItem( pBlock );
-
- // Do not allow an edit price if the material does not exist, or if the value has not changed:
- if ( pBlock == null ) {
-
- Output.get().logDebug( "sellall edit: item does not exist in shop so it cannot be edited (%s)", pBlock.getBlockNameSearch() );
- return false;
- }
- if ( pBlock.isLoreAllowed() == value ){
- Output.get().logDebug( "sellall edit: No change in 'allow lore' (%s %s)",
- pBlock.getBlockName(), Boolean.toString( pBlock.isLoreAllowed() ) );
- return false;
- }
-
- pBlock.setLoreAllowed( value );
-
- try {
- File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
- FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
-
- String itemName = pBlock.getBlockNameSearch().toUpperCase();
-// conf.set("Items." + itemName + ".ITEM_ID", key );
- conf.set("Items." + itemName + ".IS_LORE_ALLOWED", pBlock.isLoreAllowed() );
-
- conf.save(sellAllFile);
-
- // Update only if successful
- refreshClassVariablesFromConfig();
- }
- catch (IOException e) {
-
- String msg = String.format(
- "SellAllUtil.editAllowLore: Failed to edit the allow lore setting. " +
- "itemID: [%s] allow Lore?: %s [%s]",
- pBlock.getBlockNameSearch(),
- Boolean.toString( value ),
- e.getMessage() );
- Output.get().logWarn( msg );
-
- return false;
- }
-
- // pBlock is still in the sellAllItems collection so no need to readd it
-// sellAllBlocks.put(xMaterial, value);
-
- return true;
+ // Use the block that is stored in sellall:
+ PrisonBlock saBlock = getSellallItem( pBlock );
+
+ // Do not allow an edit price if the material does not exist, or if the value has not changed:
+ if ( saBlock == null ) {
+
+ Output.get().logDebug( "sellall edit: item does not exist in shop so it cannot be edited (%s)", pBlock.getBlockNameSearch() );
+ return false;
+ }
+ if ( saBlock.isLoreAllowed() == value ){
+ Output.get().logDebug( "sellall edit: No change in 'allow lore' (%s %s)",
+ saBlock.getBlockName(), Boolean.toString( saBlock.isLoreAllowed() ) );
+ return false;
+ }
+
+ saBlock.setLoreAllowed( value );
+
+ try {
+ File sellAllFile = new File(SpigotPrison.getInstance().getDataFolder() + "/SellAllConfig.yml");
+ FileConfiguration conf = YamlConfiguration.loadConfiguration(sellAllFile);
+
+ String itemName = saBlock.getBlockNameSearch().toUpperCase();
+ conf.set("Items." + itemName + ".IS_LORE_ALLOWED", saBlock.isLoreAllowed() );
+
+ conf.save(sellAllFile);
+
+ // Update only if successful
+ refreshClassVariablesFromConfig();
+ }
+ catch (IOException e) {
+
+ String msg = String.format(
+ "SellAllUtil.editAllowLore: Failed to edit the allow lore setting. " +
+ "itemID: [%s] allow Lore?: %s [%s]",
+ saBlock.getBlockNameSearch(),
+ Boolean.toString( value ),
+ e.getMessage() );
+ Output.get().logWarn( msg );
+
+ return false;
+ }
+
+ return true;
}
-// /**
-// * BUG: With Spigot versions less than 1.13 bukkit's Material will not work on all Materials since
-// * varient data is stored in the ItemStack. SO must use the XMaterial version of this function.
-// *
-// * Edit price of a block using Material.
-// *
-// * Return true if edited with success, false if error or not found.
-// *
-// * @param material - Material.
-// * @param value - New price as a double.
-// *
-// * @return boolean,
-// * */
-// public boolean editPrice(Material material, double value){
-// return editPrice(XMaterial.matchXMaterial(material), value);
-// }
/**
* Edit Prestige Multiplier value.
@@ -2515,10 +1740,6 @@ public boolean editPrestigeMultiplier(String prestigeName, double multiplier) {
return addSellallRankMultiplier(prestigeName, multiplier);
}
-// public boolean removeSellAllBlock(XMaterial xMaterial){
-//
-// return removeSellAllBlock( xMaterial.name() );
-// }
/**
* Remove block by XMaterial name.
@@ -2531,12 +1752,7 @@ public boolean editPrestigeMultiplier(String prestigeName, double multiplier) {
* */
public boolean removeSellAllBlock( String itemID ) {
- PrisonBlock pBlockKey = getSellallItem( getPrisonBlock( itemID ));
-
-// PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( itemID );
-// String key = pBlockKey.getBlockNameSearch();
-//
-// PrisonBlock pBlock = sellAllItems.get( key );
+ PrisonBlock pBlockKey = getSellallItem( getPrisonBlock( itemID ));
if ( pBlockKey == null ){
@@ -2557,25 +1773,9 @@ public boolean removeSellAllBlock( String itemID ) {
}
getSellAllItems().remove( pBlockKey.getBlockNameSearch() );
-// sellAllBlocks.remove(xMaterial);
return true;
}
-// /**
-// * BUG: With Spigot versions less than 1.13 bukkit's Material will not work on all Materials since
-// * varient data is stored in the ItemStack. SO must use the XMaterial version of this function.
-// *
-// * Remove block by XMaterial name.
-// *
-// * Return true if removed with success, false if not found or error.
-// *
-// * @param material - XMaterial to remove.
-// *
-// * @return boolean.
-// * */
-// public boolean removeSellAllBlock(Material material){
-// return removeSellAllBlock(XMaterial.matchXMaterial(material));
-// }
/**
* Remove a Rank Multiplier by name.
@@ -2637,270 +1837,7 @@ public boolean removeItemTrigger(XMaterial xMaterial){
return true;
}
-// /**
-// * BUG: With Spigot versions less than 1.13 bukkit's Material will not work on all Materials since
-// * varient data is stored in the ItemStack. SO must use the XMaterial version of this function.
-// *
-// * Delete SellAll Item Trigger.
-// *
-// * Return true if success, false if error or item not found.
-// *
-// * @param material - Material to remove.
-// *
-// * @return boolean.
-// * */
-// public boolean removeItemTrigger(Material material){
-// return removeItemTrigger(XMaterial.matchXMaterial(material));
-// }
-
-// /**
-// * Remove Sellable Blocks from HashMap of XMaterial-Integer given as a parameter.
-// * NOTE: If there aren't blocks in the SellAll shop, nothing will change.
-// * NOTE: This method will remove blocks from the HashMap, but it WON'T return the value of money, for that please use
-// * the getSellAllSellMoney method.
-// *
-// * @param p - Player.
-// * @param xMaterialIntegerHashMap - HashMap of XMaterial-Integer (Blocks of origin).
-// *
-// *
-// * @return HashMap - XMaterial-Integer.
-// * */
-// public HashMap removeSellableItems(Player p, HashMap xMaterialIntegerHashMap){
-//
-// if (sellAllItems.isEmpty()){
-// return xMaterialIntegerHashMap;
-// }
-//
-// /* Not necessary now, as this only removes what's sellable, this should be checked in another place before.
-// if (isPlayerInDisabledWorld(p)){
-// return xMaterialIntegerHashMap;
-// }
-// */
-//
-// for (HashMap.Entry xMaterialIntegerEntry : xMaterialIntegerHashMap.entrySet()){
-//
-// XMaterial xMaterial = xMaterialIntegerEntry.getKey();
-// PrisonBlock pBlockKey = Prison.get().getPlatform().getPrisonBlock( xMaterial.name() );
-// String key = pBlockKey.getBlockName();
-//
-// PrisonBlock pBlock = sellAllItems.get( key );
-//
-// if ( pBlock != null ){
-// // This is stupid but right now I'm too confused, sorry.
-// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + pBlock.getBlockName().toUpperCase() )){
-// // Nothing will happen.
-// } else {
-// xMaterialIntegerHashMap.remove( xMaterial );
-// }
-// }
-// }
-//
-// return xMaterialIntegerHashMap;
-// }
-
-// /**
-// * Remove Sellable Blocks from ArrayList of ItemStacks given as a parameter.
-// * NOTE: If there aren't blocks in the SellAll shop, nothing will change.
-// * NOTE: This method will remove blocks from the HashMap, but it WON'T return the value of money, for that please use
-// * the getSellAllSellMoney method.
-// *
-// * @param p - Player.
-// * @param itemStacks - ItemStacks.
-// *
-// * @return ArrayList - ItemStacks.
-// * */
-// private ArrayList removeSellableItems(Player p, ArrayList itemStacks){
-//
-// if (sellAllItems.isEmpty()){
-// return itemStacks;
-// }
-//
-// HashMap xMaterialIntegerHashMap = getXMaterialsHashMapFromArrayList(itemStacks);
-//
-// xMaterialIntegerHashMap = removeSellableItems(p, xMaterialIntegerHashMap);
-//
-// ArrayList newItemStacks = new ArrayList<>();
-// for (HashMap.Entry xMaterialIntegerEntry : xMaterialIntegerHashMap.entrySet()){
-//
-// // WARNING: Cannot convert XMaterial to a Material then ItemStack or it will fail on variants
-// // for spigot versions less than 1.13:
-//
-// ItemStack iStack = xMaterialIntegerEntry.getKey().parseItem();
-// if ( iStack != null ) {
-// iStack.setAmount( xMaterialIntegerEntry.getValue() );
-// newItemStacks.add( iStack );
-// }
-//
-//// Material material = xMaterialIntegerEntry.getKey().parseMaterial();
-//// if (material != null) {
-//// newItemStacks.add(new ItemStack(material, xMaterialIntegerEntry.getValue()));
-//// }
-// }
-//
-// return newItemStacks;
-// }
-
-// /**
-// * Remove Sellable blocks from an Inventory of a Player.
-// *
-// * Return an Inventory with the unsold items.
-// *
-// * @param p - Player.
-// * @param inv - Inventory.
-// *
-// * @return inv - Inventory.
-// * */
-// private Inventory removeSellableItems(Player p, Inventory inv){
-// if (sellAllItems.isEmpty()){
-// return inv;
-// }
-//
-// // ?? why?
-//// SpigotCompatibility.getInstance().getItemInOffHand( p );
-//
-// List removeable = new ArrayList<>();
-//
-// SpigotInventory sInv = new SpigotInventory( inv );
-//
-// for (tech.mcprison.prison.internal.ItemStack itemStack : sInv.getItems()) {
-// if (itemStack != null){
-// try {
-// PrisonBlock pBlock = itemStack.getMaterial();
-//
-//
-//// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
-//
-// if ( pBlock != null && sellAllItems.containsKey( pBlock.getBlockName() )) {
-// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + pBlock.getBlockName().toUpperCase() )) {
-// // Nothing will change.
-// } else {
-// removeable.add( ((SpigotItemStack) itemStack).getBukkitStack() );
-//// inv.remove(itemStack);
-// }
-// }
-// } catch (IllegalArgumentException ignored){}
-// }
-// }
-//
-//// for (ItemStack itemStack : inv.getContents()){
-//// if (itemStack != null){
-//// try {
-//// PrisonBlock
-////
-////
-//// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
-////
-//// if ( xMaterial != null && sellAllBlocks.containsKey(xMaterial)) {
-//// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + xMaterial.name())) {
-//// // Nothing will change.
-//// } else {
-//// removeable.add( itemStack );
-////// inv.remove(itemStack);
-//// }
-//// }
-//// } catch (IllegalArgumentException ignored){}
-//// }
-//// }
-//
-// for ( ItemStack remove : removeable )
-// {
-// inv.remove(remove);
-// }
-//
-// return inv;
-// }
-
-// private void removeSellableItemsInOffHand(Player p){
-//
-//
-//
-// SpigotItemStack sItemStack = SpigotCompatibility.getInstance().getPrisonItemInOffHand( p );
-//
-// if ( sItemStack != null ) {
-//
-// PrisonBlock pBlock = sItemStack.getMaterial();
-//
-// if ( pBlock != null && sellAllItems.containsKey( pBlock.getBlockName() )) {
-// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + pBlock.getBlockName().toUpperCase() )) {
-// // Nothing will change.
-// } else {
-//
-// SpigotPlayer sPlayer = new SpigotPlayer( p );
-// SpigotPlayerInventory spInventory = (SpigotPlayerInventory) sPlayer.getInventory();
-//
-// SpigotItemStack sItemStackAir = (SpigotItemStack) PrisonBlock.AIR.getItemStack( 1 );
-//
-// SpigotCompatibility.getInstance().setItemStackInOffHand( spInventory, sItemStackAir );
-// }
-// }
-// }
-//
-//
-//
-//// ItemStack itemStack = SpigotCompatibility.getInstance().getItemInOffHand( p );
-////
-//// if ( itemStack != null ) {
-////
-//// if (itemStack != null){
-//// try {
-//// XMaterial xMaterial = getXMaterialOrLapis(itemStack);
-////
-//// if ( xMaterial != null && sellAllBlocks.containsKey(xMaterial)) {
-//// if (isPerBlockPermissionEnabled && !p.hasPermission(permissionPrefixBlocks + xMaterial.name())) {
-//// // Nothing will change.
-//// }
-//// else {
-////
-//// SpigotPlayerInventory spInventory = new SpigotPlayerInventory( p.getInventory() ) ;
-//// SpigotItemStack sItemStack = new SpigotItemStack( new ItemStack( Material.AIR ) );
-////
-//// SpigotCompatibility.getInstance().setItemStackInOffHand( spInventory, sItemStack );
-////
-//// }
-//// }
-//// } catch (IllegalArgumentException ignored){}
-//// }
-//// }
-//
-//
-// }
-
-// /**
-// * Remove Sellable blocks from all Player inventories directly hooked.
-// *
-// * @param p - Player.
-// * */
-// private void removeSellableItems(Player p){
-//
-// if (sellAllItems.isEmpty()){
-// return;
-// }
-//
-// if (isSellAllBackpackItemsEnabled && getBoolean(SpigotPrison.getInstance().getConfig().getString("backpacks"))){
-// BackpacksUtil backpacksUtil = BackpacksUtil.get();
-// if (backpacksUtil.isMultipleBackpacksEnabled()){
-// for (String id : backpacksUtil.getBackpacksIDs(p)){
-// backpacksUtil.setInventory(p, removeSellableItems(p, backpacksUtil.getBackpack(p, id)), id);
-// }
-// } else {
-// String id = null;
-// backpacksUtil.setInventory(p, removeSellableItems(p, backpacksUtil.getBackpack(p, id)), id);
-// }
-// }
-//
-// if (isSellAllMinesBackpacksPluginEnabled && IntegrationMinepacksPlugin.getInstance().isEnabled()){
-// Backpack backpack = IntegrationMinepacksPlugin.getInstance().getMinepacks().getBackpackCachedOnly(p);
-// if (backpack != null) {
-// removeSellableItems(p, backpack.getInventory());
-// backpack.setChanged();
-// backpack.save();
-// }
-// }
-//
-// removeSellableItems(p, p.getInventory());
-//
-// removeSellableItemsInOffHand( p );
-// }
+
/**
* Remove Player from delay.
@@ -2919,24 +1856,22 @@ public void removeFromDelay(Player p){
public void removeFromAutoSellDelayAndNotify(Player p){
if (autoSellEarningsNotificationWaiting.containsKey(p) && autoSellEarningsNotificationWaiting.get(p) > 0.00){
- DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
- String amt = fFmt.format( autoSellEarningsNotificationWaiting.get(p) );
+ DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
+ String amt = fFmt.format( autoSellEarningsNotificationWaiting.get(p) );
+
+ String message = sellallAmountEarnedMsg( amt );
+
+ SpigotPlayer sPlayer = new SpigotPlayer(p);
+
+ if ( isSellAllNotificationByActionBar ) {
+
+ sPlayer.setActionBar( message );
+ }
+ else {
+
+ Output.get().send( sPlayer, message );
+ }
- String message = sellallAmountEarnedMsg( amt );
-
- SpigotPlayer sPlayer = new SpigotPlayer(p);
-
- if ( isSellAllNotificationByActionBar ) {
-
- sPlayer.setActionBar( message );
- }
- else {
-
- Output.get().send( sPlayer, message );
- }
-
-// String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt;
-// new SpigotPlayer(p).setActionBar( message );
}
autoSellEarningsNotificationWaiting.remove(p);
}
@@ -3001,15 +1936,15 @@ public boolean setAutoSell(Boolean isEnabled){
}
catch (IOException e) {
- String msg = String.format(
- "SellAllUtil.setAutoSell: Failed to set 'Options.Full_Inv_AutoSell' to a value of %s since " +
- "there was a problem trying to save the SellAllConfig.yml file. " +
- "[%s]",
- Boolean.toString( isAutoSellEnabled() ),
- e.getMessage() );
- Output.get().logWarn( msg );
-
- return false;
+ String msg = String.format(
+ "SellAllUtil.setAutoSell: Failed to set 'Options.Full_Inv_AutoSell' to a value of %s since " +
+ "there was a problem trying to save the SellAllConfig.yml file. " +
+ "[%s]",
+ Boolean.toString( isAutoSellEnabled() ),
+ e.getMessage() );
+ Output.get().logWarn( msg );
+
+ return false;
}
isAutoSellEnabled = isEnabled;
@@ -3046,14 +1981,14 @@ public boolean setAutoSellPlayer(Player p, boolean enable){
}
catch (IOException e) {
- String msg = String.format(
- "SellAllUtil.setAutoSellPlayer: Failed to set user %s autoSell Per Bbock toggle to a value " +
- "of %s since there was a problem trying to save the SellAllConfig.yml file. " +
- "[%s]",
- p.getName(),
- Boolean.toString( enable ),
- e.getMessage() );
- Output.get().logWarn( msg );
+ String msg = String.format(
+ "SellAllUtil.setAutoSellPlayer: Failed to set user %s autoSell Per Bbock toggle to a value " +
+ "of %s since there was a problem trying to save the SellAllConfig.yml file. " +
+ "[%s]",
+ p.getName(),
+ Boolean.toString( enable ),
+ e.getMessage() );
+ Output.get().logWarn( msg );
return false;
}
@@ -3197,44 +2132,45 @@ public boolean setDelay(int delay){
* @return boolean If successful
* */
public boolean sellAllSell(Player p,
- boolean isUsingSign,
- boolean completelySilent,
- boolean notifyPlayerEarned,
- boolean notifyPlayerDelay,
- boolean notifyPlayerEarningDelay,
- boolean playSoundOnSellAll) {
- return sellAllSell( p, isUsingSign, completelySilent,
- notifyPlayerEarned, notifyPlayerDelay,
- notifyPlayerEarningDelay, playSoundOnSellAll,
- true,
- null );
+ boolean isUsingSign,
+ boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll) {
+
+ return sellAllSell( p, isUsingSign, completelySilent,
+ notifyPlayerEarned, notifyPlayerDelay,
+ notifyPlayerEarningDelay, playSoundOnSellAll,
+ true,
+ null );
}
public boolean sellAllSell(Player p,
- boolean isUsingSign,
- boolean completelySilent,
- boolean notifyPlayerEarned,
- boolean notifyPlayerDelay,
- boolean notifyPlayerEarningDelay,
- boolean playSoundOnSellAll,
- List amounts ) {
-
- return sellAllSell( p, isUsingSign, completelySilent,
- notifyPlayerEarned, notifyPlayerDelay,
- notifyPlayerEarningDelay, playSoundOnSellAll,
- true,
- amounts );
+ boolean isUsingSign,
+ boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll,
+ List amounts ) {
+
+ return sellAllSell( p, isUsingSign, completelySilent,
+ notifyPlayerEarned, notifyPlayerDelay,
+ notifyPlayerEarningDelay, playSoundOnSellAll,
+ true,
+ amounts );
}
public boolean sellAllSell(Player p,
- boolean isUsingSign,
- boolean completelySilent,
- boolean notifyPlayerEarned,
- boolean notifyPlayerDelay,
- boolean notifyPlayerEarningDelay,
- boolean playSoundOnSellAll,
- boolean notifyNothingToSell,
- List amounts ) {
+ boolean isUsingSign,
+ boolean completelySilent,
+ boolean notifyPlayerEarned,
+ boolean notifyPlayerDelay,
+ boolean notifyPlayerEarningDelay,
+ boolean playSoundOnSellAll,
+ boolean notifyNothingToSell,
+ List amounts ) {
if (!isUsingSign && isSellAllSignEnabled && isSellAllBySignOnlyEnabled && !p.hasPermission(permissionBypassSign)){
if (!completelySilent) {
@@ -3262,8 +2198,8 @@ public boolean sellAllSell(Player p,
- double money = 0;
- double multiplier = getPlayerMultiplier(p);
+ double money = 0;
+ double multiplier = getPlayerMultiplier(p);
List soldItems = sellPlayerItems(p);
@@ -3297,7 +2233,6 @@ public boolean sellAllSell(Player p,
if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() ) {
RankPlayer rankPlayer = sPlayer.getRankPlayer();
-// RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName());
rankPlayer.addBalance(sellAllCurrency, money);
@@ -3379,21 +2314,14 @@ else if (notifyPlayerEarned) {
public double sellAllSell(Player p, SpigotItemStack itemStack,
boolean completelySilent, boolean notifyPlayerEarned, boolean notifyPlayerEarningDelay){
-// long tPoint1 = System.nanoTime();
-// long tPoint2 = tPoint1;
-// long tPoint3 = tPoint1;
-// long tPoint4 = tPoint1;
-// long tPoint5 = tPoint1;
-
-
- double money = 0;
- double multiplier = getPlayerMultiplier(p);
+ double money = 0;
+ double multiplier = getPlayerMultiplier(p);
List soldItems = new ArrayList<>();
SellAllData sad = sellItemStack( itemStack, multiplier );
if ( sad != null ) {
- soldItems.add(sad);
+ soldItems.add(sad);
}
for (SellAllData soldItem : soldItems) {
@@ -3402,77 +2330,53 @@ public double sellAllSell(Player p, SpigotItemStack itemStack,
SellAllData.debugItemsSold(soldItems, new SpigotPlayer(p), multiplier);
-// double money = getSellMoney(p, itemStack);
-
-// tPoint2 = System.nanoTime();
-
- if (money != 0) {
-
- SpigotPlayer sPlayer = new SpigotPlayer(p);
- RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName());
-
-// tPoint3 = System.nanoTime();
-
- if (sellAllCurrency != null && sellAllCurrency.equalsIgnoreCase("default")) {
- sellAllCurrency = null;
- }
- rankPlayer.addBalance(sellAllCurrency, money);
-
-// tPoint4 = System.nanoTime();
-
- if (!completelySilent) {
-
- if (notifyPlayerEarningDelay // && isAutoSellEarningNotificationDelayEnabled
- ){
-
- if (!isPlayerWaitingAutoSellNotification(p)){
- // Initialize && Force delayed notifications, even if delayed is disabled:
- autoSellEarningsNotificationWaiting.put(p, 0.00);
-
- Bukkit.getScheduler().scheduleSyncDelayedTask(
- SpigotPrison.getInstance(), () ->
- removeFromAutoSellDelayAndNotify(p), 20L * defaultAutoSellEarningNotificationDelay);
-
- }
-
- addDelayedEarningAutoSellNotification(p, money);
- }
- else if (notifyPlayerEarned){
- DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
- String amt = fFmt.format( money );
-
- String message = sellallAmountEarnedMsg( amt ) ;
-
- if ( isSellAllNotificationByActionBar ) {
- sPlayer.setActionBar( message );
- }
- else {
-
- Output.get().send( sPlayer, message );
- }
-
-// String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt;
-// new SpigotPlayer(p).setActionBar( message );
-// Output.get().send( sPlayer, message );
-
- }
- }
-
-// tPoint5 = System.nanoTime();
- }
-
-
-// DecimalFormat dFmt = Prison.get().getDecimalFormat( "0.0000" );
-// String debugMsg = "{sellAllSell::" + dFmt.format( money ) +
-// ":t1=" + dFmt.format( (tPoint2 - tPoint1)/1000000d ) +
-// ":t2=" + dFmt.format( (tPoint3 - tPoint2)/1000000d ) +
-// ":t3=" + dFmt.format( (tPoint4 - tPoint3)/1000000d ) +
-// ":t4=" + dFmt.format( (tPoint5 - tPoint4)/1000000d ) +
-// "}";
-// Output.get().logDebug( debugMsg );
-
- return money;
+ if (money != 0) {
+
+ SpigotPlayer sPlayer = new SpigotPlayer(p);
+ RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName());
+
+ if (sellAllCurrency != null && sellAllCurrency.equalsIgnoreCase("default")) {
+ sellAllCurrency = null;
+ }
+ rankPlayer.addBalance(sellAllCurrency, money);
+
+ if (!completelySilent) {
+
+ if (notifyPlayerEarningDelay // && isAutoSellEarningNotificationDelayEnabled
+ ){
+
+ if (!isPlayerWaitingAutoSellNotification(p)){
+ // Initialize && Force delayed notifications, even if delayed is disabled:
+ autoSellEarningsNotificationWaiting.put(p, 0.00);
+
+ Bukkit.getScheduler().scheduleSyncDelayedTask(
+ SpigotPrison.getInstance(), () ->
+ removeFromAutoSellDelayAndNotify(p), 20L * defaultAutoSellEarningNotificationDelay);
+
+ }
+
+ addDelayedEarningAutoSellNotification(p, money);
+ }
+ else if (notifyPlayerEarned){
+ DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
+ String amt = fFmt.format( money );
+
+ String message = sellallAmountEarnedMsg( amt ) ;
+
+ if ( isSellAllNotificationByActionBar ) {
+ sPlayer.setActionBar( message );
+ }
+ else {
+
+ Output.get().send( sPlayer, message );
+ }
+
+ }
+ }
+ }
+
+ return money;
}
@@ -3517,7 +2421,6 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
if (!completelySilent) {
sellallCanOnlyUseSignsMsg( new SpigotCommandSender(p) );
-// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_sign_only));
}
return itemStacks;
}
@@ -3526,7 +2429,6 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
if (notifyPlayerDelay && !completelySilent) {
sellallRateLimitExceededMsg( new SpigotCommandSender(p) );
-// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_delay_wait));
}
return itemStacks;
}
@@ -3535,14 +2437,13 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
if (!completelySilent){
sellallShopIsEmptyMsg( new SpigotCommandSender(p) );
-// Output.get().sendWarn(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_empty));
}
return itemStacks;
}
- double money = 0;
- double multiplier = getPlayerMultiplier(p);
+ double money = 0;
+ double multiplier = getPlayerMultiplier(p);
List soldItems = new ArrayList<>();
@@ -3550,13 +2451,13 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
for (ItemStack itemStack : itemStacks ) {
- SellAllData sad = sellItemStack( new SpigotItemStack( itemStack ), multiplier );
- if ( sad != null ) {
- soldItems.add(sad);
- }
- else {
- itemsNotSold.add( itemStack );
- }
+ SellAllData sad = sellItemStack( new SpigotItemStack( itemStack ), multiplier );
+ if ( sad != null ) {
+ soldItems.add(sad);
+ }
+ else {
+ itemsNotSold.add( itemStack );
+ }
}
// "return" all items not sold:
@@ -3566,7 +2467,7 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
// Sell the player's inventory if requested
if ( !sellInputArrayListOnly ) {
- soldItems.addAll( sellPlayerItems(p) );
+ soldItems.addAll( sellPlayerItems(p) );
}
for (SellAllData soldItem : soldItems) {
@@ -3577,31 +2478,12 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
SellAllData.debugItemsSold( soldItems, new SpigotPlayer( p ), multiplier );
- // Sell only the itemStacks and then remove the ones that were sold:
-// double arrayListMoney = getSellMoney(p, itemStacks);
-// if (arrayListMoney != 0.00){
-// itemStacks = removeSellableItems(p, itemStacks);
-// }
-
-// double money;
-//
-// // If to include the player's inventory, then add that too:
-// if (sellInputArrayListOnly){
-// money = arrayListMoney;
-// } else {
-// // Add the players inventory
-// money = getSellMoney(p) + arrayListMoney;
-// }
-
if (money != 0){
SpigotPlayer sPlayer = new SpigotPlayer(p);
RankPlayer rankPlayer = PrisonRanks.getInstance().getPlayerManager().getPlayer(sPlayer.getUUID(), sPlayer.getName());
if (sellAllCurrency != null && sellAllCurrency.equalsIgnoreCase("default")) sellAllCurrency = null;
-// if (!sellInputArrayListOnly) {
-// removeSellableItems(p);
-// }
rankPlayer.addBalance(sellAllCurrency, money);
if (isSellAllDelayEnabled){
@@ -3620,22 +2502,19 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
addDelayedEarningAutoSellNotification(p, money);
}
} else if (notifyPlayerEarned){
- DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
- String amt = fFmt.format( money );
-
- String message = sellallAmountEarnedMsg( amt );
-
- if ( isSellAllNotificationByActionBar ) {
- sPlayer.setActionBar( message );
- }
- else {
-
- Output.get().send( sPlayer, message );
- }
+ DecimalFormat fFmt = Prison.get().getDecimalFormat("#,##0.00");
+ String amt = fFmt.format( money );
+
+ String message = sellallAmountEarnedMsg( amt );
+
+ if ( isSellAllNotificationByActionBar ) {
+ sPlayer.setActionBar( message );
+ }
+ else {
+
+ Output.get().send( sPlayer, message );
+ }
-// String message = messages.getString(MessagesConfig.StringID.spigot_message_sellall_money_earned) + amt;
-// new SpigotPlayer(p).setActionBar( message );
-
}
}
} else {
@@ -3645,7 +2524,6 @@ public ArrayList sellAllSell(Player p, ArrayList itemStack
}
sellallYouHaveNothingToSellMsg( new SpigotCommandSender(p) );
-// Output.get().sendInfo(new SpigotPlayer(p), messages.getString(MessagesConfig.StringID.spigot_message_sellall_sell_nothing_sellable));
}
}
return itemStacks;
@@ -3689,4 +2567,4 @@ public boolean openSellAllGUI( Player p, int page, String cmdPage, String cmdRet
gui.open();
return true;
}
-}
\ No newline at end of file
+}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/spiget/PrisonSpigetUpdateCheckTask.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/spiget/PrisonSpigetUpdateCheckTask.java
index 1a53424bf..5591d2e15 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/spiget/PrisonSpigetUpdateCheckTask.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/spiget/PrisonSpigetUpdateCheckTask.java
@@ -29,32 +29,14 @@ public void run() {
SpigotPrison plugin = SpigotPrison.getInstance();
- SpigetUpdate updater = new SpigetUpdate( plugin, Prison.SPIGOTMC_ORG_PROJECT_ID);
-// SpigetUpdate updater = new SpigetUpdate(this, 1223);
-
-
- BluesSpigetSemVerComparator aRealSemVerComparator = new BluesSpigetSemVerComparator();
- updater.setVersionComparator( aRealSemVerComparator );
-// updater.setVersionComparator(VersionComparator.EQUAL);
+ SpigetUpdate updater = new SpigetUpdate( plugin, Prison.SPIGOTMC_ORG_PROJECT_ID);
+
+
+ BluesSpigetSemVerComparator aRealSemVerComparator = new BluesSpigetSemVerComparator();
+ updater.setVersionComparator( aRealSemVerComparator );
- updater.checkForUpdate( new PrisonSpigetUpdateCallback() );
+ updater.checkForUpdate( new PrisonSpigetUpdateCallback() );
-
-// updater.checkForUpdate(new UpdateCallback() {
-// @Override
-// public void updateAvailable(String newVersion, String downloadUrl,
-// boolean hasDirectDownload) {
-// Alerts.getInstance().sendAlert(
-// "&3%s is now available. &7Go to the &lSpigot&r&7 page to download the latest release with new features and fixes :)",
-// newVersion);
-// }
-//
-// @Override
-// public void upToDate() {
-// // Plugin is up-to-date
-// }
-// });
-
}
public long getDelayTicks() {
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/PrisonInitialStartupTask.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/PrisonInitialStartupTask.java
index a817a6335..a7dd36f32 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/PrisonInitialStartupTask.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/PrisonInitialStartupTask.java
@@ -77,22 +77,22 @@ public void run() {
if ( firstPass ) {
- display.sendtoOutputLogInfo();
-
- firstPass = false;
-
- resubmit();
+ display.sendtoOutputLogInfo();
+
+ firstPass = false;
+
+ resubmit();
}
else {
- display.addText("Please see the prison startup messages within the console.");
-
- List onlinePlayers = Prison.get().getPlatform().getOnlinePlayers();
-
- for ( Player player : onlinePlayers ) {
-
- display.send( player );
- }
+ display.addText("Please see the prison startup messages within the console.");
+
+ List onlinePlayers = Prison.get().getPlatform().getOnlinePlayers();
+
+ for ( Player player : onlinePlayers ) {
+
+ display.send( player );
+ }
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/SpigotPrisonDelayedStartupTask.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/SpigotPrisonDelayedStartupTask.java
index c1a8604cf..d38bf6f29 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/SpigotPrisonDelayedStartupTask.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/tasks/SpigotPrisonDelayedStartupTask.java
@@ -103,36 +103,36 @@ public boolean isVaultEconomyIntegrated() {
public String inspectVaultEconomy() {
- String results = null;
+ String results = null;
if ( econName == null && Bukkit.getPluginManager().getPlugin("Vault") != null &&
Bukkit.getServicesManager().getRegistration(Economy.class) != null ) {
- econ = Bukkit.getServicesManager().getRegistration(Economy.class).getProvider();
-
- if ( econ != null ) {
- econName = econ.getClass().getSimpleName();
- results = econName;
-
- if ( prison.getConfig().isBoolean( "delayedPrisonStartup.inspect-vault" ) ) {
-
- String message = String.format(
- "Inspect Vault Economy: %s Use '%s' with " +
- "'delayedPrisonStartup.triggers-vault-economy-name' ",
- econ.isEnabled() ? "enabled" : "disabled",
- econ.getClass().getSimpleName()
- );
-
- Output.get().logInfo( message );
- }
- }
+ econ = Bukkit.getServicesManager().getRegistration(Economy.class).getProvider();
+
+ if ( econ != null ) {
+ econName = econ.getClass().getSimpleName();
+ results = econName;
+
+ if ( prison.getConfig().isBoolean( "delayedPrisonStartup.inspect-vault" ) ) {
+
+ String message = String.format(
+ "Inspect Vault Economy: %s Use '%s' with " +
+ "'delayedPrisonStartup.triggers-vault-economy-name' ",
+ econ.isEnabled() ? "enabled" : "disabled",
+ econ.getClass().getSimpleName()
+ );
+
+ Output.get().logInfo( message );
+ }
+ }
}
else if ( econName != null ) {
- results = econName;
+ results = econName;
}
if ( results == null ) {
- Output.get().logInfo( "Inspect Vault Economy: Failed." );
+ Output.get().logInfo( "Inspect Vault Economy: Failed." );
}
return results;
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java
index aa9bce412..62d4806d5 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/util/SpigotYamlFileIO.java
@@ -43,8 +43,8 @@ protected boolean loadYaml() {
}
try {
- yamlConfig.load(getYamlFile());
- results = true;
+ yamlConfig.load(getYamlFile());
+ results = true;
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
@@ -93,60 +93,8 @@ protected void createSection( String key ) {
}
-// @Override
-// protected boolean getBoolean( String key ) {
-// return yamlConfig.getBoolean( key ) ;
-// }
-// @Override
-// protected boolean getBoolean( String key, boolean defaultValue ) {
-// return yamlConfig.getBoolean( key, defaultValue ) ;
-// }
-//
-// @Override
-// protected String getString( String key ) {
-// return yamlConfig.getString( key ) ;
-// }
-// @Override
-// protected String getString( String key, String defaultValue ) {
-// return yamlConfig.getString( key, defaultValue ) ;
-// }
-//
-// @Override
-// protected double getDouble( String key ) {
-// return yamlConfig.getDouble( key ) ;
-// }
-// @Override
-// protected double getDouble( String key, double defaultValue ) {
-// return yamlConfig.getDouble( key, defaultValue ) ;
-// }
-//
-// @Override
-// protected int getInteger( String key ) {
-// return yamlConfig.getInt( key ) ;
-// }
-// @Override
-// protected int getInteger( String key, int defaultValue ) {
-// return yamlConfig.getInt( key, defaultValue ) ;
-// }
-//
-// @Override
-// protected long getLong( String key ) {
-// return yamlConfig.getLong( key ) ;
-// }
-// @Override
-// protected long getLong( String key, long defaultValue ) {
-// return yamlConfig.getLong( key, defaultValue ) ;
-// }
-
-
public void test( ) {
-// yamlConfig. ;
-
-
}
-
-
-
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonBombListener.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonBombListener.java
index 9933dbd44..4ce3344e4 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonBombListener.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonBombListener.java
@@ -22,7 +22,6 @@
import tech.mcprison.prison.bombs.MineBombCooldownException;
import tech.mcprison.prison.bombs.MineBombData;
import tech.mcprison.prison.bombs.MineBombs;
-import tech.mcprison.prison.bombs.MineBombs.AnimationArmorStandItemLocation;
import tech.mcprison.prison.mines.data.Mine;
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.spigot.SpigotPrison;
@@ -79,57 +78,50 @@ public void mineBombPlacementEvent( BlockPlaceEvent event ) {
if ( iStack != null && iStack.getType() != Material.AIR ) {
- String bombName = checkMineBombItemStack( iStack );
-
- if ( bombName != null ) {
-
- Player player = event.getPlayer();
- SpigotPlayer sPlayer = new SpigotPlayer( player );
-
- MineBombData mineBomb = null;
-
- try {
- // Placing minebombs: Use cooldowns:
- mineBomb = MineBombs.getInstance().findBombByName( sPlayer, bombName);
- }
- catch (MineBombCooldownException e) {
- String msg = e.getLocalizedMessage();
-
- sPlayer.sendMessage(msg);
-
- return;
- }
-
-// MineBombData mineBomb = MineBombs.getInstance().findBombByName( sPlayer, bombName );
-
- String thrower = player.getUniqueId().toString();
- String owner = PrisonNBTUtil.getNBTString(iStack, MineBombs.MINE_BOMBS_NBT_OWNER_UUID);
-
- PrisonNBTUtil.setNBTString(iStack,
- MineBombs.MINE_BOMBS_NBT_KEY,
- bombName );
- PrisonNBTUtil.setNBTString(iStack,
- MineBombs.MINE_BOMBS_NBT_THROWER_UUID,
- thrower );
-
- Block targetBlock = event.getBlockAgainst();
-
-// SpigotBlock lsBlock = sPlayer.getLineOfSightBlock();
-
-// Output.get().logInfo(
-// "### Place mine bomb: mineBombPlacementEvent: block: %s sight: %s",
-// targetBlock.getLocation().toString(),
-// lsBlock.getLocation().toString() );
-
- EquipmentSlot hand = SpigotCompatibility.getInstance().getHand(event);
-
- boolean canceled = processBombTriggerEvent( player, mineBomb,
- targetBlock, hand, thrower, owner );
-
- if ( canceled ) {
- event.setCancelled( canceled );
- }
- }
+ String bombName = checkMineBombItemStack( iStack );
+
+ if ( bombName != null ) {
+
+ Player player = event.getPlayer();
+ SpigotPlayer sPlayer = new SpigotPlayer( player );
+
+ MineBombData mineBomb = null;
+
+ try {
+ // Placing minebombs: Use cooldowns:
+ mineBomb = MineBombs.getInstance().findBombByName( sPlayer, bombName);
+ }
+ catch (MineBombCooldownException e) {
+ String msg = e.getLocalizedMessage();
+
+ sPlayer.sendMessage(msg);
+
+ return;
+ }
+
+
+ String thrower = player.getUniqueId().toString();
+ String owner = PrisonNBTUtil.getNBTString(iStack, MineBombs.MINE_BOMBS_NBT_OWNER_UUID);
+
+ PrisonNBTUtil.setNBTString(iStack,
+ MineBombs.MINE_BOMBS_NBT_KEY,
+ bombName );
+ PrisonNBTUtil.setNBTString(iStack,
+ MineBombs.MINE_BOMBS_NBT_THROWER_UUID,
+ thrower );
+
+ Block targetBlock = event.getBlockAgainst();
+
+
+ EquipmentSlot hand = SpigotCompatibility.getInstance().getHand(event);
+
+ boolean canceled = processBombTriggerEvent( player, mineBomb,
+ targetBlock, hand, thrower, owner );
+
+ if ( canceled ) {
+ event.setCancelled( canceled );
+ }
+ }
}
@@ -157,210 +149,210 @@ public void mineBombThrowEvent( PlayerInteractEvent event ) {
String bombName = checkMineBombItemStack( iStack );
- if ( bombName != null ) {
-
- // We do not know if the bomb will be in a mine, but we know
- // it's a mine bomb so no other listener should handle it.
- event.setCancelled( true );
-
- Player player = event.getPlayer();
- SpigotPlayer sPlayer = new SpigotPlayer( player );
-
- // If the player is on a mine bomb cooldown, then mineBomb will be null:
-
- final MineBombData mineBomb;
-
- try {
- // Throw minebombs: Use cooldowns:
- mineBomb = MineBombs.getInstance().findBombByName( sPlayer, bombName);
- }
- catch (MineBombCooldownException e) {
- String msg = e.getLocalizedMessage();
-
- sPlayer.sendMessage(msg);
-
- return;
- }
-
-// MineBombData mineBomb = MineBombs.getInstance().findBombByName( sPlayer, bombName );
-
- if ( mineBomb != null ) {
-
- EquipmentSlot hand = SpigotCompatibility.getInstance().getHand(event);
-
-
-
- final String thrower = sPlayer.getName();
-// final String thrower = PrisonNBTUtil.getNBTString( iStack, MineBombs.MINE_BOMBS_NBT_THROWER_UUID );
-
- final String owner = PrisonNBTUtil.getNBTString( iStack, MineBombs.MINE_BOMBS_NBT_OWNER_UUID);
-
-
-
-
- PrisonNBTUtil.setNBTString(iStack,
- MineBombs.MINE_BOMBS_NBT_KEY,
- bombName );
- PrisonNBTUtil.setNBTString(iStack,
- MineBombs.MINE_BOMBS_NBT_THROWER_UUID,
- thrower );
-
- SpigotLocation loc = new SpigotLocation(
- player.getEyeLocation().add( player.getLocation().getDirection() ));
-
-
- ArmorStand armorStand = player.getWorld().spawn(
- loc.getBukkitLocation(),
- ArmorStand.class);
-
- armorStand.setVisible( false );
- armorStand.setItemInHand( iStack );
-
-
- SpigotArmorStand sArmorStand = new SpigotArmorStand(armorStand);
-
- sArmorStand.setNbtString( MineBombs.MINE_BOMBS_NBT_KEY, bombName );
- sArmorStand.setNbtString( MineBombs.MINE_BOMBS_NBT_THROWER_UUID, thrower );
- sArmorStand.setNbtString( MineBombs.MINE_BOMBS_NBT_OWNER_UUID, owner );
-
-
- if ( Output.get().isDebug() ) {
- String nbtJson = Text.translateAmpColorCodes(
- PrisonNBTUtil.getNBTData(
- sArmorStand.getBukkitEntity() ));
- Output.get().logInfo( "PrisonBombListener.mineBombThrowEvent ntb: %s",
- nbtJson );
- }
-
-
- Vector velocity = player.getLocation().getDirection().multiply(
- mineBomb.getThrowVelocity() );
-
- armorStand.setVelocity( velocity );
-
- armorStand.setRemoveWhenFarAway(false);
-
-
-
-
- // Remove the unused armorStand in 120 seconds:
- final int taskId = SpigotPrison.getInstance().getScheduler()
- .runTaskLater(
- new Runnable() {
- public void run() {
- armorStand.remove();
- }
- }, 120 * 20);
-
-
- // Run the following every tick to detect when the armor stand has
- // come to rest for 4 ticks, then trigger the animation.
- final SpigotArmorStand aStnd = sArmorStand;
-
-
- // Save the taskId so this task can be canceled:
- mineBomb.setTaskId(
- SpigotPrison.getInstance().getScheduler()
- .runTaskTimer(
- new Runnable() {
- private List locs = new ArrayList<>();
- private int checks = 0;
-
- /**
- * Remove the bomb.
- *
- */
- private void removeBomb() {
-
- // Cancel this task:
- SpigotPrison.getInstance().getScheduler().cancelTask( mineBomb.getTask() );
-
- // Cancel the cancellation task:
- SpigotPrison.getInstance().getScheduler().cancelTask(taskId);
-
-
- // remove armor stand:
- aStnd.remove();
- }
-
- public void run() {
- Location loc = aStnd.getLocation();
- locs.add(loc);
-
- // Only keep no more than 4 locations in the list. Purge the oldest.
- if ( locs.size() > 4 ) {
- locs.remove(0);
- }
-
-// String msg = String.format(
-// "### MineBomb: tracking minebomb movements. count=%s locs=%s current: %s",
-// Integer.toString(checks++),
-// Integer.toString(locs.size()),
-// loc.toWorldCoordinates() );
-// Output.get().logInfo( msg );
-
- // If mine bomb does not land it may have fallen in the void.. so remove it:
- if ( checks > 100 ) {
- removeBomb();
- }
-
- if ( locs.size() == 4 ) {
-
- // When there are four locations, then check to ensure the mine
- // bomb is no longer moving...
- if ( locs.get(0).equals(locs.get(1)) &&
- locs.get(1).equals(locs.get(2)) &&
- locs.get(2).equals(locs.get(3))
- ) {
-
- // Set the mine bomb's location where the item has landed:
- mineBomb.setPlacedBombLocation( loc );
-
- removeBomb();
-
-// // Cancel this task:
-// SpigotPrison.getInstance().getScheduler().cancelTask( mineBomb.getTask() );
-//
-// // Cancel the cancellation task:
-// SpigotPrison.getInstance().getScheduler().cancelTask(taskId);
-//
-//
-// // remove armor stand:
-// aStnd.remove();
-
- // Start mine bomb animation:
-// loc.setY( loc.getY() );
- SpigotBlock targetBlock = (SpigotBlock) loc.getBlockAt();
-
- Mine mine = getMine(sPlayer, mineBomb, targetBlock );
-
- if ( mine != null ) {
- // It landed within a mine... subtract one from the player's inventory,
- // if it's used up, then remove from the inventory:
-// iStack.setAmount( iStack.getAmount() - 1);
-// if ( iStack.getAmount() == 0 ) {
-// player.getInventory().removeItem( iStack );
-// }
-
- processBombTriggerEvent( sPlayer, mine, mineBomb, targetBlock,
- hand, thrower, owner );
- }
-
- }
- }
- }
-
- }, 2, 1));
- }
- else {
- int cooldownTicks = MineBombs.checkPlayerCooldown(sPlayer);
-
- getPrisonUtilsMineBombs().mineBombsCoolDownMsg( sPlayer, cooldownTicks );
- }
-
-
-
-
+ if ( bombName != null ) {
+
+ // We do not know if the bomb will be in a mine, but we know
+ // it's a mine bomb so no other listener should handle it.
+ event.setCancelled( true );
+
+ Player player = event.getPlayer();
+ SpigotPlayer sPlayer = new SpigotPlayer( player );
+
+ // If the player is on a mine bomb cooldown, then mineBomb will be null:
+
+ final MineBombData mineBomb;
+
+ try {
+ // Throw minebombs: Use cooldowns:
+ mineBomb = MineBombs.getInstance().findBombByName( sPlayer, bombName);
+ }
+ catch (MineBombCooldownException e) {
+ String msg = e.getLocalizedMessage();
+
+ sPlayer.sendMessage(msg);
+
+ return;
+ }
+
+
+ if ( mineBomb != null ) {
+
+ EquipmentSlot hand = SpigotCompatibility.getInstance().getHand(event);
+
+
+
+ final String thrower = sPlayer.getName();
+
+ // final String thrower = PrisonNBTUtil.getNBTString( iStack, MineBombs.MINE_BOMBS_NBT_THROWER_UUID );
+
+ final String owner = PrisonNBTUtil.getNBTString( iStack, MineBombs.MINE_BOMBS_NBT_OWNER_UUID);
+
+
+
+
+ PrisonNBTUtil.setNBTString(iStack,
+ MineBombs.MINE_BOMBS_NBT_KEY,
+ bombName );
+ PrisonNBTUtil.setNBTString(iStack,
+ MineBombs.MINE_BOMBS_NBT_THROWER_UUID,
+ thrower );
+
+ SpigotLocation loc = new SpigotLocation(
+ player.getEyeLocation().add( player.getLocation().getDirection() ));
+
+
+ ArmorStand armorStand = player.getWorld().spawn(
+ loc.getBukkitLocation(),
+ ArmorStand.class);
+
+ armorStand.setVisible( false );
+ armorStand.setItemInHand( iStack );
+
+
+ SpigotArmorStand sArmorStand = new SpigotArmorStand(armorStand);
+
+ sArmorStand.setNbtString( MineBombs.MINE_BOMBS_NBT_KEY, bombName );
+ sArmorStand.setNbtString( MineBombs.MINE_BOMBS_NBT_THROWER_UUID, thrower );
+ sArmorStand.setNbtString( MineBombs.MINE_BOMBS_NBT_OWNER_UUID, owner );
+
+
+ if ( Output.get().isDebug() ) {
+ String nbtJson = Text.translateAmpColorCodes(
+ PrisonNBTUtil.getNBTData(
+ sArmorStand.getBukkitEntity() ));
+ Output.get().logInfo( "PrisonBombListener.mineBombThrowEvent ntb: %s",
+ nbtJson );
+ }
+
+
+ Vector velocity = player.getLocation().getDirection().multiply(
+ mineBomb.getThrowVelocity() );
+
+ armorStand.setVelocity( velocity );
+
+ armorStand.setRemoveWhenFarAway(false);
+
+
+
+
+ // Remove the unused armorStand in 120 seconds:
+ final int taskId = SpigotPrison.getInstance().getScheduler()
+ .runTaskLater(
+ new Runnable() {
+ public void run() {
+ armorStand.remove();
+ }
+ }, 120 * 20);
+
+
+ // Run the following every tick to detect when the armor stand has
+ // come to rest for 4 ticks, then trigger the animation.
+ final SpigotArmorStand aStnd = sArmorStand;
+
+
+ // Save the taskId so this task can be canceled:
+ mineBomb.setTaskId(
+ SpigotPrison.getInstance().getScheduler()
+ .runTaskTimer(
+ new Runnable() {
+ private List locs = new ArrayList<>();
+ private int checks = 0;
+
+ /**
+ * Remove the bomb.
+ *
+ */
+ private void removeBomb() {
+
+ // Cancel this task:
+ SpigotPrison.getInstance().getScheduler().cancelTask( mineBomb.getTask() );
+
+ // Cancel the cancellation task:
+ SpigotPrison.getInstance().getScheduler().cancelTask(taskId);
+
+
+ // remove armor stand:
+ aStnd.remove();
+ }
+
+ public void run() {
+ Location loc = aStnd.getLocation();
+ locs.add(loc);
+
+ // Only keep no more than 4 locations in the list. Purge the oldest.
+ if ( locs.size() > 4 ) {
+ locs.remove(0);
+ }
+
+ // String msg = String.format(
+ // "### MineBomb: tracking minebomb movements. count=%s locs=%s current: %s",
+ // Integer.toString(checks++),
+ // Integer.toString(locs.size()),
+ // loc.toWorldCoordinates() );
+ // Output.get().logInfo( msg );
+
+ // If mine bomb does not land it may have fallen in the void.. so remove it:
+ if ( checks > 100 ) {
+ removeBomb();
+ }
+
+ if ( locs.size() == 4 ) {
+
+ // When there are four locations, then check to ensure the mine
+ // bomb is no longer moving...
+ if ( locs.get(0).equals(locs.get(1)) &&
+ locs.get(1).equals(locs.get(2)) &&
+ locs.get(2).equals(locs.get(3))
+ ) {
+
+ // Set the mine bomb's location where the item has landed:
+ mineBomb.setPlacedBombLocation( loc );
+
+ removeBomb();
+
+ // // Cancel this task:
+ // SpigotPrison.getInstance().getScheduler().cancelTask( mineBomb.getTask() );
+ //
+ // // Cancel the cancellation task:
+ // SpigotPrison.getInstance().getScheduler().cancelTask(taskId);
+ //
+ //
+ // // remove armor stand:
+ // aStnd.remove();
+
+ // Start mine bomb animation:
+ // loc.setY( loc.getY() );
+ SpigotBlock targetBlock = (SpigotBlock) loc.getBlockAt();
+
+ Mine mine = getMine(sPlayer, mineBomb, targetBlock );
+
+ if ( mine != null ) {
+ // It landed within a mine... subtract one from the player's inventory,
+ // if it's used up, then remove from the inventory:
+ // iStack.setAmount( iStack.getAmount() - 1);
+ // if ( iStack.getAmount() == 0 ) {
+ // player.getInventory().removeItem( iStack );
+ // }
+
+ processBombTriggerEvent( sPlayer, mine, mineBomb, targetBlock,
+ hand, thrower, owner );
+ }
+
+ }
+ }
+ }
+
+ }, 2, 1));
+ }
+ else {
+ int cooldownTicks = MineBombs.checkPlayerCooldown(sPlayer);
+
+ getPrisonUtilsMineBombs().mineBombsCoolDownMsg( sPlayer, cooldownTicks );
+ }
+
+
+
+
// player.launchProjectile( armorStand, velocity );
@@ -385,7 +377,7 @@ public void run() {
//iStack.setAmount(iStack.getAmount()-1);
- }
+ }
}
}
@@ -400,9 +392,6 @@ public void run() {
*/
@EventHandler( priority = EventPriority.LOW )
public void bombPlacementEvent( PlayerInteractEvent event ) {
-// if ( !event.getPlayer().hasPermission("prison.minebombs.use") ) {
-// return;
-// }
//Output.get().logInfo( "### PrisonBombListener: PlayerInteractEvent 01 " );
@@ -566,8 +555,6 @@ private boolean processBombTriggerEvent( Player player,
SpigotBlock sBlock = null;
-// SpigotPlayer sPlayer = new SpigotPlayer( player );
-
// If clicking AIR, then event.getClickedBlock() will be null...
// so if null, then use the player's location for placing the bomb.
if ( targetBlock == null ) {
@@ -680,7 +667,6 @@ else if ( !mine.hasMiningAccess( sPlayer ) ) {
mine.getTag()
);
sPlayer.setActionBar( msg );
-// sPlayer.sendMessage( msg );
mine = null;
}
@@ -700,18 +686,11 @@ public void onBlockPlace( PlayerDropItemEvent event ) {
// event.getItemDrop().getMetadata( "prisonMineBomb" );
-// event.getItemDrop().
-
- event.setCancelled( false );
+ event.setCancelled( false );
}
}
-// @EventHandler( priority = EventPriority.HIGHEST, ignoreCancelled = false )
-// public void onBlockPlace2( PlayerInteractEvent event ) {
-//
-// Output.get().logInfo( "### PrisonBombListener: PlayerInteractEvent - oof" );
-// }
//// @EventHandler( priority = EventPriority.HIGHEST, ignoreCancelled = false )
// public void onBlockPlace3( BlockPlaceEvent event ) {
@@ -746,13 +725,6 @@ public void onBlockPlace( PlayerDropItemEvent event ) {
// }
// }
-//// @EventHandler( priority = EventPriority.HIGHEST, ignoreCancelled = false )
-// public void onBlockPlace3( PlayerInteractEvent event ) {
-//
-// Output.get().logInfo( "### PrisonBombListener: PlayerInteractEvent " );
-//
-//
-// }
public PrisonUtilsMineBombs getPrisonUtilsMineBombs() {
return prisonUtilsMineBombs;
@@ -761,28 +733,4 @@ public void setPrisonUtilsMineBombs( PrisonUtilsMineBombs prisonUtilsMineBombs )
this.prisonUtilsMineBombs = prisonUtilsMineBombs;
}
-// @EventHandler( priority = EventPriority.HIGHEST, ignoreCancelled = false )
-// public void onBlockPlace3( BlockDropItemEvent event ) {
-//
-// Output.get().logInfo( "### PrisonBombListener: PlayerInteractEvent " );
-//
-//
-// }
-
-// @EventHandler( priority = EventPriority.HIGHEST )
-// public void onBlockPlace2( Player event ) {
-//
-//
-// if ( event.isCancelled() && event.getItemDrop().hasMetadata( "prisonMineBomb" ) ) {
-//
-//// event.getItemDrop().getMetadata( "prisonMineBomb" );
-//
-//// event.getItemDrop().
-//
-// event.setCancelled( false );
-// }
-//
-// }
-
-
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtils.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtils.java
index 7b08ac753..769a75e6f 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtils.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtils.java
@@ -5,10 +5,8 @@
import tech.mcprison.prison.Prison;
import tech.mcprison.prison.internal.CommandSender;
import tech.mcprison.prison.internal.Player;
-import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.ranks.data.RankPlayer;
import tech.mcprison.prison.spigot.game.SpigotPlayer;
-import tech.mcprison.prison.spigot.game.SpigotPlayerException;
public abstract class PrisonUtils
implements PrisonUtilsInterface {
@@ -49,11 +47,11 @@ private void pluginInitialize() {
setPluginRegistered( Bukkit.getPluginManager().isPluginEnabled( getPluginName() ) );
- setPluginVersion( isPluginRegistered() ?
- Bukkit.getPluginManager().getPlugin( getPluginName() )
- .getDescription().getVersion() : null );
-
- this.enabled = initialize();
+ setPluginVersion( isPluginRegistered() ?
+ Bukkit.getPluginManager().getPlugin( getPluginName() )
+ .getDescription().getVersion() : null );
+
+ this.enabled = initialize();
}
@Override
@@ -72,10 +70,6 @@ public boolean isEnabled() {
*/
abstract protected Boolean initialize();
-// protected SpigotPlayer checkPlayerPerms( CommandSender sender, String playerName,
-// String permsSelf, String permsOthers ) {
-// return checkPlayerPerms(sender, playerName, permsSelf, permsOthers, false );
-// }
/**
* This function checks the perms of the player. If the CommandSender has no
@@ -100,49 +94,49 @@ protected SpigotPlayer checkPlayerPerms( CommandSender sender, String playerName
boolean isConsole = !(sender instanceof org.bukkit.entity.Player);
- SpigotPlayer player = getSpigotPlayer( playerName );
-
- // Player's name was not found then it's either being ran from console, or on self.
- if ( player == null ) {
-
- // Ran from console, so if player is null, then playerName was either not
- // specified or was invalid:
- if ( isConsole ) {
- sender.sendMessage( String.format(
- "&3PlayerName is incorrect or they are not online. [&7%s&3]",
- (playerName == null ? "null" : playerName) ));
- }
- else if ( !sender.isOp() && !sender.hasPermission( permsSelf ) ) {
- sender.sendMessage( String.format(
- "&3You do not have the permission to use on another player. [&7%s&3]",
- (playerName == null ? "null" : playerName) ));
-
- }
- else {
-
- // sender is able to use the command on their self:
- player = new SpigotPlayer( (org.bukkit.entity.Player) sender);
- }
-
- }
- else {
-
- // The provided playerName was valid.
-
- // Need to confirm the sender is either console, OP, or has perms to
- // use command on someone else, if none of these apply, then reject
- // the request to run the command.
- if ( !isConsole && !sender.isOp() && !sender.hasPermission( permsOthers ) ) {
- sender.sendMessage( String.format(
- "&3You do not have the permission to use on another player. [%s]",
- (playerName == null ? "null" : playerName) ));
-
- // Set player to null to indicate authentication failed:
- player = null;
- }
- }
-
- return player;
+ SpigotPlayer player = getSpigotPlayer( playerName );
+
+ // Player's name was not found then it's either being ran from console, or on self.
+ if ( player == null ) {
+
+ // Ran from console, so if player is null, then playerName was either not
+ // specified or was invalid:
+ if ( isConsole ) {
+ sender.sendMessage( String.format(
+ "&3PlayerName is incorrect or they are not online. [&7%s&3]",
+ (playerName == null ? "null" : playerName) ));
+ }
+ else if ( !sender.isOp() && !sender.hasPermission( permsSelf ) ) {
+ sender.sendMessage( String.format(
+ "&3You do not have the permission to use on another player. [&7%s&3]",
+ (playerName == null ? "null" : playerName) ));
+
+ }
+ else {
+
+ // sender is able to use the command on their self:
+ player = new SpigotPlayer( (org.bukkit.entity.Player) sender);
+ }
+
+ }
+ else {
+
+ // The provided playerName was valid.
+
+ // Need to confirm the sender is either console, OP, or has perms to
+ // use command on someone else, if none of these apply, then reject
+ // the request to run the command.
+ if ( !isConsole && !sender.isOp() && !sender.hasPermission( permsOthers ) ) {
+ sender.sendMessage( String.format(
+ "&3You do not have the permission to use on another player. [%s]",
+ (playerName == null ? "null" : playerName) ));
+
+ // Set player to null to indicate authentication failed:
+ player = null;
+ }
+ }
+
+ return player;
}
@@ -163,10 +157,6 @@ protected SpigotPlayer getSpigotPlayer( String playerName ) {
RankPlayer rPlayer = Prison.get().getPlatform().getRankPlayer( null, playerName );
-// // First try to get the bukkit online player:
-// if ( rPlayer != null ) {
-// org.bukkit.entity.Player playerBukkit = Bukkit.getPlayer( rPlayer.getUUID() );
-// }
if ( rPlayer == null ) {
@@ -186,66 +176,14 @@ protected SpigotPlayer getSpigotPlayer( String playerName ) {
rPlayer = rp;
}
-
-
}
if ( rPlayer != null ) {
result = SpigotPlayer.getSpigotPlayer( rPlayer );
-// try {
-// }
-// catch (SpigotPlayerException e) {
-//
-//// String msg = String.format(
-//// "SpigotPlayer: Could not get a bukkit player object for '%s'. "
-//// + "Is their name spelled correctly? "
-//// + "Have they been removed or banned from spigot?",
-//// playerName
-//// );
-//
-// Output.get().logInfo( e.getMessage() );
-//
-// }
-
-// Player player = Prison.get().getPlatform().getPlayer( rPlayer.getUUID() ).orElse(null);
-//
-// if ( player != null ) {
-// result = (SpigotPlayer) player;
-// }
-// else if ( useOfflinePlayer ) {
-//
-//
-//// Player offLinePlayer = Prison.get().getPlatform().getOfflinePlayer( rPlayer.getUUID() ).orElse( null );
-////
-//// if ( offLinePlayer != null ) {
-////
-//// SpigotOfflinePlayer offlinePlayer = (SpigotOfflinePlayer) offLinePlayer;
-////
-//// result = new SpigotPlayer( offlinePlayer.getWrapper().getPlayer() );
-// }
-// }
}
-// if ( playerName != null ) {
-// Optional opt = Prison.get().getPlatform().getPlayer( playerName );
-//
-// if ( opt.isPresent() ) {
-// result = (SpigotPlayer) opt.get();
-// }
-// else if ( useOfflinePlayer ) {
-// Optional optOLP = Prison.get().getPlatform().getOfflinePlayer( playerName );
-//
-// if ( optOLP.isPresent() ) {
-//
-// SpigotOfflinePlayer offlinePlayer = (SpigotOfflinePlayer) optOLP.get();
-//
-// result = new SpigotPlayer( offlinePlayer.getWrapper().getPlayer() );
-// }
-// }
-//
-// }
return result;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsHealing.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsHealing.java
index 7cee5351e..7cc0f5011 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsHealing.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsHealing.java
@@ -52,9 +52,10 @@ public void utilHealingHeal(CommandSender sender,
"'-' then that is what the player's health will be set to.") String amount
){
- if( !enableHealingHeal ){
+ if ( !enableHealingHeal ) {
Output.get().logInfo("Prison's utils command heal is disabled in modules.yml.");
- } else {
+ }
+ else {
SpigotPlayer player = checkPlayerPerms( sender, playerName,
"prison.utils.healing.heal",
"prison.utils.healing.heal.others" );
@@ -82,9 +83,10 @@ public void utilHealingFeed(CommandSender sender,
"'-' then that is what the player's hunger will be set to." ) String amount
){
- if( !enableHealingFeed ){
+ if ( !enableHealingFeed ) {
Output.get().logInfo("Prison's utils command feed is disabled in modules.yml.");
- } else {
+ }
+ else {
SpigotPlayer player = checkPlayerPerms( sender, playerName,
"prison.utils.healing.feed",
"prison.utils.healing.feed.others" );
@@ -111,9 +113,10 @@ public void utilHealingBreath(CommandSender sender,
"'-' then that is what the player's hunger will be set to.") String amount
){
- if( !enableHealingBreath ){
+ if ( !enableHealingBreath ) {
Output.get().logInfo("Prison's utils command breath is disabled in modules.yml.");
- } else {
+ }
+ else {
SpigotPlayer player = checkPlayerPerms( sender, playerName,
"prison.utils.healing.breath",
"prison.utils.healing.breath.others" );
@@ -123,7 +126,7 @@ public void utilHealingBreath(CommandSender sender,
}
private void utilHealingHeal( SpigotPlayer player, String amount ) {
- if(player == null){
+ if (player == null) {
return;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsListeners.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsListeners.java
index 9b70cdf6b..b4e4286e0 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsListeners.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsListeners.java
@@ -11,8 +11,6 @@
public class PrisonUtilsListeners
implements Listener
{
-// private HashMap unbreakableBlockList;
-
public PrisonUtilsListeners() {
super();
@@ -20,26 +18,8 @@ public PrisonUtilsListeners() {
// Force it to be setup and ready:
BlockUtils.getInstance();
-// this.unbreakableBlockList = new HashMap<>();
}
- // Runtime exception for some reasons here.
-// @EventHandler( priority=EventPriority.LOWEST )
-// public void rainbowDecayBlockEvent(PrisonMinesBlockEventEvent e) {
-
-// if ( !e.isCancelled() && e.getParameter() != null &&
-// e.getParameter().startsWith("rainbow-decay" ) ) {
-//
-// PrisonUtilsRainbowDecay rainbow = new PrisonUtilsRainbowDecay(
-// e, getUnbreakableBlockList());
-//
-// PrisonUtilsTask runableTask = new PrisonUtilsTask( rainbow.getTasks() );
-//
-// // submit:
-// runableTask.submit();
-// }
-
-// }
/**
* This event prevents any block that is within the unbreakableBlockList
@@ -52,18 +32,13 @@ public PrisonUtilsListeners() {
@EventHandler( priority=EventPriority.LOWEST )
public void unbreakableBlock( BlockBreakEvent e ) {
- if ( !e.isCancelled() ) {
- PrisonBlock block = SpigotBlock.getSpigotBlock( e.getBlock() ).getPrisonBlock();
-
- if ( BlockUtils.getInstance().isUnbreakable( block ) ) {
- e.setCancelled( true );
- }
- }
+ if ( !e.isCancelled() ) {
+ PrisonBlock block = SpigotBlock.getSpigotBlock( e.getBlock() ).getPrisonBlock();
+
+ if ( BlockUtils.getInstance().isUnbreakable( block ) ) {
+ e.setCancelled( true );
+ }
+ }
}
-
-// public HashMap getUnbreakableBlockList() {
-// return unbreakableBlockList;
-// }
-
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMessages.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMessages.java
index 5469bee41..3d7693ac5 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMessages.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMessages.java
@@ -19,7 +19,6 @@ public class PrisonUtilsMessages
public PrisonUtilsMessages() {
super();
-
}
/**
@@ -79,7 +78,7 @@ public void utilMessageMsg(CommandSender sender,
public void utilMessageBroadcast(CommandSender sender,
@Wildcard(join=true)
- @Arg(name = "msg", description = "The message to send", def = "") String msg ) {
+ @Arg(name = "msg", description = "The message to send", def = "") String msg ) {
if ( !isEnableMessageMsg() ) {
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java
index 70067e3bb..857633891 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMineBombs.java
@@ -103,8 +103,6 @@ public static PrisonUtilsMineBombs getInstance() {
@Override
protected Boolean initialize()
{
- //validateMineBombs();
-
return true;
}
@@ -242,7 +240,7 @@ public void utilsFindMineBombsArmorStands( CommandSender sender,
// actions:
if ( show ) {
-// sEntity.getWrapper().
+
}
if ( list ) {
// Do nothing:
@@ -286,20 +284,8 @@ else if ( removeAll ||
sender.sendMessage( "&3-= No ArmmorStands were located with the selected filters =-");
}
-// Location EntityArea = new Location(Bukkit.getWorld("world"),125,71,105);
-// World world = Bukkit.getServer().getWorld("world");
-// List entList = world.getEntities();
-//
-// for(Entity current : entList){
-// if(current instanceof Item){
-// current.remove();
-// }
-// }
-
}
-
}
-
}
@@ -597,9 +583,10 @@ public void utilsMineBombsList( CommandSender sender,
visuals.add( p.name() );
}
Collections.sort( visuals );
-// for ( Particle p : Particle.values() ) {
-// visuals.add( p.name() );
-// }
+
+// for ( Particle p : Particle.values() ) {
+// visuals.add( p.name() );
+// }
messages.add( "&7Visual Effects (bukkit 1.8.x: Effect):" );
for ( String line : Text.formatColumnsFromList( visuals, 4 ) ) {
@@ -613,9 +600,10 @@ public void utilsMineBombsList( CommandSender sender,
visuals.add( p.name() );
}
Collections.sort( visuals );
-// for ( Particle p : Particle.values() ) {
-// visuals.add( p.name() );
-// }
+
+// for ( Particle p : Particle.values() ) {
+// visuals.add( p.name() );
+// }
messages.add( "&7Visual Effects (Particle):" );
for ( String line : Text.formatColumnsFromList( visuals, 4 ) ) {
@@ -747,6 +735,8 @@ public void utilsMineBombsList( CommandSender sender,
messageShape = " &4(no shape defined)";
}
}
+
+
if ( messageShape != null && !messageShape.isEmpty() ) {
messages.add( messageShape );
@@ -916,13 +906,13 @@ public void utilsMineBombsGive( CommandSender sender,
// MineBombs mBombs = MineBombs.getInstance();
- MineBombData bomb = null;
-
- try {
- // Give command. Do not enable cooldowns:
- bomb = MineBombs.getInstance().findBombByName( player, bombName, false );
- }
- catch (MineBombCooldownException e) {
+ MineBombData bomb = null;
+
+ try {
+ // Give command. Do not enable cooldowns:
+ bomb = MineBombs.getInstance().findBombByName( player, bombName, false );
+ }
+ catch (MineBombCooldownException e) {
String msg = e.getLocalizedMessage();
player.sendMessage(msg);
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMining.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMining.java
index 70c880546..a3de30b66 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMining.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsMining.java
@@ -65,7 +65,6 @@ public void utilMiningSmelt(CommandSender sender,
if ( Output.get().isDebug() ) {
Output.get().logInfo( debugInfo.toString() );
}
-// SpigotPrison.getInstance().getAutoFeatures().playerSmelt( player );
}
}
}
@@ -100,7 +99,6 @@ public void utilMiningBlock(CommandSender sender,
Output.get().logInfo( debugInfo.toString() );
}
-// SpigotPrison.getInstance().getAutoFeatures().playerBlock( player );
}
}
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsModule.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsModule.java
index 068ba12d8..91395c5c4 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsModule.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsModule.java
@@ -88,7 +88,6 @@ public void enable() {
PrisonUtilsPotions utils = new PrisonUtilsPotions();
utils.setEnablePotionEffects( isEnabled( "utils.potions.potionEffects", true ) );
- // utils.setEnablePotions( isEnabled( "utils.potions.potions.enabled", true ) );
Prison.get().getCommandHandler().registerCommands( utils );
@@ -186,13 +185,13 @@ private boolean isEnabled( String configPath, boolean defaultValue ) {
* @return
*/
public int getElementCount() {
- int results = isEnabled() ? 0 : -1;
-
- if ( isEnabled() ) {
- results = getModulesEnabled();
- }
-
- return results;
+ int results = isEnabled() ? 0 : -1;
+
+ if ( isEnabled() ) {
+ results = getModulesEnabled();
+ }
+
+ return results;
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsPotions.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsPotions.java
index 303affc24..344f4b3c8 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsPotions.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsPotions.java
@@ -19,7 +19,6 @@ public class PrisonUtilsPotions
{
private boolean enablePotionEffects = false;
-// private boolean enablePotions = false;
private List potionEffectsList;
@@ -103,12 +102,6 @@ public void utilPotionEffects( CommandSender sender,
sb.append( pType.name().toLowerCase() ).append( ' ' );
}
-// for ( PotionEffectType effect : PotionEffectType.values() ) {
-// if ( effect != null && effect.getName() != null ) {
-// sb.append( effect.getName().toLowerCase() ).append( ' ' );
-// }
-// }
-
sender.sendMessage( String.format( "&7Valid potion names: %s", sb.toString() ) );
return;
@@ -164,26 +157,6 @@ public void utilPotionEffects( CommandSender sender,
int ampliferValue = intValue( amplifier, -256, 0, 1024 );
-// List effects = new ArrayList<>();
-//
-// if ( options != null && options.trim().isEmpty() ) {
-// String[] opts = options.trim().split( " " );
-// for ( String opt : opts ) {
-// PotionEffectOptions effect = PotionEffectOptions.fromString( opt );
-//
-// if ( effect != null ) {
-// effects.add( effect );
-// }
-// }
-// }
-//
-
-
-// boolean isAmbient = effects.contains( PotionEffectOptions.ambient );
-// boolean isParticles = effects.contains( PotionEffectOptions.particles );
-// boolean isIcon = effects.contains( PotionEffectOptions.icon );
-
-// boolean isForceConfictRemoval = effects.contains( PotionEffectOptions.forceConfictRemoval );
if ( player != null && player.getWrapper() != null ) {
@@ -191,14 +164,6 @@ public void utilPotionEffects( CommandSender sender,
addPotion( entity, potion, durationTicks, ampliferValue );
-// PotionEffect potionEffect = new PotionEffect( potion, durationTicks, ampliferValue,
-// isAmbient, isParticles, isIcon );
-//
-// if ( potionEffect != null ) {
-// player.getWrapper().addPotionEffect( potionEffect, isForceConfictRemoval );
-// }
-
-
}
}
}
@@ -271,11 +236,4 @@ public void setEnablePotionEffects( boolean enablePotionEffects ) {
this.enablePotionEffects = enablePotionEffects;
}
-// public boolean isEnablePotions() {
-// return enablePotions;
-// }
-// public void setEnablePotions( boolean enablePotions ) {
-// this.enablePotions = enablePotions;
-// }
-
}
diff --git a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsRepair.java b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsRepair.java
index 270630590..8637d826c 100644
--- a/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsRepair.java
+++ b/prison-spigot/src/main/java/tech/mcprison/prison/spigot/utils/PrisonUtilsRepair.java
@@ -152,55 +152,55 @@ public void utilRepairInHand(CommandSender sender,
private void utilRepair( SpigotPlayer player, String playerName, List repairOptions ) {
- final List repaired = new ArrayList<>();
-
- if ( player != null && player.getWrapper() != null && player.getWrapper().getInventory() != null ) {
-
- SpigotPlayerInventory inventory = new SpigotPlayerInventory( player.getWrapper().getInventory() );
-
- if ( repairOptions.contains( RepairOptions.repairAll ) ) {
-
- repairItems( inventory.getItems(), player, repaired, repairOptions);
- }
- else if ( repairOptions.contains( RepairOptions.repairInHand ) ) {
- List