mirror of
https://github.com/LordBoos/boosCooldowns.git
synced 2024-11-26 04:25:20 +01:00
Fixed lags caused by autosave, bypasing plugin by using "\" escape
symbol in commands
This commit is contained in:
parent
1da0c6dae2
commit
8880283b10
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
name: boosCooldowns
|
||||
main: cz.boosik.boosCooldown.BoosCoolDown
|
||||
version: 3.6.4
|
||||
version: 3.6.5
|
||||
authors: [LordBoos (ingame name boosik)]
|
||||
softdepend: [Vault]
|
||||
description: >
|
||||
|
@ -581,10 +581,13 @@ public class BoosConfigManager {
|
||||
conf.load(confFile);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
BoosCoolDown.getLog().severe("[boosCooldowns] Configuration file not found!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
BoosCoolDown.getLog().severe("[boosCooldowns] Could not read configuration file!");
|
||||
} catch (InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
BoosCoolDown.getLog().severe("[boosCooldowns] Configuration file is invalid!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -596,10 +599,13 @@ public class BoosConfigManager {
|
||||
confusers.load(confusersFile);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
BoosCoolDown.getLog().severe("[boosCooldowns] Storage file not found!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
BoosCoolDown.getLog().severe("[boosCooldowns] Could not read storage file!");
|
||||
} catch (InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
BoosCoolDown.getLog().severe("[boosCooldowns] Storage file is invalid!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -620,6 +626,7 @@ public class BoosConfigManager {
|
||||
confusers.save(confusersFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
BoosCoolDown.getLog().severe("[boosCooldowns] Could not save storage file!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -645,6 +652,8 @@ public class BoosConfigManager {
|
||||
conf.save(confFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
BoosCoolDown.getLog().severe("[boosCooldowns] Could not save configuration file!");
|
||||
|
||||
}
|
||||
reload();
|
||||
}
|
||||
@ -670,6 +679,7 @@ public class BoosConfigManager {
|
||||
conf.addDefault("options.options.cooldowns_enabled", true);
|
||||
conf.addDefault("options.options.prices_enabled", true);
|
||||
conf.addDefault("options.options.limits_enabled", true);
|
||||
conf.addDefault("options.options.auto_save_enabled_CAN_CAUSE_BIG_LAGS", false);
|
||||
conf.addDefault("options.options.save_interval_in_minutes", 15);
|
||||
conf.addDefault("options.options.cancel_warmup_on_damage", false);
|
||||
conf.addDefault("options.options.cancel_warmup_on_move", false);
|
||||
@ -725,15 +735,7 @@ public class BoosConfigManager {
|
||||
"&6You are not allowed to use this sign!&f");
|
||||
}
|
||||
if (confFile.exists()) {
|
||||
try {
|
||||
conf.load(confFile);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
load();
|
||||
}
|
||||
try {
|
||||
conf.addDefault("commands.groups.default.*", "1,1,0.0,-1");
|
||||
@ -772,7 +774,12 @@ public class BoosConfigManager {
|
||||
confusersFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
BoosCoolDown.getLog().severe("[boosCooldowns] Could not save storage file!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static boolean getAutoSave() {
|
||||
return conf.getBoolean("options.options.auto_save_enabled_CAN_CAUSE_BIG_LAGS", false);
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ import cz.boosik.boosCooldown.Listeners.BoosPlayerInteractListener;
|
||||
import cz.boosik.boosCooldown.Listeners.BoosPlayerMoveListener;
|
||||
import cz.boosik.boosCooldown.Listeners.BoosPlayerToggleSneakListener;
|
||||
import cz.boosik.boosCooldown.Listeners.BoosPlayerToggleSprintListener;
|
||||
import cz.boosik.boosCooldown.Listeners.BoosSignChangeListener;
|
||||
import cz.boosik.boosCooldown.Listeners.BoosSignInteractListener;
|
||||
|
||||
/**
|
||||
* Hlavní tøída pluginu. Tøída je potomkem JavaPlugin a implementuje Runnable.
|
||||
@ -306,9 +308,11 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
|
||||
registerListeners();
|
||||
initializeVault();
|
||||
BukkitScheduler scheduler = this.getServer().getScheduler();
|
||||
if (BoosConfigManager.getAutoSave()){
|
||||
scheduler.scheduleSyncRepeatingTask(this, this,
|
||||
BoosConfigManager.getSaveInterval() * 1200,
|
||||
BoosConfigManager.getSaveInterval() * 1200);
|
||||
}
|
||||
if (BoosConfigManager.getClearOnRestart()) {
|
||||
BoosConfigManager.clear();
|
||||
}
|
||||
@ -352,6 +356,10 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
|
||||
if (BoosConfigManager.getCancelWarmupOnSprint()) {
|
||||
pm.registerEvents(new BoosPlayerToggleSprintListener(), this);
|
||||
}
|
||||
if (BoosConfigManager.getSignCommands()) {
|
||||
pm.registerEvents(new BoosSignChangeListener(), this);
|
||||
pm.registerEvents(new BoosSignInteractListener(this), this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,8 +105,8 @@ public class BoosCoolDownListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
String originalCommand = event.getMessage().trim()
|
||||
.replaceAll(" +", " ").toLowerCase();
|
||||
String originalCommand = event.getMessage().replace("\\", "\\\\");
|
||||
originalCommand.trim().replaceAll(" +", " ").toLowerCase();
|
||||
String regexCommad = "";
|
||||
Set<String> aliases = BoosConfigManager.getAliases();
|
||||
Set<String> commands = BoosConfigManager.getCommands(player);
|
||||
|
@ -0,0 +1,49 @@
|
||||
package cz.boosik.boosCooldown.Listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import util.boosChat;
|
||||
import cz.boosik.boosCooldown.BoosConfigManager;
|
||||
|
||||
/**
|
||||
* @author Jakub Koláø
|
||||
*
|
||||
*/
|
||||
public class BoosSignChangeListener implements Listener {
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onSignChange(SignChangeEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String line1 = event.getLine(0);
|
||||
String line2 = event.getLine(1);
|
||||
if (line1.equals("[boosCooldowns]")) {
|
||||
if (line2.equals("player")
|
||||
&& !player
|
||||
.hasPermission("booscooldowns.signs.player.place")) {
|
||||
boosChat.sendMessageToPlayer(player,
|
||||
BoosConfigManager.getCannotCreateSignMessage());
|
||||
event.getBlock().breakNaturally();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (line2.equals("server")
|
||||
&& !player
|
||||
.hasPermission("booscooldowns.signs.server.place")) {
|
||||
boosChat.sendMessageToPlayer(player,
|
||||
BoosConfigManager.getCannotCreateSignMessage());
|
||||
event.getBlock().breakNaturally();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package cz.boosik.boosCooldown.Listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import util.boosChat;
|
||||
import cz.boosik.boosCooldown.BoosConfigManager;
|
||||
import cz.boosik.boosCooldown.BoosCoolDown;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class BoosSignInteractListener implements Listener {
|
||||
private final BoosCoolDown plugin;
|
||||
|
||||
/**
|
||||
* @param instance
|
||||
*/
|
||||
public BoosSignInteractListener(BoosCoolDown instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onSignInteract(PlayerInteractEvent event) {
|
||||
String msg;
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (event.hasBlock() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (event.getClickedBlock().getType() == Material.SIGN_POST
|
||||
|| event.getClickedBlock().getType() == Material.WALL_SIGN) {
|
||||
Sign s = (Sign) event.getClickedBlock().getState();
|
||||
String line1 = s.getLine(0);
|
||||
String line2 = s.getLine(1);
|
||||
String line3 = s.getLine(2);
|
||||
String line4 = s.getLine(3);
|
||||
Player player = event.getPlayer();
|
||||
if (line1.equals("[boosCooldowns]")) {
|
||||
if (line2.equals("player")
|
||||
&& player
|
||||
.hasPermission("booscooldowns.signs.player.use")) {
|
||||
msg = line3;
|
||||
if (line3.endsWith("+") || !line4.isEmpty()) {
|
||||
msg = line3.substring(0, line3.length() - 1) + " "
|
||||
+ line4;
|
||||
}
|
||||
event.getPlayer().chat(msg);
|
||||
} else if (line2.equals("server")
|
||||
&& player
|
||||
.hasPermission("booscooldowns.signs.server.use")) {
|
||||
msg = line3;
|
||||
if (line3.endsWith("+") || !line4.isEmpty()) {
|
||||
msg = line3.substring(0, line3.length() - 1) + " "
|
||||
+ line4;
|
||||
}
|
||||
plugin.getServer().dispatchCommand(
|
||||
plugin.getServer().getConsoleSender(), msg);
|
||||
} else {
|
||||
boosChat.sendMessageToPlayer(player,
|
||||
BoosConfigManager.getCannotUseSignMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
name: boosCooldowns
|
||||
main: cz.boosik.boosCooldown.BoosCoolDown
|
||||
version: 3.6.4
|
||||
version: 3.6.5
|
||||
authors: [LordBoos (ingame name boosik)]
|
||||
softdepend: [Vault]
|
||||
description: >
|
||||
|
Loading…
Reference in New Issue
Block a user