Chat fixes, town color fixes, some features #72
3 changed files with 66 additions and 63 deletions
|
@ -1,58 +1,59 @@
|
|||
package buttondevteam.chat.commands.ucmds.admin;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.dynmap.towny.DynmapTownyPlugin;
|
||||
|
||||
import buttondevteam.chat.PluginMain;
|
||||
import buttondevteam.lib.chat.Color;
|
||||
import lombok.val;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.dynmap.towny.DynmapTownyPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TownColorCommand extends AdminCommandBase {
|
||||
@Override
|
||||
public String GetHelpText(String alias)[] { // TODO: Command path aliases
|
||||
return new String[] { //
|
||||
"§6---- Town Color ----", //
|
||||
"This command allows setting a color for a town.", //
|
||||
"The town will be shown with this color on Dynmap and all players in the town will appear in chat with these colors.", //
|
||||
"The colors will split the name evenly.", //
|
||||
"Usage: /" + GetCommandPath() + " <town> <colorname1> [colorname2...]", //
|
||||
"Example: /" + GetCommandPath() + " Alderon blue gray" //
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String GetHelpText(String alias)[] { // TODO: Command path aliases
|
||||
return new String[]{ //
|
||||
"§6---- Town Color ----", //
|
||||
"This command allows setting a color for a town.", //
|
||||
"The town will be shown with this color on Dynmap and all players in the town will appear in chat with these colors.", //
|
||||
"The colors will split the name evenly.", //
|
||||
"Usage: /" + GetCommandPath() + " <town> <colorname1> [colorname2...]", //
|
||||
"Example: /" + GetCommandPath() + " Alderon blue gray" //
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
return SetTownColor(sender, alias, args);
|
||||
}
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
return SetTownColor(sender, alias, args);
|
||||
}
|
||||
|
||||
public static boolean SetTownColor(CommandSender sender, String alias, String[] args) {
|
||||
if (args.length < 2)
|
||||
return false;
|
||||
if (!PluginMain.TU.getTownsMap().containsKey(args[0].toLowerCase())) {
|
||||
sender.sendMessage("§cThe town '" + args[0] + "' cannot be found.");
|
||||
return true;
|
||||
}
|
||||
val clrs = new Color[args.length - 1];
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
val ii = i;
|
||||
val c = Arrays.stream(Color.values()).filter(cc -> cc.getName().equalsIgnoreCase(args[ii])).findAny();
|
||||
if (!c.isPresent()) {
|
||||
sender.sendMessage("§cThe color '" + args[i] + "' cannot be found.");
|
||||
return true;
|
||||
}
|
||||
clrs[i - 1] = c.get();
|
||||
}
|
||||
PluginMain.TownColors.put(args[0].toLowerCase(), clrs);
|
||||
val dtp = (DynmapTownyPlugin) Bukkit.getPluginManager().getPlugin("Dynmap-Towny");
|
||||
if (dtp == null) {
|
||||
sender.sendMessage("§cDynmap-Towny couldn'5 be found to set town color.");
|
||||
return true;
|
||||
}
|
||||
PluginMain.setTownColor(dtp, args[0].toLowerCase(), clrs);
|
||||
sender.sendMessage("§bColor(s) set.");
|
||||
return true;
|
||||
}
|
||||
public static boolean SetTownColor(CommandSender sender, String alias, String[] args) {
|
||||
if (args.length < 2)
|
||||
return false;
|
||||
if (!PluginMain.TU.getTownsMap().containsKey(args[0].toLowerCase())) {
|
||||
sender.sendMessage("§cThe town '" + args[0] + "' cannot be found.");
|
||||
return true;
|
||||
}
|
||||
val clrs = new Color[args.length - 1];
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
val ii = i;
|
||||
val c = Arrays.stream(Color.values()).filter(cc -> cc.getName().equalsIgnoreCase(args[ii])).findAny();
|
||||
if (!c.isPresent()) {
|
||||
sender.sendMessage("§cThe color '" + args[i] + "' cannot be found.");
|
||||
sender.sendMessage("§cAvailable colors: " + Arrays.stream(Color.values()).map(Color::getName).collect(Collectors.joining(", ")));
|
||||
return true;
|
||||
}
|
||||
clrs[i - 1] = c.get();
|
||||
}
|
||||
PluginMain.TownColors.put(args[0].toLowerCase(), clrs);
|
||||
val dtp = (DynmapTownyPlugin) Bukkit.getPluginManager().getPlugin("Dynmap-Towny");
|
||||
if (dtp == null) {
|
||||
sender.sendMessage("§cDynmap-Towny couldn'5 be found to set town color.");
|
||||
return true;
|
||||
}
|
||||
PluginMain.setTownColor(dtp, args[0].toLowerCase(), clrs);
|
||||
sender.sendMessage("§bColor(s) set.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
package buttondevteam.chat.listener;
|
||||
|
||||
import java.util.Timer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
|
||||
import buttondevteam.chat.ChatPlayer;
|
||||
import buttondevteam.chat.FlairStates;
|
||||
import buttondevteam.chat.PlayerJoinTimerTask;
|
||||
|
@ -18,6 +8,15 @@ import buttondevteam.chat.commands.UnlolCommand;
|
|||
import buttondevteam.lib.player.TBMCPlayerJoinEvent;
|
||||
import buttondevteam.lib.player.TBMCPlayerLoadEvent;
|
||||
import buttondevteam.lib.player.TBMCPlayerSaveEvent;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.Timer;
|
||||
|
||||
public class PlayerJoinLeaveListener implements Listener {
|
||||
|
||||
|
@ -46,9 +45,7 @@ public class PlayerJoinLeaveListener implements Listener {
|
|||
tt.mp = cp;
|
||||
timer.schedule(tt, 1000);
|
||||
} else {
|
||||
if (cp.FlairTime().get() == 0x00)
|
||||
cp.SetFlair(ChatPlayer.FlairTimeNone);
|
||||
Timer timer = new Timer();
|
||||
/*Timer timer = new Timer();
|
||||
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
||||
|
||||
@Override
|
||||
|
@ -70,10 +67,13 @@ public class PlayerJoinLeaveListener implements Listener {
|
|||
}
|
||||
};
|
||||
tt.mp = cp;
|
||||
timer.schedule(tt, 15 * 1000);
|
||||
timer.schedule(tt, 15 * 1000);*/ //TODO: Better Reddit integration (OAuth)
|
||||
}
|
||||
|
||||
String nwithoutformatting = PluginMain.essentials.getUser(p).getNickname();
|
||||
|
||||
p.setDisplayName();
|
||||
|
||||
int index;
|
||||
if (nwithoutformatting != null) {
|
||||
while ((index = nwithoutformatting.indexOf("§k")) != -1)
|
||||
|
|
|
@ -79,7 +79,9 @@ public class PlayerListener implements Listener {
|
|||
else
|
||||
mp = null;
|
||||
String cmd = "";
|
||||
if (index == -1 && (sender instanceof Player || sender instanceof ConsoleCommandSender)) { // Only the command is run
|
||||
if (index == -1) { // Only the command is run
|
||||
if (!(sender instanceof Player || sender instanceof ConsoleCommandSender))
|
||||
return false;
|
||||
// ^^ We can only store player or console channels - Directly sending to channels would still work if they had an event
|
||||
cmd = sender instanceof ConsoleCommandSender ? message : message.substring(1);
|
||||
for (Channel channel : Channel.getChannels()) {
|
||||
|
|
Loading…
Reference in a new issue