Skip to content

Commit

Permalink
removed cmd-file output for good.
Browse files Browse the repository at this point in the history
Fix bundle loading problem in regions
Fix EndCommand breaking from console and being confusing named
Fix Reward command bracket error
  • Loading branch information
FireInstall committed Feb 27, 2024
1 parent 3a9c292 commit 437ee3a
Show file tree
Hide file tree
Showing 133 changed files with 148 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public void onPlayerResourcePack(@NotNull PlayerResourcePackStatusEvent event) {
}
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MinigameTimer {
private static final Minigames plugin = Minigames.getPlugin();
private final long timeLength;
private final Minigame minigame;
private final List<Long> timeMsg = new ArrayList<>();
private final List<Long> msgTimes = new ArrayList<>();
private long timeLeft = 0;
private int taskID = -1;
private boolean broadcastTime = true;
Expand All @@ -33,7 +33,7 @@ public MinigameTimer(Minigame minigame, long timeLength) {
this.timeLength = timeLength;
this.timeLeft = timeLength;
this.minigame = minigame;
timeMsg.addAll(plugin.getConfig().getLongList("multiplayer.timerMessageInterval"));
msgTimes.addAll(plugin.getConfig().getLongList("multiplayer.timerMessageInterval"));
startTimer();
}

Expand Down Expand Up @@ -95,7 +95,7 @@ private void runTimer() {
}
}

if (timeMsg.contains(timeLeft) && broadcastTime) {
if (msgTimes.contains(timeLeft) && broadcastTime) {
PlayMGSound.playSound(minigame, MGSounds.TIMER_TICK.getSound());
MinigameMessageManager.sendMinigameMessage(minigame, MinigameMessageManager.getMgMessage(MinigameLangKey.TIME_TIMELEFT,
Placeholder.component(MinigamePlaceHolderKey.TIME.getKey(), MinigameUtils.convertTime(Duration.ofSeconds(timeLeft)))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public Component getValue() {
public void setValue(Component value) {
displayname = value;
}


};
}

Expand Down Expand Up @@ -208,8 +206,6 @@ public Boolean getValue() {
public void setValue(Boolean value) {
fallDamage = value;
}


};
}

Expand All @@ -233,8 +229,6 @@ public Boolean getValue() {
public void setValue(Boolean value) {
hunger = value;
}


};
}

Expand All @@ -259,8 +253,6 @@ public void setValue(Integer value) {
if (level >= -1)
level = value;
}


};
}

Expand Down Expand Up @@ -292,8 +284,6 @@ public Boolean getValue() {
public void setValue(Boolean value) {
setInventoryLocked(value);
}


};
}

Expand All @@ -317,8 +307,6 @@ public Boolean getValue() {
public void setValue(Boolean value) {
setArmourLocked(value);
}


};
}

Expand All @@ -337,8 +325,6 @@ public Boolean getValue() {
public void setValue(Boolean value) {
allowOffHand = value;
}


};
}

