Skip to content

Commit

Permalink
[1.21.2-1.21.3] v1.2.0
Browse files Browse the repository at this point in the history
Check the CHANGELOG.md for all the new changes!
  • Loading branch information
MrSn0wy committed Dec 6, 2024
1 parent 2af88bd commit 1165839
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 34 deletions.
15 changes: 8 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### [v1.2.0] WIP!
### [v1.2.0]
- Added the following warp related commands: `/warp` `/setwarp` `/delwarp` `/renamewarp` and `/warps`
- Added `/worldspawn`
- Improved error handling and error messages a lot, this will make bug reporting (and fixing) a lot easier since it says on what command it fails, and it also gives a stack trace.
- Fixed some small things which may cause errors.
- Improved code of some commands to make them more sane and readable
- Modified storage code to make it more sane
- Improved code of some commands to make them more sane and readable.
- Modified storage code to make it more sane.
- Fixed bug with /home when in a diff dimension. (apparently I did this for /back already but forgot to add it to /home)
- Added Russian Translations (Thanks to [rfin0](https://github.com/rfin0))
- Added Russian Translations (Thanks to [rfin0](https://github.com/rfin0)!)

### [v1.1.3]
- Added support for 1.21.2 - 1.21.3

### [v1.1.2]
- Added Italian Translations (Thanks to [Vlad Andrei Morariu](https://github.com/VladAndreiMorariu)
- Added Italian Translations (Thanks to [Vlad Andrei Morariu](https://github.com/VladAndreiMorariu)!)

### [v1.1.1]
- Added support for 1.21
Expand All @@ -34,7 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added a CHANGELOG.md
- Added Tpa Accept/Deny Suggestions
- Added Dutch translations
- Added Hungarian translations (Thanks to [Martin Morningstar](https://github.com/RMI637))
- Added Hungarian translations (Thanks to [Martin Morningstar](https://github.com/RMI637)!)

#### Changed
- Limited the requests a player can do to the same player to 1
Expand Down Expand Up @@ -65,7 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
#### Changed
- Changed mappings to Mojang.
- Cleaned up commands code
- Changed build files to support multiple mod loader
- Changed build files to support multiple mod loaders


### [v1.0.2]
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Here is the [Changelog](https://github.com/MrSn0wy/TeleportCommands/blob/main/CH

#### Currently available commands:

- `/worldspawn [<Disable Safety>]` - Teleports you to the world spawn (in the overworld), if given true it will not do safety checks
- `/back [<Disable Safety>]` - Teleports you to the location where you last died, if given true it will not do safety checks
<br><br>
**Homes are player specific locations that only that player can teleport to**
Expand Down Expand Up @@ -35,10 +36,13 @@ Here is the [Changelog](https://github.com/MrSn0wy/TeleportCommands/blob/main/CH

#### Planned commands:
- [ ] `/wild` - Teleports you to a random location in the Overworld
- [ ] `/worldspawn` - Teleports you to the worldspawn
- [x] `/worldspawn` - Teleports you to the worldspawn
- [ ] `/spawn <dimension>` - Teleports you to your spawnpoint in a dimension, defaults to your current dimension

#### Improvements:
- [ ] Look into changing the mod into the more safe and sane kotlin (I love java)
- [ ] Find a way to combine the mod loader specific jars into one
- [ ] Find the easiest way to backport the mod to older version (help)
- [ ] Create a config to add any delays and disable commands, with commands for operators in game
- [ ] Add a perm system
- [x] Json Storage automatic updater & cleaner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private static void ToDeathLocation(ServerPlayer player, boolean safetyDisabled)
}

if (!found) {
player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.noLocation", player).withStyle(ChatFormatting.RED), true);
player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.noLocation", player).withStyle(ChatFormatting.RED), true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static void tpaCommandHandler(ServerPlayer FromPlayer, ServerPlayer ToPl
FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA), true);

} else if (playerTpaList >= 1) {
FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.alreadySent", FromPlayer, Component.literal(Objects.requireNonNull(ToPlayer.getName().getString())).withStyle(ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA)
FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.alreadySent", FromPlayer, Component.literal(Objects.requireNonNull(ToPlayer.getName().getString(), "ToPlayer name cannot be null")).withStyle(ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA)
, true
);

Expand All @@ -128,8 +128,8 @@ private static void tpaCommandHandler(ServerPlayer FromPlayer, ServerPlayer ToPl
tpaRequest.here = here;
tpaList.add(tpaRequest);

String ReceivedFromPlayer = Objects.requireNonNull(FromPlayer.getName().getString());
String SentToPlayer = Objects.requireNonNull(ToPlayer.getName().getString());
String ReceivedFromPlayer = Objects.requireNonNull(FromPlayer.getName().getString(), "FromPlayer name cannot be null");
String SentToPlayer = Objects.requireNonNull(ToPlayer.getName().getString(), "ToPlayer name cannot be null");

FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.sent", FromPlayer, Component.literal(hereText), Component.literal(SentToPlayer).withStyle(ChatFormatting.BOLD))
// .append(Text.literal("\n[Cancel]").formatted(Formatting.BLUE, Formatting.BOLD))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,25 @@ public static void register(Commands commandManager) {

}

private static void toWorldSpawn(ServerPlayer player, boolean safetyDisabled) {
private static void toWorldSpawn(ServerPlayer player, boolean safetyDisabled) throws NullPointerException {
ServerLevel world = TeleportCommands.SERVER.getLevel(OVERWORLD);
BlockPos worldSpawn = Objects.requireNonNull(world).getSharedSpawnPos();

BlockPos worldSpawn = Objects.requireNonNull(world,"Overworld cannot be null").getSharedSpawnPos();

if (!safetyDisabled) {
Pair<Integer, Optional<Vec3>> teleportData = teleportSafetyChecker(worldSpawn.getX(), worldSpawn.getY(), worldSpawn.getZ(), world, player);

switch (teleportData.getFirst()) {
case 0: // safe location found!
if (teleportData.getSecond().isPresent()) {
player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.go", player), true);
player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.go", player), true);
Teleporter(player, world, teleportData.getSecond().get());
} else {
player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true);
}

break;
case 1: // the location is already safe!
player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.same", player).withStyle(ChatFormatting.AQUA), true);
player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.same", player).withStyle(ChatFormatting.AQUA), true);
break;
case 2: // no safe location found!

Expand All @@ -87,9 +86,17 @@ private static void toWorldSpawn(ServerPlayer player, boolean safetyDisabled) {
.withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/worldspawn true"))),false);
break;
}
}
} else {
BlockPos playerBlockPos = new BlockPos(player.getBlockX(), player.getBlockY(), player.getBlockZ());

TeleportCommands.LOGGER.error("{}", world.getSharedSpawnPos());
}
if (!playerBlockPos.equals(worldSpawn) || player.level() != world) {

player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.go", player), true);
Teleporter(player, world, new Vec3(worldSpawn.getX() + 0.5, worldSpawn.getY(), worldSpawn.getZ() + 0.5));

} else {
player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.same", player).withStyle(ChatFormatting.AQUA), true);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ public static MutableComponent getTranslatedText(String key, ServerPlayer player
String filePath = String.format("/assets/%s/lang/en_us.json", MOD_ID);
InputStream stream = TeleportCommands.class.getResourceAsStream(filePath);

Reader reader = new InputStreamReader(Objects.requireNonNull(stream), StandardCharsets.UTF_8);
Reader reader = new InputStreamReader(Objects.requireNonNull(stream, "translation file stream cannot be null"), StandardCharsets.UTF_8);
JsonElement json = JsonParser.parseReader(reader);
String translation = json.getAsJsonObject().get(key).getAsString();


Matcher matcher = pattern.matcher(Objects.requireNonNull(translation));
// Adds the optional MutableComponents in the correct places
Matcher matcher = pattern.matcher(Objects.requireNonNull(translation, "translation cannot be null"));

MutableComponent component = Component.literal("");
int lastIndex = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"commands.teleport_commands.back.go": "Going Back",
"commands.teleport_commands.back.same": "Already Back",
"commands.teleport_commands.back.noLocation": "No Location Found!",

"commands.teleport_commands.worldspawn.go": "Going To The Worldspawn",
"commands.teleport_commands.worldspawn.same": "Already At Worldspawn",

"commands.teleport_commands.home.set": "Home Set",
"commands.teleport_commands.home.setError": "Error Setting Home!",
Expand Down Expand Up @@ -58,5 +60,6 @@
"commands.teleport_commands.common.rename": "[Rename]",
"commands.teleport_commands.common.delete": "[Delete]",
"commands.teleport_commands.common.default": "(Default)",
"commands.teleport_commands.common.renameExists": "That Name Already Exists!"
"commands.teleport_commands.common.renameExists": "That Name Already Exists!",
"commands.teleport_commands.common.noLocation": "No Location Found!"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"commands.teleport_commands.back.go": "Indulás vissza",
"commands.teleport_commands.back.same": "Vissza",
"commands.teleport_commands.back.noLocation": "Nem található a koordináta",

"commands.teleport_commands.worldspawn.go": "Going To The Worldspawn",
"commands.teleport_commands.worldspawn.same": "Already At Worldspawn",

"commands.teleport_commands.home.set": "Otthon beállítása",
"commands.teleport_commands.home.setError": "Hiba történt az otthon beállításával!",
Expand Down Expand Up @@ -58,5 +60,6 @@
"commands.teleport_commands.common.rename": "[Átnevezés]",
"commands.teleport_commands.common.delete": "[Törlés]",
"commands.teleport_commands.common.default": "(Alap)",
"commands.teleport_commands.common.renameExists": "A név már létezik!"
"commands.teleport_commands.common.renameExists": "A név már létezik!",
"commands.teleport_commands.common.noLocation": "Nem található a koordináta"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"commands.teleport_commands.back.go": "Tornando Indietro",
"commands.teleport_commands.back.same": "Già Tornato Indietro",
"commands.teleport_commands.back.noLocation": "Nessuna Posizione Trovata!",

"commands.teleport_commands.worldspawn.go": "Going To The Worldspawn",
"commands.teleport_commands.worldspawn.same": "Already At Worldspawn",

"commands.teleport_commands.home.set": "Casa Impostata",
"commands.teleport_commands.home.setError": "Errore Nell'Impostazione Della Casa!",
Expand Down Expand Up @@ -58,5 +60,6 @@
"commands.teleport_commands.common.rename": "[Rinomina]",
"commands.teleport_commands.common.delete": "[Elimina]",
"commands.teleport_commands.common.default": "(Predefinita)",
"commands.teleport_commands.common.renameExists": "Quel Nome Esiste Già!"
"commands.teleport_commands.common.renameExists": "Quel Nome Esiste Già!",
"commands.teleport_commands.common.noLocation": "Nessuna Posizione Trovata!"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"commands.teleport_commands.back.go": "Terug gaan",
"commands.teleport_commands.back.same": "Al Terug",
"commands.teleport_commands.back.noLocation": "Geen Locatie Gevonden!",

"commands.teleport_commands.worldspawn.go": "Naar de Worldspawn",
"commands.teleport_commands.worldspawn.same": "Al bij de Worldspawn",

"commands.teleport_commands.home.set": "Huis Ingesteld",
"commands.teleport_commands.home.setError": "Probleem tijdens het instellen van het Huis!",
Expand Down Expand Up @@ -58,5 +60,6 @@
"commands.teleport_commands.common.rename ": "[Naam Wijzigen]",
"commands.teleport_commands.common.delete": "[Verwijderen]",
"commands.teleport_commands.common.default": "(Standaard)",
"commands.teleport_commands.common.renameExists": "Die Naam Bestaat Al!"
"commands.teleport_commands.common.renameExists": "Die Naam Bestaat Al!",
"commands.teleport_commands.common.noLocation": "Geen Locatie Gevonden!"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"commands.teleport_commands.back.go": "Возвращение назад",
"commands.teleport_commands.back.same": "Уже на месте",
"commands.teleport_commands.back.noLocation": "Местоположение не найдено!",

"commands.teleport_commands.worldspawn.go": "Going To The Worldspawn",
"commands.teleport_commands.worldspawn.same": "Already At Worldspawn",

"commands.teleport_commands.home.set": "Дом установлен",
"commands.teleport_commands.home.setError": "Ошибка установки дома!",
Expand Down Expand Up @@ -58,5 +60,6 @@
"commands.teleport_commands.common.rename": "[Переименовать]",
"commands.teleport_commands.common.delete": "[Удалить]",
"commands.teleport_commands.common.default": "(По умолчанию)",
"commands.teleport_commands.common.renameExists": "Это имя уже занято!"
"commands.teleport_commands.common.renameExists": "Это имя уже занято!",
"commands.teleport_commands.common.noLocation": "Местоположение не найдено!"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Every field you add must be added to the root build.gradle expandProps map.

# Project
version=1.1.3
version=1.2.0
group=dev.mrsnowy.teleport_commands
java_version=21

Expand Down

0 comments on commit 1165839

Please sign in to comment.