mirror of
https://github.com/songoda/EpicHoppers.git
synced 2025-01-10 09:57:45 +01:00
Filter is now a levelup ability.
Teleport is now a levelup ability. IF you want to just give people teleport and filter perms to go with say a donator rank you may also give them perms for these and remove them from the levels as permissions will override.
This commit is contained in:
parent
08001075a3
commit
1e2c4677f3
@ -13,6 +13,10 @@ public interface Level {
|
||||
|
||||
int getBlockBreak();
|
||||
|
||||
boolean isFilter();
|
||||
|
||||
boolean isTeleport();
|
||||
|
||||
int getSuction();
|
||||
|
||||
int getCostExperience();
|
||||
|
@ -16,8 +16,10 @@ public interface LevelManager {
|
||||
* @param amount The amount of items this hopper will transfer at a single time
|
||||
* @param suction The distance in which this hopper will suck items into it
|
||||
* @param blockBreak The tick frequency in which this hopper will break blocks placed directly above it.
|
||||
* @param filter Whether or not access to the filter is allowed.
|
||||
* @param teleport Whether or not teleporting through hoppers is allowed.
|
||||
*/
|
||||
void addLevel(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak);
|
||||
void addLevel(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak, boolean filter, boolean teleport);
|
||||
|
||||
/**
|
||||
* Get {@link Level} by corresponding integer value.
|
||||
|
@ -214,9 +214,11 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
int amount = getConfig().getInt("settings.levels." + levelName + ".Amount");
|
||||
int suction = getConfig().getInt("settings.levels." + levelName + ".Suction");
|
||||
int blockBreak = getConfig().getInt("settings.levels." + levelName + ".BlockBreak");
|
||||
boolean filter = getConfig().getBoolean("settings.levels." + levelName + ".Filter");
|
||||
boolean teleport = getConfig().getBoolean("settings.levels." + levelName + ".Teleport");
|
||||
int costExperiance = getConfig().getInt("settings.levels." + levelName + ".Cost-xp");
|
||||
int costEconomy = getConfig().getInt("settings.levels." + levelName + ".Cost-eco");
|
||||
levelManager.addLevel(level, costExperiance, costEconomy, radius, amount, suction, blockBreak);
|
||||
levelManager.addLevel(level, costExperiance, costEconomy, radius, amount, suction, blockBreak, filter, teleport);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,7 +245,6 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
getConfig().addDefault("settings.levels.Level-4.Range", 40);
|
||||
getConfig().addDefault("settings.levels.Level-4.Amount", 4);
|
||||
getConfig().addDefault("settings.levels.Level-4.Suction", 2);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-4.BlockBreak", 4);
|
||||
getConfig().addDefault("settings.levels.Level-4.Cost-xp", 35);
|
||||
getConfig().addDefault("settings.levels.Level-4.Cost-eco", 12000);
|
||||
@ -251,10 +252,18 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
getConfig().addDefault("settings.levels.Level-5.Range", 50);
|
||||
getConfig().addDefault("settings.levels.Level-5.Amount", 5);
|
||||
getConfig().addDefault("settings.levels.Level-5.Suction", 3);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-5.BlockBreak", 2);
|
||||
getConfig().addDefault("settings.levels.Level-5.Cost-xp", 40);
|
||||
getConfig().addDefault("settings.levels.Level-5.Cost-eco", 15000);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-6.Range", 60);
|
||||
getConfig().addDefault("settings.levels.Level-6.Amount", 5);
|
||||
getConfig().addDefault("settings.levels.Level-6.Suction", 3);
|
||||
getConfig().addDefault("settings.levels.Level-6.BlockBreak", 2);
|
||||
getConfig().addDefault("settings.levels.Level-6.Filter", true);
|
||||
getConfig().addDefault("settings.levels.Level-6.Teleport", true);
|
||||
getConfig().addDefault("settings.levels.Level-6.Cost-xp", 45);
|
||||
getConfig().addDefault("settings.levels.Level-6.Cost-eco", 20000);
|
||||
}
|
||||
|
||||
getConfig().options().copyDefaults(true);
|
||||
|
@ -139,8 +139,8 @@ public class EHopper implements Hopper {
|
||||
nu++;
|
||||
}
|
||||
|
||||
boolean canFilter = instance.getConfig().getBoolean("Main.Allow Players To use The hopper Filter") && player.hasPermission("EpicHoppers.Filter");
|
||||
boolean canTeleport = instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") && player.hasPermission("EpicHoppers.Teleport");
|
||||
boolean canFilter = level.isFilter() || player.hasPermission("EpicHoppers.Filter");
|
||||
boolean canTeleport = level.isTeleport() || player.hasPermission("EpicHoppers.Teleport");
|
||||
if (!canFilter && canTeleport)
|
||||
i.setItem(4, perl);
|
||||
else if (!canTeleport && canFilter)
|
||||
|
@ -10,9 +10,11 @@ public class ELevel implements Level {
|
||||
|
||||
private int level, costExperience, costEconomy, range, amount, blockBreak, suction;
|
||||
|
||||
private boolean filter, teleport;
|
||||
|
||||
private List<String> description = new ArrayList<>();
|
||||
|
||||
public ELevel(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||
public ELevel(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak, boolean filter, boolean teleport) {
|
||||
this.level = level;
|
||||
this.costExperience = costExperience;
|
||||
this.costEconomy = costEconomy;
|
||||
@ -20,6 +22,8 @@ public class ELevel implements Level {
|
||||
this.amount = amount;
|
||||
this.blockBreak = blockBreak;
|
||||
this.suction = suction;
|
||||
this.filter = filter;
|
||||
this.teleport = teleport;
|
||||
|
||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||
|
||||
@ -27,6 +31,8 @@ public class ELevel implements Level {
|
||||
description.add(instance.getLocale().getMessage("interface.hopper.amount", amount));
|
||||
if (suction != 0) description.add(instance.getLocale().getMessage("interface.hopper.suction", suction));
|
||||
if (blockBreak != 0) description.add(instance.getLocale().getMessage("interface.hopper.blockbreak", blockBreak));
|
||||
if (filter) description.add(instance.getLocale().getMessage("interface.hopper.filter", true));
|
||||
if (teleport) description.add(instance.getLocale().getMessage("interface.hopper.filter", true));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,6 +60,16 @@ public class ELevel implements Level {
|
||||
return blockBreak;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTeleport() {
|
||||
return teleport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSuction() {
|
||||
return suction;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epichoppers.hopper;
|
||||
|
||||
import com.songoda.epichoppers.api.hopper.Level;
|
||||
import com.songoda.epichoppers.api.hopper.LevelManager;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -12,22 +13,22 @@ public class ELevelManager implements LevelManager {
|
||||
private final NavigableMap<Integer, ELevel> registeredLevels = new TreeMap<>();
|
||||
|
||||
@Override
|
||||
public void addLevel(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||
registeredLevels.put(level, new ELevel(level, costExperience, costEconomy, range, amount, suction, blockBreak));
|
||||
public void addLevel(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak, boolean filter, boolean teleport) {
|
||||
registeredLevels.put(level, new ELevel(level, costExperience, costEconomy, range, amount, suction, blockBreak, filter, teleport));
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.songoda.epichoppers.api.hopper.Level getLevel(int level) {
|
||||
public Level getLevel(int level) {
|
||||
return registeredLevels.get(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.songoda.epichoppers.api.hopper.Level getLowestLevel() {
|
||||
public Level getLowestLevel() {
|
||||
return registeredLevels.firstEntry().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.songoda.epichoppers.api.hopper.Level getHighestLevel() {
|
||||
public Level getHighestLevel() {
|
||||
return registeredLevels.lastEntry().getValue();
|
||||
}
|
||||
|
||||
@ -37,7 +38,7 @@ public class ELevelManager implements LevelManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, com.songoda.epichoppers.api.hopper.Level> getLevels() {
|
||||
public Map<Integer, Level> getLevels() {
|
||||
return Collections.unmodifiableMap(registeredLevels);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class InventoryListeners implements Listener {
|
||||
Hopper hopper = playerData.getLastHopper();
|
||||
if (event.getCurrentItem().getItemMeta().hasDisplayName()
|
||||
&& event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.perltitle"))
|
||||
&& (instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") || player.hasPermission("EpicHoppers.Teleport"))) {
|
||||
&& (hopper.getLevel().isTeleport() || player.hasPermission("EpicHoppers.Teleport"))) {
|
||||
if (event.isLeftClick()) {
|
||||
if (hopper.getSyncedBlock() != null) {
|
||||
instance.getTeleportHandler().tpPlayer(player, hopper);
|
||||
@ -94,7 +94,7 @@ public class InventoryListeners implements Listener {
|
||||
player.closeInventory();
|
||||
|
||||
|
||||
} else if (event.getCurrentItem().getItemMeta().hasDisplayName() && event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.filtertitle")) && player.hasPermission("EpicHoppers.Filter")) {
|
||||
} else if (event.getCurrentItem().getItemMeta().hasDisplayName() && event.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.filtertitle")) && (hopper.getLevel().isFilter() || player.hasPermission("EpicHoppers.Filter"))) {
|
||||
if (!event.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
((EHopper)hopper).filter(player);
|
||||
}
|
||||
|
@ -203,7 +203,6 @@ public class SettingsManager implements Listener {
|
||||
o2("Upgrade-with-eco", "Main.Upgrade With Economy", true),
|
||||
o3("Upgrade-with-xp", "Main.Upgrade With XP", true),
|
||||
o4("Teleport-hoppers", "Main.Allow Players To Teleport Through Hoppers", true),
|
||||
o5("Filter-hoppers", "Main.Allow Players To use The hopper Filter", true),
|
||||
o6("EnderChest-support", "Main.Support Enderchests", true),
|
||||
o7("Upgrade-particle-type", "Main.Upgrade Particle Type", "SPELL_WITCH"),
|
||||
o8("Hop-Tick", "Main.Amount of Ticks Between Hops", 8L),
|
||||
|
Loading…
Reference in New Issue
Block a user