-
-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a new Byte datafield. (#5714)
* Create a new Byte datafield. * Clear errer in metadataloader, fill out metadatautil. * Javadoc fix Co-authored-by: Llm Dl <LlmDlio@gmail.com>
- Loading branch information
1 parent
2801070
commit 04cc8a6
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/com/palmergames/bukkit/towny/object/metadata/ByteDataField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.palmergames.bukkit.towny.object.metadata; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ByteDataField extends CustomDataField<Byte> { | ||
|
||
public ByteDataField(String key) { | ||
super(key); | ||
} | ||
|
||
public ByteDataField(String key, byte value, String label) { | ||
super(key, value, label); | ||
} | ||
|
||
public ByteDataField(String key, byte value) { | ||
super(key, value); | ||
} | ||
|
||
@Override | ||
public @NotNull String getTypeID() { | ||
return typeID(); | ||
} | ||
|
||
public static String typeID() { | ||
return "towny_bytedf"; | ||
} | ||
|
||
@Override | ||
public void setValueFromString(String strValue) { | ||
setValue(Byte.parseByte(strValue)); | ||
} | ||
|
||
@Override | ||
public boolean canParseFromString(String str) { | ||
try { | ||
Byte.parseByte(str); | ||
} catch (NumberFormatException e) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public String displayFormattedValue() { | ||
return String.valueOf(getValue()); | ||
} | ||
|
||
@Override | ||
public @NotNull CustomDataField<Byte> clone() { | ||
return new ByteDataField(getKey(), getValue(), this.label); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters