mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Precache decree help
This commit is contained in:
parent
49154759c0
commit
26cb21f541
@ -19,6 +19,7 @@
|
|||||||
package com.volmit.iris.core.service;
|
package com.volmit.iris.core.service;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.commands.CommandIris;
|
import com.volmit.iris.core.commands.CommandIris;
|
||||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||||
import com.volmit.iris.util.decree.DecreeSystem;
|
import com.volmit.iris.util.decree.DecreeSystem;
|
||||||
@ -29,6 +30,7 @@ public class CommandSVC implements IrisService, DecreeSystem {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Iris.instance.getCommand("iris").setExecutor(this);
|
Iris.instance.getCommand("iris").setExecutor(this);
|
||||||
|
getRoot().cacheAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,14 +31,19 @@ import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
|||||||
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
|
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
|
import com.volmit.iris.util.plugin.CommandDummy;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
|
import com.volmit.iris.util.stream.utility.SemaphoreStream;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class VirtualDecreeCommand {
|
public class VirtualDecreeCommand {
|
||||||
@ -96,6 +101,23 @@ public class VirtualDecreeCommand {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ChronoLatch cl = new ChronoLatch(1000);
|
||||||
|
|
||||||
|
public void cacheAll()
|
||||||
|
{
|
||||||
|
VolmitSender sender = new VolmitSender(new CommandDummy());
|
||||||
|
|
||||||
|
if(isNode())
|
||||||
|
{
|
||||||
|
J.a(() -> sender.sendDecreeHelpNode(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(VirtualDecreeCommand j : nodes)
|
||||||
|
{
|
||||||
|
j.cacheAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
KList<String> n = new KList<>();
|
KList<String> n = new KList<>();
|
||||||
VirtualDecreeCommand cursor = this;
|
VirtualDecreeCommand cursor = this;
|
||||||
|
141
src/main/java/com/volmit/iris/util/plugin/CommandDummy.java
Normal file
141
src/main/java/com/volmit/iris/util/plugin/CommandDummy.java
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.util.plugin;
|
||||||
|
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.permissions.Permission;
|
||||||
|
import org.bukkit.permissions.PermissionAttachment;
|
||||||
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CommandDummy implements CommandSender {
|
||||||
|
@Override
|
||||||
|
public void sendMessage(@NotNull String message) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(@NotNull String... messages) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(@Nullable UUID sender, @NotNull String message) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(@Nullable UUID sender, @NotNull String... messages) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Server getServer() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Spigot spigot() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPermissionSet(@NotNull String name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPermissionSet(@NotNull Permission perm) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(@NotNull String name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(@NotNull Permission perm) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public PermissionAttachment addAttachment(@NotNull Plugin plugin) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAttachment(@NotNull PermissionAttachment attachment) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void recalculatePermissions() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOp() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOp(boolean value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -297,6 +297,11 @@ public class VolmitSender implements CommandSender {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
|
if(s instanceof CommandDummy)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (message.contains("<NOMINI>")) {
|
if (message.contains("<NOMINI>")) {
|
||||||
s.sendMessage(message.replaceAll("\\Q<NOMINI>\\E", ""));
|
s.sendMessage(message.replaceAll("\\Q<NOMINI>\\E", ""));
|
||||||
return;
|
return;
|
||||||
@ -318,6 +323,11 @@ public class VolmitSender implements CommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessageRaw(String message) {
|
public void sendMessageRaw(String message) {
|
||||||
|
if(s instanceof CommandDummy)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (message.contains("<NOMINI>")) {
|
if (message.contains("<NOMINI>")) {
|
||||||
s.sendMessage(message.replaceAll("\\Q<NOMINI>\\E", ""));
|
s.sendMessage(message.replaceAll("\\Q<NOMINI>\\E", ""));
|
||||||
return;
|
return;
|
||||||
@ -469,10 +479,11 @@ public class VolmitSender implements CommandSender {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static final KMap<String, String> helpCache = new KMap<>();
|
private static final KMap<String, String> helpCache = new KMap<>();
|
||||||
|
|
||||||
public void sendDecreeHelpNode(VirtualDecreeCommand i) {
|
public void sendDecreeHelpNode(VirtualDecreeCommand i) {
|
||||||
if (isPlayer()) {
|
if (isPlayer() || s instanceof CommandDummy) {
|
||||||
sendMessageRaw(helpCache.compute(i.getPath(), (k, v) -> {
|
sendMessageRaw(helpCache.compute(i.getPath(), (k, v) -> {
|
||||||
if(v != null)
|
if(v != null)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user