Skip to content

Commit

Permalink
Merge pull request #12 from TWME-TW/dev
Browse files Browse the repository at this point in the history
0.4.6 Update to Paper 1.20.6 & Java 21
  • Loading branch information
TWME-TW authored Jun 6, 2024
2 parents 3a264ef + 3d45a7a commit b2ce08a
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

<groupId>dev.twme</groupId>
<artifactId>DebugStickPro</artifactId>
<version>0.4.5</version>
<version>0.4.6</version>
<packaging>jar</packaging>

<name>DebugStickPro</name>

<properties>
<java.version>17</java.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -77,7 +77,7 @@
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,15 @@ public static ArrayList<SubBlockData> separate(BlockData blockData) {
blockDataList.add(turtleEggHatch);
}

if(isValidMaterial("vault")) {
if (blockData instanceof Vault) {
SubBlockData vaultOminous = new VaultOminousData(blockData);
blockDataList.add(vaultOminous);
SubBlockData vaultState = new VaultStateData(blockData);
blockDataList.add(vaultState);
}
}

if (blockData instanceof Wall) {
SubBlockData wallHeightEast = new WallHeightEastData(blockData);
blockDataList.add(wallHeightEast);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package dev.twme.debugstickpro.blockdatautil.subdata;

import dev.twme.debugstickpro.blockdatautil.SubBlockData;
import dev.twme.debugstickpro.localization.Lang;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Vault;

public class VaultOminousData implements SubBlockData {
private final BlockData blockData;
private boolean isUsing = false;
private boolean ominous;

public VaultOminousData(BlockData blockData) {
this.blockData = blockData;
this.ominous = ((Vault) blockData).isOminous();
}

@Override
public String name() {
return getClass().getSimpleName();
}

@Override
public String dataName() {
return Lang.DataKeyName.VaultOminousDataName;
}

@Override
public BlockData getBlockData() {
return blockData;
}

@Override
public String getDataAsString() {
return String.valueOf(ominous);
}

@Override
public SubBlockData setIsUsing(boolean isUsing) {
this.isUsing = isUsing;
return this;
}

@Override
public boolean isUsing() {
return isUsing;
}

@Override
public SubBlockData nextData() {
Vault vault = ((Vault) blockData);
vault.setOminous(!ominous);
ominous = vault.isOminous();
return this;
}

@Override
public SubBlockData previousData() {
return nextData();
}

@Override
public BlockData copyTo(BlockData blockData) {
((Vault) blockData).setOminous(ominous);
return blockData;
}

@Override
public SubBlockData fromBlockData(BlockData blockData) {
return new VaultOminousData(blockData);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package dev.twme.debugstickpro.blockdatautil.subdata;

import dev.twme.debugstickpro.blockdatautil.SubBlockData;
import dev.twme.debugstickpro.localization.Lang;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Vault;

public class VaultStateData implements SubBlockData {
private final BlockData blockData;
private boolean isUsing = false;
private Vault.State state;

public VaultStateData(BlockData blockData) {
this.blockData = blockData;
this.state = ((Vault) blockData).getTrialSpawnerState();
}

@Override
public String name() {
return this.getClass().getSimpleName();
}

@Override
public String dataName() {
return Lang.DataKeyName.VaultStateDataName;
}

@Override
public BlockData getBlockData() {
return blockData;
}

@Override
public String getDataAsString() {
return state.name();
}

@Override
public SubBlockData setIsUsing(boolean isUsing) {
this.isUsing = isUsing;
return this;
}

@Override
public boolean isUsing() {
return isUsing;
}

@Override
public SubBlockData nextData() {
if (state == Vault.State.ACTIVE) {
state = Vault.State.EJECTING;
} else if (state == Vault.State.EJECTING) {
state = Vault.State.INACTIVE;
} else if (state == Vault.State.INACTIVE) {
state = Vault.State.UNLOCKING;
} else if (state == Vault.State.UNLOCKING) {
state = Vault.State.ACTIVE;
}
((Vault) blockData).setTrialSpawnerState(state);
return this;
}

@Override
public SubBlockData previousData() {
if (state == Vault.State.ACTIVE) {
state = Vault.State.UNLOCKING;
} else if (state == Vault.State.UNLOCKING) {
state = Vault.State.INACTIVE;
} else if (state == Vault.State.INACTIVE) {
state = Vault.State.EJECTING;
} else if (state == Vault.State.EJECTING) {
state = Vault.State.ACTIVE;
}
((Vault) blockData).setTrialSpawnerState(state);
return this;
}

@Override
public BlockData copyTo(BlockData blockData) {
((Vault) blockData).setTrialSpawnerState(state);
return blockData;
}

@Override
public SubBlockData fromBlockData(BlockData blockData) {
return new VaultStateData(blockData);
}
}
2 changes: 2 additions & 0 deletions src/main/java/dev/twme/debugstickpro/localization/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public final static class DataKeyName {
public final static String TrialSpawnerDataName = "DataKeyName.TrialSpawnerDataName";
public final static String TripwireDataName = "DataKeyName.TripwireDataName";
public final static String TurtleEggDataName = "DataKeyName.TurtleEggDataName";
public final static String VaultStateDataName = "DataKeyName.VaultStateDataName";
public final static String VaultOminousDataName = "DataKeyName.VaultOminousDataName";
public final static String WallHeightEastDataName = "DataKeyName.WallHeightEastDataName";
public final static String WallHeightNorthDataName = "DataKeyName.WallHeightNorthDataName";
public final static String WallHeightSouthDataName = "DataKeyName.WallHeightSouthDataName";
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/lang/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ DataKeyName:
TrialSpawnerDataName: "State"
TripwireDataName: "Disarmed"
TurtleEggDataName: "Eggs"
VaultStateDataName: "Vault State"
VaultOminousDataName: "Ominous"
WallHeightEastDataName: "East"
WallHeightNorthDataName: "North"
WallHeightSouthDataName: "South"
Expand Down

0 comments on commit b2ce08a

Please sign in to comment.