Skip to content

Commit

Permalink
v1.0.9 パフォーマンスモードの追加 + dependの修正(#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
bea4dev committed Aug 26, 2021
1 parent 7d71d0f commit 71895b5
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>com.github.Be4rJP</groupId>
<artifactId>Parallel</artifactId>
<version>v1.0.8</version>
<version>v1.0.9</version>
<scope>provided</scope>
</dependency>
```
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>be4rjp</groupId>
<artifactId>Parallel</artifactId>
<version>1.0.8</version>
<version>1.0.9</version>
<packaging>jar</packaging>

<name>Parallel</name>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/be4rjp/parallel/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ public class Config {

private static WorkType workType = WorkType.NORMAL;

private static boolean performanceMode = false;

public static WorkType getWorkType() {return workType;}

public static boolean isPerformanceMode() {return performanceMode;}

public static void load(){
File file = new File("plugins/Parallel", "config.yml");
file.getParentFile().mkdirs();
Expand All @@ -22,6 +26,7 @@ public static void load(){
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);

if(yml.contains("work-type")) workType = WorkType.valueOf(yml.getString("work-type"));
if(yml.contains("performance-mode")) performanceMode = yml.getBoolean("performance-mode");
}

public enum WorkType{
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/be4rjp/parallel/Parallel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import be4rjp.parallel.command.parallelCommandExecutor;
import be4rjp.parallel.structure.ParallelStructure;
import be4rjp.parallel.structure.StructureData;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

Expand All @@ -25,10 +26,12 @@ public void onEnable() {
pluginManager.registerEvents(new EventListener(), this);


//Register command executors
getLogger().info("Registering command executors...");
getCommand("parallel").setExecutor(new parallelCommandExecutor());
getCommand("parallel").setTabCompleter(new parallelCommandExecutor());
if(Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
//Register command executors
getLogger().info("Registering command executors...");
getCommand("parallel").setExecutor(new parallelCommandExecutor());
getCommand("parallel").setTabCompleter(new parallelCommandExecutor());
}


//For cinema4c extensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package be4rjp.parallel.nms.manager;

import be4rjp.parallel.Config;
import be4rjp.parallel.ParallelWorld;
import be4rjp.parallel.nms.NMSUtil;
import be4rjp.parallel.nms.PacketHandler;
Expand Down Expand Up @@ -78,7 +79,7 @@ public void run() {

ChunkLocation chunkLocation = new ChunkLocation(player.getWorld(), chunkPosition.x << 4, chunkPosition.z << 4);
Object editedPacket = parallelWorld.getEditedPacketForChunkMap().get(chunkLocation);
if(editedPacket != null){
if(editedPacket != null && Config.isPerformanceMode()){
packetHandler.doWrite(channelHandlerContext, editedPacket, channelPromise);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package be4rjp.parallel.nms.manager;

import be4rjp.parallel.Config;
import be4rjp.parallel.ParallelWorld;
import be4rjp.parallel.nms.NMSUtil;
import be4rjp.parallel.nms.PacketHandler;
Expand Down Expand Up @@ -119,7 +120,7 @@ public void run() {

ChunkLocation chunkLocation = new ChunkLocation(player.getWorld(), chunkPosition.x << 4, chunkPosition.z << 4);
Object editedPacket = parallelWorld.getEditedPacketForLightMap().get(chunkLocation);
if(editedPacket != null){
if(editedPacket != null && Config.isPerformanceMode()){
packetHandler.doWrite(channelHandlerContext, editedPacket, channelPromise);
return;
}
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
# NORMAL or ONLY_ONE
# ONLY_ONEに設定した場合は全てのプレイヤーに対して同じParallelWorldが使われるようになります

work-type: NORMAL
work-type: NORMAL


# パフォーマンスモードを使用するかどうかの設定
# このプラグイン以外でブロックの設置が行われる可能性のある場合は false 推奨

performance-mode: false
3 changes: 1 addition & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Parallel
version: ${project.version}
main: be4rjp.parallel.Parallel
api-version: 1.15
softdepend: [Multiverse-Core, Cinema4C]
depend: [WorldEdit]
softdepend: [WorldEdit, Multiverse-Core, Cinema4C]
#--------------------------------------
commands:
parallel:
Expand Down

0 comments on commit 71895b5

Please sign in to comment.