2020-06-06 01:26:14 +02:00
/ *
* This file is part of GriefDefender , licensed under the MIT License ( MIT ) .
*
* Copyright ( c ) bloodmc
* Copyright ( c ) contributors
*
* Permission is hereby granted , free of charge , to any person obtaining a copy
* of this software and associated documentation files ( the " Software " ) , to deal
* in the Software without restriction , including without limitation the rights
* to use , copy , modify , merge , publish , distribute , sublicense , and / or sell
* copies of the Software , and to permit persons to whom the Software is
* furnished to do so , subject to the following conditions :
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
* IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER
* LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM ,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE .
* /
package com.griefdefender.command ;
import co.aikar.commands.BaseCommand ;
import co.aikar.commands.InvalidCommandArgument ;
import co.aikar.commands.annotation.CommandAlias ;
import co.aikar.commands.annotation.CommandCompletion ;
import co.aikar.commands.annotation.CommandPermission ;
import co.aikar.commands.annotation.Description ;
import co.aikar.commands.annotation.Optional ;
import co.aikar.commands.annotation.Subcommand ;
import co.aikar.commands.annotation.Syntax ;
Update for 1.5.5 release.
* Add potion effects support.
* Add item enchantment support.
* Add pvp lookup methods for claim and playerdata.
* Add 'block-tileentity-id-list' used to override mod block id's that are used for many TE's.
- Ex. IC2 uses a base block id 'ic2:te' for all TE's. When the id is detected during block/item usage, it will be converted to the actual id.
* Add TileEntity registry to better support hybrid servers.
* Add '/claiminfo' UUID click support to copy text to chat.
* Add support for overriding option 'player-command-exit/enter' on player.
* Add command description translation support.
* Add zh_HK language support.
* Fix event cause not clearing on push.
* Fix abandon claim within town returning funds to owner in economy mode.
* Fix player afk detection during claim block task.
* Fix async chunk load during visual revert.
* Fix '/gd claim we' command.
* Fix advanced flag GUI toggle with definitions.
* Fix rent sign update not checking all children claims.
* Fix rent sign not being updated when cancelled via '/claimrent cancel'.
* Fix '/claimsell' on admin claim.
* Fix NPE when attempting to purchase an admin claim for sale.
* Fix command description translations.
* Fix isInvulnerable NPE on 1.8.8 servers.
* Fix '/abandonworld' exiting when no economy data found for player.
* Fix '/deletealladmin' only deleting admin claims in current world when passing no world argument.
* Fix '/claimcontract' and '/claimexpand' NPE in economy mode.
* Fix GD claim enter/exit prefix. The prefix will now use '[<playername>]'.
Note: This can be configured in lang file under 'claim-prefix-enter' and 'claim-prefix-exit'
* Clean up advanced flag GUI code.
* Disable /buyblocks command when economy-block-cost is <= 0
* Deny town claim abandon if basic claims exist owned by owner.
* Allow to input string as option value.
* Improve pvp source contexts.
* Clean up '/acb' command code.
* (Bukkit) Add potion splash protection support.
* (Bukkit) Fix tamed entities being hit by projectiles.
* (Bukkit) Fix enderman block place protection.
* (Hybrid) Fix wrong EnumCreatureType being registered for entities.
* (Hybrid) Add TileEntity registry.
* (Hybrid) Add mod command support for 'command-execute' flag.
* (Sponge) Add PlaceHolderAPI support.
* (Sponge) Add Nucleus v2 support.
* (Sponge) Add IgniteEntityEvent support.
* (Sponge) Fix '/cpp' and '/cpg' command.
* (Sponge) Fix player block placement deny not sending message.
Fixes #4
Fixes #200, Fixes #206, Fixes #222
Fixes #232, Fixes #237, Fixes #267
Fixes #269, Fixes #276, Fixes #296
Fixes #310, Fixes #311, Fixes #317
Fixes #324, Fixes #333, Fixes #334
Fixes #335, Fixes #336, Fixes #347
2020-12-28 23:28:12 +01:00
import com.flowpowered.math.vector.Vector3i ;
2020-06-06 01:26:14 +02:00
import com.google.common.collect.ImmutableMap ;
import com.griefdefender.GDPlayerData ;
import com.griefdefender.GriefDefenderPlugin ;
import com.griefdefender.api.claim.Claim ;
import com.griefdefender.api.economy.PaymentType ;
import com.griefdefender.api.economy.TransactionType ;
import com.griefdefender.cache.MessageCache ;
import com.griefdefender.cache.PermissionHolderCache ;
import com.griefdefender.claim.GDClaim ;
import com.griefdefender.claim.GDClaimManager ;
import com.griefdefender.configuration.MessageStorage ;
import com.griefdefender.internal.pagination.PaginationList ;
Update for 1.5.5 release.
* Add potion effects support.
* Add item enchantment support.
* Add pvp lookup methods for claim and playerdata.
* Add 'block-tileentity-id-list' used to override mod block id's that are used for many TE's.
- Ex. IC2 uses a base block id 'ic2:te' for all TE's. When the id is detected during block/item usage, it will be converted to the actual id.
* Add TileEntity registry to better support hybrid servers.
* Add '/claiminfo' UUID click support to copy text to chat.
* Add support for overriding option 'player-command-exit/enter' on player.
* Add command description translation support.
* Add zh_HK language support.
* Fix event cause not clearing on push.
* Fix abandon claim within town returning funds to owner in economy mode.
* Fix player afk detection during claim block task.
* Fix async chunk load during visual revert.
* Fix '/gd claim we' command.
* Fix advanced flag GUI toggle with definitions.
* Fix rent sign update not checking all children claims.
* Fix rent sign not being updated when cancelled via '/claimrent cancel'.
* Fix '/claimsell' on admin claim.
* Fix NPE when attempting to purchase an admin claim for sale.
* Fix command description translations.
* Fix isInvulnerable NPE on 1.8.8 servers.
* Fix '/abandonworld' exiting when no economy data found for player.
* Fix '/deletealladmin' only deleting admin claims in current world when passing no world argument.
* Fix '/claimcontract' and '/claimexpand' NPE in economy mode.
* Fix GD claim enter/exit prefix. The prefix will now use '[<playername>]'.
Note: This can be configured in lang file under 'claim-prefix-enter' and 'claim-prefix-exit'
* Clean up advanced flag GUI code.
* Disable /buyblocks command when economy-block-cost is <= 0
* Deny town claim abandon if basic claims exist owned by owner.
* Allow to input string as option value.
* Improve pvp source contexts.
* Clean up '/acb' command code.
* (Bukkit) Add potion splash protection support.
* (Bukkit) Fix tamed entities being hit by projectiles.
* (Bukkit) Fix enderman block place protection.
* (Hybrid) Fix wrong EnumCreatureType being registered for entities.
* (Hybrid) Add TileEntity registry.
* (Hybrid) Add mod command support for 'command-execute' flag.
* (Sponge) Add PlaceHolderAPI support.
* (Sponge) Add Nucleus v2 support.
* (Sponge) Add IgniteEntityEvent support.
* (Sponge) Fix '/cpp' and '/cpg' command.
* (Sponge) Fix player block placement deny not sending message.
Fixes #4
Fixes #200, Fixes #206, Fixes #222
Fixes #232, Fixes #237, Fixes #267
Fixes #269, Fixes #276, Fixes #296
Fixes #310, Fixes #311, Fixes #317
Fixes #324, Fixes #333, Fixes #334
Fixes #335, Fixes #336, Fixes #347
2020-12-28 23:28:12 +01:00
import com.griefdefender.internal.util.VecHelper ;
2020-06-06 01:26:14 +02:00
import com.griefdefender.permission.GDPermissionUser ;
import com.griefdefender.permission.GDPermissions ;
import com.griefdefender.text.action.GDCallbackHolder ;
import com.griefdefender.util.ChatCaptureUtil ;
import com.griefdefender.util.EconomyUtil ;
import com.griefdefender.util.PlayerUtil ;
import com.griefdefender.util.SignUtil ;
import net.kyori.text.Component ;
import net.kyori.text.TextComponent ;
import net.kyori.text.event.ClickEvent ;
import net.kyori.text.event.HoverEvent ;
import net.kyori.text.format.TextColor ;
import net.kyori.text.format.TextDecoration ;
import net.kyori.text.serializer.plain.PlainComponentSerializer ;
import net.milkbowl.vault.economy.Economy ;
Update for 1.5.5 release.
* Add potion effects support.
* Add item enchantment support.
* Add pvp lookup methods for claim and playerdata.
* Add 'block-tileentity-id-list' used to override mod block id's that are used for many TE's.
- Ex. IC2 uses a base block id 'ic2:te' for all TE's. When the id is detected during block/item usage, it will be converted to the actual id.
* Add TileEntity registry to better support hybrid servers.
* Add '/claiminfo' UUID click support to copy text to chat.
* Add support for overriding option 'player-command-exit/enter' on player.
* Add command description translation support.
* Add zh_HK language support.
* Fix event cause not clearing on push.
* Fix abandon claim within town returning funds to owner in economy mode.
* Fix player afk detection during claim block task.
* Fix async chunk load during visual revert.
* Fix '/gd claim we' command.
* Fix advanced flag GUI toggle with definitions.
* Fix rent sign update not checking all children claims.
* Fix rent sign not being updated when cancelled via '/claimrent cancel'.
* Fix '/claimsell' on admin claim.
* Fix NPE when attempting to purchase an admin claim for sale.
* Fix command description translations.
* Fix isInvulnerable NPE on 1.8.8 servers.
* Fix '/abandonworld' exiting when no economy data found for player.
* Fix '/deletealladmin' only deleting admin claims in current world when passing no world argument.
* Fix '/claimcontract' and '/claimexpand' NPE in economy mode.
* Fix GD claim enter/exit prefix. The prefix will now use '[<playername>]'.
Note: This can be configured in lang file under 'claim-prefix-enter' and 'claim-prefix-exit'
* Clean up advanced flag GUI code.
* Disable /buyblocks command when economy-block-cost is <= 0
* Deny town claim abandon if basic claims exist owned by owner.
* Allow to input string as option value.
* Improve pvp source contexts.
* Clean up '/acb' command code.
* (Bukkit) Add potion splash protection support.
* (Bukkit) Fix tamed entities being hit by projectiles.
* (Bukkit) Fix enderman block place protection.
* (Hybrid) Fix wrong EnumCreatureType being registered for entities.
* (Hybrid) Add TileEntity registry.
* (Hybrid) Add mod command support for 'command-execute' flag.
* (Sponge) Add PlaceHolderAPI support.
* (Sponge) Add Nucleus v2 support.
* (Sponge) Add IgniteEntityEvent support.
* (Sponge) Fix '/cpp' and '/cpg' command.
* (Sponge) Fix player block placement deny not sending message.
Fixes #4
Fixes #200, Fixes #206, Fixes #222
Fixes #232, Fixes #237, Fixes #267
Fixes #269, Fixes #276, Fixes #296
Fixes #310, Fixes #311, Fixes #317
Fixes #324, Fixes #333, Fixes #334
Fixes #335, Fixes #336, Fixes #347
2020-12-28 23:28:12 +01:00
import org.bukkit.block.Sign ;
2020-06-06 01:26:14 +02:00
import org.bukkit.entity.Player ;
import java.time.Instant ;
import java.util.ArrayList ;
import java.util.Date ;
import java.util.HashSet ;
import java.util.List ;
import java.util.Set ;
import java.util.UUID ;
@CommandAlias ( " %griefdefender " )
@CommandPermission ( GDPermissions . COMMAND_CLAIM_RENT )
public class CommandClaimRent extends BaseCommand {
@CommandCompletion ( " @gdrentcommands @gddummy " )
@CommandAlias ( " claimrent " )
Update for 1.5.5 release.
* Add potion effects support.
* Add item enchantment support.
* Add pvp lookup methods for claim and playerdata.
* Add 'block-tileentity-id-list' used to override mod block id's that are used for many TE's.
- Ex. IC2 uses a base block id 'ic2:te' for all TE's. When the id is detected during block/item usage, it will be converted to the actual id.
* Add TileEntity registry to better support hybrid servers.
* Add '/claiminfo' UUID click support to copy text to chat.
* Add support for overriding option 'player-command-exit/enter' on player.
* Add command description translation support.
* Add zh_HK language support.
* Fix event cause not clearing on push.
* Fix abandon claim within town returning funds to owner in economy mode.
* Fix player afk detection during claim block task.
* Fix async chunk load during visual revert.
* Fix '/gd claim we' command.
* Fix advanced flag GUI toggle with definitions.
* Fix rent sign update not checking all children claims.
* Fix rent sign not being updated when cancelled via '/claimrent cancel'.
* Fix '/claimsell' on admin claim.
* Fix NPE when attempting to purchase an admin claim for sale.
* Fix command description translations.
* Fix isInvulnerable NPE on 1.8.8 servers.
* Fix '/abandonworld' exiting when no economy data found for player.
* Fix '/deletealladmin' only deleting admin claims in current world when passing no world argument.
* Fix '/claimcontract' and '/claimexpand' NPE in economy mode.
* Fix GD claim enter/exit prefix. The prefix will now use '[<playername>]'.
Note: This can be configured in lang file under 'claim-prefix-enter' and 'claim-prefix-exit'
* Clean up advanced flag GUI code.
* Disable /buyblocks command when economy-block-cost is <= 0
* Deny town claim abandon if basic claims exist owned by owner.
* Allow to input string as option value.
* Improve pvp source contexts.
* Clean up '/acb' command code.
* (Bukkit) Add potion splash protection support.
* (Bukkit) Fix tamed entities being hit by projectiles.
* (Bukkit) Fix enderman block place protection.
* (Hybrid) Fix wrong EnumCreatureType being registered for entities.
* (Hybrid) Add TileEntity registry.
* (Hybrid) Add mod command support for 'command-execute' flag.
* (Sponge) Add PlaceHolderAPI support.
* (Sponge) Add Nucleus v2 support.
* (Sponge) Add IgniteEntityEvent support.
* (Sponge) Fix '/cpp' and '/cpg' command.
* (Sponge) Fix player block placement deny not sending message.
Fixes #4
Fixes #200, Fixes #206, Fixes #222
Fixes #232, Fixes #237, Fixes #267
Fixes #269, Fixes #276, Fixes #296
Fixes #310, Fixes #311, Fixes #317
Fixes #324, Fixes #333, Fixes #334
Fixes #335, Fixes #336, Fixes #347
2020-12-28 23:28:12 +01:00
@Description ( " %claim-rent " )
2020-06-06 01:26:14 +02:00
@Syntax ( " create <rate> [<max_days>]|info|list|cancel] " )
@Subcommand ( " claim rent " )
public void execute ( Player player , @Optional String [ ] args ) {
if ( GriefDefenderPlugin . getInstance ( ) . getVaultProvider ( ) = = null ) {
GriefDefenderPlugin . sendMessage ( player , MessageCache . getInstance ( ) . ECONOMY_NOT_INSTALLED ) ;
return ;
}
if ( ! GriefDefenderPlugin . getGlobalConfig ( ) . getConfig ( ) . economy . rentSystem ) {
GriefDefenderPlugin . sendMessage ( player , MessageCache . getInstance ( ) . RENT_SYSTEM_DISABLED ) ;
return ;
}
final Economy economy = GriefDefenderPlugin . getInstance ( ) . getVaultProvider ( ) . getApi ( ) ;
if ( ! economy . hasAccount ( player ) ) {
final Component message = GriefDefenderPlugin . getInstance ( ) . messageData . getMessage ( MessageStorage . ECONOMY_PLAYER_NOT_FOUND , ImmutableMap . of (
" player " , player . getName ( ) ) ) ;
GriefDefenderPlugin . sendMessage ( player , message ) ;
return ;
}
if ( args . length = = 0 ) {
throw new InvalidCommandArgument ( ) ;
}
if ( args ! = null & & args . length > 0 ) {
final String subCommand = args [ 0 ] ;
// cancel
if ( subCommand . equalsIgnoreCase ( " cancel " ) ) {
final GDPlayerData playerData = GriefDefenderPlugin . getInstance ( ) . dataStore . getOrCreatePlayerData ( player . getWorld ( ) , player . getUniqueId ( ) ) ;
final GDClaim claim = GriefDefenderPlugin . getInstance ( ) . dataStore . getClaimAtPlayer ( playerData , player . getLocation ( ) ) ;
2020-06-08 23:03:04 +02:00
if ( claim . isWilderness ( ) ) {
return ;
}
2020-06-06 01:26:14 +02:00
boolean isRenter = false ;
for ( UUID uuid : claim . getEconomyData ( ) . getRenters ( ) ) {
if ( player . getUniqueId ( ) . equals ( uuid ) ) {
isRenter = true ;
break ;
}
}
if ( ! playerData . canIgnoreClaim ( claim ) & & ! claim . getEconomyData ( ) . isForRent ( ) & & ! isRenter ) {
if ( player . getUniqueId ( ) . equals ( claim . getOwnerUniqueId ( ) ) ) {
GriefDefenderPlugin . sendMessage ( player , MessageCache . getInstance ( ) . ECONOMY_CLAIM_RENT_OWNER_NOT_RENTING ) ;
} else {
GriefDefenderPlugin . sendMessage ( player , MessageCache . getInstance ( ) . ECONOMY_CLAIM_RENT_NOT_RENTING ) ;
}
return ;
}
Update for 1.5.5 release.
* Add potion effects support.
* Add item enchantment support.
* Add pvp lookup methods for claim and playerdata.
* Add 'block-tileentity-id-list' used to override mod block id's that are used for many TE's.
- Ex. IC2 uses a base block id 'ic2:te' for all TE's. When the id is detected during block/item usage, it will be converted to the actual id.
* Add TileEntity registry to better support hybrid servers.
* Add '/claiminfo' UUID click support to copy text to chat.
* Add support for overriding option 'player-command-exit/enter' on player.
* Add command description translation support.
* Add zh_HK language support.
* Fix event cause not clearing on push.
* Fix abandon claim within town returning funds to owner in economy mode.
* Fix player afk detection during claim block task.
* Fix async chunk load during visual revert.
* Fix '/gd claim we' command.
* Fix advanced flag GUI toggle with definitions.
* Fix rent sign update not checking all children claims.
* Fix rent sign not being updated when cancelled via '/claimrent cancel'.
* Fix '/claimsell' on admin claim.
* Fix NPE when attempting to purchase an admin claim for sale.
* Fix command description translations.
* Fix isInvulnerable NPE on 1.8.8 servers.
* Fix '/abandonworld' exiting when no economy data found for player.
* Fix '/deletealladmin' only deleting admin claims in current world when passing no world argument.
* Fix '/claimcontract' and '/claimexpand' NPE in economy mode.
* Fix GD claim enter/exit prefix. The prefix will now use '[<playername>]'.
Note: This can be configured in lang file under 'claim-prefix-enter' and 'claim-prefix-exit'
* Clean up advanced flag GUI code.
* Disable /buyblocks command when economy-block-cost is <= 0
* Deny town claim abandon if basic claims exist owned by owner.
* Allow to input string as option value.
* Improve pvp source contexts.
* Clean up '/acb' command code.
* (Bukkit) Add potion splash protection support.
* (Bukkit) Fix tamed entities being hit by projectiles.
* (Bukkit) Fix enderman block place protection.
* (Hybrid) Fix wrong EnumCreatureType being registered for entities.
* (Hybrid) Add TileEntity registry.
* (Hybrid) Add mod command support for 'command-execute' flag.
* (Sponge) Add PlaceHolderAPI support.
* (Sponge) Add Nucleus v2 support.
* (Sponge) Add IgniteEntityEvent support.
* (Sponge) Fix '/cpp' and '/cpg' command.
* (Sponge) Fix player block placement deny not sending message.
Fixes #4
Fixes #200, Fixes #206, Fixes #222
Fixes #232, Fixes #237, Fixes #267
Fixes #269, Fixes #276, Fixes #296
Fixes #310, Fixes #311, Fixes #317
Fixes #324, Fixes #333, Fixes #334
Fixes #335, Fixes #336, Fixes #347
2020-12-28 23:28:12 +01:00
Sign sign = null ;
final Vector3i signPos = claim . getEconomyData ( ) . getRentSignPosition ( ) ;
if ( signPos ! = null ) {
sign = SignUtil . getSign ( VecHelper . toLocation ( player . getWorld ( ) , signPos ) ) ;
}
EconomyUtil . getInstance ( ) . rentCancelConfirmation ( player , claim , sign ) ;
2020-06-06 01:26:14 +02:00
return ;
} else if ( subCommand . equalsIgnoreCase ( " clearbalance " ) ) {
if ( args . length ! = 2 ) {
return ;
}
final GDPlayerData playerData = GriefDefenderPlugin . getInstance ( ) . dataStore . getOrCreatePlayerData ( player . getWorld ( ) , player . getUniqueId ( ) ) ;
final GDClaim claim = GriefDefenderPlugin . getInstance ( ) . dataStore . getClaimAtPlayer ( playerData , player . getLocation ( ) ) ;
2020-06-08 23:03:04 +02:00
if ( claim . isWilderness ( ) ) {
return ;
}
2020-06-06 01:26:14 +02:00
if ( playerData . canIgnoreClaim ( claim ) | | player . hasPermission ( GDPermissions . COMMAND_DELETE_ADMIN_CLAIMS ) ) {
final GDPermissionUser renter = PermissionHolderCache . getInstance ( ) . getOrCreateUser ( args [ 1 ] ) ;
if ( renter ! = null ) {
claim . getEconomyData ( ) . setRentBalance ( renter . getUniqueId ( ) , 0 ) ;
}
}
} else if ( subCommand . equalsIgnoreCase ( " list " ) ) {
final GDPlayerData playerData = GriefDefenderPlugin . getInstance ( ) . dataStore . getOrCreatePlayerData ( player . getWorld ( ) , player . getUniqueId ( ) ) ;
Set < Claim > claimsForRent = new HashSet < > ( ) ;
GDClaimManager claimManager = GriefDefenderPlugin . getInstance ( ) . dataStore . getClaimWorldManager ( player . getWorld ( ) . getUID ( ) ) ;
for ( Claim worldClaim : claimManager . getWorldClaims ( ) ) {
if ( worldClaim . isWilderness ( ) ) {
continue ;
}
if ( ! worldClaim . isAdminClaim ( ) & & worldClaim . getEconomyData ( ) . isForRent ( ) & & worldClaim . getEconomyData ( ) . getRentRate ( ) > - 1 ) {
claimsForRent . add ( worldClaim ) ;
}
for ( Claim child : worldClaim . getChildren ( true ) ) {
if ( child . isAdminClaim ( ) ) {
continue ;
}
if ( child . getEconomyData ( ) . isForRent ( ) & & child . getEconomyData ( ) . getRentRate ( ) > - 1 ) {
claimsForRent . add ( child ) ;
}
}
}
List < Component > textList = CommandHelper . generateClaimTextListCommand ( new ArrayList < Component > ( ) , claimsForRent , player . getWorld ( ) . getName ( ) , null , player , CommandHelper . createCommandConsumer ( player , " claimrent " , " " ) , false ) ;
Component footer = TextComponent . empty ( ) ;
int fillSize = 20 - ( textList . size ( ) + 2 ) ;
if ( player . hasPermission ( GDPermissions . CHAT_CAPTURE ) ) {
footer = TextComponent . builder ( )
. append ( ChatCaptureUtil . getInstance ( ) . createRecordChatComponent ( player , null , playerData , " claimrent " ) )
. build ( ) ;
fillSize = 20 - ( textList . size ( ) + 3 ) ;
}
for ( int i = 0 ; i < fillSize ; i + + ) {
textList . add ( TextComponent . of ( " " ) ) ;
}
PaginationList . Builder paginationBuilder = PaginationList . builder ( )
. title ( MessageCache . getInstance ( ) . TITLE_RENT ) . padding ( TextComponent . of ( " " ) . decoration ( TextDecoration . STRIKETHROUGH , true ) ) . contents ( textList ) . footer ( footer ) ;
paginationBuilder . sendTo ( player ) ;
return ;
} else if ( subCommand . equalsIgnoreCase ( " create " ) & & args . length > 1 ) {
// create
final String strRate = args [ 1 ] ;
if ( strRate . length ( ) < 2 ) {
// invalid rate
return ;
}
if ( args . length < = 3 ) {
// no max
final PaymentType paymentType = SignUtil . getPaymentType ( strRate ) ;
if ( paymentType = = PaymentType . UNDEFINED ) {
// invalid
return ;
}
Double rate = null ;
try {
rate = Double . valueOf ( strRate . substring ( 0 , strRate . length ( ) - 1 ) ) ;
} catch ( NumberFormatException e ) {
return ;
}
int rentMin = 0 ;
int rentMax = 0 ;
if ( args . length = = 3 ) {
rentMin = SignUtil . getRentMinTime ( args [ 2 ] ) ;
rentMax = SignUtil . getRentMaxTime ( args [ 2 ] ) ;
}
final GDPlayerData playerData = GriefDefenderPlugin . getInstance ( ) . dataStore . getOrCreatePlayerData ( player . getWorld ( ) , player . getUniqueId ( ) ) ;
final GDClaim claim = GriefDefenderPlugin . getInstance ( ) . dataStore . getClaimAtPlayer ( playerData , player . getLocation ( ) ) ;
SignUtil . setClaimForRent ( claim , player , null , rate , rentMin , rentMax , paymentType ) ;
return ;
}
} else if ( subCommand . equalsIgnoreCase ( " info " ) ) {
final GDPlayerData playerData = GriefDefenderPlugin . getInstance ( ) . dataStore . getOrCreatePlayerData ( player . getWorld ( ) , player . getUniqueId ( ) ) ;
final GDClaim claim = GriefDefenderPlugin . getInstance ( ) . dataStore . getClaimAtPlayer ( playerData , player . getLocation ( ) ) ;
2020-06-08 23:03:04 +02:00
if ( claim . isWilderness ( ) ) {
return ;
}
Update for 1.5.5 release.
* Add potion effects support.
* Add item enchantment support.
* Add pvp lookup methods for claim and playerdata.
* Add 'block-tileentity-id-list' used to override mod block id's that are used for many TE's.
- Ex. IC2 uses a base block id 'ic2:te' for all TE's. When the id is detected during block/item usage, it will be converted to the actual id.
* Add TileEntity registry to better support hybrid servers.
* Add '/claiminfo' UUID click support to copy text to chat.
* Add support for overriding option 'player-command-exit/enter' on player.
* Add command description translation support.
* Add zh_HK language support.
* Fix event cause not clearing on push.
* Fix abandon claim within town returning funds to owner in economy mode.
* Fix player afk detection during claim block task.
* Fix async chunk load during visual revert.
* Fix '/gd claim we' command.
* Fix advanced flag GUI toggle with definitions.
* Fix rent sign update not checking all children claims.
* Fix rent sign not being updated when cancelled via '/claimrent cancel'.
* Fix '/claimsell' on admin claim.
* Fix NPE when attempting to purchase an admin claim for sale.
* Fix command description translations.
* Fix isInvulnerable NPE on 1.8.8 servers.
* Fix '/abandonworld' exiting when no economy data found for player.
* Fix '/deletealladmin' only deleting admin claims in current world when passing no world argument.
* Fix '/claimcontract' and '/claimexpand' NPE in economy mode.
* Fix GD claim enter/exit prefix. The prefix will now use '[<playername>]'.
Note: This can be configured in lang file under 'claim-prefix-enter' and 'claim-prefix-exit'
* Clean up advanced flag GUI code.
* Disable /buyblocks command when economy-block-cost is <= 0
* Deny town claim abandon if basic claims exist owned by owner.
* Allow to input string as option value.
* Improve pvp source contexts.
* Clean up '/acb' command code.
* (Bukkit) Add potion splash protection support.
* (Bukkit) Fix tamed entities being hit by projectiles.
* (Bukkit) Fix enderman block place protection.
* (Hybrid) Fix wrong EnumCreatureType being registered for entities.
* (Hybrid) Add TileEntity registry.
* (Hybrid) Add mod command support for 'command-execute' flag.
* (Sponge) Add PlaceHolderAPI support.
* (Sponge) Add Nucleus v2 support.
* (Sponge) Add IgniteEntityEvent support.
* (Sponge) Fix '/cpp' and '/cpg' command.
* (Sponge) Fix player block placement deny not sending message.
Fixes #4
Fixes #200, Fixes #206, Fixes #222
Fixes #232, Fixes #237, Fixes #267
Fixes #269, Fixes #276, Fixes #296
Fixes #310, Fixes #311, Fixes #317
Fixes #324, Fixes #333, Fixes #334
Fixes #335, Fixes #336, Fixes #347
2020-12-28 23:28:12 +01:00
if ( ! claim . getEconomyData ( ) . isForRent ( ) & & ! claim . getEconomyData ( ) . isRented ( ) ) {
if ( player . getUniqueId ( ) . equals ( claim . getOwnerUniqueId ( ) ) ) {
GriefDefenderPlugin . sendMessage ( player , MessageCache . getInstance ( ) . ECONOMY_CLAIM_RENT_OWNER_NOT_RENTING ) ;
} else {
GriefDefenderPlugin . sendMessage ( player , MessageCache . getInstance ( ) . ECONOMY_CLAIM_RENT_NOT_RENTING ) ;
}
return ;
}
2020-06-06 01:26:14 +02:00
final UUID ownerUniqueId = claim . getOwnerUniqueId ( ) ;
final boolean isAdmin = player . getUniqueId ( ) . equals ( ownerUniqueId ) | | player . hasPermission ( GDPermissions . COMMAND_DELETE_ADMIN_CLAIMS ) | | claim . allowEdit ( player ) = = null ;
List < Component > textList = new ArrayList < > ( ) ;
PaymentType paymentType = claim . getEconomyData ( ) . getPaymentType ( ) ;
if ( paymentType = = PaymentType . UNDEFINED ) {
paymentType = PaymentType . DAILY ;
}
Component rentRate = TextComponent . builder ( )
. append ( MessageCache . getInstance ( ) . LABEL_RATE . color ( TextColor . YELLOW ) )
. append ( " : " )
. append ( " $ " , TextColor . GOLD )
. append ( String . format ( " %.2f " , ( claim . getEconomyData ( ) . getRentRate ( ) ) ) , TextColor . GOLD )
. append ( " / " , TextColor . GOLD )
. append ( paymentType = = PaymentType . DAILY ? MessageCache . getInstance ( ) . LABEL_DAY . color ( TextColor . GOLD ) : MessageCache . getInstance ( ) . LABEL_HOUR . color ( TextColor . GOLD ) )
. build ( ) ;
Component rentBalance = null ;
Component rentStart = null ;
Component rentDue = null ;
Date rentStartDate = null ;
Date rentDueDate = null ;
Instant instant = claim . getEconomyData ( ) . getRentStartDate ( ) ;
if ( instant ! = null ) {
rentBalance = TextComponent . builder ( )
. append ( MessageCache . getInstance ( ) . LABEL_BALANCE . color ( TextColor . YELLOW ) )
. append ( " : " )
. append ( " $ " + String . format ( " %.2f " , claim . getEconomyData ( ) . getRentBalance ( player . getUniqueId ( ) ) ) )
. build ( ) ;
rentStartDate = Date . from ( instant ) ;
rentStart = TextComponent . builder ( )
. append ( MessageCache . getInstance ( ) . RENT_UI_START_DATE . color ( TextColor . YELLOW ) )
. append ( " : " )
. append ( rentStartDate = = null ? " N/A " : rentStartDate . toString ( ) )
. build ( ) ;
}
if ( claim . getEconomyData ( ) . getRentPaymentDueDate ( ) ! = null ) {
rentDue = EconomyUtil . getInstance ( ) . getUserTimeRemaining ( claim . getEconomyData ( ) . getRentPaymentDueDate ( ) , MessageCache . getInstance ( ) . RENT_UI_NEXT_PAYMENT_DUE_DATE ) ;
}
final String ownerName = PlayerUtil . getInstance ( ) . getUserName ( ownerUniqueId ) ;
final Component nameComponent = claim . getName ( ) . orElse ( null ) ;
Component ownerLine = TextComponent . builder ( )
. append ( MessageCache . getInstance ( ) . LABEL_OWNER . color ( TextColor . YELLOW ) )
. append ( " : " )
. append ( ownerName ! = null & & ! claim . isAdminClaim ( ) & & ! claim . isWilderness ( ) ? ownerName : " administrator " , TextColor . GOLD )
. build ( ) ;
Component claimName = TextComponent . builder ( )
. append ( MessageCache . getInstance ( ) . LABEL_NAME . color ( TextColor . YELLOW ) )
. append ( " : " , TextColor . YELLOW )
. append ( claim . getName ( ) . orElse ( TextComponent . of ( claim . getFriendlyName ( ) ) ) )
. build ( ) ;
final int min = claim . getEconomyData ( ) . getRentMinTime ( ) ;
final int max = claim . getEconomyData ( ) . getRentMaxTime ( ) ;
Component maxTime = null ;
Component minTime = null ;
2020-11-14 03:49:02 +01:00
if ( max > 0 & & claim . getEconomyData ( ) . getRentEndDate ( ) ! = null ) {
2020-06-06 01:26:14 +02:00
maxTime = EconomyUtil . getInstance ( ) . getUserTimeRemaining ( claim . getEconomyData ( ) . getRentEndDate ( ) , MessageCache . getInstance ( ) . RENT_UI_END_DATE ) ;
}
if ( min > 0 ) {
minTime = TextComponent . builder ( )
. append ( MessageCache . getInstance ( ) . RENT_UI_MINIMUM . color ( TextColor . YELLOW ) )
. append ( " : " )
. append ( String . valueOf ( min ) )
. append ( " " )
. append ( claim . getEconomyData ( ) . getPaymentType ( ) = = PaymentType . DAILY ?
( min > 1 ? MessageCache . getInstance ( ) . LABEL_DAYS : MessageCache . getInstance ( ) . LABEL_DAY ) :
( min > 1 ? MessageCache . getInstance ( ) . LABEL_HOURS : MessageCache . getInstance ( ) . LABEL_HOUR ) )
. build ( ) ;
}
Component transactions = null ;
if ( isAdmin ) {
if ( claim . getEconomyData ( ) . getPaymentTransactions ( TransactionType . RENT ) . isEmpty ( ) ) {
transactions = TextComponent . builder ( )
. append ( " [ " )
. append ( MessageCache . getInstance ( ) . RENT_UI_VIEW_TRANSACTIONS . color ( TextColor . AQUA ) )
. append ( " ] " )
. hoverEvent ( HoverEvent . showText ( MessageCache . getInstance ( ) . RENT_UI_NO_TRANSACTIONS ) )
. build ( ) ;
} else {
transactions = TextComponent . builder ( )
. append ( " [ " )
. append ( MessageCache . getInstance ( ) . RENT_UI_VIEW_TRANSACTIONS . color ( TextColor . AQUA ) )
. append ( " ] " )
. clickEvent ( ClickEvent . runCommand ( GDCallbackHolder . getInstance ( ) . createCallbackRunCommand ( CommandHelper . createRentTransactionsConsumer ( player , claim , false , false ) ) ) )
. hoverEvent ( HoverEvent . showText ( MessageCache . getInstance ( ) . UI_CLICK_VIEW_TRANSACTIONS ) )
. build ( ) ;
}
}
textList . add ( claimName ) ;
textList . add ( ownerLine ) ;
textList . add ( rentRate ) ;
if ( rentStart ! = null ) {
textList . add ( rentBalance ) ;
textList . add ( rentStart ) ;
textList . add ( rentDue ) ;
}
if ( minTime ! = null ) {
textList . add ( minTime ) ;
}
if ( maxTime ! = null ) {
textList . add ( maxTime ) ;
}
if ( transactions ! = null ) {
textList . add ( transactions ) ;
}
Component rentClaim = null ;
if ( player ! = null & & claim . getEconomyData ( ) . isForRent ( ) & & ! player . getUniqueId ( ) . equals ( ownerUniqueId ) & & player . hasPermission ( GDPermissions . USER_RENT_BASE ) ) {
Component rentInfo = TextComponent . builder ( )
. append ( MessageCache . getInstance ( ) . LABEL_PRICE . color ( TextColor . AQUA ) )
. append ( " : " , TextColor . WHITE )
. append ( String . valueOf ( claim . getEconomyData ( ) . getRentRate ( ) + " per " + ( claim . getEconomyData ( ) . getPaymentType ( ) = = PaymentType . DAILY ? " day " : " hour " ) ) , TextColor . GOLD )
. build ( ) ;
rentClaim = TextComponent . builder ( )
. append ( TextComponent . builder ( " [ " ) . append ( MessageCache . getInstance ( ) . RENT_UI_CLICK_RENT . color ( TextColor . GREEN ) ) . append ( " ] " , TextColor . WHITE ) . build ( ) )
. clickEvent ( ClickEvent . runCommand ( GDCallbackHolder . getInstance ( ) . createCallbackRunCommand ( EconomyUtil . getInstance ( ) . rentClaimConsumerConfirmation ( player , claim ) ) ) )
. hoverEvent ( HoverEvent . showText ( player . getUniqueId ( ) . equals ( claim . getOwnerUniqueId ( ) ) ? MessageCache . getInstance ( ) . CLAIM_OWNER_ALREADY : rentInfo ) ) . build ( ) ;
textList . add ( rentClaim ) ;
}
int fillSize = 20 - ( textList . size ( ) + 2 ) ;
Component footer = null ;
if ( player ! = null & & player . hasPermission ( GDPermissions . CHAT_CAPTURE ) ) {
footer = ChatCaptureUtil . getInstance ( ) . createRecordChatComponent ( player , claim , playerData , " claimrent info " ) ;
fillSize = 20 - ( textList . size ( ) + 3 ) ;
}
for ( int i = 0 ; i < fillSize ; i + + ) {
textList . add ( TextComponent . of ( " " ) ) ;
}
Component header = TextComponent . builder ( )
. append ( PlainComponentSerializer . INSTANCE . serialize ( MessageCache . getInstance ( ) . RENT_UI_INFO_HEADER ) , TextColor . AQUA )
. build ( ) ;
PaginationList . Builder paginationBuilder = PaginationList . builder ( )
. title ( header ) . padding ( TextComponent . of ( " " ) . decoration ( TextDecoration . STRIKETHROUGH , true ) ) . contents ( textList ) . footer ( footer ) ;
paginationBuilder . sendTo ( player ) ;
}
}
}
}