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.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
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.main.HologramSubCommand;
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.object.NamedHologram;
import com.gmail.filoghost.holographicdisplays.object.NamedHologramManager;
@ -43,6 +45,7 @@ public class AddlineCommand extends HologramSubCommand {
HologramDatabase.saveHologram(hologram);
HologramDatabase.trySaveToDisk();
sender.sendMessage(Colors.PRIMARY + "Line added!");
Bukkit.getPluginManager().callEvent(new NamedHologramEditedEvent(hologram));
}
@Override

View File

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

View File

@ -9,6 +9,7 @@ import java.net.URL;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
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.main.HologramSubCommand;
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.TooWideException;
import com.gmail.filoghost.holographicdisplays.exception.UnreadableImageException;
@ -113,6 +115,7 @@ public class ReadimageCommand extends HologramSubCommand {
} else {
sender.sendMessage(Colors.PRIMARY + "The image was drawn in the hologram!");
}
Bukkit.getPluginManager().callEvent(new NamedHologramEditedEvent(hologram));
} catch (MalformedURLException e) {
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.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
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.disk.HologramDatabase;
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.object.NamedHologram;
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!");
Bukkit.getPluginManager().callEvent(new NamedHologramEditedEvent(hologram));
} catch (FileNotFoundException e) {
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.Set;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
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.HologramDatabase;
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.HologramNotFoundException;
import com.gmail.filoghost.holographicdisplays.exception.InvalidFormatException;
@ -54,7 +56,7 @@ public class ReloadCommand extends HologramSubCommand {
AnimationsRegister.loadAnimations(HolographicDisplays.getInstance());
PlaceholdersManager.untrackAll();
NamedHologramManager.clearAll();
NamedHologramManager.clearAll();
Set<String> savedHolograms = HologramDatabase.getHolograms();
if (savedHolograms != null && savedHolograms.size() > 0) {
@ -84,6 +86,8 @@ public class ReloadCommand extends HologramSubCommand {
ex.printStackTrace();
throw new CommandException("Exception while reloading the configuration. Please look the console.");
}
Bukkit.getPluginManager().callEvent(new HolographicDisplaysReloadEvent());
}
@Override

View File

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

View File

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

View File

@ -3,23 +3,11 @@ package com.gmail.filoghost.holographicdisplays.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.gmail.filoghost.holographicdisplays.object.NamedHologram;
public class HolographicDisplaysReloadEvent extends Event {
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() {
return handlers;
}

View File

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