Skip to content
This repository was archived by the owner on Aug 13, 2022. It is now read-only.

Commit 733226a

Browse files
committed
patch 2.1.6
QoL Change, command/console-command runs after relogging in if the player spawns inside the region
1 parent 258fa68 commit 733226a

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

WGEF-Abstraction/src/main/java/io/github/invvk/wgef/abstraction/flags/handler/command/CommandOnEntryHandler.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,21 @@ protected CommandOnEntryHandler(Session session, Flag<Set<String>> flag) {
3131
super(session, flag);
3232
}
3333

34+
@Override
35+
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, Set<String> value) {
36+
this.handleCommands(WGEFUtils.wrapPlayer(player), set);
37+
}
38+
3439
@Override
3540
protected boolean onSetValue(LocalPlayer localPlayer, Location from, Location to, ApplicableRegionSet toSet, Set<String> currentValue, Set<String> lastValue, MoveType moveType) {
36-
Player player = WGEFUtils.wrapPlayer(localPlayer);
41+
this.handleCommands(WGEFUtils.wrapPlayer(localPlayer), toSet);
42+
return true;
43+
}
44+
45+
@Override
46+
protected boolean onAbsentValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> exited, Set<String> lastValue, MoveType moveType) {return true;}
47+
48+
private void handleCommands(Player player, ApplicableRegionSet toSet) {
3749
Set<String> execute = new HashSet<>();
3850
for (ProtectedRegion region: toSet) {
3951
if (WGEFUtils.hasBypass(player, player.getWorld(), region, WGEFlags.COMMAND_ON_ENTRY))
@@ -43,11 +55,7 @@ protected boolean onSetValue(LocalPlayer localPlayer, Location from, Location to
4355
execute.addAll(commands);
4456
}
4557
execute.forEach(e -> player.performCommand(e.substring(1).replace("%username%", player.getName())));
46-
return true;
58+
4759
}
4860

49-
@Override
50-
protected boolean onAbsentValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> exited, Set<String> lastValue, MoveType moveType) {return true;}
51-
@Override
52-
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, Set<String> value) {}
5361
}

WGEF-Abstraction/src/main/java/io/github/invvk/wgef/abstraction/flags/handler/command/ConsoleCommandOnEntryHandler.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,23 @@ protected ConsoleCommandOnEntryHandler(Session session) {
3131
super(session, WGEFlags.CONSOLE_COMMAND_ON_ENTRY);
3232
}
3333

34+
@Override
35+
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, Set<String> value) {
36+
this.handleCommands(WGEFUtils.wrapPlayer(player), set);
37+
}
38+
3439
@Override
3540
protected boolean onSetValue(LocalPlayer localPlayer, Location from, Location to, ApplicableRegionSet toSet, Set<String> currentValue, Set<String> lastValue, MoveType moveType) {
36-
Player player = WGEFUtils.wrapPlayer(localPlayer);
41+
this.handleCommands(WGEFUtils.wrapPlayer(localPlayer), toSet);
42+
return true;
43+
}
44+
45+
@Override
46+
protected boolean onAbsentValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> exited, Set<String> lastValue, MoveType moveType) {
47+
return true;
48+
}
49+
50+
private void handleCommands(Player player, ApplicableRegionSet toSet) {
3751
Set<String> execute = new HashSet<>();
3852
for (ProtectedRegion region: toSet) {
3953
if (WGEFUtils.hasBypass(player, player.getWorld(), region, WGEFlags.CONSOLE_COMMAND_ON_ENTRY))
@@ -43,14 +57,6 @@ protected boolean onSetValue(LocalPlayer localPlayer, Location from, Location to
4357
execute.addAll(commands);
4458
}
4559
execute.forEach(e -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), e.substring(1).replace("%username%", player.getName())));
46-
return true;
4760
}
4861

49-
@Override
50-
protected boolean onAbsentValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> exited, Set<String> lastValue, MoveType moveType) {
51-
return true;
52-
}
53-
54-
@Override
55-
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, Set<String> value) {}
5662
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group 'io.github.invvk'
12-
version '2.1.5'
12+
version '2.1.6'
1313

1414
repositories {
1515
mavenCentral()

0 commit comments

Comments
 (0)