Comments (10)
Will look into adding a label to the villagers when AVL disables the villager so it will only work with villagers the plugin changed
from antivillagerlag.
`
@EventHandler(priority = EventPriority.MONITOR)
public void RightClick(PlayerInteractEntityEvent e) {
if(e.isCancelled())
return;
boolean right = true;
boolean useblock = false;
Player player = e.getPlayer();
Entity entity = e.getRightClicked();
PlayerInventory inv = player.getInventory();
if (!(entity.getType().equals(EntityType.VILLAGER))) return;
Villager vil = (Villager) entity;
ItemStack item;
currenttime = System.currentTimeMillis() / 1000;
//If he doesn't have a cooldown, add it?
if (!VilUtil.hasCooldown(vil, plugin)) {
VilUtil.setNewCooldown(vil, plugin, cooldown);
return;
}
long vilCooldown = VilUtil.getCooldown(vil, plugin);
if (!plugin.getConfig().getBoolean("toggleableoptions.userenaming")) return;
if (e.getHand().equals(EquipmentSlot.HAND)) {
if (!inv.getItemInMainHand().getType().equals(Material.NAME_TAG)) {
return;
}
item = inv.getItemInMainHand();
} else {
if (!inv.getItemInOffHand().getType().equals(Material.NAME_TAG)) {
return;
}
item = inv.getItemInOffHand();
right = false;
}
if (!item.getItemMeta().getDisplayName().equalsIgnoreCase(plugin.getConfig().getString("NameThatDisables"))) return;
if (!player.hasPermission("avl.renamecooldown.bypass")) {
if (vilCooldown >= currenttime) {
Long totalseconds = vilCooldown - currenttime;
Long sec = totalseconds % 60;
Long min = (totalseconds - sec) / 60;
String message = plugin.getConfig().getString("messages.cooldown-message");
if (message.contains("%avlminutes%")) {
message = VilUtil.replaceText(message, "%avlminutes%", Long.toString(min));
}
message = VilUtil.replaceText(message, "%avlseconds%", Long.toString(sec));
player.sendMessage(colorcodes.cm(message));
e.setCancelled(true);
return;
}
}
if (!plugin.getConfig().getBoolean("toggleableoptions.usenametags")) {
if (right) {
inv.getItemInMainHand().setAmount(inv.getItemInMainHand().getAmount() + 1);
} else {
inv.getItemInOffHand().setAmount(inv.getItemInOffHand().getAmount() + 1);
}
}
vil.setAI(false);
VilUtil.setNewCooldown(vil, plugin, cooldown);
}
`
I ended doing this and now works perfect !
Most antigriefing / worldguard plugins handles event cancellation on interacts inside some areas.
from antivillagerlag.
So the issue is that nametags are messing up EliteMobs?
possible work around is not to use nametags and instead use a block to disable villagers?
If that's not the issue please tell me.
Checking again i think i understand the issue now:
EliteMobs spawns villagers with disabled AI, when right clicking with AVL, since villagers are not name tagged or on a block, AVL will re-enable the AI again, cue pandemonium.
Possible fix to this:
add a flag to check if Villager Ai was disabled by AVL AND ( if villager is not on block OR villager doesn't have the right name ), before enabling AI.
As a note to possible feature request implementation:
Don't know how easy it is to implement, a plugin is loaded in a server for all worlds.
Generally Plugins seem to give perms which can then be enabled by world, which should be the angle to address this, if this feature should be integrated (having a blacklist in config seems a lot more complicated than adding a permission).
External ways to address this issue:
There is a plugin to try and handle this: https://github.com/FormallyMyles/PerWorldPlugins
But questionable how well it works.
Bigger servers use proxies which solves the problem by running different servers with different plugins.
from antivillagerlag.
checking Elite Mobs, it seems they disable AI for villagers they spawn as NPC:
https://github.com/MagmaGuy/EliteMobs/blob/384ad3a2cf3bbf644f47ddd79c1327b8da9c457c/src/main/java/com/magmaguy/elitemobs/npcs/NPCEntity.java#L88
from antivillagerlag.
yeah that's the true fix to this issue. Will also help with other plugins which might mess with villagers, might be a good idea to update the ReadMe after it's added to highlight potential issues (i.e. keep NPCs away from blocks or name tags).
I think enabling on a per world basis is a low priority feature.
from antivillagerlag.
The only problem is that this will not fix your existing problem, since the villager AI of the NPCs is now enabled. You need to either spawn the NPCs again (without avl enabled until a fix is pushed) or place them on blocks to deactivate their AI with avl. @apatuka
from antivillagerlag.
created a new issue to track root cause, this issue can stay open as a low priority feature request (add permissions for plugin use to allow restriction per world / player)
from antivillagerlag.
very good!
I think adding this would be good (maybe make it configurable? I don't know if this might have unintended consequences)
adding a permission check at the same position would enable the disable per world option.
from antivillagerlag.
2.0.0 should fix the core issue, please try it out (just don't leave NPC on the disabling block / name)
only try it out once it's hit the spigot plugin page
from antivillagerlag.
plugin now has a permission to disable the plug-in for users or worlds, using a permission plugin. config option may be added in the future.
from antivillagerlag.
Related Issues (20)
- Multiple block that can disable villager HOT 1
- Cannot un optimize after converting to zombie HOT 2
- Moving villagers too far from origin restores vanilla behavior HOT 1
- Emerald block doesn't optimize villagers HOT 4
- Do the plugin support 1.19.3? HOT 1
- Allow to add tags to villagers in addition to names HOT 1
- Feature to check for job block and disable villager AI HOT 1
- Disabling the ability to bargain for villagers with AI HOT 2
- Villagers trade price reset on restock
- Villager not losing his job.
- Folia Support HOT 3
- Work automatically without invoking command HOT 3
- Explicit AI re-enablement
- 1.20.2 Refill and Nametag problems HOT 2
- [Feature Request] Send message to player when they try to interact with villager HOT 2
- After removing the plugin, villagers are not restocking HOT 2
- Cooldown not working 1.20.4 HOT 2
- Add option to config to allow villagers to roam while optimized
- Villagers not un-optimizing on 1.20.4 HOT 1
- Nametag Dupe
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from antivillagerlag.