Skip to content

Commit

Permalink
Release 1.7.0: Add flag, warp, rename commands, change color names
Browse files Browse the repository at this point in the history
  • Loading branch information
kivattt committed Jan 26, 2024
1 parent ac4ece3 commit 776d2cf
Show file tree
Hide file tree
Showing 48 changed files with 882 additions and 243 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ bin/

### KIVA ###
.idea
org
96 changes: 68 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![Example chat](images/chatexample.png)

## Features
- Improved player chat, with colors, nicknames and pronouns aswell as red usernames for OP players
- Improved player chat, with colors, nicknames, pronouns, flags aswell as red usernames for OP players
- Player teleport request commands
- Adds spawn and home commands
- Adds a stricter mob cap which allows mobs to be enabled for servers without lag
Expand All @@ -30,6 +30,9 @@ Sets a home location

`/delhome <optional home name>`\
Deletes a home. If no name is specified, it deletes your main home

`/renamehome <old name> <new name>`\
Renames a home
</details>

<details>
Expand All @@ -41,10 +44,10 @@ Teleport to spawn (If spawn location specified)
`/spawnwhere`\
Show spawn location without teleporting to it

`/spawnset` (OP-only command)\
`/spawnset` (OP-only)\
Sets the spawn location, and where `/spawn` sends the player

`/spawnreset` (OP-only command)\
`/spawnreset` (OP-only)\
Removes spawn location
</details>

Expand Down Expand Up @@ -79,14 +82,24 @@ See the nicknames of everyone currently in the server
`/nicklistall`\
See everyone's nicknames

`/nickset <player> <nickname>` (OP-only command)\
`/nickset <player> <nickname>` (OP-only)\
Force set a players nickname

`/nickreset <optional player>`\
Resets / removes your nickname\
When player supplied, an OP can force reset a players nickname
</details>

<details>
<summary>Name colors</summary>

`/namecolor <color>` or `/namecolour <color>`\
Change your name color

`/namecolorreset` or `/namecolourreset`\
Resets your name color
</details>

<details>
<summary>Pronouns</summary>

Expand All @@ -99,7 +112,7 @@ See the pronouns of everyone currently in the server
`/pronounslistall`\
See everyone's pronouns

`/pronounsset <player> <pronouns>` (OP-only command)\
`/pronounsset <player> <pronouns>` (OP-only)\
Force set a players pronouns

`/pronounsreset <optional player>`\
Expand All @@ -108,7 +121,7 @@ When player supplied, an OP can force reset a players pronouns
</details>

<details>
<summary>Pronouns color</summary>
<summary>Pronouns colors</summary>

`/pronounscolor <color>` or `/pronounscolour <color>`\
Change your pronouns color
Expand All @@ -118,19 +131,40 @@ Resets your pronouns color
</details>

<details>
<summary>Name colors</summary>
<summary>Flags</summary>

`/namecolor <color>` or `/namecolour <color>`\
Change your name color
`/flag <colors...>`\
Set a flag in your chat messages\
Example: `/flag lightred orange yellow green blue purple`

`/flagreset`\
Resets your flag (removes it)
</details>

<details>
<summary>Warps</summary>

`/warp <name>`\
Teleports you to the location

`/warps <optional name>`\
Lists all warps on the server, if a name is provided it will only show that warp

`/warpset <name>` (OP-only)\
Adds a new warp at your location

`/warpdel <name>` (OP-only)\
Deletes a warp

`/warprename <old name> <new name>` (OP-only)\
Renames a warp

`/namecolorreset` or `/namecolourreset`\
Resets your name color
</details>

<details>
<summary>Chat mute</summary>

`/mute <player>` (OP-only command)\
`/mute <player>` (OP-only)\
Toggles preventing the player from sending chat messages\
Commands are still allowed while muted, except for /me and /tell

Expand All @@ -144,25 +178,25 @@ Lists all muted players
<details>
<summary>Restrictive mode</summary>

