Skip to content

Commit

Permalink
PrisonBlock: Add isSellallOnly to prevent blocks added through sellal…
Browse files Browse the repository at this point in the history
…l from being used in mines.
  • Loading branch information
rbluer committed Dec 23, 2024
1 parent eafe1b2 commit c2de65a
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 18 deletions.
4 changes: 4 additions & 0 deletions docs/changelog_v3.3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.19e 2024-12-22


* **PrisonBlock: Add isSellallOnly to prevent blocks added through sellall from being used in mines.**



* **Sellall: Much better support for blocks with custom names.** Both for rejecting the wrong blocks, but also for now being able to sell them.
These changes are not perfect and does not support some conditions.
Prison currently does not support multiple custom blocks with the same material types and the same display name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public interface Block {
*
* @return The {@link Location} of the block.
*/
Location getLocation();
public Location getLocation();

/**
* Returns the {@link Block} at the position relative to this one.
*
* @param face The {@link BlockFace} that the relative block touches.
* @return The {@link Block} relative to this one.
*/
Block getRelative(BlockFace face);
public Block getRelative(BlockFace face);

// /**
// * Returns the type of this block.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class PrisonBlock

private boolean valid = true;
private boolean block = true;
private boolean sellallOnly = false;

private boolean legacyBlock = false;

Expand Down Expand Up @@ -150,6 +151,8 @@ public PrisonBlock( PrisonBlock clonable ) {
this.useBlockTypeAsPrefix = clonable.isUseBlockTypeAsPrefix();
this.valid = clonable.isValid();
this.block = clonable.isBlock();
this.sellallOnly = clonable.isSellallOnly();

this.legacyBlock = clonable.isLegacyBlock();

this.setLoreAllowed( clonable.isLoreAllowed() );
Expand Down Expand Up @@ -340,6 +343,25 @@ public void setBlock( boolean isBlock ){
this.block = isBlock;
}

/**
* <p>If isSellallOnly, this item should never be used within a mine since prison
* cannot regenerate the block to place it in the mines. Custom blocks have
* many uncontrollable aspects on how they create and use blocks, of which
* prison cannot begin to magically guess all of these requirements.
* </p>
*
* <p>If this value is set to true, then the PrisonBlock was added to prison as
* a custom block that is supported only within sellall.
* </p>
*
* @return
*/
public boolean isSellallOnly() {
return sellallOnly;
}
public void setSellallOnly(boolean sellallOnly) {
this.sellallOnly = sellallOnly;
}
/**
* <p>This value isLegacyBlock indicates that there was not a direct match
* with the stored (saved) name of the block, and list of valid block types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public List<PrisonBlock> getBlockTypes( String searchTerm, boolean restrictToBlo
searchTerm = searchTerm.toLowerCase().replace(" ", "_");

for ( PrisonBlock pBlock : getBlockTypes() ) {
if ( (!restrictToBlocks || restrictToBlocks && pBlock.isBlock()) &&
if ( (!restrictToBlocks ||
restrictToBlocks &&
pBlock.isBlock() && !pBlock.isSellallOnly()) &&
pBlock.getBlockNameSearch().contains( searchTerm )) {
results.add( pBlock );
}
Expand Down
3 changes: 2 additions & 1 deletion prison-core/src/main/resources/lang/mines/en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=5
messages__version=6
messages__auto_refresh=true


Expand Down Expand Up @@ -90,6 +90,7 @@ spawn_set=&7The mine spawnpoint has been set.
spawn_removed=&7The mine spawnpoint has been removed.
spawnpoint_same_world=&7The &cspawnpoint &7must be in the same &cworld &7as the mine.
not_a_block=&c%1 &7is not a block.
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7That block has already been added to the mine.
mine_full=&cThe mine will be too full. &7Try lowering the percentage of this block and/or other blocks in the mine to make some room.
block_added=&7Added block &3%1 &7to mine &3%2&7.
Expand Down
3 changes: 2 additions & 1 deletion prison-core/src/main/resources/lang/mines/es_ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=5
messages__version=6
messages__auto_refresh=true

reset_warning=&7Todas las minas %1 se reiniciarán en &3%2&7.
Expand All @@ -86,6 +86,7 @@ spawn_set=&7El punto de aparición (spawnpoint) de la mina ha sido definid.
spawn_removed=&7The mine spawnpoint has been removed.
spawnpoint_same_world=&7El &cpunto de aparición &7debe estar en el mismo &cmundo &7que la mina.
not_a_block=&c%1 &7no es un bloque.
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7Ese bloque ya ha sido añadido a la mina.
mine_full=&cLa mina estará demasiado llena. &7Intenta reduciendo el porcentaje de este bloque y/u otros bloques en la mina para hacer más espacio.
block_added=&7Se ha añadido el bloque &3%1 &7a la mina &3%2&7.
Expand Down
3 changes: 2 additions & 1 deletion prison-core/src/main/resources/lang/mines/fi_FI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=5
messages__version=6
messages__auto_refresh=true


Expand Down Expand Up @@ -90,6 +90,7 @@ spawn_set=&7Mainin spawni on asetettu.
spawn_removed=&7Mainin spawni on onnistuneesti poistettu.
spawnpoint_same_world=&cspawnpoint &7pitää olla samassa mailmassa kuin maini.
not_a_block=&c%1 &7ei ole blockki.
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7Tämä blockki on jo lisätty mainiin..
mine_full=&cMaini on jo täynnä.
block_added=&7Lisätty &3%1 &7mainiin &3%2&7.
Expand Down
5 changes: 3 additions & 2 deletions prison-core/src/main/resources/lang/mines/fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=5
messages__version=6
messages__auto_refresh=true


Expand Down Expand Up @@ -89,7 +89,8 @@ mine_does_not_exist=&7Une mine du même nom existe déjà.
spawn_set=&7Le point de spawn de la mine a été défini.
spawn_removed=&7Le point de spawn de la mine a été supprimé.
spawnpoint_same_world=&7Le &cpoint de spawn &7doit être dans le même &cmonde &7que la mine.
not_a_block=&c%1 &7n'est pas un bloc.
not_a_block=&c%1 &7n'est pas un bloc..
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7Ce bloc a déjà été ajouté dans la mine.
mine_full=&cCette mine sera trop remplie. &7Essaye de réduire le percentage de ce block ou d'un autre dans la mine pour faire de la place.
block_added=&7Le bloc &3%1 &7a été ajoutée à la mine &3%2&7.
Expand Down
3 changes: 2 additions & 1 deletion prison-core/src/main/resources/lang/mines/hu_HU.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=5
messages__version=6
messages__auto_refresh=true


Expand Down Expand Up @@ -90,6 +90,7 @@ spawn_set=&7A bánya spawnpontja beállítva.
spawn_removed=&7The mine spawnpoint has been removed.
spawnpoint_same_world=&7A &cspawnpont-nak&7 ugyanabban a &cvilágban&7 bányában kell lennie.
not_a_block=&c%1 &7nem egy blokk.
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7Ez a blokk már felkerült a bányába.
mine_full=&cA bánya túlságosan tele lesz. &7Jobban próbáld csökkenteni a blokk és/vagy más blokkok százalékos arányát a bányában.
block_added=&7A blokk hozzáadva &3%1 &7a(z) &3%2&7 bányához.
Expand Down
3 changes: 2 additions & 1 deletion prison-core/src/main/resources/lang/mines/it_IT.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=5
messages__version=6
messages__auto_refresh=true


Expand Down Expand Up @@ -90,6 +90,7 @@ spawn_set=&7Il punto di spawn della miniera è stato settato.
spawn_removed=&7The mine spawnpoint has been removed.
spawnpoint_same_world=&7Il &cPunto di spawn &7deve essere nello stesso &cmondo &7della miniera.
not_a_block=&c%1 &7non è un blocco.
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7Quel blocco è già stato aggiunto alla miniera.
mine_full=&cLa miniera con quel valore supera il limite. &7Prova ad abbassare la percentuale di questo blocco e / o altri blocchi nella miniera per fare spazio.
block_added=&7Aggiunto il blocco &3%1 &7alla miniera &3%2&7.
Expand Down
3 changes: 2 additions & 1 deletion prison-core/src/main/resources/lang/mines/nl_BE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=5
messages__version=6
messages__auto_refresh=true


Expand Down Expand Up @@ -88,6 +88,7 @@ spawn_set=&7De mijn zijn startpunt is gezet.
spawn_removed=&7The mine spawnpoint has been removed.
spawnpoint_same_world=&7Het startpunt moet in dezelfde wereld als de mijn zijn .
not_a_block=&c%1 &7is geen blok.
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7Deze blok is al in de mijn toegevoegd.
mine_full=&cDe mijn zal te vol worden. &7Probeer het precentage te verlagen van deze blok en/of andere bloken in de mijn om plaats te maken.
block_added=&7blok &3%1 &7bijgevoeg &7bij mijn &3%2&7.
Expand Down
3 changes: 2 additions & 1 deletion prison-core/src/main/resources/lang/mines/nl_NL.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=5
messages__version=6
messages__auto_refresh=true


Expand Down Expand Up @@ -88,6 +88,7 @@ spawn_set=&7De mijn zijn startpunt is gezet.
spawn_removed=&7The mine spawnpoint has been removed.
spawnpoint_same_world=&7Het startpunt moet in dezelfde wereld als de mijn zijn .
not_a_block=&c%1 &7is geen blok.
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7Deze blok is al in de mijn toegevoegd.
mine_full=&cDe mijn zal te vol worden. &7Probeer het precentage te verlagen van deze blok en/of andere bloken in de mijn om plaats te maken.
block_added=&7blok &3%1 &7bijgevoeg &7bij mijn &3%2&7.
Expand Down
3 changes: 2 additions & 1 deletion prison-core/src/main/resources/lang/mines/pt_PT.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=5
messages__version=6
messages__auto_refresh=true


Expand Down Expand Up @@ -90,6 +90,7 @@ spawn_set=&7O spawnpoint da mina foi defenido.
spawn_removed=&7O spawnpoint da mina foi eliminado.
spawnpoint_same_world=&7O &cspawnpoint &7tem de ser no mesmo &cmundo &7que a mina.
not_a_block=&c%1 &7não é um bloco.
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7Esse bloco já foi adicionado à mina.
mine_full=&cA mina vai estar cheia demais. &7Tenta baixa a precentagem deste bloco e/ou outros blocos dentro da mina para fazer espaço.
block_added=&7Bloco adicionado &3%1 &7á mina &3%2&7.
Expand Down
3 changes: 2 additions & 1 deletion prison-core/src/main/resources/lang/mines/ro_RO.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=5
messages__version=6
messages__auto_refresh=true


Expand Down Expand Up @@ -90,6 +90,7 @@ spawn_set=&7Spawnpoint-ul minei a fost setat.
spawn_removed=&7Spawnpoint-ul minei a fost șters.
spawnpoint_same_world=&cSpawnpoint-ul &7trebuie să fie în aceeași &clume &7cu mina.
not_a_block=&c%1 &7nu este un block.
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7Acel block a fost adăugat deja în mină.
mine_full=&cMina va fi prea plină. &7Încearcă să scazi șansele apariției acestui block și/sau altor block-uri din mină pentru a avea mai mult spațiu.
block_added=&7Block-ul &3%1 &7a fost adăugat în mina &3%2&7.
Expand Down
5 changes: 3 additions & 2 deletions prison-core/src/main/resources/lang/mines/zh-CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=4
messages__version=6
messages__auto_refresh=true


Expand Down Expand Up @@ -89,7 +89,8 @@ mine_does_not_exist=&7没有叫这个名字的矿区
spawn_set=&7矿区出生点已设置
spawn_removed=&7矿区出生点已移除
spawnpoint_same_world=&7&c出生点&7必须与矿区位于同一个&c世界&7中
not_a_block=&c%1 &7不是一个方块,请检查拼写
not_a_block=&c%1 &7不是一个方块,请检查拼å
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7该方块已成功添加到矿区中
mine_full=&c矿区满了 &7试着降低该方块或其他方块的百分比,以腾出一些空间
block_added=&7将方块&3%1 &7添加到矿区&3%2&7.
Expand Down
5 changes: 3 additions & 2 deletions prison-core/src/main/resources/lang/mines/zh_TW.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#


messages__version=6
messages__version=7
messages__auto_refresh=true


Expand Down Expand Up @@ -89,7 +89,8 @@ mine_does_not_exist=&7此礦場名稱並不存在
spawn_set=&7礦場出生點 已成功 設定
spawn_removed=&7The mine spawnpoint has been removed.
spawnpoint_same_world=&7這個 &c出生點 &7必須與其他 礦場 在同一個 &c世界
not_a_block=&c%1 &7不是一個方塊
not_a_block=&c%1 &7不是一個方å¡
not_a_block_sellall=&c%1 &7is not a block that can be used in mines. Its only for sellall usage.
block_already_added=&7此方塊已經被新增到礦場
mine_full=&c此礦場已經滿了。 &7請降低礦場中該方塊或其他方塊的 百分比 以騰出更多空間
block_added=&7將方塊 &3%1 &7加入到礦場 &3%2&7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public void addBlockCommand(CommandSender sender,
return;
}

if ( prisonBlock.isSellallOnly() ) {
pMines.getMinesMessages().getLocalizable("not_a_block_sellall").
withReplacements(block).sendTo(sender);
return;
}

if ( !prisonBlock.isBlock() ) {
pMines.getMinesMessages().getLocalizable("not_a_block").
withReplacements(block).sendTo(sender);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,10 @@ public HashMap<String, PrisonBlock> initSellAllItems(){
// 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<PrisonBlock> newBlockTypes = new ArrayList<>();
newBlockTypes.add( pBlock );
Expand Down

0 comments on commit c2de65a

Please sign in to comment.