mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-26 07:54:41 +02:00
Fix indents, file perms (sorry! XD)
This commit is contained in:
264
Essentials/src/net/ess3/commands/Commandrecipe.java
Executable file → Normal file
264
Essentials/src/net/ess3/commands/Commandrecipe.java
Executable file → Normal file
@@ -18,142 +18,142 @@ import java.util.Map;
|
|||||||
public class Commandrecipe extends EssentialsCommand
|
public class Commandrecipe extends EssentialsCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
final ItemStack item = ess.getItemDb().get(args[0]);
|
final ItemStack item = ess.getItemDb().get(args[0]);
|
||||||
final List<Recipe> recipes = ess.getServer().getRecipesFor(item);
|
final List<Recipe> recipes = ess.getServer().getRecipesFor(item);
|
||||||
if (recipes.size() < 1)
|
if (recipes.size() < 1)
|
||||||
{
|
{
|
||||||
throw new Exception(_("recipeNone", getMaterialName(item)));
|
throw new Exception(_("recipeNone", getMaterialName(item)));
|
||||||
}
|
}
|
||||||
int recipeNo = 0;
|
int recipeNo = 0;
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
if (Util.isInt(args[1]))
|
if (Util.isInt(args[1]))
|
||||||
{
|
{
|
||||||
recipeNo = Integer.parseInt(args[1]) - 1;
|
recipeNo = Integer.parseInt(args[1]) - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception(_("invalidNumber"));
|
throw new Exception(_("invalidNumber"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (recipeNo < 0 || recipeNo >= recipes.size())
|
if (recipeNo < 0 || recipeNo >= recipes.size())
|
||||||
{
|
{
|
||||||
throw new Exception(_("recipeBadIndex"));
|
throw new Exception(_("recipeBadIndex"));
|
||||||
}
|
}
|
||||||
final Recipe recipe = recipes.get(recipeNo);
|
final Recipe recipe = recipes.get(recipeNo);
|
||||||
sender.sendMessage(_("recipe", getMaterialName(item), recipeNo + 1, recipes.size()));
|
sender.sendMessage(_("recipe", getMaterialName(item), recipeNo + 1, recipes.size()));
|
||||||
if (recipe instanceof FurnaceRecipe)
|
if (recipe instanceof FurnaceRecipe)
|
||||||
{
|
{
|
||||||
furnaceRecipe(sender, (FurnaceRecipe)recipe);
|
furnaceRecipe(sender, (FurnaceRecipe) recipe);
|
||||||
}
|
}
|
||||||
else if (recipe instanceof ShapedRecipe)
|
else if (recipe instanceof ShapedRecipe)
|
||||||
{
|
{
|
||||||
shapedRecipe(sender, (ShapedRecipe)recipe);
|
shapedRecipe(sender, (ShapedRecipe) recipe);
|
||||||
}
|
}
|
||||||
else if (recipe instanceof ShapelessRecipe)
|
else if (recipe instanceof ShapelessRecipe)
|
||||||
{
|
{
|
||||||
shapelessRecipe(sender, (ShapelessRecipe)recipe);
|
shapelessRecipe(sender, (ShapelessRecipe) recipe);
|
||||||
}
|
}
|
||||||
if (recipes.size() > 1 && args.length == 1)
|
if (recipes.size() > 1 && args.length == 1)
|
||||||
{
|
{
|
||||||
sender.sendMessage(_("recipeMore", commandLabel, args[0], getMaterialName(item)));
|
sender.sendMessage(_("recipeMore", commandLabel, args[0], getMaterialName(item)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void furnaceRecipe(CommandSender sender, FurnaceRecipe recipe)
|
public void furnaceRecipe(CommandSender sender, FurnaceRecipe recipe)
|
||||||
{
|
{
|
||||||
sender.sendMessage(_("recipeFurnace", getMaterialName(recipe.getInput())));
|
sender.sendMessage(_("recipeFurnace", getMaterialName(recipe.getInput())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shapedRecipe(CommandSender sender, ShapedRecipe recipe)
|
public void shapedRecipe(CommandSender sender, ShapedRecipe recipe)
|
||||||
{
|
{
|
||||||
Map<Character, ItemStack> recipeMap = recipe.getIngredientMap();
|
Map<Character, ItemStack> recipeMap = recipe.getIngredientMap();
|
||||||
if (sender instanceof IUser)
|
if (sender instanceof IUser)
|
||||||
{
|
{
|
||||||
IUser user = getUser(sender);
|
IUser user = getUser(sender);
|
||||||
user.setRecipeSee(true);
|
user.setRecipeSee(true);
|
||||||
InventoryView view = user.getPlayer().openWorkbench(null, true);
|
InventoryView view = user.getPlayer().openWorkbench(null, true);
|
||||||
for (Map.Entry<Character, ItemStack> e : recipe.getIngredientMap().entrySet())
|
for (Map.Entry<Character, ItemStack> e : recipe.getIngredientMap().entrySet())
|
||||||
{
|
{
|
||||||
view.setItem(" abcdefghi".indexOf(e.getKey()), e.getValue());
|
view.setItem(" abcdefghi".indexOf(e.getKey()), e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HashMap<ItemStack, String> colorMap = new HashMap<ItemStack, String>();
|
HashMap<ItemStack, String> colorMap = new HashMap<ItemStack, String>();
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (Character c : "abcdefghi".toCharArray())
|
for (Character c : "abcdefghi".toCharArray())
|
||||||
{
|
{
|
||||||
if (!colorMap.containsKey(recipeMap.get(c)))
|
if (!colorMap.containsKey(recipeMap.get(c)))
|
||||||
{
|
{
|
||||||
colorMap.put(recipeMap.get(c), String.valueOf(i++));
|
colorMap.put(recipeMap.get(c), String.valueOf(i++));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(_("recipeGrid", colorMap.get(recipeMap.get('a')), colorMap.get(recipeMap.get('b')), colorMap.get(recipeMap.get('c'))));
|
sender.sendMessage(_("recipeGrid", colorMap.get(recipeMap.get('a')), colorMap.get(recipeMap.get('b')), colorMap.get(recipeMap.get('c'))));
|
||||||
sender.sendMessage(_("recipeGrid", colorMap.get(recipeMap.get('d')), colorMap.get(recipeMap.get('e')), colorMap.get(recipeMap.get('f'))));
|
sender.sendMessage(_("recipeGrid", colorMap.get(recipeMap.get('d')), colorMap.get(recipeMap.get('e')), colorMap.get(recipeMap.get('f'))));
|
||||||
sender.sendMessage(_("recipeGrid", colorMap.get(recipeMap.get('g')), colorMap.get(recipeMap.get('h')), colorMap.get(recipeMap.get('i'))));
|
sender.sendMessage(_("recipeGrid", colorMap.get(recipeMap.get('g')), colorMap.get(recipeMap.get('h')), colorMap.get(recipeMap.get('i'))));
|
||||||
|
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
for (ItemStack items : colorMap.keySet().toArray(new ItemStack[colorMap.size()]))
|
for (ItemStack items : colorMap.keySet().toArray(new ItemStack[colorMap.size()]))
|
||||||
{
|
{
|
||||||
s.append(_("recipeGridItem", colorMap.get(items), getMaterialName(items)));
|
s.append(_("recipeGridItem", colorMap.get(items), getMaterialName(items)));
|
||||||
}
|
}
|
||||||
sender.sendMessage(_("recipeWhere", s.toString()));
|
sender.sendMessage(_("recipeWhere", s.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shapelessRecipe(CommandSender sender, ShapelessRecipe recipe)
|
public void shapelessRecipe(CommandSender sender, ShapelessRecipe recipe)
|
||||||
{
|
{
|
||||||
List<ItemStack> ingredients = recipe.getIngredientList();
|
List<ItemStack> ingredients = recipe.getIngredientList();
|
||||||
if (sender instanceof IUser)
|
if (sender instanceof IUser)
|
||||||
{
|
{
|
||||||
IUser user = getUser(sender);
|
IUser user = getUser(sender);
|
||||||
user.setRecipeSee(true);
|
user.setRecipeSee(true);
|
||||||
InventoryView view = user.getPlayer().openWorkbench(null, true);
|
InventoryView view = user.getPlayer().openWorkbench(null, true);
|
||||||
for (int i = 0; i < ingredients.size(); i++)
|
for (int i = 0; i < ingredients.size(); i++)
|
||||||
{
|
{
|
||||||
view.setItem(i + 1, ingredients.get(i));
|
view.setItem(i + 1, ingredients.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ess.getLogger().info(sender.getClass().getName());
|
ess.getLogger().info(sender.getClass().getName());
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
for (int i = 0; i < ingredients.size(); i++)
|
for (int i = 0; i < ingredients.size(); i++)
|
||||||
{
|
{
|
||||||
s.append(getMaterialName(ingredients.get(i)));
|
s.append(getMaterialName(ingredients.get(i)));
|
||||||
if (i != ingredients.size() - 1)
|
if (i != ingredients.size() - 1)
|
||||||
{
|
{
|
||||||
s.append(",");
|
s.append(",");
|
||||||
}
|
}
|
||||||
s.append(" ");
|
s.append(" ");
|
||||||
}
|
}
|
||||||
sender.sendMessage(_("recipeShapeless", s.toString()));
|
sender.sendMessage(_("recipeShapeless", s.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMaterialName(ItemStack stack)
|
public String getMaterialName(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack == null)
|
if (stack == null)
|
||||||
{
|
{
|
||||||
return _("recipeNothing");
|
return _("recipeNothing");
|
||||||
}
|
}
|
||||||
return getMaterialName(stack.getType());
|
return getMaterialName(stack.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMaterialName(Material type)
|
public String getMaterialName(Material type)
|
||||||
{
|
{
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
return _("recipeNothing");
|
return _("recipeNothing");
|
||||||
}
|
}
|
||||||
return type.toString().replace("_", " ").toLowerCase(Locale.ENGLISH);
|
return type.toString().replace("_", " ").toLowerCase(Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
}
|
}
|
34
Essentials/src/net/ess3/listener/EssentialsPlayerListener.java
Executable file → Normal file
34
Essentials/src/net/ess3/listener/EssentialsPlayerListener.java
Executable file → Normal file
@@ -495,14 +495,14 @@ public class EssentialsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH)
|
if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH)
|
||||||
{
|
{
|
||||||
final IUser user = ess.getUserMap().getUser((Player)event.getWhoClicked());
|
final IUser user = ess.getUserMap().getUser((Player)event.getWhoClicked());
|
||||||
if(user.isRecipeSee())
|
if(user.isRecipeSee())
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
@@ -513,15 +513,15 @@ public class EssentialsPlayerListener implements Listener
|
|||||||
final IUser user = ess.getUserMap().getUser((Player)event.getPlayer());
|
final IUser user = ess.getUserMap().getUser((Player)event.getPlayer());
|
||||||
user.setInvSee(false);
|
user.setInvSee(false);
|
||||||
}
|
}
|
||||||
else if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH)
|
else if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH)
|
||||||
{
|
{
|
||||||
final IUser user = ess.getUserMap().getUser((Player)event.getPlayer());
|
final IUser user = ess.getUserMap().getUser((Player)event.getPlayer());
|
||||||
if(user.isRecipeSee())
|
if (user.isRecipeSee())
|
||||||
{
|
{
|
||||||
user.setRecipeSee(false);
|
user.setRecipeSee(false);
|
||||||
event.getView().getTopInventory().clear();
|
event.getView().getTopInventory().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
6
Essentials/src/net/ess3/user/User.java
Executable file → Normal file
6
Essentials/src/net/ess3/user/User.java
Executable file → Normal file
@@ -54,9 +54,9 @@ public class User extends UserBase implements IUser
|
|||||||
private transient Location afkPosition;
|
private transient Location afkPosition;
|
||||||
private AtomicBoolean gotMailInfo = new AtomicBoolean(false);
|
private AtomicBoolean gotMailInfo = new AtomicBoolean(false);
|
||||||
private WeakReference<Player> playerCache;
|
private WeakReference<Player> playerCache;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private boolean recipeSee = false;
|
private boolean recipeSee = false;
|
||||||
|
|
||||||
public User(final OfflinePlayer base, final IEssentials ess) throws InvalidNameException
|
public User(final OfflinePlayer base, final IEssentials ess) throws InvalidNameException
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user