mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-26 20:26:33 +01:00
Fix a bug where regions would not update after added to a group
Also applicable for removing regions from a group.
This commit is contained in:
parent
b679c49405
commit
715bbfd9e3
@ -37,7 +37,7 @@ postCommandErrors: true
|
||||
## Enables / disables debug messages in the console, could be useful to figure out where errors come from
|
||||
debug: false
|
||||
## Version of the config, do not change!
|
||||
version: 2.1.0
|
||||
version: 2.1.1
|
||||
|
||||
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: AreaShop
|
||||
main: nl.evolutioncoding.areashop.AreaShop
|
||||
version: 2.1.0
|
||||
version: 2.1.1
|
||||
depend: [Vault, WorldGuard, WorldEdit]
|
||||
softdepend: [Multiverse-Core]
|
||||
author: NLThijs48
|
||||
|
@ -479,6 +479,29 @@ public class FileManager {
|
||||
}.runTaskTimer(plugin, 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update regions in a task to minimize lag
|
||||
* @param regions Regions to update
|
||||
*/
|
||||
public void updateRegions(final List<GeneralRegion> regions) {
|
||||
new BukkitRunnable() {
|
||||
private int current = 0;
|
||||
@Override
|
||||
public void run() {
|
||||
for(int i=0; i<plugin.getConfig().getInt("update.regionsPerTick"); i++) {
|
||||
if(current < regions.size()) {
|
||||
regions.get(current).updateSigns();
|
||||
regions.get(current).updateRegionFlags();
|
||||
current++;
|
||||
}
|
||||
}
|
||||
if(current >= regions.size()) {
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the group file to disk
|
||||
*/
|
||||
|
@ -67,13 +67,17 @@ public class GroupaddCommand extends CommandAreaShop {
|
||||
}
|
||||
ArrayList<String> namesSuccess = new ArrayList<String>();
|
||||
ArrayList<String> namesFailed = new ArrayList<String>();
|
||||
ArrayList<GeneralRegion> toUpdate = new ArrayList<GeneralRegion>();
|
||||
for(GeneralRegion region : regions) {
|
||||
if(group.addMember(region)) {
|
||||
namesSuccess.add(region.getName());
|
||||
toUpdate.add(region);
|
||||
} else {
|
||||
namesFailed.add(region.getName());
|
||||
}
|
||||
}
|
||||
// Update all regions, this does it in a task, updating them without lag
|
||||
plugin.getFileManager().updateRegions(toUpdate);
|
||||
if(namesSuccess.size() != 0) {
|
||||
plugin.message(player, "groupadd-weSuccess", group.getName(), Utils.createCommaSeparatedList(namesSuccess));
|
||||
}
|
||||
@ -88,6 +92,8 @@ public class GroupaddCommand extends CommandAreaShop {
|
||||
return;
|
||||
}
|
||||
if(group.addMember(region)) {
|
||||
region.updateRegionFlags();
|
||||
region.updateSigns();
|
||||
plugin.message(sender, "groupadd-success", region.getName(), group.getName(), group.getMembers().size());
|
||||
} else {
|
||||
plugin.message(sender, "groupadd-failed", region.getName(), group.getName());
|
||||
|
@ -67,13 +67,17 @@ public class GroupdelCommand extends CommandAreaShop {
|
||||
}
|
||||
ArrayList<String> namesSuccess = new ArrayList<String>();
|
||||
ArrayList<String> namesFailed = new ArrayList<String>();
|
||||
ArrayList<GeneralRegion> toUpdate = new ArrayList<GeneralRegion>();
|
||||
for(GeneralRegion region : regions) {
|
||||
if(group.removeMember(region)) {
|
||||
if(group.addMember(region)) {
|
||||
namesSuccess.add(region.getName());
|
||||
toUpdate.add(region);
|
||||
} else {
|
||||
namesFailed.add(region.getName());
|
||||
}
|
||||
}
|
||||
// Update all regions, this does it in a task, updating them without lag
|
||||
plugin.getFileManager().updateRegions(toUpdate);
|
||||
if(namesSuccess.size() != 0) {
|
||||
plugin.message(player, "groupdel-weSuccess", group.getName(), Utils.createCommaSeparatedList(namesSuccess));
|
||||
}
|
||||
@ -88,6 +92,8 @@ public class GroupdelCommand extends CommandAreaShop {
|
||||
return;
|
||||
}
|
||||
if(group.removeMember(region)) {
|
||||
region.updateRegionFlags();
|
||||
region.updateSigns();
|
||||
plugin.message(sender, "groupdel-success", region.getName(), group.getName(), group.getMembers().size());
|
||||
} else {
|
||||
plugin.message(sender, "groupdel-failed", region.getName(), group.getName());
|
||||
|
Loading…
Reference in New Issue
Block a user