Compare commits
2 commits
fc27e415f4
...
d10e195b35
Author | SHA1 | Date | |
---|---|---|---|
|
d10e195b35 | ||
|
08cfd82d09 |
3 changed files with 37 additions and 21 deletions
10
build.ps1
Normal file
10
build.ps1
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Check if the test_server directory exists, if not, create it
|
||||||
|
if (-not (Test-Path -Path test_server)) {
|
||||||
|
New-Item -ItemType Directory -Path test_server
|
||||||
|
}
|
||||||
|
|
||||||
|
# mvn clean package dependency:copy -DskipTests -DoutputDirectory=test_server/plugins
|
||||||
|
|
||||||
|
Set-Location -Path test_server
|
||||||
|
java -jar server.jar -nogui
|
||||||
|
Set-Location -Path ..
|
|
@ -15,7 +15,7 @@ import rip.iwakura.civilcore.types.DbPlayer;
|
||||||
|
|
||||||
public class PlayerHandler implements Listener {
|
public class PlayerHandler implements Listener {
|
||||||
|
|
||||||
private CivilCore civilCore = null;
|
private final CivilCore civilCore;
|
||||||
|
|
||||||
public PlayerHandler(CivilCore civilCore) {
|
public PlayerHandler(CivilCore civilCore) {
|
||||||
this.civilCore = civilCore;
|
this.civilCore = civilCore;
|
||||||
|
@ -33,7 +33,7 @@ public class PlayerHandler implements Listener {
|
||||||
String prefix = (inTeamChat ? ChatColor.DARK_BLUE + "TC " + ChatColor.RESET : "")
|
String prefix = (inTeamChat ? ChatColor.DARK_BLUE + "TC " + ChatColor.RESET : "")
|
||||||
+ (dbPlayer.team.prefix == null ?
|
+ (dbPlayer.team.prefix == null ?
|
||||||
"" :
|
"" :
|
||||||
ChatColor.translateAlternateColorCodes('&', dbPlayer.team.prefix) + " ");
|
ChatColor.translateAlternateColorCodes('&', "[" + dbPlayer.team.prefix + "]") + " ");
|
||||||
String message = String.format("%s%s: %s", prefix, player_name, e.getMessage());
|
String message = String.format("%s%s: %s", prefix, player_name, e.getMessage());
|
||||||
|
|
||||||
if (!inTeamChat) {
|
if (!inTeamChat) {
|
||||||
|
|
|
@ -1,47 +1,53 @@
|
||||||
package rip.iwakura.civilcore.commands;
|
package rip.iwakura.civilcore.commands;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import rip.iwakura.civilcore.Utils;
|
import rip.iwakura.civilcore.Utils;
|
||||||
import rip.iwakura.civilcore.CivilCore;
|
import rip.iwakura.civilcore.CivilCore;
|
||||||
import rip.iwakura.civilcore.types.DbPlayer;
|
|
||||||
import rip.iwakura.civilcore.types.Team;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class TeamChatCommand implements CommandExecutor {
|
public class TeamChatCommand implements CommandExecutor {
|
||||||
private CivilCore civilCore = null;
|
private final CivilCore civilCore;
|
||||||
|
|
||||||
public TeamChatCommand(CivilCore civilCore) {
|
public TeamChatCommand(CivilCore civilCore) {
|
||||||
this.civilCore = civilCore;
|
this.civilCore = civilCore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
args = Utils.parser(args).toArray(new String[0]);
|
args = Objects.requireNonNull(Utils.parser(args)).toArray(new String[0]);
|
||||||
|
|
||||||
if (!(sender instanceof Player)) return true;
|
if (!(sender instanceof Player p)) return true;
|
||||||
|
if (args.length == 0) {
|
||||||
Player p = (Player) sender;
|
if (civilCore.teamChatRegister.contains(p)) {
|
||||||
|
civilCore.teamChatRegister.remove(p);
|
||||||
|
p.sendMessage(ChatColor.GREEN + "You are now in the " + ChatColor.GOLD + "GLOBAL" + ChatColor.GREEN + " channel");
|
||||||
|
} else {
|
||||||
|
civilCore.teamChatRegister.add(p);
|
||||||
|
p.sendMessage(ChatColor.GREEN + "You are now in the " + ChatColor.GOLD + "TEAM" + ChatColor.GREEN + " channel");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String message = String.join(" ", args);
|
||||||
if (civilCore.teamChatRegister.contains(p)) {
|
if (civilCore.teamChatRegister.contains(p)) {
|
||||||
civilCore.teamChatRegister.remove(p);
|
civilCore.teamChatRegister.remove(p);
|
||||||
p.sendMessage(ChatColor.RED + "Team chat has been disabled.");
|
Bukkit.broadcastMessage(ChatColor.DARK_GREEN + "TEAM > " + ChatColor.GREEN + p.getName() + ": " + message);
|
||||||
return true;
|
civilCore.teamChatRegister.add(p);
|
||||||
|
} else {
|
||||||
|
civilCore.teamChatRegister.add(p);
|
||||||
|
Bukkit.broadcastMessage(p.getName() + ": " + message);
|
||||||
|
civilCore.teamChatRegister.remove(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (civilCore.db.getPlayerByName(p.getName()).team.name == null) {
|
|
||||||
p.sendMessage(ChatColor.RED + "You aren't in a team :(");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
civilCore.teamChatRegister.add(p);
|
|
||||||
p.sendMessage(ChatColor.GREEN + "Team chat has been enabled.");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue