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

Commit

Permalink
patch 2.1.6
Browse files Browse the repository at this point in the history
QoL Change, command/console-command runs after relogging in if the player spawns inside the region
  • Loading branch information
Invvk committed Oct 30, 2021
1 parent 258fa68 commit 733226a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,21 @@ protected CommandOnEntryHandler(Session session, Flag<Set<String>> flag) {
super(session, flag);
}

@Override
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, Set<String> value) {
this.handleCommands(WGEFUtils.wrapPlayer(player), set);
}

@Override
protected boolean onSetValue(LocalPlayer localPlayer, Location from, Location to, ApplicableRegionSet toSet, Set<String> currentValue, Set<String> lastValue, MoveType moveType) {
Player player = WGEFUtils.wrapPlayer(localPlayer);
this.handleCommands(WGEFUtils.wrapPlayer(localPlayer), toSet);
return true;
}

@Override
protected boolean onAbsentValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> exited, Set<String> lastValue, MoveType moveType) {return true;}

private void handleCommands(Player player, ApplicableRegionSet toSet) {
Set<String> execute = new HashSet<>();
for (ProtectedRegion region: toSet) {
if (WGEFUtils.hasBypass(player, player.getWorld(), region, WGEFlags.COMMAND_ON_ENTRY))
Expand All @@ -43,11 +55,7 @@ protected boolean onSetValue(LocalPlayer localPlayer, Location from, Location to
execute.addAll(commands);
}
execute.forEach(e -> player.performCommand(e.substring(1).replace("%username%", player.getName())));
return true;

}

@Override
protected boolean onAbsentValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> exited, Set<String> lastValue, MoveType moveType) {return true;}
@Override
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, Set<String> value) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,23 @@ protected ConsoleCommandOnEntryHandler(Session session) {
super(session, WGEFlags.CONSOLE_COMMAND_ON_ENTRY);
}

@Override
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, Set<String> value) {
this.handleCommands(WGEFUtils.wrapPlayer(player), set);
}

@Override
protected boolean onSetValue(LocalPlayer localPlayer, Location from, Location to, ApplicableRegionSet toSet, Set<String> currentValue, Set<String> lastValue, MoveType moveType) {
Player player = WGEFUtils.wrapPlayer(localPlayer);
this.handleCommands(WGEFUtils.wrapPlayer(localPlayer), toSet);
return true;
}

@Override
protected boolean onAbsentValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> exited, Set<String> lastValue, MoveType moveType) {
return true;
}

private void handleCommands(Player player, ApplicableRegionSet toSet) {
Set<String> execute = new HashSet<>();
for (ProtectedRegion region: toSet) {
if (WGEFUtils.hasBypass(player, player.getWorld(), region, WGEFlags.CONSOLE_COMMAND_ON_ENTRY))
Expand All @@ -43,14 +57,6 @@ protected boolean onSetValue(LocalPlayer localPlayer, Location from, Location to
execute.addAll(commands);
}
execute.forEach(e -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), e.substring(1).replace("%username%", player.getName())));
return true;
}

@Override
protected boolean onAbsentValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> exited, Set<String> lastValue, MoveType moveType) {
return true;
}

@Override
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, Set<String> value) {}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group 'io.github.invvk'
version '2.1.5'
version '2.1.6'

repositories {
mavenCentral()
Expand Down

0 comments on commit 733226a

Please sign in to comment.