mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-11-15 06:35:11 +01:00
Ajout d'une option à la commande /tomap pour écrire ou pas le pseudo du joueur sur la carte
This commit is contained in:
parent
d5b5868a5d
commit
3655cffd38
@ -1,6 +1,6 @@
|
||||
name: ImageOnMap
|
||||
main: fr.moribus.ImageOnMap.ImageOnMap
|
||||
version: 1.2
|
||||
version: 1.2.2
|
||||
|
||||
commands:
|
||||
tomap:
|
||||
@ -8,4 +8,9 @@ commands:
|
||||
usage: /<command> [URL]
|
||||
rmmap:
|
||||
description: remove an image
|
||||
usage: /<command>
|
||||
usage: /<command>
|
||||
|
||||
permissions:
|
||||
imageonmap.userender:
|
||||
description: Allows you to use /tomap
|
||||
default: op
|
@ -9,29 +9,30 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class ImageOnMap extends JavaPlugin
|
||||
{
|
||||
int test = 0;
|
||||
File dossier;
|
||||
boolean dossierCree;
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
dossier = new File(getDataFolder().getPath() + "/Image");
|
||||
if (!dossier.exists())
|
||||
{
|
||||
dossierCree = dossier.mkdirs();
|
||||
}
|
||||
else
|
||||
dossierCree = true;
|
||||
// On crée si besoin le dossier où les images seront stockées
|
||||
dossierCree = ImgUtility.CreeRepImg(this);
|
||||
|
||||
// On ajoute si besoin les params par défaut du plugin
|
||||
ImgUtility.CreeSectionConfig(this);
|
||||
|
||||
if(dossierCree)
|
||||
{
|
||||
System.out.println("Loading ImageOnMap");
|
||||
getCommand("tomap").setExecutor(new ImageRenduCommande(this));
|
||||
getCommand("rmmap").setExecutor(new ImageSupprCommande(this));
|
||||
this.saveDefaultConfig();
|
||||
ChargerMap();
|
||||
getCommand("tomap").setExecutor(new ImageRenduCommande(this));
|
||||
getCommand("rmmap").setExecutor(new ImageSupprCommande(this));
|
||||
this.saveDefaultConfig();
|
||||
ChargerMap();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("[ImageOnMap] An error occured ! Unable to create Image folder. Plugin will NOT work !");
|
||||
this.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,11 +46,17 @@ public final class ImageOnMap extends JavaPlugin
|
||||
Set<String> cle = getConfig().getKeys(false);
|
||||
for (String s: cle)
|
||||
{
|
||||
System.out.println("Loading " + s);
|
||||
@SuppressWarnings("deprecation")
|
||||
MapView carte = Bukkit.getMap(Short.parseShort(getConfig().getStringList(s).get(0)));
|
||||
Rendu.SupprRendu(carte);
|
||||
carte.addRenderer(new Rendu("./plugins/ImageOnMap/Image/" + getConfig().getStringList(s).get(1) + ".png", getConfig().getStringList(s).get(2)));
|
||||
if(getConfig().getStringList(s).size() >= 3)
|
||||
{
|
||||
System.out.println("Loading " + s);
|
||||
@SuppressWarnings("deprecation")
|
||||
MapView carte = Bukkit.getMap(Short.parseShort(getConfig().getStringList(s).get(0)));
|
||||
Rendu.SupprRendu(carte);
|
||||
if (getConfig().getStringList(s).size() == 4)
|
||||
carte.addRenderer(new Rendu("./plugins/ImageOnMap/Image/" + getConfig().getStringList(s).get(1) + ".png", getConfig().getStringList(s).get(2), getConfig().getStringList(s).get(3)));
|
||||
else if (getConfig().getStringList(s).size() == 3)
|
||||
carte.addRenderer(new Rendu("./plugins/ImageOnMap/Image/" + getConfig().getStringList(s).get(1) + ".png", getConfig().getStringList(s).get(2), "True"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ public class ImageRenduCommande implements CommandExecutor
|
||||
{
|
||||
|
||||
Player joueur;
|
||||
boolean renderName;
|
||||
ImageOnMap ca;
|
||||
boolean imgSvg;
|
||||
|
||||
@ -56,9 +57,19 @@ public class ImageRenduCommande implements CommandExecutor
|
||||
return false;
|
||||
}
|
||||
|
||||
if (arg3.length == 2)
|
||||
{
|
||||
if (arg3[1].contains("true"))
|
||||
renderName = true;
|
||||
else
|
||||
renderName = false;
|
||||
}
|
||||
else
|
||||
renderName = false;
|
||||
|
||||
imgSvg = true;
|
||||
// On crée une map
|
||||
Rendu ren = new Rendu(arg3[0], imgSvg, ca);
|
||||
Rendu ren = new Rendu(arg3[0], imgSvg, ca, renderName);
|
||||
MapView carte = Bukkit.getMap(joueur.getItemInHand().getDurability());
|
||||
Rendu.SupprRendu(carte);
|
||||
carte.addRenderer(ren);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package fr.moribus.ImageOnMap;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -23,4 +25,27 @@ public class ImgUtility
|
||||
else
|
||||
{System.out.println(ChatColor.RED + "Cette commande ne peut être lancée de cette façon !"); return false;}
|
||||
}
|
||||
}
|
||||
|
||||
// Creation du dossier où sera stocké les images
|
||||
static boolean CreeRepImg(ImageOnMap plugin)
|
||||
{
|
||||
File dossier;
|
||||
dossier = new File(plugin.getDataFolder().getPath() + "/Image");
|
||||
if (!dossier.exists())
|
||||
{
|
||||
return dossier.mkdirs();
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
static void CreeSectionConfig(ImageOnMap plugin)
|
||||
{
|
||||
if(plugin.getConfig().get("Limit-map-by-server") == null)
|
||||
plugin.getConfig().set("Limit-map-by-server", 0);
|
||||
if(plugin.getConfig().get("Limit-map-by-player") == null)
|
||||
plugin.getConfig().set("Limit-map-by-player", 0);
|
||||
plugin.saveConfig();
|
||||
|
||||
}
|
||||
}
|
@ -18,32 +18,33 @@ import org.bukkit.map.MinecraftFont;
|
||||
public class Rendu extends MapRenderer implements Runnable
|
||||
{
|
||||
|
||||
boolean estRendu, estSVGee, local = false;
|
||||
BufferedImage touhou;
|
||||
BufferedImage resizedImage;
|
||||
boolean estRendu, estSVGee, hasFail, renderName, local = false;
|
||||
BufferedImage touhou, resizedImage;
|
||||
private Thread TRendu;
|
||||
public MapCanvas canvas;
|
||||
MapView carte;
|
||||
String URLImage, nomJoueur;
|
||||
Player joueur;
|
||||
boolean hasFail;
|
||||
ImageOnMap plugin;
|
||||
|
||||
public Rendu(String url, boolean svg, ImageOnMap plug)
|
||||
public Rendu(String url, boolean svg, ImageOnMap plug, boolean rn)
|
||||
{
|
||||
estRendu = true;
|
||||
estSVGee = svg;
|
||||
URLImage = url;
|
||||
plugin = plug;
|
||||
renderName = rn;
|
||||
}
|
||||
|
||||
public Rendu(String url, String pseudo)
|
||||
public Rendu(String url, String pseudo, String boolRN)
|
||||
{
|
||||
estRendu = true;
|
||||
estSVGee = false;
|
||||
URLImage = url;
|
||||
local = true; // Sert à indiquer que le rendu a été lancé par le plugin au démarrage, et non par un joueur en jeu.
|
||||
nomJoueur = pseudo;
|
||||
renderName = Boolean.parseBoolean(boolRN);
|
||||
System.out.println(boolRN + " " + renderName);
|
||||
}
|
||||
@Override
|
||||
public void render(MapView v, final MapCanvas mc, Player p)
|
||||
@ -73,6 +74,7 @@ public class Rendu extends MapRenderer implements Runnable
|
||||
try
|
||||
{
|
||||
touhou = ImageIO.read(URI.create(URLImage).toURL().openStream());
|
||||
System.out.println(touhou.getWidth() + " " + touhou.getHeight());
|
||||
//System.out.println("chargement de l'image");
|
||||
}
|
||||
catch (IOException e) {
|
||||
@ -118,10 +120,13 @@ public class Rendu extends MapRenderer implements Runnable
|
||||
canvas.drawImage(0, 0, MapPalette.resizeImage(touhou));
|
||||
|
||||
// On écrit le pseudo du joueur qui a téléchargé l'image
|
||||
if(!local)
|
||||
canvas.drawText(2, 120, MinecraftFont.Font, new String("(" + joueur.getName() + ")"));
|
||||
else
|
||||
canvas.drawText(2, 120, MinecraftFont.Font, new String("(" + nomJoueur + ")"));
|
||||
if (renderName)
|
||||
{
|
||||
if(!local)
|
||||
canvas.drawText(2, 120, MinecraftFont.Font, new String("(" + joueur.getName() + ")"));
|
||||
else
|
||||
canvas.drawText(2, 120, MinecraftFont.Font, new String("(" + nomJoueur + ")"));
|
||||
}
|
||||
|
||||
//System.out.println("Rendu de l'image fini");
|
||||
|
||||
@ -134,6 +139,7 @@ public class Rendu extends MapRenderer implements Runnable
|
||||
liste.add(String.valueOf(IdMap));
|
||||
liste.add(nomImage);
|
||||
liste.add(nomJoueur);
|
||||
liste.add(String.valueOf(renderName));
|
||||
plugin.getConfig().set("map" + IdMap, liste);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user