mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-28 21:45:18 +01:00
Updated plugin organisation and disabled console portals by default
This commit is contained in:
parent
d392dfa88c
commit
160d1e4cc3
@ -72,3 +72,17 @@ CustomPrefixFail: '&c[&7AdvancedPortals&c]'
|
||||
|
||||
PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate.
|
||||
ThrowbackAmount: 0.7 # How fast to throw them back, 0 or lower to disable throwback
|
||||
|
||||
# Letters are flags. Include them to activate. n always disables everything, remove if you want it to work.
|
||||
# Lettering may not make too much sense but meh its useful. Examples are "ocpk" or "cop" (doesnt matter order)
|
||||
#
|
||||
# Remember enabling this means potentially admins could leave a portal lying around which could let them reop themselves.
|
||||
# If you think this may be an issue use a permission plugin and specifically give the users you trust permissions.
|
||||
#
|
||||
# n Disabled (none
|
||||
# o Admin Heighten Enabled Permission advancedportals.createportal.commandlevel.op
|
||||
# c Console Heighten Enabled Permission advancedportals.createportal.commandlevel.console
|
||||
# p Ops can create admin commands without special perms
|
||||
# k Ops can create console commands without special perms
|
||||
#
|
||||
CommandLevels: n
|
||||
|
@ -24,6 +24,18 @@ permissions:
|
||||
advancedportals.createportal:
|
||||
description: Allows you to create portals
|
||||
default: op
|
||||
advancedportals.createportal.commandlevel.*:
|
||||
description: Gives access to all level raisers
|
||||
default: false
|
||||
children:
|
||||
advancedportals.createportal.commandlevel.op: true
|
||||
advancedportals.createportal.commandlevel.console: true
|
||||
advancedportals.createportal.commandlevel.op:
|
||||
description: Allows you to increase the users level temporaily to op
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.console:
|
||||
description: Executes command in the console
|
||||
default: false
|
||||
advancedportals.portal:
|
||||
description: Allows use of portal commands
|
||||
default: op
|
||||
|
@ -126,6 +126,20 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
executesCommand = true;
|
||||
portalCommand = parseArgVariable(args, i, "command:");
|
||||
i += this.portalArgsStringLength - 1;
|
||||
if(!( portalCommand.startsWith("#")
|
||||
&& this.plugin.getSettings().hasCommandLevel("c")
|
||||
&& (sender.hasPermission("advancedportals.createportal.commandlevel.console")
|
||||
|| (this.plugin.getSettings().hasCommandLevel("k") && sender.isOp()) ) )){
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a console command portal!");
|
||||
return true;
|
||||
}
|
||||
else if(!( portalCommand.startsWith("!")
|
||||
&& this.plugin.getSettings().hasCommandLevel("o")
|
||||
&& (sender.hasPermission("advancedportals.createportal.commandlevel.op")
|
||||
|| (this.plugin.getSettings().hasCommandLevel("p") && sender.isOp()) ) )){
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a op command portal!");
|
||||
return true;
|
||||
}
|
||||
extraData.add(new PortalArg("command.1", portalCommand));
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import java.io.IOException;
|
||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
|
||||
public CraftBukkit compat = null;
|
||||
private Settings settings;
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
@ -38,10 +39,7 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
ConfigAccessor destinationConfig = new ConfigAccessor(this, "destinations.yml");
|
||||
destinationConfig.saveDefaultConfig();
|
||||
|
||||
new Assets(this);
|
||||
|
||||
// Opens a channel that messages bungeeCord
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
this.settings = new Settings(this);
|
||||
|
||||
// Loads the portal and destination editors
|
||||
new Portal(this);
|
||||
@ -50,27 +48,14 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
new DataCollector(this);
|
||||
|
||||
|
||||
// These register the commands
|
||||
new PluginMessages(this);
|
||||
new AdvancedPortalsCommand(this);
|
||||
new DestinationCommand(this);
|
||||
this.registerCommands();
|
||||
|
||||
new WarpEffects(this);
|
||||
|
||||
this.addListeners();
|
||||
this.setupDataCollector();
|
||||
|
||||
// These register the listeners
|
||||
new Listeners(this);
|
||||
|
||||
new FlowStopper(this);
|
||||
new PortalProtect(this);
|
||||
new PortalPlacer(this);
|
||||
|
||||
Selection.LoadData(this);
|
||||
|
||||
DataCollector.setupMetrics();
|
||||
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
|
||||
this.setupBungee();
|
||||
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!");
|
||||
|
||||
@ -92,10 +77,38 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
// only copy the file if it doesnt exist!
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
new PluginMessages(this);
|
||||
new AdvancedPortalsCommand(this);
|
||||
new DestinationCommand(this);
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
new Listeners(this);
|
||||
|
||||
new FlowStopper(this);
|
||||
new PortalProtect(this);
|
||||
new PortalPlacer(this);
|
||||
}
|
||||
|
||||
private void setupDataCollector() {
|
||||
Selection.LoadData(this);
|
||||
|
||||
DataCollector.setupMetrics();
|
||||
}
|
||||
|
||||
private void setupBungee() {
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
|
||||
}
|
||||
|
||||
|
||||
public void onDisable() {
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7cAdvanced portals are being disabled!");
|
||||
}
|
||||
|
||||
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
package com.sekwah.advancedportals;
|
||||
|
||||
public class Assets {
|
||||
|
||||
public static int currentWarpParticles = 0;
|
||||
|
||||
public static int currentWarpSound = 0;
|
||||
|
||||
public Assets(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
currentWarpParticles = config.getConfig().getInt("WarpParticles");
|
||||
currentWarpSound = config.getConfig().getInt("WarpSound");
|
||||
}
|
||||
|
||||
}
|
40
src/com/sekwah/advancedportals/Settings.java
Normal file
40
src/com/sekwah/advancedportals/Settings.java
Normal file
@ -0,0 +1,40 @@
|
||||
package com.sekwah.advancedportals;
|
||||
|
||||
/**
|
||||
* This contains generally used settings mostly
|
||||
*/
|
||||
public class Settings {
|
||||
|
||||
private int currentWarpParticles = 0;
|
||||
|
||||
private int currentWarpSound = 0;
|
||||
|
||||
private String commandLevels = "n";
|
||||
|
||||
public Settings(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
currentWarpParticles = config.getConfig().getInt("WarpParticles");
|
||||
currentWarpSound = config.getConfig().getInt("WarpSound");
|
||||
|
||||
commandLevels = config.getConfig().getString("CommandLevels", "n");
|
||||
if(commandLevels.equals("")){
|
||||
commandLevels = "n";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandLevels(){
|
||||
return this.commandLevels;
|
||||
}
|
||||
|
||||
public boolean hasCommandLevel(String level){
|
||||
return this.commandLevels.contains(level);
|
||||
}
|
||||
|
||||
public int getCurrentWarpSound() {
|
||||
return currentWarpSound;
|
||||
}
|
||||
|
||||
public int getCurrentWarpParticles() {
|
||||
return currentWarpParticles;
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package com.sekwah.advancedportals.effects;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.Assets;
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
@ -11,13 +9,17 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class WarpEffects {
|
||||
|
||||
private static AdvancedPortalsPlugin plugin = null;
|
||||
|
||||
public boolean oldSoundLoc = true;
|
||||
|
||||
public static Sound[] sounds = new Sound[2];
|
||||
|
||||
public static boolean soundError = false;
|
||||
|
||||
public WarpEffects(AdvancedPortalsPlugin plugin) {
|
||||
public WarpEffects(AdvancedPortalsPlugin pluginTemp) {
|
||||
|
||||
plugin = pluginTemp;
|
||||
|
||||
sounds[0] = findSound(plugin, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT");
|
||||
|
||||
@ -46,7 +48,7 @@ public class WarpEffects {
|
||||
public static void activateParticles(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
World world = player.getWorld();
|
||||
switch (Assets.currentWarpParticles){
|
||||
switch (plugin.getSettings().getCurrentWarpParticles()){
|
||||
case 1:
|
||||
for(int i = 0; i < 10; i++){
|
||||
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
@ -64,7 +66,7 @@ public class WarpEffects {
|
||||
if(!soundError){
|
||||
Location loc = player.getLocation();
|
||||
World world = player.getWorld();
|
||||
switch (Assets.currentWarpParticles){
|
||||
switch (plugin.getSettings().getCurrentWarpSound()){
|
||||
case 1:
|
||||
world.playSound(loc, sounds[0], 1F, 1F);
|
||||
default: break;
|
||||
|
@ -421,7 +421,7 @@ public class Portal {
|
||||
// (?i) makes the search case insensitive
|
||||
command = command.replaceAll("@player", player.getName());
|
||||
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
|
||||
if (command.startsWith("#")) {
|
||||
if (command.startsWith("#") && plugin.getSettings().hasCommandLevel("c")) {
|
||||
command = command.substring(1);
|
||||
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
|
||||
try{
|
||||
@ -430,7 +430,7 @@ public class Portal {
|
||||
catch(Exception e){
|
||||
plugin.getLogger().warning("Error while executing: " + command);
|
||||
}
|
||||
} else if (command.startsWith("!")) {
|
||||
} else if (command.startsWith("!") && plugin.getSettings().hasCommandLevel("o")) {
|
||||
command = command.substring(1);
|
||||
boolean wasOp = player.isOp();
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user