dunno if it works

This commit is contained in:
2023-11-12 10:40:18 +08:00
parent fb4baac9d4
commit dc680883ac
5 changed files with 25 additions and 10 deletions
-1
View File
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<list size="1">
+1
View File
@@ -2,6 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/cf.sobrooms.notifyonstart.main.iml" filepath="$PROJECT_DIR$/.idea/modules/cf.sobrooms.notifyonstart.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/notifyonstart.main.iml" filepath="$PROJECT_DIR$/.idea/modules/notifyonstart.main.iml" />
</modules>
</component>
+12 -7
View File
@@ -5,7 +5,11 @@
</component>
<component name="ChangeListManager">
<list default="true" id="ce97b9f5-6785-4670-b350-12f90ab9ea27" name="Changes" comment="wrong version number">
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/cf/sobrooms/commands/SetLoggingModeCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/cf/sobrooms/commands/SetLoggingModeCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/cf/sobrooms/events/player/PlayerJoin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/cf/sobrooms/events/player/PlayerJoin.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -44,18 +48,19 @@
&quot;associatedIndex&quot;: 8
}</component>
<component name="ProjectId" id="2VtRIra79d9tkHTc8fsXlFQRFWj" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "main"
}
}</component>
}]]></component>
<component name="RunManager">
<configuration name="notify-on-start [build]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
@@ -1,6 +1,7 @@
package cf.sobrooms.commands;
import cf.sobrooms.Main;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -12,17 +13,24 @@ import java.io.IOException;
public class SetLoggingModeCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args[0].isBlank()) {
sender.sendMessage("Please only provide true or false.");
sender.sendMessage("Please only provide true or false in the command arguments.");
return false;
} else {
if (args[0].equals("true") || args[0].equals("false")) {
try {
FileWriter writer = new FileWriter(Main.isLoggingConfig);
writer.write(args[0]);
writer.close();
System.out.println("Wrote to config, closing writer...");
sender.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Changes will only apply once the server has restarted.");
sender.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Restart your server if you would like to apply the changes.");
String status = "";
if (args[0].equals("true"))
status = "enabled";
else if (args[0].equals("false"))
status = "disabled";
Bukkit.broadcastMessage(ChatColor.ITALIC + "%s %s server logging.".formatted(sender.getName(), status));
Bukkit.broadcastMessage(ChatColor.ITALIC + "Changes will only apply once the server has restarted.");
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -24,6 +24,8 @@ public class PlayerJoin implements Listener {
.setColor(Color.BLUE);
notify.addEmbed(embedObject);
try {
if (!player.hasPlayedBefore())
player.sendMessage("Welcome to the server!");
notify.execute();
} catch (IOException e) {
throw new RuntimeException(e);