Async changes & Bug fixes
Made diamond radius search async Fixed join listener firing accept twicemaster
parent
0920ecce90
commit
7cdf9509ae
8
pom.xml
8
pom.xml
|
@ -160,6 +160,14 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>8</source>
|
||||||
|
<target>8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
|
@ -1,11 +1,11 @@
|
||||||
package xyz.etztech.minecraftmanager.listeners;
|
package xyz.etztech.minecraftmanager.listeners;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
@ -45,7 +45,9 @@ public class AsyncPlayerChatListener implements Listener {
|
||||||
String chat = event.getMessage();
|
String chat = event.getMessage();
|
||||||
boolean applyChat = MinecraftManager.inApplyMode(sender.getUniqueId().toString());
|
boolean applyChat = MinecraftManager.inApplyMode(sender.getUniqueId().toString());
|
||||||
|
|
||||||
TextComponent pre = new TextComponent(ChatColor.GOLD + sender.getName() + " > ");
|
ComponentBuilder message = new ComponentBuilder("");
|
||||||
|
|
||||||
|
message.append(sender.getName() + " > ").color(ChatColor.GOLD);
|
||||||
if (!applyChat) {
|
if (!applyChat) {
|
||||||
boolean hasPermission = sender.hasPermission("minecraftmanager.staff");
|
boolean hasPermission = sender.hasPermission("minecraftmanager.staff");
|
||||||
boolean singlePrefix = false;
|
boolean singlePrefix = false;
|
||||||
|
@ -65,19 +67,18 @@ public class AsyncPlayerChatListener implements Listener {
|
||||||
chat = chat.replaceFirst(Pattern.quote(prefix), "");
|
chat = chat.replaceFirst(Pattern.quote(prefix), "");
|
||||||
}
|
}
|
||||||
HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create());
|
HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create());
|
||||||
pre.setHoverEvent(hover);
|
message.event(hover);
|
||||||
TextComponent message = generateMessage(chat);
|
message.append(chat).color(ChatColor.GREEN).event(hover);
|
||||||
message.setHoverEvent(hover);
|
|
||||||
for (Player player : event.getRecipients()) {
|
for (Player player : event.getRecipients()) {
|
||||||
if (player.hasPermission("minecraftmanager.staff")) {
|
if (player.hasPermission("minecraftmanager.staff")) {
|
||||||
player.spigot().sendMessage(pre, message);
|
player.spigot().sendMessage(message.create());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MCMUtil.log(MCMUtil.staffLog, componentText(pre, message));
|
MCMUtil.log(MCMUtil.staffLog, componentText(message.create()));
|
||||||
} else {
|
} else {
|
||||||
TextComponent message = generateMessage(chat);
|
message.append(chat);
|
||||||
if (!MinecraftManager.getLogOverride()) {
|
if (!MinecraftManager.getLogOverride()) {
|
||||||
MCMUtil.log(MCMUtil.globalLog, componentText(pre, message));
|
MCMUtil.log(MCMUtil.globalLog, componentText(message.create()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -153,13 +154,7 @@ public class AsyncPlayerChatListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TextComponent generateMessage(String message) {
|
|
||||||
TextComponent text = new TextComponent();
|
|
||||||
for (String part : message.split(" ")) {
|
|
||||||
text.addExtra(new TextComponent(ChatColor.GREEN + part + " "));
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> trimmed(List<String> list) {
|
private List<String> trimmed(List<String> list) {
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package xyz.etztech.minecraftmanager.listeners;
|
package xyz.etztech.minecraftmanager.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -25,15 +26,19 @@ public class BlockBreakListener implements Listener {
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
boolean isDiamond = Material.DIAMOND_ORE == block.getType();
|
if (Material.DIAMOND_ORE == block.getType()) {
|
||||||
if (isDiamond) {
|
if (MinecraftManager.addDiamond(getLocationString(block))) {
|
||||||
boolean notify = MinecraftManager.addDiamond(getLocationString(block));
|
|
||||||
for (Block radiusBlock : getBlocks(block, 5)) {
|
|
||||||
MinecraftManager.addDiamond(getLocationString(radiusBlock));
|
|
||||||
}
|
|
||||||
if (notify) {
|
|
||||||
plugin.log("[OreAlert]: " + event.getPlayer().getName());
|
plugin.log("[OreAlert]: " + event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
|
for (Block radiusBlock : getBlocks(block, 5)) {
|
||||||
|
if (Material.DIAMOND_ORE == radiusBlock.getType()) {
|
||||||
|
MinecraftManager.addDiamond(getLocationString(radiusBlock));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,14 +45,6 @@ public class SessionListener implements Listener {
|
||||||
Map<String, String> filters = MCMAPI.setup();
|
Map<String, String> filters = MCMAPI.setup();
|
||||||
filters.put("username__iexact", player.getName());
|
filters.put("username__iexact", player.getName());
|
||||||
CoreWeb.asyncGetCallback(plugin, MCMAPI.getModelUrl("application"), filters, new JoinCallback(player.getName()));
|
CoreWeb.asyncGetCallback(plugin, MCMAPI.getModelUrl("application"), filters, new JoinCallback(player.getName()));
|
||||||
JsonArray query = MCMAPI.queryModel("application", filters);
|
|
||||||
if (query.size() == 1) {
|
|
||||||
JsonElement element = query.get(0).getAsJsonObject().get("accepted");
|
|
||||||
boolean accepted = !element.isJsonNull() && element.getAsBoolean();
|
|
||||||
if (accepted) {
|
|
||||||
MinecraftManagerThread.action(player.getName(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue