Chat Management Menu
This commit is contained in:
parent
24d2c9cb36
commit
3683e2151e
@ -1,9 +1,9 @@
|
||||
package com.loganmagnan.eventcore.commands;
|
||||
|
||||
import com.loganmagnan.eventcore.EventCore;
|
||||
import com.loganmagnan.eventcore.menusystem.menus.ChatManagementMenu;
|
||||
import com.loganmagnan.eventcore.utils.ColorUtils;
|
||||
import com.loganmagnan.eventcore.utils.Constants;
|
||||
import com.loganmagnan.eventcore.utils.CustomLocation;
|
||||
import com.loganmagnan.eventcore.utils.Utils;
|
||||
import com.loganmagnan.eventcore.utils.command.BaseCommand;
|
||||
import com.loganmagnan.eventcore.utils.command.Command;
|
||||
@ -28,7 +28,7 @@ public class ChatCommand extends BaseCommand {
|
||||
} else {
|
||||
switch (args[0]) {
|
||||
case "manage":
|
||||
// To Do: Setup Chat Management Menu
|
||||
new ChatManagementMenu(this.main.getPlayerMenuUtil(player), this.main.getChatManager().getDelayAmount()).open(player);
|
||||
|
||||
break;
|
||||
case "toggle":
|
||||
|
@ -21,8 +21,8 @@ public class ChatManager {
|
||||
|
||||
// Slow Chat System
|
||||
private int delayAmount = 0;
|
||||
private UUID delayedBy = null;
|
||||
private long lastDelayedTime = 0;
|
||||
private UUID slowedBy = null;
|
||||
private long lastSlowedTime = 0;
|
||||
|
||||
// Clear Chat System
|
||||
private UUID clearedBy = null;
|
||||
@ -45,8 +45,8 @@ public class ChatManager {
|
||||
// Slow Chat
|
||||
public void slowChat(Player player, int amount) {
|
||||
this.delayAmount = amount;
|
||||
this.delayedBy = player.getUniqueId();
|
||||
this.lastDelayedTime = System.currentTimeMillis();
|
||||
this.slowedBy = player.getUniqueId();
|
||||
this.lastSlowedTime = System.currentTimeMillis();
|
||||
this.broadcastMessage(Constants.CHAT_MANAGEMENT_MESSAGES.get("slowed").get(0).replace("%player%", player.getName()).replace("%amount%", amount + " &csecond" + (amount > 1 ? "s" : "")));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,134 @@
|
||||
package com.loganmagnan.eventcore.menusystem.menus;
|
||||
|
||||
import com.loganmagnan.eventcore.EventCore;
|
||||
import com.loganmagnan.eventcore.menusystem.ItemStackButton;
|
||||
import com.loganmagnan.eventcore.menusystem.Menu;
|
||||
import com.loganmagnan.eventcore.menusystem.PlayerMenuUtil;
|
||||
import com.loganmagnan.eventcore.utils.ColorUtils;
|
||||
import com.loganmagnan.eventcore.utils.Utils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ChatManagementMenu extends Menu {
|
||||
|
||||
private EventCore main = EventCore.getInstance();
|
||||
|
||||
private int delayAmount = 0;
|
||||
|
||||
public ChatManagementMenu(PlayerMenuUtil playerMenuUtil, int delayAmount) {
|
||||
super(playerMenuUtil);
|
||||
|
||||
this.delayAmount = delayAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMenuName() {
|
||||
return ColorUtils.getMessageType("&bChat Management");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return 27;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMenu(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
if (event.getView().getTitle().equalsIgnoreCase(ColorUtils.getMessageType("&bChat Management"))) {
|
||||
switch (event.getCurrentItem().getType()) {
|
||||
case DIAMOND_SWORD:
|
||||
this.main.getChatManager().toggleChat(player);
|
||||
|
||||
break;
|
||||
case SOUL_SAND:
|
||||
if (event.getClick().isLeftClick()) {
|
||||
this.delayAmount++;
|
||||
|
||||
new ChatManagementMenu(this.playerMenuUtil, this.delayAmount).open(player);
|
||||
} else if (event.getClick().isRightClick()) {
|
||||
if (this.delayAmount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.delayAmount--;
|
||||
|
||||
new ChatManagementMenu(this.playerMenuUtil, this.delayAmount).open(player);
|
||||
} else if (event.getClick().isShiftClick()) {
|
||||
this.main.getChatManager().slowChat(player, this.delayAmount);
|
||||
}
|
||||
|
||||
break;
|
||||
case GLASS:
|
||||
this.main.getChatManager().clearChat(player);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMenuItems(Player player) {
|
||||
ItemStackButton muteChatItemStackButton = new ItemStackButton(
|
||||
ColorUtils.getMessageType("&bToggle Chat"),
|
||||
ColorUtils.getMessageType(
|
||||
Arrays.asList(
|
||||
"&fMuted: " + (this.main.getChatManager().isMuted() ? "&aYes" : "&4No"),
|
||||
"&fToggled By: &b" + (this.main.getChatManager().getToggledBy() == null ? "None" : this.main.getServer().getOfflinePlayer(this.main.getChatManager().getToggledBy()).getName()),
|
||||
"&fLast Toggled: &b" + (this.main.getChatManager().getLastToggledTime() == 0 ? "Never" : Utils.getTimeAsAString(this.main.getChatManager().getLastToggledTime())),
|
||||
"",
|
||||
"&bClick to mute the chat"
|
||||
)
|
||||
),
|
||||
Material.DIAMOND_SWORD,
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
||||
ItemStackButton slowChatItemStackButton = new ItemStackButton(
|
||||
ColorUtils.getMessageType("&bSlow Chat"),
|
||||
ColorUtils.getMessageType(
|
||||
Arrays.asList(
|
||||
"&fDelay Amount: &b" + this.main.getChatManager().getDelayAmount(),
|
||||
"&fSlowed By: &b" + (this.main.getChatManager().getSlowedBy() == null ? "None" : this.main.getServer().getOfflinePlayer(this.main.getChatManager().getSlowedBy()).getName()),
|
||||
"&fLast Slowed: &b" + (this.main.getChatManager().getLastSlowedTime() == 0 ? "Never" : Utils.getTimeAsAString(this.main.getChatManager().getLastSlowedTime())),
|
||||
"",
|
||||
"&bShift click to slow the chat for &3" + (this.delayAmount + "second" + (this.delayAmount > 1 ? "s" : "")),
|
||||
"",
|
||||
"&fLeft Click: &b+1",
|
||||
"&fRight Click: &b-1"
|
||||
)
|
||||
),
|
||||
Material.SOUL_SAND,
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
||||
ItemStackButton clearChatItemStackButton = new ItemStackButton(
|
||||
ColorUtils.getMessageType("&bClear Chat"),
|
||||
ColorUtils.getMessageType(
|
||||
Arrays.asList(
|
||||
"&fCleared By: &b" + (this.main.getChatManager().getClearedBy() == null ? "None" : this.main.getServer().getOfflinePlayer(this.main.getChatManager().getClearedBy()).getName()),
|
||||
"&fLast Cleared: &b" + (this.main.getChatManager().getLastClearedTime() == 0 ? "Never" : Utils.getTimeAsAString(this.main.getChatManager().getLastClearedTime())),
|
||||
"",
|
||||
"&bClick to clear the chat"
|
||||
)
|
||||
),
|
||||
Material.GLASS,
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
||||
ItemStack muteChatItemStack = muteChatItemStackButton.makeItemStack();
|
||||
ItemStack slowChatItemStack = slowChatItemStackButton.makeItemStack();
|
||||
ItemStack clearChatItemStack = clearChatItemStackButton.makeItemStack();
|
||||
|
||||
this.setFillerGlass();
|
||||
this.inventory.setItem(11, muteChatItemStack);
|
||||
this.inventory.setItem(13, slowChatItemStack);
|
||||
this.inventory.setItem(15, clearChatItemStack);
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ public class Constants {
|
||||
public static Map<String, List<String>> COMMAND_MESSAGES = new HashMap<String, List<String>>();
|
||||
public static Map<String, List<String>> LISTENER_MESSAGES = new HashMap<String, List<String>>();
|
||||
public static Map<String, List<String>> CHAT_MANAGEMENT_MESSAGES = new HashMap<String, List<String>>();
|
||||
|
||||
public static Map<String, String> PERMISSION_NODES = new HashMap<String, String>();
|
||||
|
||||
public Constants() {
|
||||
|
@ -78,11 +78,11 @@ public class Utils {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public static String getAddedAtDate(long addedAt) {
|
||||
public static String getTimeAsAString(long time) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
|
||||
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("EST"));
|
||||
|
||||
return simpleDateFormat.format(new Date(addedAt));
|
||||
return simpleDateFormat.format(new Date(time));
|
||||
}
|
||||
|
||||
public static List<Block> getBlocks(Location loc1, Location loc2) {
|
||||
|
Loading…
Reference in New Issue
Block a user