use of org.bukkit.plugin.java.JavaPlugin in project BKCommonLib by bergerhealer.
the class CommonMapController method handleMapShowEvent.
private synchronized void handleMapShowEvent(MapShowEvent event) {
// Check if there are other map displays that should be shown to the player automatically
// This uses the 'isGlobal()' property of the display
MapDisplayInfo info = CommonMapController.this.getInfo(event.getMapUUID());
boolean hasDisplay = false;
if (info != null) {
for (MapSession session : info.sessions) {
if (session.display.isGlobal()) {
session.display.addOwner(event.getPlayer());
hasDisplay = true;
break;
}
}
}
// When defined in the NBT of the item, construct the Map Display automatically
CommonTagCompound tag = ItemUtil.getMetaTag(event.getMapItem(), false);
if (tag != null && !hasDisplay) {
String pluginName = tag.getValue("mapDisplayPlugin", String.class);
String displayClassName = tag.getValue("mapDisplayClass", String.class);
if (pluginName != null && displayClassName != null) {
Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
Class<?> displayClass = null;
if (plugin != null) {
try {
displayClass = plugin.getClass().getClassLoader().loadClass(displayClassName);
if (!MapDisplay.class.isAssignableFrom(displayClass)) {
displayClass = null;
}
} catch (ClassNotFoundException e) {
}
}
if (displayClass != null && !event.hasDisplay()) {
try {
MapDisplay display = (MapDisplay) displayClass.newInstance();
event.setDisplay((JavaPlugin) plugin, display);
;
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
CommonUtil.callEvent(event);
}
use of org.bukkit.plugin.java.JavaPlugin in project MyMaid2 by jaoafa.
the class Jail method SaveJailData.
/**
* Jail情報をセーブする。
* @return 実行できたかどうか
* @author mine_book000
* @throws Exception IOExceptionの発生時に発生
*/
@SuppressWarnings("unchecked")
public static boolean SaveJailData() throws Exception {
JSONArray JailJSON = new JSONArray();
for (String player : Jail) {
JailJSON.add(player);
}
JSONObject BlockJSON = new JSONObject();
for (Entry<String, Boolean> one : block.entrySet()) {
BlockJSON.put(one.getKey(), one.getValue());
}
JSONObject AreaJSON = new JSONObject();
for (Entry<String, Boolean> one : area.entrySet()) {
AreaJSON.put(one.getKey(), one.getValue());
}
JSONObject LastTextJSON = new JSONObject();
for (Entry<String, Boolean> one : lasttext.entrySet()) {
LastTextJSON.put(one.getKey(), one.getValue());
}
JSONObject ALLJSON = new JSONObject();
ALLJSON.put("Jail", JailJSON);
ALLJSON.put("Block", BlockJSON);
ALLJSON.put("Area", AreaJSON);
ALLJSON.put("LastText", LastTextJSON);
try {
JavaPlugin plugin = JavaPlugin();
File file = new File(plugin.getDataFolder(), "jail.json");
FileWriter filewriter = new FileWriter(file);
filewriter.write(ALLJSON.toJSONString());
filewriter.close();
} catch (IOException e) {
BugReporter(e);
throw new Exception("IOException");
}
return true;
}
use of org.bukkit.plugin.java.JavaPlugin in project MyMaid2 by jaoafa.
the class Cmd_DT method onTabComplete.
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
if (args.length == 1) {
if (args[0].length() == 0) {
// /dtまで
Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
if (dynmap == null || !dynmap.isEnabled()) {
SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
return plugin.onTabComplete(sender, cmd, alias, args);
}
List<String> tablist = new ArrayList<>();
tablist.add("add");
tablist.add("del");
tablist.add("list");
DynmapAPI dynmapapi = (DynmapAPI) dynmap;
MarkerAPI markerapi = dynmapapi.getMarkerAPI();
for (MarkerSet markerset : markerapi.getMarkerSets()) {
for (Marker marker : markerset.getMarkers()) {
tablist.add(marker.getLabel());
}
}
return tablist;
} else {
Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
if (dynmap == null || !dynmap.isEnabled()) {
SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
return plugin.onTabComplete(sender, cmd, alias, args);
}
List<String> tablist = new ArrayList<>();
tablist.add("add");
tablist.add("del");
tablist.add("list");
DynmapAPI dynmapapi = (DynmapAPI) dynmap;
MarkerAPI markerapi = dynmapapi.getMarkerAPI();
for (MarkerSet markerset : markerapi.getMarkerSets()) {
for (Marker marker : markerset.getMarkers()) {
tablist.add(marker.getLabel());
}
}
List<String> tablistFor = new ArrayList<>();
tablistFor.addAll(tablist);
for (String tab : tablistFor) {
if (!tab.toLowerCase().startsWith(args[0].toLowerCase())) {
tablist.remove(tab);
}
}
if (tablist.size() == 0) {
return plugin.onTabComplete(sender, cmd, alias, args);
}
return tablist;
}
} else if (args.length == 2) {
if (args[1].length() == 0) {
// /dt ~まで
if (args[0].equalsIgnoreCase("del")) {
Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
if (dynmap == null || !dynmap.isEnabled()) {
SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
return plugin.onTabComplete(sender, cmd, alias, args);
}
List<String> tablist = new ArrayList<>();
DynmapAPI dynmapapi = (DynmapAPI) dynmap;
MarkerAPI markerapi = dynmapapi.getMarkerAPI();
for (MarkerSet markerset : markerapi.getMarkerSets()) {
for (Marker marker : markerset.getMarkers()) {
tablist.add(marker.getLabel());
}
}
return tablist;
} else {
Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
if (dynmap == null || !dynmap.isEnabled()) {
SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
return plugin.onTabComplete(sender, cmd, alias, args);
}
Player player = Bukkit.getPlayerExact(args[0]);
if (player == null) {
SendMessage(sender, cmd, "入力されているプレイヤー「" + args[0] + "」は見つかりません。");
Player any_chance_player = Bukkit.getPlayer(args[0]);
if (any_chance_player != null) {
SendMessage(sender, cmd, "もしかして: " + any_chance_player.getName());
}
return plugin.onTabComplete(sender, cmd, alias, args);
}
List<String> tablist = new ArrayList<>();
DynmapAPI dynmapapi = (DynmapAPI) dynmap;
MarkerAPI markerapi = dynmapapi.getMarkerAPI();
for (MarkerSet markerset : markerapi.getMarkerSets()) {
for (Marker marker : markerset.getMarkers()) {
tablist.add(marker.getLabel());
}
}
List<String> tablistFor = new ArrayList<>();
tablistFor.addAll(tablist);
for (String tab : tablistFor) {
if (!tab.toLowerCase().startsWith(args[1].toLowerCase())) {
tablist.remove(tab);
}
}
if (tablist.size() == 0) {
return plugin.onTabComplete(sender, cmd, alias, args);
}
return tablist;
}
} else {
if (args[0].equalsIgnoreCase("del")) {
Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
if (dynmap == null || !dynmap.isEnabled()) {
SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
return plugin.onTabComplete(sender, cmd, alias, args);
}
List<String> tablist = new ArrayList<>();
DynmapAPI dynmapapi = (DynmapAPI) dynmap;
MarkerAPI markerapi = dynmapapi.getMarkerAPI();
for (MarkerSet markerset : markerapi.getMarkerSets()) {
for (Marker marker : markerset.getMarkers()) {
tablist.add(marker.getLabel());
}
}
List<String> tablistFor = new ArrayList<>();
tablistFor.addAll(tablist);
for (String tab : tablistFor) {
if (!tab.startsWith(args[1])) {
tablist.remove(tab);
}
}
if (tablist.size() == 0) {
return plugin.onTabComplete(sender, cmd, alias, args);
}
return tablist;
} else {
Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
if (dynmap == null || !dynmap.isEnabled()) {
SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
return plugin.onTabComplete(sender, cmd, alias, args);
}
Player player = Bukkit.getPlayerExact(args[0]);
if (player == null) {
SendMessage(sender, cmd, "入力されているプレイヤー「" + args[0] + "」は見つかりません。");
Player any_chance_player = Bukkit.getPlayer(args[0]);
if (any_chance_player != null) {
SendMessage(sender, cmd, "もしかして: " + any_chance_player.getName());
}
return plugin.onTabComplete(sender, cmd, alias, args);
}
List<String> tablist = new ArrayList<>();
DynmapAPI dynmapapi = (DynmapAPI) dynmap;
MarkerAPI markerapi = dynmapapi.getMarkerAPI();
for (MarkerSet markerset : markerapi.getMarkerSets()) {
for (Marker marker : markerset.getMarkers()) {
tablist.add(marker.getLabel());
}
}
List<String> tablistFor = new ArrayList<>();
tablistFor.addAll(tablist);
for (String tab : tablistFor) {
if (!tab.toLowerCase().startsWith(args[1].toLowerCase())) {
tablist.remove(tab);
}
}
if (tablist.size() == 0) {
return plugin.onTabComplete(sender, cmd, alias, args);
}
return tablist;
}
}
} else if (args.length == 3) {
if (args[2].length() == 0) {
// /dt ~ ~まで
if (args[0].equalsIgnoreCase("add")) {
// <MarkerType>を出す
Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
if (dynmap == null || !dynmap.isEnabled()) {
SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
return plugin.onTabComplete(sender, cmd, alias, args);
}
List<String> tablist = new ArrayList<>();
DynmapAPI dynmapapi = (DynmapAPI) dynmap;
MarkerAPI markerapi = dynmapapi.getMarkerAPI();
for (MarkerSet markerset : markerapi.getMarkerSets()) {
tablist.add(markerset.getMarkerSetLabel());
}
return tablist;
}
} else {
if (args[0].equalsIgnoreCase("add")) {
Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
if (dynmap == null || !dynmap.isEnabled()) {
SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
return plugin.onTabComplete(sender, cmd, alias, args);
}
List<String> tablist = new ArrayList<>();
DynmapAPI dynmapapi = (DynmapAPI) dynmap;
MarkerAPI markerapi = dynmapapi.getMarkerAPI();
for (MarkerSet markerset : markerapi.getMarkerSets()) {
tablist.add(markerset.getMarkerSetLabel());
}
List<String> tablistFor = new ArrayList<>();
tablistFor.addAll(tablist);
for (String tab : tablistFor) {
if (!tab.toLowerCase().startsWith(args[2].toLowerCase())) {
tablist.remove(tab);
}
}
if (tablist.size() == 0) {
return plugin.onTabComplete(sender, cmd, alias, args);
}
return tablist;
}
}
}
// JavaPlugin#onTabComplete()を呼び出す
return plugin.onTabComplete(sender, cmd, alias, args);
}
use of org.bukkit.plugin.java.JavaPlugin in project Karus-Commons by Pante.
the class PluginProcessor method process.
@Override
public void process(Class<? extends JavaPlugin> plugin, ConfigurationSection config) {
Plugin annotation = plugin.getAnnotation(Plugin.class);
processName(annotation, config);
processMain(plugin, config);
processVersion(annotation, config);
}
use of org.bukkit.plugin.java.JavaPlugin in project Karus-Commons by Pante.
the class Resolver method load.
protected Set<Class<? extends JavaPlugin>> load() {
URL[] urls = elements.stream().map(element -> {
try {
return new File(element).toURI().toURL();
} catch (MalformedURLException e) {
throw new UncheckedIOException(e);
}
}).toArray(URL[]::new);
Reflections reflections = new Reflections(URLClassLoader.newInstance(urls, getClass().getClassLoader()));
return reflections.getSubTypesOf(JavaPlugin.class).stream().filter(type -> type.getAnnotation(Plugin.class) != null).collect(toSet());
}
Aggregations