13

I won't repeat @victor's answer, but Python is a language that comes with batteries included; meaning that a lot of behaviour has already been bundled into modules, and is maintained for correctness and performance. You should really avoid to reinvent the wheel if it is not for learning purposes. Python also comes with an official style guide: PEP8, which ...


10

If all you need is just readability and maintainability, and general best practice, don't reinvent the wheel. You have the json library and it would be a sin not to use it. Firstly, you are greatly complicated the readability and extensibility. Secondly, JSON is not so simple (at least, you need to escape some special characters). I rewrote your code and ...


7

I'm guessing that you call this method frequently. If so, you might consider memoizing the result. Something like private Map<Player, ChatColor> playerChatColors = new HashMap<>(); in the class. Possibly make this static. And then at the beginning of the method, replace ChatColor color = ChatColor.GRAY; with ChatColor color = ...


5

Nice code! It was fun to review. Note that I do not know how this API you are using works, so I've made quite a few assumptions about it. Also, I've some assumptions about your knowledge of Java (despite your post) because you said you were familiar with other programming languages, so if you have any questions you can ask me in a comment. Different times ...


5

A few things that could be improved upon: TEXTURES = { "dirt": pygame.transform.scale(pygame.image.load("./images/gameDirtBlock.png"), (TILE_SIZE, TILE_SIZE)), "grass": pygame.transform.scale(pygame.image.load("./images/gameGrassBlock.png"), (TILE_SIZE, TILE_SIZE)), "stone": pygame.transform.scale(pygame.image.load("./images/gameStoneBlock.png"),...


4

I would prefer your second plan, with inheritence and mixin modules. I'll restate their different uses, which I am sure you know: Use inheritance to model relationships between objects (B is a A). Use mixins to model behavior (C logs, D remembers its position). Unless you have a need to dynamically add mixins, apply YAGNI and don't do it yet. Wait until ...


4

import time import os import sys #class for parsing settings.ini class parseIni(object): Python style guide recommends names like ParseIni def __init__(self, fileStream): Python style guide recommends argument like file_stream. self.lines = fileStream.readlines() You don't use the lines again, so why are you storing them on the object. ...


4

Don't do this: /** Defined variables START **/ ListView listView; ImageView image; EditText editsearch; List<String> recipes; TextView itemname; /** Defined variables END**/ This looks as if you're transitioning from being a C developer to Java. In more modern languages you are not required to declare at the top the variables that you use. And in ...


4

Building on @ovs answer. I would use the for loop approach (it is almost always nicer in Python, unless you do an infinite while True loop. def create_image(players): # create a blank transparent image with the dimensions: 212x147px. base_image = Image.new("RGBA", (212, 147)) slot_list = [(17, 17), (82, 17), (147, 17), (17, 82), (82, 82), (147, ...


4

Maybe it will not increase the performance, but I have some general tips: Use while loops instead of for-loops with break. It will make your code more readable. I have rewritten the createImage function for you: def createImage(players): # create a blank transparent image with the dimensions: 212x147px. baseImage = Image.new("RGBA", (212, 147)) ...


3

First of all, there is a dinstinction between comments and documentation. Documentation (Javadoc) defines the contract of what it documents. The Javadoc on a class, for example, describes what the purpose of the class is and can even give examples on how to use it. On a method, Javadoc describes what the method should be used for, along with its parameters, ...


3

public static NoFullBrightMining plugin; This static field seems unused, in which case it can be removed. // Global variables ArrayList<String> block_list = new ArrayList<String>(); boolean perm_nfbm_disabled = false; // Configuration variables boolean nfbm_enabled; I'm not really sure why you have both a perm_nfbm_disabled and nfbm_enabled ...


3

One of my hobbies is woodworking. When I'm about to embark on a new project, I have a general idea of how I'm going to do it, just based on experience. I almost always begin by working up plans with Sketchup, which includes the materials I'll be using for each part. I then give considerable thought to which individual boards I'll use for which parts (e.g.,...


3

First of all, the way you're formatting your code is horribly confusing. if(Inside(neigh, ivec3(0), ivec3(SIZE) - 1)) if(data[neigh.x][neigh.y][neigh.z]) goto skip; { ... } The block here looks a lot like it's in the if condition but it's not (it's just a C-like block without any condition attached to it). I really suggest using braces for ...


3

As it is mentioned in the comments, It seems your code is exactly same as the below. So that is the first suggestion. main = block.getType(); up1 = block.getRelative(BlockFace.UP, 1).getType(); up2 = block.getRelative(BlockFace.UP, 2).getType(); down1 = block.getRelative(BlockFace.DOWN, 1).getType(); down2 = block.getRelative(BlockFace.DOWN, 2).getType(); ...


3

Foreword Bearing in mind that this post was created more than 4 years ago, you likely have changed the code and learned more about PHP features - perhaps you don't even use/maintain this code anymore. I honestly have never played Minecraft, nor had any reason to monitor server statuses. But I wanted to give some feedback to this question. Feedback The ...


3

Your Table Declarations are a little redundant with the DROP TABLE if it exists and then CREATE TABLE if it doesn't exist. The SQL Engine is going to do an extra search to see if the table exists when we already know that if it existed it was dropped. DROP TABLE IF EXISTS `actors`; CREATE TABLE IF NOT EXISTS `actors` (... If you have a large Table the ...


2

I may be missing some deep reason here, but it looks like you've got an if-condition that already does exactly what you need, except that you're using it to feed a GOTO instead of to (not) execute the defined code block.... Shouldn't you do something like: if (!(Inside(neigh, ivec3(0), ivec3(SIZE)-1) && data[neigh.x][neigh.y][neigh.z])) { ... }


2

Building upon Vadym's answer - the vector instantiation could probably be eliminated entirely. It appears they are only created to provide nice groupings of x,y,z coordinates, as they are only ever referenced by pulling the x,y,z values back out. If performance is really an issue, I would suggest keeping individual values instead for xincreasing, ...


2

First of all, I think you should try to respect coding conventions such as indentation, white space, naming, etc. About the name, if I were you I'd try to use meaningful names (ie: avoid one letter variables for parameters like s for CharSequence). I would also try to name those temp variables. They probably represent something real anyway. Finally for ...


2

To address the issue of your 100+ item if statement I think it is best if you use an Enum to store all you items. public enum Item { REDSTONE_TORCH("Redstone Torch", R.drawable.recipe_redstonetorch) , CHEST("Chest", R.drawable.recipe_chest) ; // Etc private static final String NAME; private static final int DRAWABLE_RES_ID; ...


2

Something which occurs to me is that catching the exception and not rethrowing is a very bad practice. Printing the stack trace is helpful, it tells the consumer of your API that something went wrong, but it is inflexible (it cannot be redirected to another IO device) and, more importantly the failure itself is swallowed. The program keeps on running after ...


2

General recomendations Prefer immutable classes without add(), set(), etc. It leads to simple programs without errors. Avoid the inheritance. Honestly I thick there are only few cases when it's appropriate. Use streams. They help to do lazy traversing or many collection operations. Also I'm big fan of Kotlin language so I recomend you to try it (but this ...


2

Here are my comments: Item common super class of itself and Recipe I understand this design decision stems from the requirement that Recipes are Items of other Recipes. and this is the cause of the confusing isItem property of the Item class. It would be more clear if Item and Recipee would have a common super class, say RecipeComponent and then you can ...


2

You can put the different parts of the building in a list and then iterate through this list, using the values in the list. I would propose this structure: parts = [ # x0 y0 z0 x1 y1 z1 block id meta data (( 1, 0, 1), (19, 4, 19), (block.STONE_BRICK, 0)), # Main structure (( 2, 1, 2), (18, 3, 5), (block.AIR , ...


1

The provided code sample is incomplete, so I don't know the control flow at runtime. However, this is what I noticed: The variables are static and so is getBlockLookingAt() method. However, the reflection code is done in the constructor of GetTargetBlock113 class. a more suitable place would be the static constructor of the class. depending on how many ...


1

First of all, use more local. It will save you a lot of headache in the future. Instead of the three place functions, you could just do local function selectAnyBlock() for i=1,16 -- 4 x 4 inventory if turtle.getItemCount(i) > 0 then return true end end os.reboot() -- No idea why you'd want to reboot here though end and then call ...


1

Your updated version is pretty darn good. As in, "You're basically done, no need to make any further changes." (See note at the bottom). The only thing I did differently (aside from creating non-normal registration methods as well that do all sorts of things) was to take two classes I already had and give them the register function: ClientProxy and ...


1

This is really interesting! I've never seen the source of a Minecraft mod before :) Using a set If you don't need the ability to store duplicate elements, sets are usually a better choice than lists. The most significant difference in this case is the contains method. It runs in constant time on a HashSet and linear time on an ArrayList. This is because ...


1

This class is doing too much. Think of separate classes for things like: database object instantiation/management/vending (i.e. singleton) a house house collection utilities - search, paginate, etc. to return collection of houses house construction (perhaps factory and/or decorator patterns would be useful here) blocks rows Don't use SELECT *. It can ...


Only top voted, non community-wiki answers of a minimum length are eligible