Skip to content

Commit

Permalink
text new system langage and new system ThreadVirutal and Query support
Browse files Browse the repository at this point in the history
  • Loading branch information
SenseiTarzan committed Dec 18, 2024
1 parent 8f9f730 commit f308e01
Show file tree
Hide file tree
Showing 21 changed files with 518 additions and 192 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/sculk/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.sculk.network.session.SculkServerSession;
import org.sculk.player.Player;
import org.sculk.player.client.ClientChainData;
import org.sculk.player.text.RawTextBuilder;
import org.sculk.player.text.TranslaterBuilder;
import org.sculk.plugin.PluginManager;
import org.sculk.resourcepack.ResourcePackManager;
import org.sculk.scheduler.Scheduler;
Expand Down Expand Up @@ -100,6 +102,8 @@ public class Server {
private int maxPlayers;
@Getter
private UUID serverId;
@Getter
private final boolean query;
private long nextTick;
private int tickCounter;

Expand All @@ -126,6 +130,8 @@ public Server(LocalManager localManager, Logger logger, String dataPath) {
this.motd = this.properties.get(ServerPropertiesKeys.MOTD, "A Sculk Server Software");
this.submotd = this.properties.get(ServerPropertiesKeys.SUB_MOTD, "Powered by Sculk");
this.maxPlayers = this.properties.get(ServerPropertiesKeys.MAX_PLAYERS, 20);
System.out.println(this.properties.getProperties());
this.query = this.properties.get(ServerPropertiesKeys.QUERY, false);

this.operators = new SculkOperators();
this.whitelist = new SculkWhitelist();
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/org/sculk/command/defaults/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void onRun(CommandSender sender, String commandLabel, Map<String, Object>
.setTranslate("§6/%%s: §f%%s\nUsage: §e%%s")
.setWith(new RawTextBuilder()
.add(new TextBuilder().setText(command.getLabel()))
.add(new TextBuilder().setText(command.getDescription()))
.add(new TranslaterBuilder<Void>().setTranslate(command.getDescription()))
.add(new TextBuilder().setText(command.getUsageMessage()))
)
));
Expand All @@ -77,29 +77,29 @@ public void onRun(CommandSender sender, String commandLabel, Map<String, Object>
}
return;
}

RawTextBuilder commands = RawTextBuilder.create();
int startIndex = (actualPage - 1) * commandsPerPage;
int endIndex = Math.min(startIndex + commandsPerPage, totalCommands);

TranslaterBuilder<RawTextBuilder> commandSentence = new TranslaterBuilder<>();
commandSentence.setTranslate("§6/%%s:§f %%s\n");
for (int i = startIndex; i < endIndex; i++) {
String commandName = commandSending.toArray(new String[0])[i];
Command command = Server.getInstance().getCommandMap().getCommand(commandName);
if (i == endIndex - 1)
commandSentence.setTranslate("§6/%%s:§f %%s");
if (command != null) {
builder.append("§6/").append(commandName).append(":§f ").append(command.getDescription()).append("\n");
TranslaterBuilder<RawTextBuilder> clone = commandSentence.clone();
commands.add(clone.setWith(RawTextBuilder.create(new TextBuilder().setText(commandName), new TranslaterBuilder<>().setTranslate(command.getDescription()))));
}
}

