Actually call the events.

This commit is contained in:
filoghost 2014-12-22 14:41:22 +01:00
parent 295e6a675b
commit 85390990f2
9 changed files with 37 additions and 15 deletions

View File

@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.commands.main.subs;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.filoghost.holographicdisplays.commands.Colors; import com.gmail.filoghost.holographicdisplays.commands.Colors;
@ -10,6 +11,7 @@ import com.gmail.filoghost.holographicdisplays.commands.CommandValidator;
import com.gmail.filoghost.holographicdisplays.commands.Strings; import com.gmail.filoghost.holographicdisplays.commands.Strings;
import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand; import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand;
import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase; import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase;
import com.gmail.filoghost.holographicdisplays.event.NamedHologramEditedEvent;
import com.gmail.filoghost.holographicdisplays.exception.CommandException; import com.gmail.filoghost.holographicdisplays.exception.CommandException;
import com.gmail.filoghost.holographicdisplays.object.NamedHologram; import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager; import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
@ -43,6 +45,7 @@ public class AddlineCommand extends HologramSubCommand {
HologramDatabase.saveHologram(hologram); HologramDatabase.saveHologram(hologram);
HologramDatabase.trySaveToDisk(); HologramDatabase.trySaveToDisk();
sender.sendMessage(Colors.PRIMARY + "Line added!"); sender.sendMessage(Colors.PRIMARY + "Line added!");
Bukkit.getPluginManager().callEvent(new NamedHologramEditedEvent(hologram));
} }
@Override @Override

View File

@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.commands.main.subs;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.filoghost.holographicdisplays.commands.Colors; import com.gmail.filoghost.holographicdisplays.commands.Colors;
@ -10,6 +11,7 @@ import com.gmail.filoghost.holographicdisplays.commands.CommandValidator;
import com.gmail.filoghost.holographicdisplays.commands.Strings; import com.gmail.filoghost.holographicdisplays.commands.Strings;
import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand; import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand;
import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase; import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase;
import com.gmail.filoghost.holographicdisplays.event.NamedHologramEditedEvent;
import com.gmail.filoghost.holographicdisplays.exception.CommandException; import com.gmail.filoghost.holographicdisplays.exception.CommandException;
import com.gmail.filoghost.holographicdisplays.object.NamedHologram; import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager; import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
@ -58,6 +60,7 @@ public class InsertlineCommand extends HologramSubCommand {
} else { } else {
sender.sendMessage(Colors.PRIMARY + "Line inserted between lines " + insertAfter + " and " + (insertAfter + 1) + "!"); sender.sendMessage(Colors.PRIMARY + "Line inserted between lines " + insertAfter + " and " + (insertAfter + 1) + "!");
} }
Bukkit.getPluginManager().callEvent(new NamedHologramEditedEvent(hologram));
} }
@Override @Override

View File

@ -9,6 +9,7 @@ import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -18,6 +19,7 @@ import com.gmail.filoghost.holographicdisplays.commands.CommandValidator;
import com.gmail.filoghost.holographicdisplays.commands.Strings; import com.gmail.filoghost.holographicdisplays.commands.Strings;
import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand; import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand;
import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase; import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase;
import com.gmail.filoghost.holographicdisplays.event.NamedHologramEditedEvent;
import com.gmail.filoghost.holographicdisplays.exception.CommandException; import com.gmail.filoghost.holographicdisplays.exception.CommandException;
import com.gmail.filoghost.holographicdisplays.exception.TooWideException; import com.gmail.filoghost.holographicdisplays.exception.TooWideException;
import com.gmail.filoghost.holographicdisplays.exception.UnreadableImageException; import com.gmail.filoghost.holographicdisplays.exception.UnreadableImageException;
@ -113,6 +115,7 @@ public class ReadimageCommand extends HologramSubCommand {
} else { } else {
sender.sendMessage(Colors.PRIMARY + "The image was drawn in the hologram!"); sender.sendMessage(Colors.PRIMARY + "The image was drawn in the hologram!");
} }
Bukkit.getPluginManager().callEvent(new NamedHologramEditedEvent(hologram));
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
throw new CommandException("The provided URL was not valid."); throw new CommandException("The provided URL was not valid.");

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -16,6 +17,7 @@ import com.gmail.filoghost.holographicdisplays.commands.Strings;
import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand; import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand;
import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase; import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase;
import com.gmail.filoghost.holographicdisplays.disk.StringConverter; import com.gmail.filoghost.holographicdisplays.disk.StringConverter;
import com.gmail.filoghost.holographicdisplays.event.NamedHologramEditedEvent;
import com.gmail.filoghost.holographicdisplays.exception.CommandException; import com.gmail.filoghost.holographicdisplays.exception.CommandException;
import com.gmail.filoghost.holographicdisplays.object.NamedHologram; import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager; import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
@ -69,6 +71,7 @@ public class ReadtextCommand extends HologramSubCommand {
} }
sender.sendMessage(Colors.PRIMARY + "The lines were pasted into the hologram!"); sender.sendMessage(Colors.PRIMARY + "The lines were pasted into the hologram!");
Bukkit.getPluginManager().callEvent(new NamedHologramEditedEvent(hologram));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new CommandException("A file named '" + args[1] + "' doesn't exist in the plugin's folder."); throw new CommandException("A file named '" + args[1] + "' doesn't exist in the plugin's folder.");