`/restrict <player>` (OP-only command)\
`/restrict <player>` (OP-only)\
Toggles [restrictive mode](#restrictive-mode)

`/restrictlist` (OP-only command)\
`/restrictlist` (OP-only)\
Lists players in [restrictive mode](#restrictive-mode) currently in the server

`/restrictlistall` (OP-only command)\
`/restrictlistall` (OP-only)\
Lists all players in [restrictive mode](#restrictive-mode)

`/restrictbydefault <true or false>` (OP-only command)\
`/restrictbydefault <true or false>` (OP-only)\
All players will be in [restrictive mode](#restrictive-mode) when `true` (`/restrictlist` is ignored), unless specifically excluded with `/restrictexclude`

`/restrictexclude <player>` (OP-only command)\
`/restrictexclude <player>` (OP-only)\
Excludes player from restrictive mode when `/restrictbydefault` is true

`/restrictexcludelist` (OP-only command)\
`/restrictexcludelist` (OP-only)\
List players excluded from restrictive mode currently in the server

`/restrictexcludelistall` (OP-only command)\
`/restrictexcludelistall` (OP-only)\
Lists all players excluded from restrictive mode
</details>

Expand Down Expand Up @@ -198,29 +232,32 @@ See a regions coordinates and dimension
<details>
<summary>Configuration</summary>

`/mobcapdisabled <true or false>` (OP-only command)\
`/mobcapdisabled <true or false>` (OP-only)\
Enable or disable the mobcap (setting mobcapdisabled to true will introduce lag!)

`/explosionsbreakchests <true or false>` (OP-only command)\
`/explosionsbreakchests <true or false>` (OP-only)\
Set if explosions break chests and crates

`/homecommandsdisabled <true or false>` (OP-only command)\
Enable/disable the `/home` and `/sethome` commands
`/homecommandsdisabled <true or false>` (OP-only)\
Enable/disable the `/home`, `/sethome` commands

`/tpacommandsdisabled <true or false>` (OP-only)\
Enable/disable the `/tpa`, `/tpaccept`, `/tprevoke`, `/tpdeny` commands

`/tpacommandsdisabled <true or false>` (OP-only command)\
Enable/disable the `/tpa`, `/tpaccept`, `/tprevoke`, and `/tpdeny` commands
`/warpcommandsdisabled <true or false>` (OP-only)\
Enabled/disable the `/warp`, `/warps`, `/warpset`, `/warpdel`, `/warprename` commands

`/falldamagedisabled <true or false>` (OP-only command)\
`/falldamagedisabled <true or false>` (OP-only)\
Enable/disable fall damage

`/maxhomes <number>` (OP-only command)\
`/maxhomes <number>` (OP-only)\
Sets the max amount of homes per player. Will not delete any existing homes. **Default: 10**

`/kivashowconfig`\
Shows config for KivaServerUtils
</details>

`/teleport <x> <y> <z>` (OP-only command)\
`/teleport <x> <y> <z>` (OP-only)\
Teleport to coordinate

`/kivaversion`\
Expand Down Expand Up @@ -264,6 +301,9 @@ You can't place blocks beside protected regions when right-clicking a block in t

When `/maxhomes` is set to 1, all commands after the first sethome will fail and the player will have to manually `/delhome` every time

# Reporting bugs
Either add me on Discord where my username is `kivattt`, or open an issue

# Other
`/sethome` doesn't follow the naming convention `...set` because it's such a common command name in Minecraft servers

Expand Down
5 changes: 3 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
- Better system for configuration, less confusing commands (something like /gamerule \<key> \<value>)

- Chat messages stored in a file with the normal Minecraft language format string system

- Clean up the `/*list` and `/*listall` commands with optional "all" argument so it would be `/*list all`. Alternatively do an alias with an if for it
- Clean up the `/*list` and `/*listall` commands with optional "all" argument, so it would be `/*list all`. Alternatively do an alias with an if for it

- Better system for configuration, less confusing commands (something like /gamerule \<key> \<value>)
- In `/spawn`, `/teleport`, `/home` commands check if the target chunk is loaded by the player
and if not, warn them to try relogging if they're stuck in air

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ buildscript {
maven { url 'https://jitpack.io/' }
}
dependencies {
classpath('com.github.Fox2Code.FoxLoader:dev:1.2.33')
classpath('com.github.Fox2Code.FoxLoader:dev:1.2.38')
}
}

apply plugin: 'foxloader.dev'

version '1.6.6'
version '1.7.0'

foxloader {
// forceReload = true
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/kiva/kivaserverutils/KivaServerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

public class KivaServerUtils extends Mod {
public static HashMap<String, String> playerNicknames = new HashMap<>();
public static HashMap<String, String> playerFlags = new HashMap<>(); // Flags in chat messages
public static HashMap<String, String> playerPronouns = new HashMap<>();
public static HashMap<String, String> playerNameColors = new HashMap<>();
public static HashMap<String, String> playerPronounColors = new HashMap<>();
Expand All @@ -18,17 +19,21 @@ public class KivaServerUtils extends Mod {
public static Set<String> playersExcludedFromRestrictiveMode;
public static Set<String> playersMuted;

public static HashMap<String, Coordinate> warps = new HashMap<>();
public static HashMap<String, ArrayList<String>> tpaRequests = new HashMap<>(); // String to, List<String> from
public static HashMap<String, ProtectedRegion> protectedRegions = new HashMap<>();

public static HashMap<String, Boolean> config = new HashMap<>();
public static Coordinate spawnCommandLocation = null;

public static String defaultPlayerNameColor = ChatColors.AQUA;
public static String flagDataCharacterToBeReplaced = "F"; // This is how the flag data is stored internally, replaced on-the-fly with the character below
public static String flagCharacter = "■";
public static String defaultPlayerPronounColor = ChatColors.GREEN;
public static LinkedHashMap<String, String> nameColorChoicesNames = new LinkedHashMap<>();
public static LinkedHashMap<String, String> flagColorChoicesNames = new LinkedHashMap<>();
public static LinkedHashMap<String, String> pronounColorChoicesNames = new LinkedHashMap<>();
public static String version = "1.6.6";
public static String version = "1.7.0";
public static String KSUBroadcastPrefix = ChatColors.DARK_GRAY + "[" + ChatColors.GRAY + "KSU" + ChatColors.DARK_GRAY + "] " + ChatColors.RESET;

public static String handleWindowClickLatestPlayerUsername;
Expand All @@ -49,6 +54,11 @@ public static String getPlayerPronounColor(final String playerName){
return color == null ? defaultPlayerPronounColor : color;
}

public static String getPlayerFlag(final String playerName){
String flag = KivaServerUtils.playerFlags.get(playerName);
return flag == null ? "" : flag.replaceAll(flagDataCharacterToBeReplaced, flagCharacter) + " "; // We need an extra space if the flag is present
}

public static Boolean getConfigValue(String key){
final Boolean value = config.get(key);
return value == null ? false : value;
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/com/kiva/kivaserverutils/UsageMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@

import com.fox2code.foxloader.network.NetworkPlayer;

import java.util.Arrays;

public class UsageMessage {
public static void sendUsageMessage(String commandSyntax, NetworkPlayer player){
public static void sendUsageMessage(String commandSyntax, NetworkPlayer player) {
sendUsageMessage(commandSyntax, player, true);
}

public static void sendUsageMessage(String commandSyntax, NetworkPlayer player, boolean startWithSyntaxText){
// Could maybe make this some pop() thing with the right datatype to clean things up
String[] syntaxSplitByNewlines = commandSyntax.split("\n");
player.displayChatMessage("§aSyntax: " + syntaxSplitByNewlines[0]);

if (syntaxSplitByNewlines.length == 0)
return;

if (startWithSyntaxText)
player.displayChatMessage("§aSyntax: " + syntaxSplitByNewlines[0]);
else
player.displayChatMessage(syntaxSplitByNewlines[0]);

for (int i = 1; i < syntaxSplitByNewlines.length; i++)
player.displayChatMessage(syntaxSplitByNewlines[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import java.nio.file.Files;
import java.nio.file.Paths;

public class FileWriteAndLoadCoordinate {
public static void writeCoordinateToFile(final Coordinate coordinate, final String filename){
public class FileWriteAndLoadSpawn {
public static void writeSpawnToFile(final Coordinate coordinate, final String filename){
if (coordinate == null) {
File f = new File(filename);
if (!f.exists())
return;

System.out.println("No spawn set, attempting to delete " + filename);
System.out.println("No spawn set, deleting " + filename);

if (f.delete())
System.out.println("Deleted " + filename + " successfully");
Expand All @@ -28,19 +28,18 @@ public static void writeCoordinateToFile(final Coordinate coordinate, final Stri
fileWriter.write(coordinate.toString());
fileWriter.close();
} catch(IOException e){
System.err.println("Failed to write coordinate to file: " + filename);
System.err.println("Failed to write spawn coordinate to file: " + filename);
e.printStackTrace();
}
}

public static Coordinate loadCoordinateFromFile(final String filename){
public static Coordinate loadSpawnFromFile(final String filename){
Coordinate ret = new Coordinate();

try {
ret.fromString(Files.readAllLines(Paths.get(filename)).get(0));
} catch(IOException | IndexOutOfBoundsException e) {
// Removed since this is expected when no spawn is set, to avoid confusion
//System.err.println("Failed to load coordinate from file: " + filename);
// No error msg since it's expected when no spawn is set, to avoid confusion
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ public class FileWriteAndLoadStringProtectedRegionHashmap {
public static void writeStringProtectedRegionHashmapToFile(final HashMap<String, ProtectedRegion> hashMap, final String filename){
try{
FileWriter fileWriter = new FileWriter(filename);
for (Map.Entry<String, ProtectedRegion> entry : hashMap.entrySet()) {
for (Map.Entry<String, ProtectedRegion> entry : hashMap.entrySet())
fileWriter.write(entry.getKey() + "=" + entry.getValue().toWriteableDataString() + "\n");
}
fileWriter.close();
} catch (IOException e) {
System.err.println("Failed to write string & protected region hashmap to file: " + filename);
Expand Down
Loading

0 comments on commit 776d2cf

Please sign in to comment.