use of org.bukkit.plugin.PluginManager in project Essentials by drtshock.
the class EssentialsAntiBuild method onEnable.
@Override
public void onEnable() {
final PluginManager pm = this.getServer().getPluginManager();
final Plugin essPlugin = pm.getPlugin("Essentials");
if (essPlugin == null || !essPlugin.isEnabled()) {
return;
}
ess = new EssentialsConnect(essPlugin, this);
final EssentialsAntiBuildListener blockListener = new EssentialsAntiBuildListener(this);
pm.registerEvents(blockListener, this);
if (metrics == null) {
metrics = new MetricsWrapper(this, 3813, false);
}
}
use of org.bukkit.plugin.PluginManager in project Essentials by drtshock.
the class EssentialsChat method onEnable.
@Override
public void onEnable() {
final PluginManager pluginManager = getServer().getPluginManager();
ess = (IEssentials) pluginManager.getPlugin("Essentials");
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
getLogger().log(Level.WARNING, tl("versionMismatchAll"));
}
if (!ess.isEnabled()) {
this.setEnabled(false);
return;
}
final Map<AsyncPlayerChatEvent, ChatStore> chatStore = Collections.synchronizedMap(new HashMap<>());
final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatStore);
final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, chatStore);
final EssentialsChatPlayerListenerHighest playerListenerHighest = new EssentialsChatPlayerListenerHighest(getServer(), ess, chatStore);
pluginManager.registerEvents(playerListenerLowest, this);
pluginManager.registerEvents(playerListenerNormal, this);
pluginManager.registerEvents(playerListenerHighest, this);
if (metrics == null) {
metrics = new MetricsWrapper(this, 3814, false);
}
}
use of org.bukkit.plugin.PluginManager in project EvenMoreFish by Oheers.
the class Reward method run.
public void run(OfflinePlayer player, Location hookLocation) {
Player p = null;
if (player.isOnline())
p = (Player) player;
switch(type) {
case COMMAND:
String inputCommand = this.action.replace("{player}", player.getName());
if (hookLocation != null) {
inputCommand = inputCommand.replace("{x}", Double.toString(hookLocation.getX())).replace("{y}", Double.toString(hookLocation.getY())).replace("{z}", Double.toString(hookLocation.getZ())).replace("{world}", hookLocation.getWorld().getName());
}
// running the command
String finalCommand = inputCommand;
Bukkit.getScheduler().callSyncMethod(plugin, () -> Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), finalCommand));
break;
case EFFECT:
if (p != null) {
String[] parsedEffect = action.split(",");
// Adds a potion effect in accordance to the config.yml "EFFECT:" value
p.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(parsedEffect[0])), Integer.parseInt(parsedEffect[2]) * 20, Integer.parseInt(parsedEffect[1])));
}
break;
case HEALTH:
if (p != null) {
if (!(p.getHealth() > 20)) {
double newhealth = p.getHealth() + Integer.parseInt(action);
// checking the new health won't go above 20
if (newhealth > 20) {
p.setHealth(20);
} else {
p.setHealth(newhealth);
}
}
}
break;
case HUNGER:
if (p != null) {
p.setFoodLevel(p.getFoodLevel() + Integer.parseInt(action));
}
break;
case ITEM:
if (p != null) {
String[] parsedItem = action.split(",");
FishUtils.giveItems(Collections.singletonList(new ItemStack(Material.getMaterial(parsedItem[0]), Integer.parseInt(parsedItem[1]))), p);
}
break;
case MESSAGE:
if (p != null) {
p.sendMessage(FishUtils.translateHexColorCodes(action));
}
break;
case MONEY:
EvenMoreFish.econ.depositPlayer(player, Integer.parseInt(action));
break;
case OTHER:
PluginManager pM = Bukkit.getPluginManager();
EMFRewardEvent event = new EMFRewardEvent(this, p, fishVelocity, hookLocation);
pM.callEvent(event);
break;
default:
EvenMoreFish.logger.log(Level.SEVERE, "Error in loading a reward.");
}
}
use of org.bukkit.plugin.PluginManager in project NextEconomy by NextPlugins.
the class PurseAPI method updatePurse.
/**
* Change purse value with messages and calling event (Better way)
*
* @param newValue to purse
*/
public void updatePurse(int newValue) {
val lastNextUpdate = nextUpdate;
val duration = PurseValue.get(PurseValue::nextUpdate);
setNextUpdate(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(duration));
Bukkit.getScheduler().runTaskAsynchronously(NextEconomy.getInstance(), () -> {
val asyncPurseUpdateEvent = new AsyncPurseUpdateEvent(newValue, purse, lastNextUpdate);
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.callEvent(asyncPurseUpdateEvent);
});
}
use of org.bukkit.plugin.PluginManager in project NoCheatPlus by NoCheatPlus.
the class PermissionUtil method addChildPermissionBySuffix.
/**
* @param permissionName
* A permission already registered with Bukkit.
* @param childPermissionSuffix
* The suffix to add, the resulting permission will b registered
* with the permissionRegistry and Bukkit, if not yet done. No
* leading dot, results in: permissionName.childPermissionSuffix
* @param permissionDefault
* Default for child permissions.
* @throws NullPointerException
* If no permission is registered for permissionName.
*/
public static void addChildPermissionBySuffix(final RegisteredPermission registeredPermission, final String childPermissionSuffix, final PermissionRegistry permissionRegistry, final PermissionDefault permissionDefault, final boolean childValue) {
final String permissionName = registeredPermission.getStringRepresentation();
final String childPermissionName = permissionName + "." + childPermissionSuffix;
// Ensure it s registered like this.
permissionRegistry.getOrRegisterPermission(childPermissionName);
final PluginManager pm = Bukkit.getPluginManager();
final Permission permission = pm.getPermission(permissionName);
if (permission == null) {
throw new NullPointerException("Permission is not registered: " + permissionName);
}
Permission childPermission = pm.getPermission(childPermissionName);
if (childPermission == null) {
childPermission = new Permission(childPermissionName, AUTO_GENERATED, permissionDefault);
pm.addPermission(childPermission);
}
if (!permission.getChildren().containsKey(childPermissionName)) {
childPermission.addParent(permission, childValue);
}
}
Aggregations