world hopper: add region filter config
This commit is contained in:
@@ -136,6 +136,17 @@ public interface WorldHopperConfig extends Config
|
|||||||
return SubscriptionFilterMode.BOTH;
|
return SubscriptionFilterMode.BOTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "regionFilter",
|
||||||
|
name = "Filter worlds by region",
|
||||||
|
description = "Restrict sidebar worlds to one region",
|
||||||
|
position = 8
|
||||||
|
)
|
||||||
|
default RegionFilterMode regionFilter()
|
||||||
|
{
|
||||||
|
return RegionFilterMode.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "displayPing",
|
keyName = "displayPing",
|
||||||
name = "Display current ping",
|
name = "Display current ping",
|
||||||
|
|||||||
@@ -209,7 +209,8 @@ public class WorldHopperPlugin extends Plugin
|
|||||||
|
|
||||||
overlayManager.add(worldHopperOverlay);
|
overlayManager.add(worldHopperOverlay);
|
||||||
|
|
||||||
panel.setFilterMode(config.subscriptionFilter());
|
panel.setSubscriptionFilterMode(config.subscriptionFilter());
|
||||||
|
panel.setRegionFilterMode(config.regionFilter());
|
||||||
|
|
||||||
// The plugin has its own executor for pings, as it blocks for a long time
|
// The plugin has its own executor for pings, as it blocks for a long time
|
||||||
hopperExecutorService = new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor());
|
hopperExecutorService = new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor());
|
||||||
@@ -272,7 +273,11 @@ public class WorldHopperPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "subscriptionFilter":
|
case "subscriptionFilter":
|
||||||
panel.setFilterMode(config.subscriptionFilter());
|
panel.setSubscriptionFilterMode(config.subscriptionFilter());
|
||||||
|
updateList();
|
||||||
|
break;
|
||||||
|
case "regionFilter":
|
||||||
|
panel.setRegionFilterMode(config.regionFilter());
|
||||||
updateList();
|
updateList();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,9 @@ class WorldSwitcherPanel extends PluginPanel
|
|||||||
private final ArrayList<WorldTableRow> rows = new ArrayList<>();
|
private final ArrayList<WorldTableRow> rows = new ArrayList<>();
|
||||||
private final WorldHopperPlugin plugin;
|
private final WorldHopperPlugin plugin;
|
||||||
@Setter(AccessLevel.PACKAGE)
|
@Setter(AccessLevel.PACKAGE)
|
||||||
private SubscriptionFilterMode filterMode;
|
private SubscriptionFilterMode subscriptionFilterMode;
|
||||||
|
@Setter(AccessLevel.PACKAGE)
|
||||||
|
private RegionFilterMode regionFilterMode;
|
||||||
|
|
||||||
WorldSwitcherPanel(WorldHopperPlugin plugin)
|
WorldSwitcherPanel(WorldHopperPlugin plugin)
|
||||||
{
|
{
|
||||||
@@ -231,7 +233,7 @@ class WorldSwitcherPanel extends PluginPanel
|
|||||||
{
|
{
|
||||||
World world = worlds.get(i);
|
World world = worlds.get(i);
|
||||||
|
|
||||||
switch (filterMode)
|
switch (subscriptionFilterMode)
|
||||||
{
|
{
|
||||||
case FREE:
|
case FREE:
|
||||||
if (world.getTypes().contains(WorldType.MEMBERS))
|
if (world.getTypes().contains(WorldType.MEMBERS))
|
||||||
@@ -247,6 +249,11 @@ class WorldSwitcherPanel extends PluginPanel
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (regionFilterMode.getRegion() != null && !regionFilterMode.getRegion().equals(world.getRegion()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
rows.add(buildRow(world, i % 2 == 0, world.getId() == plugin.getCurrentWorld() && plugin.getLastWorld() != 0, plugin.isFavorite(world)));
|
rows.add(buildRow(world, i % 2 == 0, world.getId() == plugin.getCurrentWorld() && plugin.getLastWorld() != 0, plugin.isFavorite(world)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user