View File

@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.filoghost.holographicdisplays.HolographicDisplays; import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
@ -14,6 +15,7 @@ import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand;
import com.gmail.filoghost.holographicdisplays.disk.Configuration; import com.gmail.filoghost.holographicdisplays.disk.Configuration;
import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase; import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase;
import com.gmail.filoghost.holographicdisplays.disk.UnicodeSymbols; import com.gmail.filoghost.holographicdisplays.disk.UnicodeSymbols;
import com.gmail.filoghost.holographicdisplays.event.HolographicDisplaysReloadEvent;
import com.gmail.filoghost.holographicdisplays.exception.CommandException; import com.gmail.filoghost.holographicdisplays.exception.CommandException;
import com.gmail.filoghost.holographicdisplays.exception.HologramNotFoundException; import com.gmail.filoghost.holographicdisplays.exception.HologramNotFoundException;
import com.gmail.filoghost.holographicdisplays.exception.InvalidFormatException; import com.gmail.filoghost.holographicdisplays.exception.InvalidFormatException;
@ -84,6 +86,8 @@ public class ReloadCommand extends HologramSubCommand {
ex.printStackTrace(); ex.printStackTrace();
throw new CommandException("Exception while reloading the configuration. Please look the console."); throw new CommandException("Exception while reloading the configuration. Please look the console.");
} }
Bukkit.getPluginManager().callEvent(new HolographicDisplaysReloadEvent());
} }
@Override @Override

View File

@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.commands.main.subs;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.filoghost.holographicdisplays.commands.Colors; import com.gmail.filoghost.holographicdisplays.commands.Colors;
@ -10,6 +11,7 @@ import com.gmail.filoghost.holographicdisplays.commands.CommandValidator;
import com.gmail.filoghost.holographicdisplays.commands.Strings; import com.gmail.filoghost.holographicdisplays.commands.Strings;
import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand; import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand;
import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase; import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase;
import com.gmail.filoghost.holographicdisplays.event.NamedHologramEditedEvent;
import com.gmail.filoghost.holographicdisplays.exception.CommandException; import com.gmail.filoghost.holographicdisplays.exception.CommandException;
import com.gmail.filoghost.holographicdisplays.object.NamedHologram; import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager; import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
@ -50,6 +52,7 @@ public class RemovelineCommand extends HologramSubCommand {
HologramDatabase.saveHologram(hologram); HologramDatabase.saveHologram(hologram);
HologramDatabase.trySaveToDisk(); HologramDatabase.trySaveToDisk();
sender.sendMessage(Colors.PRIMARY + "Line " + lineNumber + " removed!"); sender.sendMessage(Colors.PRIMARY + "Line " + lineNumber + " removed!");
Bukkit.getPluginManager().callEvent(new NamedHologramEditedEvent(hologram));
} }
@Override @Override

View File

@ -3,6 +3,7 @@ package com.gmail.filoghost.holographicdisplays.commands.main.subs;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.filoghost.holographicdisplays.commands.Colors; import com.gmail.filoghost.holographicdisplays.commands.Colors;
@ -10,6 +11,7 @@ import com.gmail.filoghost.holographicdisplays.commands.CommandValidator;
import com.gmail.filoghost.holographicdisplays.commands.Strings; import com.gmail.filoghost.holographicdisplays.commands.Strings;
import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand; import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand;
import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase; import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase;
import com.gmail.filoghost.holographicdisplays.event.NamedHologramEditedEvent;
import com.gmail.filoghost.holographicdisplays.exception.CommandException; import com.gmail.filoghost.holographicdisplays.exception.CommandException;
import com.gmail.filoghost.holographicdisplays.object.NamedHologram; import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager; import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
@ -50,6 +52,7 @@ public class SetlineCommand extends HologramSubCommand {
HologramDatabase.saveHologram(hologram); HologramDatabase.saveHologram(hologram);
HologramDatabase.trySaveToDisk(); HologramDatabase.trySaveToDisk();
sender.sendMessage(Colors.PRIMARY + "Line " + lineNumber + " changed!"); sender.sendMessage(Colors.PRIMARY + "Line " + lineNumber + " changed!");
Bukkit.getPluginManager().callEvent(new NamedHologramEditedEvent(hologram));
} }

View File

@ -3,22 +3,10 @@ package com.gmail.filoghost.holographicdisplays.event;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
public class HolographicDisplaysReloadEvent extends Event { public class HolographicDisplaysReloadEvent extends Event {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private NamedHologram namedHologram;
public HolographicDisplaysReloadEvent(NamedHologram namedHologram) {
this.namedHologram = namedHologram;
}
public NamedHologram getNamedHologram() {
return namedHologram;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -3,10 +3,22 @@ package com.gmail.filoghost.holographicdisplays.event;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
public class NamedHologramEditedEvent extends Event { public class NamedHologramEditedEvent extends Event {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private NamedHologram namedHologram;
public NamedHologramEditedEvent(NamedHologram namedHologram) {
this.namedHologram = namedHologram;
}
public NamedHologram getNamedHologram() {
return namedHologram;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;