Skip to content

Commit

Permalink
[v1.0.7] ScriptBlockPlus v2.0.3に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
yuttyann committed Dec 25, 2020
1 parent dc580fe commit bbc9d92
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>com.github.yuttyann</groupId>
<name>ScriptEntityPlus</name>
<artifactId>ScriptEntityPlus</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>

<licenses>
<license>
Expand Down Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>com.github.yuttyann</groupId>
<artifactId>ScriptBlockPlus</artifactId>
<version>v2.0.2</version>
<version>v2.0.3</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

public class ScriptEntity extends JavaPlugin {

public static final String SBP_VERSION = "2.0.2";
public static final String SBP_VERSION = "2.0.3";

private Updater updater;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
package com.github.yuttyann.scriptentityplus.script;

import com.github.yuttyann.scriptblockplus.event.ScriptReadEndEvent;
import com.github.yuttyann.scriptblockplus.event.ScriptReadStartEvent;
import com.github.yuttyann.scriptblockplus.file.config.SBConfig;
import com.github.yuttyann.scriptblockplus.file.json.PlayerCountJson;
import com.github.yuttyann.scriptblockplus.file.json.element.PlayerCount;
import com.github.yuttyann.scriptblockplus.manager.EndProcessManager;
import com.github.yuttyann.scriptblockplus.manager.OptionManager;
import com.github.yuttyann.scriptblockplus.script.SBRead;
import com.github.yuttyann.scriptblockplus.script.ScriptMap;
import com.github.yuttyann.scriptblockplus.script.ScriptRead;
import com.github.yuttyann.scriptblockplus.script.ScriptType;
import com.github.yuttyann.scriptblockplus.script.option.Option;
import com.github.yuttyann.scriptblockplus.utils.StreamUtils;
import com.github.yuttyann.scriptblockplus.utils.StringUtils;
import com.github.yuttyann.scriptblockplus.utils.unmodifiable.UnmodifiableLocation;
import com.github.yuttyann.scriptentityplus.ScriptEntity;
import com.github.yuttyann.scriptentityplus.listener.EntityListener;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.jetbrains.annotations.NotNull;

import java.util.List;
Expand Down Expand Up @@ -50,22 +59,34 @@ public boolean read(int index) {
SBConfig.CONSOLE_ERROR_SCRIPT_EXECUTE.replace(sbPlayer.getName(), scriptLocation, scriptType).console();
return false;
}
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.callEvent(new ScriptReadStartEvent(ramdomId, this));
try {
return perform(index);
} finally {
pluginManager.callEvent(new ScriptReadEndEvent(ramdomId, this));
StreamUtils.filter(this, SBRead::isInitialize, ScriptMap::clear);
}
}

@Override
protected boolean perform(int index) {
for (scriptIndex = index; scriptIndex < script.size(); scriptIndex++) {
if (!sbPlayer.isOnline()) {
executeEndProcess(e -> e.failed(this));
EndProcessManager.forEach(e -> e.failed(this));
return false;
}
String script = replace(this.script.get(scriptIndex));
Option option = OptionManager.newInstance(script);
optionValue = setPlaceholders(getSBPlayer(), option.getValue(script));
if (!hasPermission(option) || !option.callOption(this)) {
if (!option.isFailedIgnore()) {
executeEndProcess(e -> e.failed(this));
EndProcessManager.forEach(e -> e.failed(this));
}
return false;
}
}
executeEndProcess(e -> e.success(this));
EndProcessManager.forEach(e -> e.success(this));
new PlayerCountJson(sbPlayer.getUniqueId()).action(PlayerCount::add, scriptLocation, scriptType);
SBConfig.CONSOLE_SUCCESS_SCRIPT_EXECUTE.replace(sbPlayer.getName(), scriptLocation, scriptType).console();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected boolean isValid() throws Exception {
if (saveDelay) {
Delay.DELAY_SET.add(newTimerTemp());
}
((SBRead) getTempMap()).setInitialize(false);
Bukkit.getScheduler().runTaskLater(ScriptBlock.getInstance(), this, Long.parseLong(array[0]));
}
return false;
Expand All @@ -51,9 +52,10 @@ public void run() {
}
SBRead sbRead = (SBRead) getTempMap();
if (getSBPlayer().isOnline()) {
sbRead.setInitialize(true);
sbRead.read(getScriptIndex() + 1);
} else {
EndProcessManager.forEach(e -> e.failed(sbRead));
EndProcessManager.forEachFinally(e -> e.failed(sbRead), () -> sbRead.clear());
}
}

Expand Down

0 comments on commit bbc9d92

Please sign in to comment.