-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
279 additions
and
34 deletions.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
...leearth/architect/specialBlockHandling/customInventories/editor/prompt/add/CmdPrompt.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,35 @@ | ||
package com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.add; | ||
|
||
import com.mcmiddleearth.pluginutil.NumericUtil; | ||
import org.bukkit.conversations.ConversationContext; | ||
import org.bukkit.conversations.Prompt; | ||
import org.bukkit.conversations.ValidatingPrompt; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class CmdPrompt extends ValidatingPrompt { | ||
|
||
@Override | ||
protected boolean isInputValid(@NotNull ConversationContext conversationContext, @NotNull String input) { | ||
return input.equalsIgnoreCase("!skip") | ||
|| NumericUtil.isInt(input) && NumericUtil.getInt(input)>-1; | ||
} | ||
|
||
@Override | ||
protected @Nullable Prompt acceptValidatedInput(@NotNull ConversationContext conversationContext, @NotNull String input) { | ||
if(!input.equalsIgnoreCase("!skip")) { | ||
conversationContext.setSessionData("cmd",NumericUtil.getInt(input)); | ||
} | ||
return new ColorPrompt(); //todo: only for leather | ||
} | ||
|
||
@Override | ||
public @NotNull String getPromptText(@NotNull ConversationContext conversationContext) { | ||
return "Type in a value for custom model data or '!skip'"; //todo prompt current cmd | ||
} | ||
|
||
@Override | ||
protected @Nullable String getFailedValidationText(@NotNull ConversationContext context, @NotNull String invalidInput) { | ||
return "You need to type in a not negative integer or '!skip'."; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...earth/architect/specialBlockHandling/customInventories/editor/prompt/add/ColorPrompt.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,30 @@ | ||
package com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.add; | ||
|
||
import com.mcmiddleearth.pluginutil.NumericUtil; | ||
import org.bukkit.conversations.ConversationContext; | ||
import org.bukkit.conversations.Prompt; | ||
import org.bukkit.conversations.ValidatingPrompt; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ColorPrompt extends ValidatingPrompt { | ||
|
||
@Override | ||
protected boolean isInputValid(@NotNull ConversationContext conversationContext, @NotNull String input) { | ||
return input.equalsIgnoreCase("!skip") | ||
|| NumericUtil.isInt(input) && NumericUtil.getInt(input)>-1; | ||
} | ||
|
||
@Override | ||
protected @Nullable Prompt acceptValidatedInput(@NotNull ConversationContext conversationContext, @NotNull String input) { | ||
if(!input.equalsIgnoreCase("!skip")) { | ||
conversationContext.setSessionData("color", NumericUtil.getInt(input)); | ||
} | ||
return new DisplayPrompt(); | ||
} | ||
|
||
@Override | ||
public @NotNull String getPromptText(@NotNull ConversationContext conversationContext) { | ||
return "Type in a color for leather armor or '!skip'"; | ||
} | ||
} |
19 changes: 12 additions & 7 deletions
19
...eearth/architect/specialBlockHandling/customInventories/editor/prompt/add/ItemPrompt.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 |
---|---|---|
@@ -1,26 +1,31 @@ | ||
package com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.add; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.conversations.ConversationContext; | ||
import org.bukkit.conversations.FixedSetPrompt; | ||
import org.bukkit.conversations.Prompt; | ||
import org.bukkit.conversations.ValidatingPrompt; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ItemPrompt extends FixedSetPrompt { | ||
|
||
public ItemPrompt() { | ||
super("ok"); | ||
} | ||
public class ItemPrompt extends ValidatingPrompt { | ||
|
||
@Override | ||
protected @Nullable Prompt acceptValidatedInput(@NotNull ConversationContext conversationContext, @NotNull String input) { | ||
conversationContext.setSessionData("inventoryItem", ((Player)conversationContext.getForWhom()).getInventory().getItemInMainHand()); | ||
return new DisplayPrompt(); | ||
return new CmdPrompt(); | ||
} | ||
|
||
@Override | ||
protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) { | ||
return !((Player)context.getForWhom()).getInventory().getItemInMainHand().getType().equals(Material.AIR) | ||
&& input.equalsIgnoreCase("ok"); | ||
|
||
} | ||
|
||
@Override | ||
public @NotNull String getPromptText(@NotNull ConversationContext conversationContext) { | ||
return "Hold the item you want to add to custom inventory in main hand and type 'ok'"; | ||
return "Hold the item you want to add to custom inventory in main hand and type 'ok'."; | ||
} | ||
} |
25 changes: 24 additions & 1 deletion
25
...tect/specialBlockHandling/customInventories/editor/prompt/edit/ChangeBlockDataPrompt.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 |
---|---|---|
@@ -1,4 +1,27 @@ | ||
package com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.edit; | ||
|
||
public class ChangeBlockDataPrompt { | ||
import com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.add.BlockDataPrompt; | ||
import org.bukkit.conversations.ConversationContext; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Arrays; | ||
|
||
public class ChangeBlockDataPrompt extends BlockDataPrompt { | ||
|
||
public ChangeBlockDataPrompt(String... blockStateKeys) { | ||
super(blockStateKeys); | ||
} | ||
|
||
@Override | ||
public @NotNull String getPromptText(@NotNull ConversationContext conversationContext) { | ||
return "Current blockData"+getBlockStateKeys()[0]+" is " | ||
+conversationContext.getSessionData(getBlockStateKeys()[0])+". Left-click a block to use for blockData"+getBlockStateKeys()[0]+". Or type !skip!"; | ||
} | ||
|
||
private static String[] getFixedSet(String[] blockstateKeys) { | ||
String[] result = Arrays.copyOf(blockstateKeys, blockstateKeys.length+1); | ||
result[result.length-1] = "!skip"; | ||
return result; | ||
} | ||
|
||
} |
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
36 changes: 23 additions & 13 deletions
36
...tect/specialBlockHandling/customInventories/editor/prompt/edit/ChangeBlockTypePrompt.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 |
---|---|---|
@@ -1,37 +1,47 @@ | ||
package com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.edit; | ||
|
||
import com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.add.BlockDataPrompt; | ||
import com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.add.ItemPrompt; | ||
import com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.add.BlockTypePrompt; | ||
import org.bukkit.conversations.ConversationContext; | ||
import org.bukkit.conversations.FixedSetPrompt; | ||
import org.bukkit.conversations.Prompt; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Arrays; | ||
|
||
public class ChangeBlockTypePrompt extends FixedSetPrompt { | ||
|
||
public ChangeBlockTypePrompt() { | ||
super("block", "bisected", "four_directions", "three_axis", "vanilla", "!skip"); | ||
super(getFixedSet()); | ||
} | ||
|
||
@Override | ||
protected @Nullable Prompt acceptValidatedInput(@NotNull ConversationContext conversationContext, @NotNull String input) { | ||
if(!input.equalsIgnoreCase("!skip")) { | ||
conversationContext.setSessionData("type",input); | ||
} | ||
return switch(input) { | ||
case "block" -> new ChangeBlockDataPrompt(""); | ||
case "bisected" -> new ChangeBlockDataPrompt("Up", "Down"); | ||
case "four_directions" -> new ChangeBlockDataPrompt("North", "West", "South", "East"); | ||
case "three_axis" -> new ChangeBlockDataPrompt("X", "Y", "Z"); | ||
case "six_faces" -> new Chan | ||
case "vanilla" -> new ChangeItemPrompt(); | ||
default -> END_OF_CONVERSATION; | ||
}; | ||
for (String[] blockDatum : BlockTypePrompt.blockData) { | ||
if (input.equalsIgnoreCase(blockDatum[0])) { | ||
String[] blockOrientations = Arrays.copyOfRange(blockDatum, 1, blockDatum.length); | ||
if(blockOrientations.length == 0) { | ||
return new ChangeItemPrompt(); | ||
} else { | ||
return new ChangeBlockDataPrompt(blockOrientations); | ||
} | ||
} | ||
} | ||
return END_OF_CONVERSATION; | ||
} | ||
|
||
@Override | ||
public @NotNull String getPromptText(@NotNull ConversationContext conversationContext) { | ||
return "Type in a new block type or '!skip'"; | ||
return "Current block type is "+conversationContext.getSessionData("type") | ||
+". Type in a new block type or '!skip' "+formatFixedSet(); | ||
} | ||
|
||
private static String[] getFixedSet() { | ||
String[] result = Arrays.copyOf(BlockTypePrompt.getBlockTypes(), BlockTypePrompt.getBlockTypes().length+1); | ||
result[result.length-1] = "!skip"; | ||
return result; | ||
} | ||
} |
25 changes: 24 additions & 1 deletion
25
...pecialBlockHandling/customInventories/editor/prompt/edit/ChangeCategoryVisiblePrompt.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 |
---|---|---|
@@ -1,4 +1,27 @@ | ||
package com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.edit; | ||
|
||
public class ChangeCategoryVisiblePrompt { | ||
import org.bukkit.conversations.ConversationContext; | ||
import org.bukkit.conversations.FixedSetPrompt; | ||
import org.bukkit.conversations.Prompt; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ChangeCategoryVisiblePrompt extends FixedSetPrompt { | ||
|
||
public ChangeCategoryVisiblePrompt() { | ||
super("yes", "no", "!skip"); | ||
} | ||
|
||
@Override | ||
protected @Nullable Prompt acceptValidatedInput(@NotNull ConversationContext conversationContext, @NotNull String input) { | ||
if(!input.equalsIgnoreCase("!skip")) { | ||
conversationContext.setSessionData("inCategory", input.equalsIgnoreCase("yes")); | ||
} | ||
return END_OF_CONVERSATION; | ||
} | ||
|
||
@Override | ||
public @NotNull String getPromptText(@NotNull ConversationContext conversationContext) { | ||
return "Should the inventory item be listed directly in the category of it's collection? "+formatFixedSet(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
.../architect/specialBlockHandling/customInventories/editor/prompt/edit/ChangeCmdPrompt.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,21 @@ | ||
package com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.edit; | ||
|
||
import com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.add.CmdPrompt; | ||
import org.bukkit.conversations.ConversationContext; | ||
import org.bukkit.conversations.Prompt; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ChangeCmdPrompt extends CmdPrompt { | ||
|
||
@Override | ||
public @NotNull String getPromptText(@NotNull ConversationContext conversationContext) { | ||
return "Current custom model data is "+conversationContext.getSessionData("cmd")+". Type in a new custom model data or '!skip'"; | ||
} | ||
|
||
@Override | ||
protected @Nullable Prompt acceptValidatedInput(@NotNull ConversationContext conversationContext, @NotNull String input) { | ||
super.acceptValidatedInput(conversationContext, input); | ||
return new ChangeColorPrompt(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...rchitect/specialBlockHandling/customInventories/editor/prompt/edit/ChangeColorPrompt.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,21 @@ | ||
package com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.edit; | ||
|
||
import com.mcmiddleearth.architect.specialBlockHandling.customInventories.editor.prompt.add.ColorPrompt; | ||
import org.bukkit.conversations.ConversationContext; | ||
import org.bukkit.conversations.Prompt; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ChangeColorPrompt extends ColorPrompt { | ||
|
||
@Override | ||
public @NotNull String getPromptText(@NotNull ConversationContext conversationContext) { | ||
return "Current color is "+conversationContext.getSessionData("color")+". Type in a new color or '!skip'"; | ||
} | ||
|
||
@Override | ||
protected @Nullable Prompt acceptValidatedInput(@NotNull ConversationContext conversationContext, @NotNull String input) { | ||
super.acceptValidatedInput(conversationContext, input); | ||
return new ChangeDisplayPrompt(); | ||
} | ||
} |
Oops, something went wrong.