TranslaterBuilder<RawTextBuilder> translaterBuilder = new TranslaterBuilder<>();
translaterBuilder.setTranslate("§6-------------- §fHelp - %%s command(s) §7[%%s/%%s] §6--------------\n%%s");
translaterBuilder.setWith(new RawTextBuilder()
.add(new TextBuilder()
.setText(Integer.toString(totalCommands)))
.add(new TextBuilder()
.setText(Integer.toString(actualPage)))
.add(new TextBuilder()
.setText(Integer.toString(totalPage)))
.add(new TextBuilder()
.setText(builder.substring(0, builder.length() - 1)))
translaterBuilder.setTranslate("commands.help.header");
translaterBuilder.setWith(
RawTextBuilder.create(
new TextBuilder().setText(Integer.toString(totalCommands)),
new TextBuilder().setText(Integer.toString(actualPage)),
new TextBuilder().setText(Integer.toString(totalPage)),
commands)
);
sender.sendMessage(new RawTextBuilder().add(translaterBuilder));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected void prepare() {
public void onRun(CommandSender sender, String commandLabel, Map<String, Object> args) {
sender.sendMessage(new RawTextBuilder().add(
new TranslaterBuilder()
.setTranslate("§fThis server is running §a%%s\n§fServer version: §a%%s\n§fCompatible Minecraft version: §a%%s §f(protocol version: §a%%s§f)\nOperating system: §a%%s")
.setTranslate("§fThis server is running §a%s\n§fServer version: §a%s\n§fCompatible Minecraft version: §a%s §f(protocol version: §a%s§f)\nOperating system: §a%s")
.setWith(new RawTextBuilder()
.add(new TextBuilder().setText(Sculk.CODE_NAME)) // software name
.add(new TextBuilder().setText(Sculk.CODE_VERSION)) // software version
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/sculk/config/ServerProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private ConfigSection getDefaultValues() {
defaults.put(ServerPropertiesKeys.SPAWN_MONSTERS.toString(), "on");
defaults.put(ServerPropertiesKeys.AUTO_SAVE.toString(), "on");
defaults.put(ServerPropertiesKeys.XBOX_AUTH.toString(), "on");
defaults.put(ServerPropertiesKeys.QUERY.toString(), "false");
defaults.put(ServerPropertiesKeys.FORCE_RESOURCE_PACKS.toString(), "off");
return defaults;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/sculk/config/ServerPropertiesKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum ServerPropertiesKeys {
SPAWN_MONSTERS("spawn-monsters"),
AUTO_SAVE("auto-save"),
XBOX_AUTH("xbox-auth"),
QUERY("query"),
FORCE_RESOURCE_PACKS("force-resource-packs");

private final String key;
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/org/sculk/event/server/QueryHandlerEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.sculk.event.server;


import lombok.Getter;
import lombok.Setter;
import org.sculk.player.Player;

import java.net.InetSocketAddress;
import java.util.Collection;

/*
* ____ _ _
* / ___| ___ _ _| | | __
* \___ \ / __| | | | | |/ /
* ___) | (__| |_| | | <
* |____/ \___|\__,_|_|_|\_\
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author: SculkTeams
* @link: http://www.sculkmp.org/
*/
public class QueryHandlerEvent extends ServerEvent {
@Getter @Setter
private String motd;
@Getter @Setter
private String smp;
@Getter @Setter
private String mcpe;
@Getter @Setter
private String s;
@Getter @Setter
private Collection<Player> values;
@Getter @Setter
private int maxPlayers;
@Getter @Setter
private String waterdogPE;
@Getter @Setter
private InetSocketAddress address;

public QueryHandlerEvent(String motd, String smp, String mcpe, String s, Collection<Player> values, int maxPlayers, String waterdogPE, InetSocketAddress address) {
super();
this.motd = motd;
this.smp = smp;
this.mcpe = mcpe;
this.s = s;
this.values = values;
this.maxPlayers = maxPlayers;
this.waterdogPE = waterdogPE;
this.address = address;
}
}
24 changes: 24 additions & 0 deletions src/main/java/org/sculk/event/server/ServerEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.sculk.event.server;


import org.sculk.Server;
import org.sculk.event.Event;

/*
* ____ _ _
* / ___| ___ _ _| | | __
* \___ \ / __| | | | | |/ /
* ___) | (__| |_| | | <
* |____/ \___|\__,_|_|_|\_\
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author: SculkTeams
* @link: http://www.sculkmp.org/
*/
public class ServerEvent extends Event {

}
Loading

0 comments on commit f308e01

Please sign in to comment.