Merge branch 'master' into 1.16
This commit is contained in:
commit
39a85976fd
7 files changed
+28
-19
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package carpet.script;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.value.BlockValue;
|
||||
import carpet.script.value.EntityValue;
|
||||
@@ -88,21 +89,33 @@ public class CarpetEventServer
|
||||
this.dueTime = dueTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* used in scheduled calls
|
||||
*/
|
||||
public void execute()
|
||||
{
|
||||
CarpetServer.scriptServer.runas(ctx.origin, ctx.s, host, function, lazify(args));
|
||||
}
|
||||
|
||||
public void execute(List<Value> args)
|
||||
/**
|
||||
* Used in entity events
|
||||
* @param asSource - entity command source
|
||||
* @param args = options
|
||||
*/
|
||||
public void execute(ServerCommandSource asSource, List<Value> args)
|
||||
{
|
||||
if (this.args == null || this.args.isEmpty())
|
||||
CarpetServer.scriptServer.runas(ctx.origin, ctx.s, host, function, lazify(args));
|
||||
CarpetServer.scriptServer.runas(
|
||||
ctx.origin, asSource.withLevel(CarpetSettings.runPermissionLevel),
|
||||
host, function, lazify(args));
|
||||
else
|
||||
{
|
||||
List<Value> combinedArgs = new ArrayList<>();
|
||||
combinedArgs.addAll(args);
|
||||
combinedArgs.addAll(this.args);
|
||||
CarpetServer.scriptServer.runas(ctx.origin, ctx.s, host, function, lazify(combinedArgs));
|
||||
CarpetServer.scriptServer.runas(
|
||||
ctx.origin, asSource.withLevel(CarpetSettings.runPermissionLevel),
|
||||
host, function, lazify(combinedArgs));
|
||||
}
|
||||
}
|
||||
private List<LazyValue> lazify(List<Value> args)
|
||||
|
||||
@@ -22,12 +22,14 @@ import java.util.stream.Collectors;
|
||||
public class EntityEventsGroup
|
||||
{
|
||||
private final Map<EntityEventType, Map<String, CarpetEventServer.ScheduledCall>> actions;
|
||||
public EntityEventsGroup()
|
||||
private Entity entity;
|
||||
public EntityEventsGroup(Entity e)
|
||||
{
|
||||
actions = new EnumMap<>(EntityEventType.class);
|
||||
entity = e;
|
||||
}
|
||||
|
||||
public void onEvent(EntityEventType type, Entity entity, Object ... args)
|
||||
public void onEvent(EntityEventType type, Object... args)
|
||||
{
|
||||
if (actions.isEmpty()) return; // most of the cases, trying to be nice
|
||||
Map<String, CarpetEventServer.ScheduledCall> actionSet = actions.get(type);
|
||||
@@ -116,7 +118,7 @@ public class EntityEventsGroup
|
||||
public void call(CarpetEventServer.ScheduledCall tickCall, Entity entity, Object ... args)
|
||||
{
|
||||
assert args.length == argcount-1;
|
||||
tickCall.execute(makeArgs(entity, args));
|
||||
tickCall.execute(entity.getCommandSource(), makeArgs(entity, args));
|
||||
}
|
||||
protected List<Value> makeArgs(Entity entity, Object ... args)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user