Skip to content

Commit

Permalink
Merge pull request #11 from RubixDev/development
Browse files Browse the repository at this point in the history
v1.1.4
  • Loading branch information
RubixDev authored Mar 9, 2021
2 parents d14b619 + 803c477 commit 8389b9f
Show file tree
Hide file tree
Showing 17 changed files with 333 additions and 92 deletions.
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ Extension Mod for [gnembon's fabric-carpet](https://github.com/gnembon/fabric-ca
- [`SURVIVAL`](markdown/SURVIVAL_Category.md)

## Index
Count: 67
Count: 69
- [anvilledBlueIce](#anvilledblueice)
- [anvilledIce](#anvilledice)
- [anvilledPackedIce](#anvilledpackedice)
- [cactusFurnaceXp](#cactusfurnacexp)
- [campSleeping](#campsleeping)
- [commandFrame](#commandframe)
- [commandSkull](#commandskull)
- [commandSlimeChunk](#commandslimechunk)
- [concreteConvertOnCauldron](#concreteconvertoncauldron)
- [craftableCobwebs](#craftablecobwebs)
Expand Down Expand Up @@ -139,12 +141,25 @@ Allows players to sleep in a Bed without setting their spawn point by entering w
- Required options: `true`, `false`
- Categories: `EXPERIMENTAL`, `FEATURE`, `RUG`, `SURVIVAL`

### commandFrame
A command that makes the nearest item frame in a 5 Block radius around the player, that holds an item, invisible or visible
- Type: `String`
- Default value: `ops`
- Required options: `true`, `false`, `ops`
- Categories: `COMMAND`, `RUG`

### commandSkull
A command that gives the executing Player the Player Head of the selected Player
- Type: `String`
- Default value: `ops`
- Required options: `true`, `false`, `ops`
- Categories: `COMMAND`, `RUG`

### commandSlimeChunk
A command that shows if the current chunk is a slime chunk based on the set slimeChunkPercentage
Players do not need extra permissions to use this command
- Type: `boolean`
- Default value: `false`
- Required options: `true`, `false`
A command that shows if the current chunk is a slime chunk based on the set slimeChunkPercentage
- Type: `String`
- Default value: `ops`
- Required options: `true`, `false`, `ops`
- Categories: `COMMAND`, `RUG`

### concreteConvertOnCauldron
Expand Down
69 changes: 46 additions & 23 deletions generate_readme.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Dict


class Rule:
Expand All @@ -14,40 +14,47 @@ class Rule:
additional: str = ""

def __repr__(self):
nl = '\n'
nl: str = '\n'
options: List[str] = ['true', 'false'] if self.type == 'boolean' else self.options
if 'COMMAND' in self.categories:
options: List[str] = ['true', 'false', 'ops']

self.categories.sort()

out = f'### {self.name}\n' \
f'{self.desc} {nl + self.extra if self.extra else ""} \n' \
f'- Type: `{self.type}`\n' \
f'- Default value: `{self.value}`\n' \
f'- {"Required" if self.strict else "Suggested"} ' \
f'options: `{"`, `".join(["true", "false"] if self.type == "boolean" else self.options)}`\n' \
f'options: `{"`, `".join(options)}`\n' \
f'- Categories: `{"`, `".join(self.categories)}`'

if self.restriction or self.additional:
out += '\n- Additional notes:'
if self.restriction:
out += f'\n - {self.restriction}'
if self.additional:
out += f'\n - {self.additional}'

return out


def read_rules() -> List[Rule]:
with open('src/main/java/com/rubixdev/rug/RugSettings.java', 'r') as settings_file:
settings_string = settings_file.read()
raw_settings = [i.split(';')[0] for i in settings_string.split('@Rule')[1:]]
raw_rules: List[str] = [i.split(';')[0] for i in settings_string.split('@Rule')[1:]]

rules = []
for raw_rule in raw_settings:
rule = Rule()
field = raw_rule.split('\n')[-1][18:].split(' ')
rules: List[Rule] = []
for raw_rule in raw_rules:
rule: Rule = Rule()
field: List[str] = raw_rule.split('\n')[-1][18:].split(' ')
rule.type = field[0]
rule.name = field[1]
rule.value = field[3].replace('"', '')

keys = [i[12:].split(' = ')[0] for i in raw_rule.split('\n')[1:-2]]
values = [i[12:].split(' = ')[1] for i in raw_rule.split('\n')[1:-2]]
attr_dict = {k: v for k, v in zip(keys, values)}
keys: List[str] = [i[12:].split(' = ')[0] for i in raw_rule.split('\n')[1:-2]]
values: List[str] = [i[12:].split(' = ')[1] for i in raw_rule.split('\n')[1:-2]]
attr_dict: Dict[str: str] = {k: v for k, v in zip(keys, values)}

rule.desc = attr_dict['desc'][1:-2]
if 'extra' in keys:
Expand All @@ -57,22 +64,22 @@ def read_rules() -> List[Rule]:
rule.strict = not ('strict' in keys)
rule.categories = [i.replace('}', '') for i in attr_dict['category'][1:-1].split(', ')]
if not rule.strict:
validator = attr_dict['validate'].replace(',', '')[:-6]
validator: str = attr_dict['validate'].replace(',', '')[:-6]
rule.restriction = settings_string.split(f'class {validator} extends')[1].split('"')[1]
found_additional = settings_string.split(f'// {rule.name}Additional: ')
found_additional: List[str] = settings_string.split(f'// {rule.name}Additional: ')
if len(found_additional) > 1:
rule.additional = found_additional[1].split('\n')[0]

rules.append(rule)
return rules


def write_file(rules: List[Rule]):
def write_files(rules: List[Rule]):
with open('markdown/README-header.md', 'r') as header_file:
out = header_file.read()
out: str = header_file.read()

all_categories = list(set([item for sublist in [rule.categories for rule in rules] for item in sublist]))
all_categories = [category for category in all_categories if category.upper() != 'RUG']
all_categories: List[str] = list(set([item for sublist in [rule.categories for rule in rules] for item in sublist]))
all_categories: List[str] = [category for category in all_categories if category.upper() != 'RUG']
all_categories.sort()
out += f'## Lists of Categories\n'
for category in all_categories:
Expand All @@ -87,19 +94,21 @@ def write_file(rules: List[Rule]):
readme_file.write(out[:-1])

for category in all_categories:
rules_in_category = [rule for rule in rules if category in rule.categories]
rules_in_category: List[Rule] = [rule for rule in rules if category in rule.categories]
rules_in_category.sort(key=lambda e: e.name)
out = f'# List of Rules in the {category} Category\n\n' \
f'For a list of all implemented Rules go [here](../README.md)\n'
out: str = f'# List of Rules in the {category} Category\n\n' \
f'For a list of all implemented Rules go [here](../README.md)\n'
out += list_rules(rules_in_category, f'Rules in {category} Category')

with open(f'markdown/{category}_Category.md', 'w') as category_readme:
category_readme.write(out[:-1])

curseforge_list(rules)


def list_rules(rules: List[Rule], rule_headline: str) -> str:
out = f'## Index\n' \
f'Count: {len(rules)}\n'
out: str = f'## Index\n' \
f'Count: {len(rules)}\n'
for rule in rules:
out += f'- [{rule.name}](#{rule.name.lower()})\n'
out += f'\n## {rule_headline}\n\n'
Expand All @@ -109,5 +118,19 @@ def list_rules(rules: List[Rule], rule_headline: str) -> str:
return out


def curseforge_list(rules: List[Rule]):
out: str = f'# Rug Mod for Fabric\n\n' \
f'Extension Mod for [gnembon\'s fabric-carpet](https://github.com/gnembon/fabric-carpet) ' \
f'with some more features\n\n' \
f'**Visit the [GitHub page](https://github.com/RubixDev/fabric-rug) ' \
f'for a more detailed explanation of all features.**\n\n' \
f'## List of implemented Carpet Rules\n' \
f'Count: {len(rules)} \n'
for rule in rules:
out += f'- {rule.name} \n'
with open('markdown/curseforge.md', 'w') as curse_file:
curse_file.write(out)


if __name__ == '__main__':
write_file(read_rules())
write_files(read_rules())
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ org.gradle.jvmargs=-Xmx2G
carpet_core_version=1.4.23+v210115

# Mod Properties
mod_version = 1.1.3
mod_version = 1.1.4
maven_group = com.rubixdev.rug
archives_base_name = fabric-rug

Expand Down
27 changes: 21 additions & 6 deletions markdown/COMMAND_Category.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@

For a list of all implemented Rules go [here](../README.md)
## Index
Count: 1
Count: 3
- [commandFrame](#commandframe)
- [commandSkull](#commandskull)
- [commandSlimeChunk](#commandslimechunk)

## Rules in COMMAND Category

### commandFrame
A command that makes the nearest item frame in a 5 Block radius around the player, that holds an item, invisible or visible
- Type: `String`
- Default value: `ops`
- Required options: `true`, `false`, `ops`
- Categories: `COMMAND`, `RUG`

### commandSkull
A command that gives the executing Player the Player Head of the selected Player
- Type: `String`
- Default value: `ops`
- Required options: `true`, `false`, `ops`
- Categories: `COMMAND`, `RUG`

### commandSlimeChunk
A command that shows if the current chunk is a slime chunk based on the set slimeChunkPercentage
Players do not need extra permissions to use this command
- Type: `boolean`
- Default value: `false`
- Required options: `true`, `false`
A command that shows if the current chunk is a slime chunk based on the set slimeChunkPercentage
- Type: `String`
- Default value: `ops`
- Required options: `true`, `false`, `ops`
- Categories: `COMMAND`, `RUG`
77 changes: 77 additions & 0 deletions markdown/curseforge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Rug Mod for Fabric

Extension Mod for [gnembon's fabric-carpet](https://github.com/gnembon/fabric-carpet) with some more features

**Visit the [GitHub page](https://github.com/RubixDev/fabric-rug) for a more detailed explanation of all features.**

## List of implemented Carpet Rules
Count: 69
- anvilledBlueIce
- anvilledIce
- anvilledPackedIce
- cactusFurnaceXp
- campSleeping
- commandFrame
- commandSkull
- commandSlimeChunk
- concreteConvertOnCauldron
- craftableCobwebs
- craftableHorseArmor
- craftableNameTags
- craftableNotchApple
- dragonDrops
- dragonEggConvertsCobbleToEndstone
- dragonXpDrop
- easyBlueIceCrafting
- easyBoneBlockCrafting
- easyChestCrafting
- easyDispenserCrafting
- easyHarvesting
- easyMinecartsCrafting
- easyRepeaterCrafting
- easyStickCrafting
- easyTrappedChestCrafting
- edibleGoldIngots
- edibleMagmaCream
- edibleNetheriteScraps
- edibleSlimeBalls
- eggWaterDrag
- enderPearlDamage
- enderPearlWaterDrag
- foodInstantHeal
- honeyCombStickiness
- infinityNeedsArrow
- kelpBlockHardness
- lilyPadsOnCauldron
- longerRepeaters
- maxBannerLayers
- moreBarkCrafting
- moreFortressSpawningBlocks
- newShulkerBehavior
- noCreeperGriefing
- noEndermanGriefing
- noGhastGriefing
- oldFishingLoot
- peacefulHunger
- playerHeadDrops
- powderToGlassSmelting
- reachDistance
- redstoneLampTurnOffDelay
- shapelessCrafting
- silenceMobs
- silkTouchFarmland
- silkTouchPathBlocks
- silkTouchSpawners
- slimeChunkPercentage
- snowballWaterDrag
- stonecutterDamage
- strictShulkerShells
- tallPlantNoUpdate
- universalDyeing
- unpackableIce
- unpackableNetherWart
- unpackableQuartz
- unpackableWool
- woodcutting
- zeroTickPlants
- zombifiedPiglinsSpawningInPortals
4 changes: 4 additions & 0 deletions src/main/java/com/rubixdev/rug/RugServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.google.common.collect.Lists;
import com.google.gson.*;
import com.mojang.brigadier.CommandDispatcher;
import com.rubixdev.rug.commands.FrameCommand;
import com.rubixdev.rug.commands.SkullCommand;
import com.rubixdev.rug.commands.SlimeChunkCommand;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.minecraft.block.*;
Expand Down Expand Up @@ -55,6 +57,8 @@ public void onGameStarted() {
@Override
public void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher) {
SlimeChunkCommand.register(dispatcher);
FrameCommand.register(dispatcher);
SkullCommand.register(dispatcher);
}

@Override
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/com/rubixdev/rug/RugSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -954,10 +954,9 @@ public String description() {

@Rule(
desc = "A command that shows if the current chunk is a slime chunk based on the set slimeChunkPercentage",
extra = "Players do not need extra permissions to use this command",
category = {COMMAND, RUG}
)
public static boolean commandSlimeChunk = false;
public static String commandSlimeChunk = "ops";

@Rule(
desc = "Tall Plants do not update blocks around the top part if the bottom half got broken",
Expand All @@ -966,6 +965,18 @@ public String description() {
)
public static boolean tallPlantNoUpdate = false;
// Additional: [Idea from DragonEggBedrockBreaking](https://github.com/gnembon/carpet-extra/issues/185)

@Rule(
desc = "A command that makes the nearest item frame in a 5 Block radius around the player, that holds an item, invisible or visible",
category = {COMMAND, RUG}
)
public static String commandFrame = "ops";

@Rule(
desc = "A command that gives the executing Player the Player Head of the selected Player",
category = {COMMAND, RUG}
)
public static String commandSkull = "ops";
}

// BUGFIX
Expand Down
Loading

0 comments on commit 8389b9f

Please sign in to comment.