mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2025-02-19 13:01:20 +01:00
divers
This commit is contained in:
parent
939b01f995
commit
2828445706
@ -3,11 +3,14 @@ package fr.moribus.ImageOnMap;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public final class ImageOnMap extends JavaPlugin
|
public final class ImageOnMap extends JavaPlugin
|
||||||
@ -17,6 +20,9 @@ public final class ImageOnMap extends JavaPlugin
|
|||||||
boolean dossierCree;
|
boolean dossierCree;
|
||||||
private FileConfiguration customConfig = null;
|
private FileConfiguration customConfig = null;
|
||||||
private File customConfigFile = null;
|
private File customConfigFile = null;
|
||||||
|
// liste contenant les maps ne pouvant être placé dans l'inventaire du joueur. Je le fous ici afin que ce soit
|
||||||
|
// accessible de partout dans le plugin..
|
||||||
|
private HashMap<String, ArrayList<ItemStack>> cache = new HashMap<String, ArrayList<ItemStack>>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
@ -127,4 +133,19 @@ public final class ImageOnMap extends JavaPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<ItemStack> getRemainingMaps(String j)
|
||||||
|
{
|
||||||
|
return cache.get(j);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemainingMaps(String j, ArrayList<ItemStack> remaining)
|
||||||
|
{
|
||||||
|
cache.put(j, remaining);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeRemaingMaps(String j)
|
||||||
|
{
|
||||||
|
cache.remove(j);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package fr.moribus.ImageOnMap;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -10,6 +11,8 @@ import org.bukkit.command.BlockCommandSender;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.map.MapView;
|
import org.bukkit.map.MapView;
|
||||||
|
|
||||||
public class ImgUtility
|
public class ImgUtility
|
||||||
@ -228,4 +231,14 @@ public class ImgUtility
|
|||||||
}
|
}
|
||||||
return listeMap;
|
return listeMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void AddMap(ItemStack map, Inventory inv, ArrayList<ItemStack> restant)
|
||||||
|
{
|
||||||
|
HashMap<Integer,ItemStack> reste = inv.addItem(map);
|
||||||
|
|
||||||
|
if(!reste.isEmpty())
|
||||||
|
{
|
||||||
|
restant.add(reste.get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -130,6 +130,31 @@ public class MapToolCommand implements CommandExecutor
|
|||||||
"\nYou have rendered "+ ChatColor.DARK_PURPLE+ (compteur + 1)+ ChatColor.RESET+ " pictures");
|
"\nYou have rendered "+ ChatColor.DARK_PURPLE+ (compteur + 1)+ ChatColor.RESET+ " pictures");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if(arg3[0].equalsIgnoreCase("getrest"))
|
||||||
|
{
|
||||||
|
if(plugin.getRemainingMaps(joueur.getName()) == null)
|
||||||
|
{
|
||||||
|
joueur.sendMessage("All maps have already be placed in your inventory");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ArrayList<ItemStack> reste = plugin.getRemainingMaps(joueur.getName());
|
||||||
|
ArrayList<ItemStack> restant = new ArrayList<ItemStack>();
|
||||||
|
for(int i = 0; i < reste.size(); i++)
|
||||||
|
{
|
||||||
|
ImgUtility.AddMap(reste.get(i), inv, restant);
|
||||||
|
}
|
||||||
|
if(restant.isEmpty())
|
||||||
|
{
|
||||||
|
plugin.removeRemaingMaps(joueur.getName());
|
||||||
|
joueur.sendMessage("All maps have been placed in your inventory");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.setRemainingMaps(joueur.getName(), restant);
|
||||||
|
joueur.sendMessage(restant.size()+ " maps can't be placed in your inventory. Please run "+ ChatColor.GOLD+ "/maptool getrest again");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package fr.moribus.ImageOnMap;
|
package fr.moribus.ImageOnMap;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -59,6 +61,7 @@ public class TacheTraitementMap extends BukkitRunnable
|
|||||||
}
|
}
|
||||||
MapView carte;
|
MapView carte;
|
||||||
|
|
||||||
|
ArrayList<ItemStack> restant = new ArrayList<ItemStack>();
|
||||||
for (int i = 0; i < nbImage; i++)
|
for (int i = 0; i < nbImage; i++)
|
||||||
{
|
{
|
||||||
carte = Bukkit.createMap(joueur.getWorld());
|
carte = Bukkit.createMap(joueur.getWorld());
|
||||||
@ -68,14 +71,18 @@ public class TacheTraitementMap extends BukkitRunnable
|
|||||||
ItemMeta meta = map.getItemMeta();
|
ItemMeta meta = map.getItemMeta();
|
||||||
meta.setDisplayName("Map (" +renduImg.getImg().NumeroMap.get(i) +")");
|
meta.setDisplayName("Map (" +renduImg.getImg().NumeroMap.get(i) +")");
|
||||||
map.setItemMeta(meta);
|
map.setItemMeta(meta);
|
||||||
inv.addItem(map);
|
|
||||||
|
ImgUtility.AddMap(map, inv, restant);
|
||||||
|
|
||||||
//Svg de la map
|
//Svg de la map
|
||||||
SavedMap svg = new SavedMap(plugin, joueur.getName(), carte.getId(), renduImg.getImg().getPoster()[i]);
|
SavedMap svg = new SavedMap(plugin, joueur.getName(), carte.getId(), renduImg.getImg().getPoster()[i]);
|
||||||
svg.SaveMap();
|
svg.SaveMap();
|
||||||
joueur.sendMap(carte);
|
joueur.sendMap(carte);
|
||||||
}
|
}
|
||||||
joueur.sendMessage("Rendu de l'image fini");
|
if(!restant.isEmpty())
|
||||||
|
joueur.sendMessage(restant.size()+ " maps can't be place in your inventory. Please make free space in your inventory and run "+ ChatColor.GOLD+ "/maptool rest");
|
||||||
|
plugin.setRemainingMaps(joueur.getName(), restant);
|
||||||
|
joueur.sendMessage("Render finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user