Archived
0

Fixed /minecart

This commit is contained in:
Minenash
2018-11-07 20:49:51 -05:00
parent a01bd12331
commit f4c6d0b74a
2 changed files with 32 additions and 22 deletions

View File

@@ -51,16 +51,18 @@ alias nv;
command minecart { command minecart {
alias cart; alias cart;
perm utils.spawncart; perm utils.spawncart;
help Spawn's a Minecart;
type player; type player;
deafult [string type] { default [string:variation] {
run minecart_default type; run minecart_default variation;
help Sets a default minecart variation.;
} }
[string type] { [string:variation] {
run minecart_type type; run minecart_variation variation;
help Spawns a certain minecart;
} }
[empty] { [empty] {
run minecart; run minecart;
help Spawns a minecart;
} }
} }

View File

@@ -285,50 +285,58 @@ public class Misc implements Module, Listener
@Command(hook = "minecart") @Command(hook = "minecart")
public void minecart(CommandSender sender) { public void minecart(CommandSender sender) {
String type = (String) DataManager.getOrDefault(sender, "minecart_default", "normal"); String type = (String) DataManager.getOrDefault(sender, "minecart_default", "normal");
minecartDefault(sender, type); minecartType(sender, type);
} }
@Command(hook = "minecart_type") @Command(hook = "minecart_variation")
public void minecartType(CommandSender sender, String type) { public boolean minecartType(CommandSender sender, String type) {
if (type.equals("help") || type.equals("h") || type.equals("?"))
return false;
Player p = (Player) sender; Player p = (Player) sender;
if (!canBuild(p, p.getLocation())) { if (!canBuild(p, p.getLocation())) {
ChatAPI.sendActionBar(sender, "&cYou do not have permission to build here!"); getLogger().message(sender, true, "You do not have permission to build here!");
return; return true;
} }
EntityType typeE = convertMinecartTypeString(type); EntityType typeE = convertMinecartTypeString(type);
if (typeE != null) { if (typeE != null) {
p.getWorld().spawnEntity(p.getLocation(), typeE); p.getWorld().spawnEntity(p.getLocation(), typeE);
ChatAPI.sendActionBar(sender, "&aMinecart Spawned!"); getLogger().message(sender, "Minecart Spawned!");
} }
else else
ChatAPI.sendActionBar(sender, "&cThe type of Minecart you've requested does not exist."); getLogger().message(sender, true, "The type of Minecart you've requested does not exist.");
return false;
} }
@Command(hook = "minecart_default") @Command(hook = "minecart_default")
public void minecartDefault(CommandSender sender, String type) { public boolean minecartDefault(CommandSender sender, String type) {
EntityType typeE = convertMinecartTypeString(type); EntityType typeE = convertMinecartTypeString(type);
if (type.equals("help") || type.equals("h") || type.equals("?"))
return false;
if (typeE != null) { if (typeE != null) {
DataManager.setData(sender, "minecart_default", type); DataManager.setData(sender, "minecart_default", type);
ChatAPI.sendActionBar(sender, "&aMinecart Spawned!"); getLogger().message(sender, "Minecart Spawned!");
} }
else else
ChatAPI.sendActionBar(sender, "&cThe type of Minecart you've requested does not exist."); getLogger().message(sender, true, "The type of Minecart you've requested does not exist.");
return true;
} }
public EntityType convertMinecartTypeString(String type) { public EntityType convertMinecartTypeString(String type) {
EntityType typeE = null; EntityType typeE = null;
switch (type) { switch (type) {
case "normal": typeE = EntityType.MINECART; case "normal": typeE = EntityType.MINECART; break;
case "chest": typeE = EntityType.MINECART_CHEST; case "chest": typeE = EntityType.MINECART_CHEST; break;
case "furnace": typeE = EntityType.MINECART_FURNACE; case "furnace": typeE = EntityType.MINECART_FURNACE; break;
case "hopper": typeE = EntityType.MINECART_HOPPER; case "hopper": typeE = EntityType.MINECART_HOPPER; break;
case "tnt": typeE = EntityType.MINECART_TNT; case "tnt": typeE = EntityType.MINECART_TNT; break;
case "command": typeE = EntityType.MINECART_COMMAND; case "command": typeE = EntityType.MINECART_COMMAND; break;
case "spawner": typeE = EntityType.MINECART_MOB_SPAWNER; case "spawner": typeE = EntityType.MINECART_MOB_SPAWNER; break;
} }
return typeE; return typeE;