-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,972 additions
and
1,537 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
109 changes: 63 additions & 46 deletions
109
...anadu/slimefunrecipe/SlimeRecipeType.java → ...anadu/slimefunrecipe/SlimeRecipeType.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,46 +1,63 @@ | ||
package xanadu.slimefunrecipe; | ||
|
||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
public enum SlimeRecipeType { | ||
ancient_altar, | ||
armor_forge, | ||
barter_drop, | ||
compressor, | ||
enhanced_crafting_table, | ||
food_composter, | ||
food_fabricator, | ||
freezer, | ||
geo_miner, | ||
gold_pan, | ||
grind_stone, | ||
heated_pressure_chamber, | ||
interact, | ||
juicer, | ||
magic_workbench, | ||
mob_drop, | ||
multiblock, | ||
nuclear_reactor, | ||
NULL, | ||
ore_crusher, | ||
ore_washer, | ||
pressure_chamber, | ||
refinery, | ||
smeltery, | ||
_unknown; | ||
public static final Map<String, SlimeRecipeType> mp = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); | ||
public static SlimeRecipeType getByName(String str){ | ||
if(str == null) return _unknown; | ||
str=str.toLowerCase(); | ||
if("null".equals(str)) return NULL; | ||
return mp.getOrDefault(str,_unknown); | ||
} | ||
static{ | ||
SlimeRecipeType[] values = values(); | ||
for (SlimeRecipeType recipeType : values) { | ||
String name = recipeType.name(); | ||
mp.put(name, recipeType); | ||
} | ||
} | ||
} | ||
package pers.xanadu.slimefunrecipe; | ||
|
||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
public enum SlimeRecipeType { | ||
ancient_altar, | ||
armor_forge, | ||
barter_drop, | ||
compressor, | ||
enhanced_crafting_table, | ||
food_composter, | ||
food_fabricator, | ||
freezer, | ||
geo_miner, | ||
gold_pan, | ||
grind_stone, | ||
heated_pressure_chamber, | ||
interact, | ||
juicer, | ||
magic_workbench, | ||
mob_drop, | ||
multiblock, | ||
nuclear_reactor, | ||
NULL, | ||
ore_crusher, | ||
ore_washer, | ||
pressure_chamber, | ||
refinery, | ||
smeltery, | ||
//ExoticGarden starts | ||
kitchen, | ||
breaking_grass, | ||
harvest_tree, | ||
harvest_bush, | ||
//InfinityExpansion starts | ||
infinity_forge, | ||
mob_data_infuser, | ||
storage_forge, | ||
//TranscEndence starts | ||
//useless: quirp_oscillator, | ||
quirp_annihilator, | ||
stabilizer, | ||
nanobot_crafter, | ||
zot_overloader, | ||
//FlowerPower starts | ||
magic_basin, | ||
_unknown; | ||
public static final Map<String, SlimeRecipeType> mp = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); | ||
public static SlimeRecipeType getByName(String str){ | ||
if(str == null) return _unknown; | ||
str=str.toLowerCase(); | ||
if("null".equals(str)) return NULL; | ||
return mp.getOrDefault(str,_unknown); | ||
} | ||
static{ | ||
SlimeRecipeType[] values = values(); | ||
for (SlimeRecipeType recipeType : values) { | ||
String name = recipeType.name(); | ||
mp.put(name, recipeType); | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
src/main/java/pers/xanadu/slimefunrecipe/commands/MainCommand.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,85 @@ | ||
package pers.xanadu.slimefunrecipe.commands; | ||
|
||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import pers.xanadu.slimefunrecipe.config.Lang; | ||
import pers.xanadu.slimefunrecipe.gui.GUISize; | ||
|
||
import static pers.xanadu.slimefunrecipe.Main.langF; | ||
import static pers.xanadu.slimefunrecipe.Main.reloadAll; | ||
import static pers.xanadu.slimefunrecipe.config.Config.enable; | ||
import static pers.xanadu.slimefunrecipe.config.Lang.*; | ||
import static pers.xanadu.slimefunrecipe.manager.GuiManager.openSizedSlimeInv; | ||
import static pers.xanadu.slimefunrecipe.manager.GuiManager.openSlimeInv; | ||
import static pers.xanadu.slimefunrecipe.manager.ItemManager.isEmpty; | ||
|
||
public class MainCommand implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(CommandSender sender, Command cmd, String name, String[] args) { | ||
if(args.length == 0){ | ||
sendCommandTips(sender); | ||
return false; | ||
} | ||
if(!sender.hasPermission("slimefunrecipe.admin")){ | ||
sendFeedback(sender, command_no_permission); | ||
return false; | ||
} | ||
switch (args[0].toLowerCase()){ | ||
case "reload" : { | ||
if(args.length != 1){ | ||
sendCommandTips(sender); | ||
return false; | ||
} | ||
reloadAll(); | ||
sendFeedback(sender,Lang.command_reload_config); | ||
return true; | ||
} | ||
case "edit" : { | ||
if(!enable){ | ||
sendFeedback(sender,plugin_fun_not_enable); | ||
return false; | ||
} | ||
if (!(sender instanceof Player)) { | ||
sendFeedback(sender, Lang.command_only_player); | ||
return false; | ||
} | ||
Player p = (Player) sender; | ||
ItemStack item = p.getItemInHand(); | ||
if(isEmpty(item)){ | ||
sendFeedback(sender, command_item_error); | ||
return false; | ||
} | ||
SlimefunItem si = SlimefunItem.getByItem(item); | ||
if(si==null) { | ||
sendFeedback(sender, command_item_error); | ||
return false; | ||
} | ||
if(args.length == 1){ | ||
openSlimeInv(p, si); | ||
return true; | ||
} | ||
else if(args.length == 2){ | ||
openSizedSlimeInv(p,si, GUISize.of(args[1])); | ||
return true; | ||
} | ||
else{ | ||
sendCommandTips(sender); | ||
return false; | ||
} | ||
} | ||
default : { | ||
sendCommandTips(sender); | ||
return false; | ||
} | ||
} | ||
} | ||
private static void sendCommandTips(CommandSender sender){ | ||
for(String str : CommandTips){ | ||
sender.sendMessage(str); | ||
} | ||
} | ||
} |
62 changes: 36 additions & 26 deletions
62
...slimefunrecipe/commands/TabCompleter.java → ...slimefunrecipe/commands/TabCompleter.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,36 @@ | ||
package xanadu.slimefunrecipe.commands; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class TabCompleter implements org.bukkit.command.TabCompleter { | ||
private static final List<String> arguments_1 = Arrays.asList("reload","edit"); | ||
@Override | ||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { | ||
|
||
List<String> result = new ArrayList<>(); | ||
if (args.length == 1) { | ||
for (String s : arguments_1) { | ||
if (s.toLowerCase().startsWith(args[0].toLowerCase())) { | ||
result.add(s); | ||
} | ||
} | ||
return result; | ||
} | ||
return null; | ||
} | ||
} | ||
package pers.xanadu.slimefunrecipe.commands; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class TabCompleter implements org.bukkit.command.TabCompleter { | ||
private static final List<String> arguments_1 = Arrays.asList("reload","edit"); | ||
private static final List<String> arguments_2 = Arrays.asList("1x4","3x3","6x6"); | ||
@Override | ||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { | ||
List<String> result = new ArrayList<>(); | ||
if (args.length == 1) { | ||
for (String s : arguments_1) { | ||
if (s.toLowerCase().startsWith(args[0].toLowerCase())) { | ||
result.add(s); | ||
} | ||
} | ||
return result; | ||
} | ||
else if(args.length==2){ | ||
if (args[0].equalsIgnoreCase("edit")) { | ||
for(String s : arguments_2){ | ||
if(s.toLowerCase().startsWith(args[1].toLowerCase())){ | ||
result.add(s); | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.