mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Added enchant interface
Other misc stuff
This commit is contained in:
parent
41f2a0e232
commit
d60963cc7c
@ -34,6 +34,7 @@ disable_weather: true
|
|||||||
# Enable misc. features:
|
# Enable misc. features:
|
||||||
landmines_enabled: false
|
landmines_enabled: false
|
||||||
mp44_enabled: false
|
mp44_enabled: false
|
||||||
|
tossmob_enabled: false
|
||||||
|
|
||||||
# Moblimiter:
|
# Moblimiter:
|
||||||
mob_limiter_enabled: true
|
mob_limiter_enabled: true
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -33,13 +34,21 @@ public class Command_creative extends TFM_Command
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
|
||||||
{
|
{
|
||||||
p = getPlayer(args[0]);
|
try
|
||||||
|
{
|
||||||
|
p = getPlayer(args[0]);
|
||||||
|
}
|
||||||
|
catch (CantFindPlayerException ex)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CantFindPlayerException ex)
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage("Only superadmins can change other user's gamemode.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,130 @@
|
|||||||
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class Command_enchant extends TFM_Command
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sender.isOp())
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack itemInHand = sender_p.getItemInHand();
|
||||||
|
|
||||||
|
if (itemInHand == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage("You are holding an invalid item.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
|
{
|
||||||
|
boolean has_enchantments = false;
|
||||||
|
|
||||||
|
StringBuilder possible_ench = new StringBuilder("Possible enchantments for held item: ");
|
||||||
|
for (Enchantment ench : Enchantment.values())
|
||||||
|
{
|
||||||
|
if (ench.canEnchantItem(itemInHand))
|
||||||
|
{
|
||||||
|
has_enchantments = true;
|
||||||
|
possible_ench.append(ench.getName()).append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_enchantments)
|
||||||
|
{
|
||||||
|
sender.sendMessage(possible_ench.toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("The held item has no enchantments.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("addall"))
|
||||||
|
{
|
||||||
|
for (Enchantment ench : Enchantment.values())
|
||||||
|
{
|
||||||
|
if (ench.canEnchantItem(itemInHand))
|
||||||
|
{
|
||||||
|
itemInHand.addEnchantment(ench, ench.getMaxLevel());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage("Added all possible enchantments for this item.");
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("reset"))
|
||||||
|
{
|
||||||
|
for (Enchantment ench : itemInHand.getEnchantments().keySet())
|
||||||
|
{
|
||||||
|
itemInHand.removeEnchantment(ench);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage("Removed all enchantments.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Enchantment ench = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ench = Enchantment.getByName(args[1]);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ench == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(args[1] + " is an invalid enchantment for the held item. Type \"/enchant list\" for valid enchantments for this item.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("add"))
|
||||||
|
{
|
||||||
|
if (ench.canEnchantItem(itemInHand))
|
||||||
|
{
|
||||||
|
itemInHand.addEnchantment(ench, ench.getMaxLevel());
|
||||||
|
|
||||||
|
sender.sendMessage("Added enchantment: " + ench.getName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("Can't use this enchantment on held item.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("remove"))
|
||||||
|
{
|
||||||
|
itemInHand.removeEnchantment(ench);
|
||||||
|
|
||||||
|
sender.sendMessage("Removed enchantment: " + ench.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Command_setexp extends TFM_Command
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sender.isOp())
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int exp_amount;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
exp_amount = Integer.parseInt(args[0]);
|
||||||
|
|
||||||
|
if (exp_amount < 0)
|
||||||
|
{
|
||||||
|
exp_amount = 0;
|
||||||
|
}
|
||||||
|
else if (exp_amount > (int) Short.MAX_VALUE)
|
||||||
|
{
|
||||||
|
exp_amount = (int) Short.MAX_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "Invalid exp amount.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender_p.setExperience(exp_amount);
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.AQUA + "Experience points set to: " + sender_p.getExperience());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -33,13 +34,21 @@ public class Command_survival extends TFM_Command
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
|
||||||
{
|
{
|
||||||
p = getPlayer(args[0]);
|
try
|
||||||
|
{
|
||||||
|
p = getPlayer(args[0]);
|
||||||
|
}
|
||||||
|
catch (CantFindPlayerException ex)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CantFindPlayerException ex)
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage("Only superadmins can change other user's gamemode.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,12 @@ public class Command_tossmob extends TFM_Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
if (!TotalFreedomMod.tossmobEnabled)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "Tossmob is currently disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
||||||
|
@ -144,6 +144,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public static boolean mobLimiterDisableGhast = true;
|
public static boolean mobLimiterDisableGhast = true;
|
||||||
public static boolean mobLimiterDisableSlime = true;
|
public static boolean mobLimiterDisableSlime = true;
|
||||||
public static boolean mobLimiterDisableGiant = true;
|
public static boolean mobLimiterDisableGiant = true;
|
||||||
|
public static boolean tossmobEnabled = false;
|
||||||
|
|
||||||
public void loadMainConfig()
|
public void loadMainConfig()
|
||||||
{
|
{
|
||||||
@ -174,6 +175,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
mobLimiterDisableGhast = config.getBoolean("mob_limiter_disable_ghast", mobLimiterDisableGhast);
|
mobLimiterDisableGhast = config.getBoolean("mob_limiter_disable_ghast", mobLimiterDisableGhast);
|
||||||
mobLimiterDisableSlime = config.getBoolean("mob_limiter_disable_slime", mobLimiterDisableSlime);
|
mobLimiterDisableSlime = config.getBoolean("mob_limiter_disable_slime", mobLimiterDisableSlime);
|
||||||
mobLimiterDisableGiant = config.getBoolean("mob_limiter_disable_giant", mobLimiterDisableGiant);
|
mobLimiterDisableGiant = config.getBoolean("mob_limiter_disable_giant", mobLimiterDisableGiant);
|
||||||
|
tossmobEnabled = config.getBoolean("mp44_enabled", tossmobEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> superadmins = new ArrayList<String>();
|
public static List<String> superadmins = new ArrayList<String>();
|
||||||
|
@ -25,6 +25,9 @@ commands:
|
|||||||
deopall:
|
deopall:
|
||||||
description: Superadmin command - Deop everyone on the server. Use 'purge' to clear ops.txt as well.
|
description: Superadmin command - Deop everyone on the server. Use 'purge' to clear ops.txt as well.
|
||||||
usage: /<command> [purge]
|
usage: /<command> [purge]
|
||||||
|
enchant:
|
||||||
|
description: Enchant items.
|
||||||
|
usage: /<command> <list | addall | reset | add <name> | remove <name>>
|
||||||
expel:
|
expel:
|
||||||
description: Superadmin command - Push people away from you.
|
description: Superadmin command - Push people away from you.
|
||||||
usage: /<command> [radius] [strength]
|
usage: /<command> [radius] [strength]
|
||||||
@ -121,6 +124,9 @@ commands:
|
|||||||
setspawnworld:
|
setspawnworld:
|
||||||
description: Superadmin Command - Set world spawnpoint.
|
description: Superadmin Command - Set world spawnpoint.
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
# setexp:
|
||||||
|
# description: Sets how many expierence points you have (this is not the same as your "level").
|
||||||
|
# usage: /<command> <value>
|
||||||
ender:
|
ender:
|
||||||
description: Goto the ender / "The End".
|
description: Goto the ender / "The End".
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
Loading…
Reference in New Issue
Block a user