Expand Down Expand Up @@ -388,8 +374,6 @@ public Boolean getValue() {
public void setValue(Boolean value) {
setDisplayInMenu(value);
}


};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public void setDatabase(File dbbath) {

@Override
public boolean initialize(ConfigurationSection config) {

try {
Class.forName("org.sqlite.JDBC");

Expand Down Expand Up @@ -115,7 +114,6 @@ private boolean checkForColumn(Statement statement, String columnName) {
logger.error("Exception looking for SQLite column " + columnName + " on table " + "PlayerStats", e);
return false;
}

}

private void ensureTables(ConnectionHandler connection) throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,4 @@ public boolean onCommand(@NotNull CommandSender sender,
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,4 @@ public boolean onCommand(@NotNull CommandSender sender,
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,4 @@ public boolean onCommand(@NotNull CommandSender sender,
List<String> mgs = new ArrayList<>(PLUGIN.getMinigameManager().getAllMinigames().keySet());
return CommandDispatcher.tabCompleteMatch(mgs, args[args.length - 1]);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public boolean onCommand(@NotNull CommandSender sender,
if (sender instanceof Player player) {
MinigamePlayer mgPlayer = PLUGIN.getPlayerManager().getMinigamePlayer(player);
mgm.displayMenu(mgPlayer);
return true;
} else {
MinigameMessageManager.sendMgMessage(sender, MinigameMessageType.ERROR, MgCommandLangKey.COMMAND_ERROR_SENDERNOTAPLAYER);
}
return true;
} else {
MinigameMessageManager.sendMgMessage(sender, MinigameMessageType.ERROR, MinigameLangKey.MINIGAME_ERROR_NOMINIGAME,
Placeholder.unparsed(MinigamePlaceHolderKey.MINIGAME.getKey(), args[0]));
Expand All @@ -74,5 +74,4 @@ public boolean onCommand(@NotNull CommandSender sender,
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,4 @@ public boolean onCommand(@NotNull CommandSender sender,
List<String> mgs = new ArrayList<>(PLUGIN.getMinigameManager().getAllMinigames().keySet());
return CommandDispatcher.tabCompleteMatch(mgs, args[args.length - 1]);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,4 @@ public boolean onCommand(@NotNull CommandSender sender,
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,4 @@ public boolean onCommand(@NotNull CommandSender sender,
@NotNull String @NotNull [] args) {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,17 @@ public boolean onCommand(final @NotNull CommandSender sender, @NotNull String @N
if (sender instanceof Player player) {
mgPlayer = PLUGIN.getPlayerManager().getMinigamePlayer(player);
} else {
return false;
MinigameMessageManager.sendMgMessage(sender, MinigameMessageType.ERROR, MgCommandLangKey.COMMAND_ERROR_SENDERNOTAPLAYER,
Placeholder.unparsed(MinigamePlaceHolderKey.TEXT.getKey(), args[2]));
return true;
}
} else {
mgPlayer = PLUGIN.getPlayerManager().getMinigamePlayer(args[2]);

if (mgPlayer == null) {
MinigameMessageManager.sendMgMessage(sender, MinigameMessageType.ERROR, MgCommandLangKey.COMMAND_ERROR_SENDERNOTAPLAYER,
MinigameMessageManager.sendMgMessage(sender, MinigameMessageType.ERROR, MgCommandLangKey.COMMAD_ERROR_NOTPLAYER,
Placeholder.unparsed(MinigamePlaceHolderKey.TEXT.getKey(), args[2]));
return false;
return true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull String @NotNull
@NotNull String @NotNull [] args) {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,4 @@ public boolean onCommand(@NotNull CommandSender sender,
List<String> mgs = new ArrayList<>(PLUGIN.getMinigameManager().getAllMinigames().keySet());
return CommandDispatcher.tabCompleteMatch(mgs, args[args.length - 1]);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,4 @@ else if (team != null && pos >= team.getStartLocations().size())
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,4 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull String @NotNull
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,4 @@ else if (args.length == 2 && args[0].equalsIgnoreCase("remove")) {
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,4 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Minigame miniga
return CommandDispatcher.tabCompleteMatch(List.of("true", "false"), args[0]);
return null;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package au.com.mineauz.minigames.commands.set;

import au.com.mineauz.minigames.Minigames;
import au.com.mineauz.minigames.commands.ACommand;
import au.com.mineauz.minigames.commands.CommandDispatcher;
import au.com.mineauz.minigames.managers.MinigameMessageManager;
Expand All @@ -11,45 +10,20 @@
import au.com.mineauz.minigames.minigame.Minigame;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;

public class SetCommand extends ACommand {
private static final @NotNull Map<@NotNull String, @NotNull ASetCommand> parameterList = new TreeMap<>(); // sort by name for display in help
private static BufferedWriter cmdFile;

static {
if (PLUGIN.getConfig().getBoolean("outputCMDToFile")) {
try {
cmdFile = new BufferedWriter(new FileWriter(PLUGIN.getDataFolder() + File.pathSeparator + "setcmds.txt"));
cmdFile.write("{| class=\"wikitable\"");
cmdFile.newLine();
cmdFile.write("! Command");
cmdFile.newLine();
cmdFile.write("! Syntax");
cmdFile.newLine();
cmdFile.write("! Description");
cmdFile.newLine();
cmdFile.write("! Permission");
cmdFile.newLine();
cmdFile.write("! Alias");
cmdFile.newLine();
} catch (IOException e) {
Minigames.getCmpnntLogger().warn("couldn't write cmd file", e);
}
}
registerSetCommand(new SetStartCommand());
registerSetCommand(new SetEndCommand());
registerSetCommand(new SetQuitCommand());
registerSetCommand(new SetEndLocationCommand());
registerSetCommand(new SetQuitLocationCommand());
registerSetCommand(new SetLobbyCommand());
registerSetCommand(new SetRewardCommand());
registerSetCommand(new SetSecondaryRewardCommand());
Expand All @@ -63,7 +37,7 @@ public class SetCommand extends ACommand {
registerSetCommand(new SetMinTreasureCommand());
registerSetCommand(new SetMaxTreasureCommand());
registerSetCommand(new SetFlagCommand());
registerSetCommand(new SetLocationCommand());
registerSetCommand(new SetLocationHintCommand());
registerSetCommand(new SetUsePermissionsCommand());
registerSetCommand(new SetMinScoreCommand());
registerSetCommand(new SetMaxScoreCommand());
Expand Down Expand Up @@ -99,69 +73,16 @@ public class SetCommand extends ACommand {
registerSetCommand(new SetFlightCommand());
registerSetCommand(new SetHintDelayCommand());
registerSetCommand(new SetRestartDelayCommand());
registerSetCommand(new SetSpectatorSpawnCommand());
registerSetCommand(new SetSpectatorSpawnLocationCommand());
registerSetCommand(new SetInfectedPercentCommand());
registerSetCommand(new SetGameOverCommand());
registerSetCommand(new SetDisplayScoreboardCommand());
registerSetCommand(new SetInfectedTeamCommand());
registerSetCommand(new SetSurvivorTeamCommand());

if (PLUGIN.getConfig().getBoolean("outputCMDToFile")) {
try {
cmdFile.write("|}");
cmdFile.close();
} catch (IOException e) {
Minigames.getCmpnntLogger().warn("couldn't write cmd file", e);
}
}
}

public static void registerSetCommand(ASetCommand command) {
parameterList.put(command.getName(), command);

if (PLUGIN.getConfig().getBoolean("outputCMDToFile")) {
PlainTextComponentSerializer plainCmpntSerial = PlainTextComponentSerializer.plainText();

try {
cmdFile.write("|-");
cmdFile.newLine();
cmdFile.write("| '''" + command.getName() + "'''");
cmdFile.newLine();
if (command.getUsage() != null) {
cmdFile.write("| ");
cmdFile.write(plainCmpntSerial.serialize(command.getUsage()));
} else {
cmdFile.write("| N/A");
}
cmdFile.newLine();
command.getDescription();
cmdFile.write("| " + command.getDescription());
cmdFile.newLine();
if (command.getPermission() != null) {
cmdFile.write("| " + command.getPermission());
} else {
cmdFile.write("| N/A");
}
cmdFile.newLine();
if (command.getAliases() != null) {
int count = 0;
cmdFile.write("| ");
for (String alias : command.getAliases()) {
cmdFile.write(alias);
count++;
if (count != command.getAliases().length) {
cmdFile.write("\n\n");
}
}
} else {
cmdFile.write("| N/A");
}
cmdFile.newLine();

} catch (IOException e) {
Minigames.getCmpnntLogger().warn("couldn't write cmd file", e);
}
}
}

public static @NotNull Collection<@NotNull ASetCommand> getSetCommands() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,4 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Minigame miniga
}
return null;
}

}
Loading

0 comments on commit 437ee3a

Please sign in to comment.