Crëscendø
Veteran Member
Posts: 3,168
| Likes: 1,254
|
Post by Crëscendø on Oct 21, 2017 1:34:48 GMT
What more should I add to this simple freeze plugin? Give me some ideas of what I should add and what Its function would be pastebin.com/yebinuuB
|
|
StevenNL2000
Forum Admin
Posts: 6,415
| Likes: 6,936
IGN: StevenNL2000
Timezone: UTC+01:00
Member is Staff. Need immediate assistance? Send a PM
|
Post by StevenNL2000 on Oct 21, 2017 17:19:06 GMT
If I can give you some tips:
It's recommended to make class names camel case, so that you can't confuse the class with the variable when you do this:private GlobalFreeze globalfreeze = new GlobalFreeze(); You should use org.bukkit.ChatColor instead of net.md_5.bungee.api.ChatColor; the latter doesn't work on non-Spigot Bukkit servers.
If you look at TFM's freeze, you will notice that it also enables flying for the player. This is because if freeze is activated while the player is falling, the server will stop the fall 20 times per second, which is very glitchy.
The part of the code where you freeze malicious command senders doesn't need to be inside the for loop. That way, the server won't have to execute getOnlinePlayers() when it's not going to be used.
You are understanding for loops wrong. In your current code, the server first gets the list of online players, and then assigns the first player in the list to the OnlinePlayers variable. It then runs all code inside the loop with that one player in the variable. Once it's done, the next player is assigned to OnlinePlayers, and it starts at the top again. You are currently performing actions for one player, and then returning true, which cancels the loop and breaks you out of onCommand(). If you fix this, make sure to take the chat messages out of the loop, because they will be sent to the sender once for each online player.
All non-OPs are always frozen regardless of whether the command is executed because your code says that when a player moves and isn't OP, they should be added to the freeze list.
The above is inconsistent with the command, which freezes all players whether they are OP or not.
|
|